Freeciv-3.3: /fast/freeciv/nightly/main/common/packets_gen.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
packets_gen.c
Go to the documentation of this file.
1 /**************************************************************************
2 * THIS FILE WAS GENERATED *
3 * Script: common/generate_packets.py *
4 * Input: common/networking/packets.def *
5 * DO NOT CHANGE THIS FILE *
6 **************************************************************************/
7
8#ifdef HAVE_CONFIG_H
9#include <fc_config.h>
10#endif
11
12#include <string.h>
13
14/* utility */
15#include "bitvector.h"
16#include "capability.h"
17#include "genhash.h"
18#include "log.h"
19#include "mem.h"
20#include "support.h"
21
22/* common */
23#include "capstr.h"
24#include "connection.h"
25#include "dataio.h"
26#include "game.h"
27
28#include "packets.h"
29
30 const char *const packet_functional_capability = "";
31
32#ifdef FREECIV_DELTA_PROTOCOL
33static genhash_val_t hash_const(const void *vkey)
34{
35 return 0;
36}
37
38static bool cmp_const(const void *vkey1, const void *vkey2)
39{
40 return TRUE;
41}
42#endif /* FREECIV_DELTA_PROTOCOL */
43
44 void delta_stats_report(void) {}
45 void delta_stats_reset(void) {}
46
47 const char *packet_name(enum packet_type type)
48{
49 static const char *const names[PACKET_LAST] = {
50 "PACKET_PROCESSING_STARTED",
51 "PACKET_PROCESSING_FINISHED",
52 "unknown",
53 "unknown",
54 "PACKET_SERVER_JOIN_REQ",
55 "PACKET_SERVER_JOIN_REPLY",
56 "PACKET_AUTHENTICATION_REQ",
57 "PACKET_AUTHENTICATION_REPLY",
58 "PACKET_SERVER_SHUTDOWN",
59 "PACKET_RULESET_TECH_CLASS",
60 "PACKET_NATION_SELECT_REQ",
61 "PACKET_PLAYER_READY",
62 "PACKET_ENDGAME_REPORT",
63 "PACKET_SCENARIO_DESCRIPTION",
64 "PACKET_EDIT_SCENARIO_DESC",
65 "PACKET_TILE_INFO",
66 "PACKET_GAME_INFO",
67 "PACKET_MAP_INFO",
68 "PACKET_NUKE_TILE_INFO",
69 "PACKET_TEAM_NAME_INFO",
70 "PACKET_RULESET_IMPR_FLAG",
71 "PACKET_INVESTIGATE_STARTED",
72 "PACKET_INVESTIGATE_FINISHED",
73 "unknown",
74 "unknown",
75 "PACKET_CHAT_MSG",
76 "PACKET_CHAT_MSG_REQ",
77 "PACKET_CONNECT_MSG",
78 "PACKET_EARLY_CHAT_MSG",
79 "PACKET_SERVER_INFO",
80 "PACKET_CITY_REMOVE",
81 "PACKET_CITY_INFO",
82 "PACKET_CITY_SHORT_INFO",
83 "PACKET_CITY_SELL",
84 "PACKET_CITY_BUY",
85 "PACKET_CITY_CHANGE",
86 "PACKET_CITY_WORKLIST",
87 "PACKET_CITY_MAKE_SPECIALIST",
88 "PACKET_CITY_MAKE_WORKER",
89 "PACKET_CITY_CHANGE_SPECIALIST",
90 "PACKET_CITY_RENAME",
91 "PACKET_CITY_OPTIONS_REQ",
92 "PACKET_CITY_REFRESH",
93 "PACKET_CITY_NAME_SUGGESTION_REQ",
94 "PACKET_CITY_NAME_SUGGESTION_INFO",
95 "PACKET_CITY_SABOTAGE_LIST",
96 "PACKET_CITY_NATIONALITIES",
97 "unknown",
98 "unknown",
99 "unknown",
100 "PACKET_PLAYER_REMOVE",
101 "PACKET_PLAYER_INFO",
102 "PACKET_PLAYER_PHASE_DONE",
103 "PACKET_PLAYER_RATES",
104 "PACKET_PLAYER_CHANGE_GOVERNMENT",
105 "PACKET_PLAYER_RESEARCH",
106 "PACKET_PLAYER_TECH_GOAL",
107 "PACKET_PLAYER_ATTRIBUTE_BLOCK",
108 "PACKET_PLAYER_ATTRIBUTE_CHUNK",
109 "PACKET_PLAYER_DIPLSTATE",
110 "PACKET_RESEARCH_INFO",
111 "PACKET_PLAYER_PLACE_INFRA",
112 "PACKET_UNIT_REMOVE",
113 "PACKET_UNIT_INFO",
114 "PACKET_UNIT_SHORT_INFO",
115 "PACKET_UNIT_COMBAT_INFO",
116 "PACKET_UNKNOWN_RESEARCH",
117 "unknown",
118 "unknown",
119 "unknown",
120 "unknown",
121 "PACKET_UNIT_SSCS_SET",
122 "unknown",
123 "PACKET_UNIT_ORDERS",
124 "PACKET_UNIT_SERVER_SIDE_AGENT_SET",
125 "unknown",
126 "unknown",
127 "unknown",
128 "unknown",
129 "unknown",
130 "unknown",
131 "unknown",
132 "PACKET_UNIT_ACTION_QUERY",
133 "PACKET_UNIT_TYPE_UPGRADE",
134 "PACKET_UNIT_DO_ACTION",
135 "PACKET_UNIT_ACTION_ANSWER",
136 "unknown",
137 "PACKET_UNIT_GET_ACTIONS",
138 "PACKET_CONN_PING",
139 "PACKET_CONN_PONG",
140 "PACKET_UNIT_ACTIONS",
141 "unknown",
142 "unknown",
143 "unknown",
144 "unknown",
145 "PACKET_DIPLOMACY_INIT_MEETING_REQ",
146 "PACKET_DIPLOMACY_INIT_MEETING",
147 "PACKET_DIPLOMACY_CANCEL_MEETING_REQ",
148 "PACKET_DIPLOMACY_CANCEL_MEETING",
149 "PACKET_DIPLOMACY_CREATE_CLAUSE_REQ",
150 "PACKET_DIPLOMACY_CREATE_CLAUSE",
151 "PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ",
152 "PACKET_DIPLOMACY_REMOVE_CLAUSE",
153 "PACKET_DIPLOMACY_ACCEPT_TREATY_REQ",
154 "PACKET_DIPLOMACY_ACCEPT_TREATY",
155 "PACKET_DIPLOMACY_CANCEL_PACT",
156 "unknown",
157 "unknown",
158 "unknown",
159 "unknown",
160 "PACKET_PAGE_MSG",
161 "PACKET_REPORT_REQ",
162 "unknown",
163 "unknown",
164 "unknown",
165 "PACKET_CONN_INFO",
166 "PACKET_CONN_PING_INFO",
167 "unknown",
168 "unknown",
169 "PACKET_CLIENT_INFO",
170 "unknown",
171 "unknown",
172 "unknown",
173 "unknown",
174 "unknown",
175 "PACKET_END_PHASE",
176 "PACKET_START_PHASE",
177 "PACKET_NEW_YEAR",
178 "PACKET_BEGIN_TURN",
179 "PACKET_END_TURN",
180 "PACKET_FREEZE_CLIENT",
181 "PACKET_THAW_CLIENT",
182 "unknown",
183 "unknown",
184 "unknown",
185 "PACKET_SPACESHIP_LAUNCH",
186 "PACKET_SPACESHIP_PLACE",
187 "PACKET_SPACESHIP_INFO",
188 "PACKET_CITY_RALLY_POINT",
189 "unknown",
190 "PACKET_RULESET_UNIT",
191 "PACKET_RULESET_GAME",
192 "PACKET_RULESET_SPECIALIST",
193 "PACKET_RULESET_GOVERNMENT_RULER_TITLE",
194 "PACKET_RULESET_TECH",
195 "PACKET_RULESET_GOVERNMENT",
196 "PACKET_RULESET_TERRAIN_CONTROL",
197 "PACKET_RULESET_NATION_GROUPS",
198 "PACKET_RULESET_NATION",
199 "PACKET_RULESET_CITY",
200 "PACKET_RULESET_BUILDING",
201 "PACKET_RULESET_TERRAIN",
202 "PACKET_RULESET_UNIT_CLASS",
203 "PACKET_RULESET_BASE",
204 "unknown",
205 "PACKET_RULESET_CONTROL",
206 "unknown",
207 "unknown",
208 "unknown",
209 "unknown",
210 "PACKET_SINGLE_WANT_HACK_REQ",
211 "PACKET_SINGLE_WANT_HACK_REPLY",
212 "PACKET_RULESET_CHOICES",
213 "PACKET_GAME_LOAD",
214 "PACKET_SERVER_SETTING_CONTROL",
215 "PACKET_SERVER_SETTING_CONST",
216 "PACKET_SERVER_SETTING_BOOL",
217 "PACKET_SERVER_SETTING_INT",
218 "PACKET_SERVER_SETTING_STR",
219 "PACKET_SERVER_SETTING_ENUM",
220 "PACKET_SERVER_SETTING_BITWISE",
221 "PACKET_RULESET_SELECT",
222 "unknown",
223 "unknown",
224 "unknown",
225 "PACKET_RULESET_EFFECT",
226 "unknown",
227 "PACKET_RULESET_RESOURCE",
228 "unknown",
229 "unknown",
230 "PACKET_SCENARIO_INFO",
231 "PACKET_SAVE_SCENARIO",
232 "unknown",
233 "unknown",
234 "unknown",
235 "PACKET_VOTE_NEW",
236 "PACKET_VOTE_UPDATE",
237 "PACKET_VOTE_REMOVE",
238 "PACKET_VOTE_RESOLVE",
239 "PACKET_VOTE_SUBMIT",
240 "PACKET_EDIT_MODE",
241 "unknown",
242 "unknown",
243 "unknown",
244 "unknown",
245 "unknown",
246 "unknown",
247 "PACKET_EDIT_RECALCULATE_BORDERS",
248 "PACKET_EDIT_CHECK_TILES",
249 "PACKET_EDIT_TOGGLE_FOGOFWAR",
250 "PACKET_EDIT_TILE_TERRAIN",
251 "unknown",
252 "PACKET_EDIT_TILE_EXTRA",
253 "unknown",
254 "PACKET_EDIT_STARTPOS",
255 "PACKET_EDIT_STARTPOS_FULL",
256 "PACKET_EDIT_TILE",
257 "PACKET_EDIT_UNIT_CREATE",
258 "PACKET_EDIT_UNIT_REMOVE",
259 "PACKET_EDIT_UNIT_REMOVE_BY_ID",
260 "PACKET_EDIT_UNIT",
261 "PACKET_EDIT_CITY_CREATE",
262 "PACKET_EDIT_CITY_REMOVE",
263 "PACKET_EDIT_CITY",
264 "PACKET_EDIT_PLAYER_CREATE",
265 "PACKET_EDIT_PLAYER_REMOVE",
266 "PACKET_EDIT_PLAYER",
267 "PACKET_EDIT_PLAYER_VISION",
268 "PACKET_EDIT_GAME",
269 "PACKET_EDIT_OBJECT_CREATED",
270 "PACKET_RULESET_ROAD",
271 "unknown",
272 "PACKET_UNIT_CHANGE_ACTIVITY",
273 "PACKET_ENDGAME_PLAYER",
274 "PACKET_RULESET_DISASTER",
275 "PACKET_RULESETS_READY",
276 "PACKET_RULESET_EXTRA_FLAG",
277 "PACKET_RULESET_TRADE",
278 "PACKET_RULESET_UNIT_BONUS",
279 "PACKET_RULESET_UNIT_FLAG",
280 "PACKET_RULESET_UNIT_CLASS_FLAG",
281 "PACKET_RULESET_TERRAIN_FLAG",
282 "PACKET_RULESET_EXTRA",
283 "PACKET_RULESET_ACHIEVEMENT",
284 "PACKET_RULESET_TECH_FLAG",
285 "PACKET_RULESET_ACTION_ENABLER",
286 "PACKET_RULESET_NATION_SETS",
287 "PACKET_NATION_AVAILABILITY",
288 "PACKET_ACHIEVEMENT_INFO",
289 "PACKET_RULESET_STYLE",
290 "PACKET_RULESET_MUSIC",
291 "PACKET_WORKER_TASK",
292 "PACKET_PLAYER_MULTIPLIER",
293 "PACKET_RULESET_MULTIPLIER",
294 "PACKET_TIMEOUT_INFO",
295 "PACKET_PLAY_MUSIC",
296 "PACKET_RULESET_ACTION",
297 "PACKET_RULESET_DESCRIPTION_PART",
298 "PACKET_RULESET_GOODS",
299 "PACKET_TRADE_ROUTE_INFO",
300 "PACKET_PAGE_MSG_PART",
301 "PACKET_RULESET_SUMMARY",
302 "PACKET_RULESET_ACTION_AUTO",
303 "PACKET_SET_TOPOLOGY",
304 "PACKET_CLIENT_HEARTBEAT",
305 "PACKET_CALENDAR_INFO",
306 "PACKET_WEB_CITY_INFO_ADDITION",
307 "PACKET_WEB_CMA_SET",
308 "PACKET_WEB_CMA_CLEAR",
309 "PACKET_WEB_PLAYER_INFO_ADDITION",
310 "PACKET_WEB_RULESET_UNIT_ADDITION",
311 "unknown",
312 "unknown",
313 "unknown",
314 "unknown",
315 "unknown",
316 "unknown",
317 "unknown",
318 "unknown",
319 "unknown",
320 "unknown",
321 "unknown",
322 "unknown",
323 "unknown",
324 "unknown",
325 "unknown",
326 "unknown",
327 "unknown",
328 "unknown",
329 "unknown",
330 "unknown",
331 "unknown",
332 "unknown",
333 "unknown",
334 "unknown",
335 "unknown",
336 "unknown",
337 "unknown",
338 "unknown",
339 "unknown",
340 "unknown",
341 "unknown",
342 "unknown",
343 "unknown",
344 "unknown",
345 "unknown",
346 "unknown",
347 "unknown",
348 "unknown",
349 "unknown",
350 "unknown",
351 "unknown",
352 "unknown",
353 "unknown",
354 "unknown",
355 "unknown",
356 "unknown",
357 "unknown",
358 "unknown",
359 "unknown",
360 "unknown",
361 "unknown",
362 "unknown",
363 "unknown",
364 "unknown",
365 "unknown",
366 "unknown",
367 "unknown",
368 "unknown",
369 "unknown",
370 "unknown",
371 "unknown",
372 "unknown",
373 "unknown",
374 "unknown",
375 "unknown",
376 "unknown",
377 "unknown",
378 "unknown",
379 "unknown",
380 "unknown",
381 "unknown",
382 "unknown",
383 "unknown",
384 "unknown",
385 "unknown",
386 "unknown",
387 "unknown",
388 "unknown",
389 "unknown",
390 "unknown",
391 "unknown",
392 "unknown",
393 "unknown",
394 "unknown",
395 "unknown",
396 "unknown",
397 "unknown",
398 "unknown",
399 "unknown",
400 "unknown",
401 "unknown",
402 "unknown",
403 "unknown",
404 "unknown",
405 "unknown",
406 "unknown",
407 "unknown",
408 "unknown",
409 "unknown",
410 "unknown",
411 "unknown",
412 "unknown",
413 "unknown",
414 "unknown",
415 "unknown",
416 "unknown",
417 "unknown",
418 "unknown",
419 "unknown",
420 "unknown",
421 "unknown",
422 "unknown",
423 "unknown",
424 "unknown",
425 "unknown",
426 "unknown",
427 "unknown",
428 "unknown",
429 "unknown",
430 "unknown",
431 "unknown",
432 "unknown",
433 "unknown",
434 "unknown",
435 "unknown",
436 "unknown",
437 "unknown",
438 "unknown",
439 "unknown",
440 "unknown",
441 "unknown",
442 "unknown",
443 "unknown",
444 "unknown",
445 "unknown",
446 "unknown",
447 "unknown",
448 "unknown",
449 "unknown",
450 "unknown",
451 "unknown",
452 "unknown",
453 "unknown",
454 "unknown",
455 "unknown",
456 "unknown",
457 "unknown",
458 "unknown",
459 "unknown",
460 "unknown",
461 "unknown",
462 "unknown",
463 "unknown",
464 "unknown",
465 "unknown",
466 "unknown",
467 "unknown",
468 "unknown",
469 "unknown",
470 "unknown",
471 "unknown",
472 "unknown",
473 "unknown",
474 "unknown",
475 "unknown",
476 "unknown",
477 "unknown",
478 "unknown",
479 "unknown",
480 "unknown",
481 "unknown",
482 "unknown",
483 "unknown",
484 "unknown",
485 "unknown",
486 "unknown",
487 "unknown",
488 "unknown",
489 "unknown",
490 "unknown",
491 "unknown",
492 "unknown",
493 "unknown",
494 "unknown",
495 "unknown",
496 "unknown",
497 "unknown",
498 "unknown",
499 "unknown",
500 "unknown",
501 "unknown",
502 "unknown",
503 "unknown",
504 "unknown",
505 "unknown",
506 "unknown",
507 "unknown",
508 "unknown",
509 "unknown",
510 "unknown",
511 "unknown",
512 "unknown",
513 "unknown",
514 "unknown",
515 "unknown",
516 "unknown",
517 "unknown",
518 "unknown",
519 "unknown",
520 "unknown",
521 "unknown",
522 "unknown",
523 "unknown",
524 "unknown",
525 "unknown",
526 "unknown",
527 "unknown",
528 "unknown",
529 "unknown",
530 "unknown",
531 "unknown",
532 "unknown",
533 "unknown",
534 "unknown",
535 "unknown",
536 "unknown",
537 "unknown",
538 "unknown",
539 "unknown",
540 "unknown",
541 "unknown",
542 "unknown",
543 "unknown",
544 "unknown",
545 "unknown",
546 "unknown",
547 "unknown",
548 "unknown",
549 "unknown",
550 "unknown",
551 "unknown",
552 "unknown",
553 "unknown",
554 "unknown",
555 "unknown",
556 "unknown",
557 "unknown",
558 "unknown",
559 "unknown",
560 "unknown",
561 "unknown",
562 "PACKET_RULESET_CLAUSE",
563 "PACKET_RULESET_COUNTER",
564 "PACKET_CITY_UPDATE_COUNTERS",
565 "PACKET_POPUP_IMAGE",
566 };
567
568 return (type < PACKET_LAST ? names[type] : "unknown");
569}
570
571 bool packet_has_game_info_flag(enum packet_type type)
572{
573 static const bool flag[PACKET_LAST] = {
574 [PACKET_TILE_INFO] = TRUE,
575 [PACKET_CITY_INFO] = TRUE,
576 [PACKET_CITY_NATIONALITIES] = TRUE,
577 [PACKET_CITY_UPDATE_COUNTERS] = TRUE,
578 [PACKET_CITY_SHORT_INFO] = TRUE,
579 [PACKET_CITY_RALLY_POINT] = TRUE,
580 [PACKET_RESEARCH_INFO] = TRUE,
581 [PACKET_UNKNOWN_RESEARCH] = TRUE,
582 [PACKET_UNIT_INFO] = TRUE,
583 [PACKET_UNIT_SHORT_INFO] = TRUE,
584 [PACKET_SPACESHIP_INFO] = TRUE,
585 [PACKET_WEB_CITY_INFO_ADDITION] = TRUE,
586 /* others are FALSE by default */
587 };
588
589 return (type < PACKET_LAST) && flag[type];
590}
591
592 static inline void init_packet_processing_started(struct packet_processing_started *packet)
593{
594 memset(packet, 0, sizeof(*packet));
595}
596
597#define free_packet_processing_started(_packet) (void) 0
598#define destroy_packet_processing_started free
599
600 static struct packet_processing_started *receive_packet_processing_started_100(struct connection *pc)
601{
602#define FREE_PACKET_STRUCT(_packet) free_packet_processing_started(_packet)
603 RECEIVE_PACKET_START(packet_processing_started, real_packet);
604
605 log_packet_detailed("packet_processing_started_100: got info about ()");
606
607 real_packet->__dummy = 0xff;
608
609 RECEIVE_PACKET_END(real_packet);
610#undef FREE_PACKET_STRUCT
611}
612
613 static int send_packet_processing_started_100(struct connection *pc)
614{
615 SEND_PACKET_START(PACKET_PROCESSING_STARTED);
616
617 log_packet_detailed("packet_processing_started_100: sending info about ()");
618
619 SEND_PACKET_END(PACKET_PROCESSING_STARTED);
620}
621
622 int send_packet_processing_started(struct connection *pc)
623{
624 if (!pc->used) {
625 log_error("WARNING: trying to send data to the closed connection %s",
626 conn_description(pc));
627 return -1;
628 }
629 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PROCESSING_STARTED].no_packet != nullptr, -1,
630 "Handler for PACKET_PROCESSING_STARTED not installed");
631 return pc->phs.handlers->send[PACKET_PROCESSING_STARTED].no_packet(pc);
632}
633
634 static inline void init_packet_processing_finished(struct packet_processing_finished *packet)
635{
636 memset(packet, 0, sizeof(*packet));
637}
638
639#define free_packet_processing_finished(_packet) (void) 0
640#define destroy_packet_processing_finished free
641
642 static struct packet_processing_finished *receive_packet_processing_finished_100(struct connection *pc)
643{
644#define FREE_PACKET_STRUCT(_packet) free_packet_processing_finished(_packet)
645 RECEIVE_PACKET_START(packet_processing_finished, real_packet);
646
647 log_packet_detailed("packet_processing_finished_100: got info about ()");
648
649 real_packet->__dummy = 0xff;
650
651 RECEIVE_PACKET_END(real_packet);
652#undef FREE_PACKET_STRUCT
653}
654
655 static int send_packet_processing_finished_100(struct connection *pc)
656{
657 SEND_PACKET_START(PACKET_PROCESSING_FINISHED);
658
659 log_packet_detailed("packet_processing_finished_100: sending info about ()");
660
661 SEND_PACKET_END(PACKET_PROCESSING_FINISHED);
662}
663
664 int send_packet_processing_finished(struct connection *pc)
665{
666 if (!pc->used) {
667 log_error("WARNING: trying to send data to the closed connection %s",
668 conn_description(pc));
669 return -1;
670 }
671 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PROCESSING_FINISHED].no_packet != nullptr, -1,
672 "Handler for PACKET_PROCESSING_FINISHED not installed");
673 return pc->phs.handlers->send[PACKET_PROCESSING_FINISHED].no_packet(pc);
674}
675
676 static inline void init_packet_investigate_started(struct packet_investigate_started *packet)
677{
678 memset(packet, 0, sizeof(*packet));
679}
680
681#define free_packet_investigate_started(_packet) (void) 0
682#define destroy_packet_investigate_started free
683
684#ifdef FREECIV_DELTA_PROTOCOL
685#define hash_packet_investigate_started_100 hash_const
686#define cmp_packet_investigate_started_100 cmp_const
687 BV_DEFINE(packet_investigate_started_100_fields, 1);
688#endif /* FREECIV_DELTA_PROTOCOL */
689
690 static struct packet_investigate_started *receive_packet_investigate_started_100(struct connection *pc)
691{
692#define FREE_PACKET_STRUCT(_packet) free_packet_investigate_started(_packet)
693 RECEIVE_PACKET_START(packet_investigate_started, real_packet);
694
695#ifdef FREECIV_JSON_CONNECTION
696 struct plocation field_addr;
697 {
698 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
699 field_addr = *field_addr_tmp;
700 FC_FREE(field_addr_tmp);
701 }
702#endif /* FREECIV_JSON_CONNECTION */
703
704 log_packet_detailed("packet_investigate_started_100: got info about ()");
705
706#ifdef FREECIV_DELTA_PROTOCOL
707 packet_investigate_started_100_fields fields;
708 struct packet_investigate_started *old;
709 struct genhash **hash = pc->phs.received + PACKET_INVESTIGATE_STARTED;
710
711 if (nullptr == *hash) {
712 *hash = genhash_new_full(hash_packet_investigate_started_100, cmp_packet_investigate_started_100,
713 nullptr, nullptr, nullptr, destroy_packet_investigate_started);
714 }
715
716 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
717 *real_packet = *old;
718 } else {
719 /* packet is already initialized empty */
720 log_packet_detailed(" no old info");
721 }
722
723#ifdef FREECIV_JSON_CONNECTION
724 field_addr.name = "fields";
725#endif /* FREECIV_JSON_CONNECTION */
726 DIO_BV_GET(&din, &field_addr, fields);
727
728 if (BV_ISSET(fields, 0)) {
729 log_packet_detailed(" got field 'city_id'");
730
731#ifdef FREECIV_JSON_CONNECTION
732 field_addr.name = "city_id";
733#endif /* FREECIV_JSON_CONNECTION */
734
735 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
736 RECEIVE_PACKET_FIELD_ERROR(city_id);
737 }
738 }
739
740 if (nullptr == old) {
741 old = fc_malloc(sizeof(*old));
742 init_packet_investigate_started(old);
743 *old = *real_packet;
744 genhash_insert(*hash, old, old);
745 } else {
746 *old = *real_packet;
747 }
748
749#else /* FREECIV_DELTA_PROTOCOL */
750#ifdef FREECIV_JSON_CONNECTION
751 field_addr.name = "city_id";
752#endif /* FREECIV_JSON_CONNECTION */
753
754 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
755 RECEIVE_PACKET_FIELD_ERROR(city_id);
756 }
757#endif /* FREECIV_DELTA_PROTOCOL */
758
759 RECEIVE_PACKET_END(real_packet);
760#undef FREE_PACKET_STRUCT
761}
762
763 static int send_packet_investigate_started_100(struct connection *pc, const struct packet_investigate_started *packet)
764{
765 const struct packet_investigate_started *real_packet = packet;
766 int e;
767 SEND_PACKET_START(PACKET_INVESTIGATE_STARTED);
768
769 log_packet_detailed("packet_investigate_started_100: sending info about ()");
770
771#ifdef FREECIV_DELTA_PROTOCOL
772 packet_investigate_started_100_fields fields;
773 struct packet_investigate_started *old;
774 bool differ;
775 struct genhash **hash = pc->phs.sent + PACKET_INVESTIGATE_STARTED;
776
777 if (nullptr == *hash) {
778 *hash = genhash_new_full(hash_packet_investigate_started_100, cmp_packet_investigate_started_100,
779 nullptr, nullptr, nullptr, destroy_packet_investigate_started);
780 }
781 BV_CLR_ALL(fields);
782
783 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
784 old = fc_malloc(sizeof(*old));
785 /* temporary bitcopy just to insert correctly */
786 *old = *real_packet;
787 genhash_insert(*hash, old, old);
788 init_packet_investigate_started(old);
789 }
790
791 differ = (old->city_id != real_packet->city_id);
792 if (differ) {
793 BV_SET(fields, 0);
794 }
795#endif /* FREECIV_DELTA_PROTOCOL */
796
797#ifdef FREECIV_JSON_CONNECTION
798 struct plocation field_addr;
799 {
800 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
801 field_addr = *field_addr_tmp;
802 FC_FREE(field_addr_tmp);
803 }
804#endif /* FREECIV_JSON_CONNECTION */
805
806#ifdef FREECIV_DELTA_PROTOCOL
807#ifdef FREECIV_JSON_CONNECTION
808 field_addr.name = "fields";
809#endif /* FREECIV_JSON_CONNECTION */
810 e = 0;
811 e |= DIO_BV_PUT(&dout, &field_addr, fields);
812 if (e) {
813 log_packet_detailed("fields bitvector error detected");
814 }
815
816 if (BV_ISSET(fields, 0)) {
817 log_packet_detailed(" field 'city_id' has changed");
818
819#ifdef FREECIV_JSON_CONNECTION
820 field_addr.name = "city_id";
821#endif /* FREECIV_JSON_CONNECTION */
822 e = 0;
823
824 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
825
826 if (e) {
827 log_packet_detailed("'city_id' field error detected");
828 }
829 }
830
831 *old = *real_packet;
832
833#else /* FREECIV_DELTA_PROTOCOL */
834#ifdef FREECIV_JSON_CONNECTION
835 field_addr.name = "city_id";
836#endif /* FREECIV_JSON_CONNECTION */
837 e = 0;
838
839 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
840
841 if (e) {
842 log_packet_detailed("'city_id' field error detected");
843 }
844#endif /* FREECIV_DELTA_PROTOCOL */
845
846 SEND_PACKET_END(PACKET_INVESTIGATE_STARTED);
847}
848
849 int send_packet_investigate_started(struct connection *pc, const struct packet_investigate_started *packet)
850{
851 if (!pc->used) {
852 log_error("WARNING: trying to send data to the closed connection %s",
853 conn_description(pc));
854 return -1;
855 }
856 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_INVESTIGATE_STARTED].packet != nullptr, -1,
857 "Handler for PACKET_INVESTIGATE_STARTED not installed");
858 return pc->phs.handlers->send[PACKET_INVESTIGATE_STARTED].packet(pc, packet);
859}
860
861 void lsend_packet_investigate_started(struct conn_list *dest, const struct packet_investigate_started *packet)
862{
863 conn_list_iterate(dest, pconn) {
864 send_packet_investigate_started(pconn, packet);
865 } conn_list_iterate_end;
866}
867
868 int dsend_packet_investigate_started(struct connection *pc, int city_id)
869{
870 struct packet_investigate_started packet, *real_packet = &packet;
871
872 real_packet->city_id = city_id;
873
874 return send_packet_investigate_started(pc, real_packet);
875}
876
877 void dlsend_packet_investigate_started(struct conn_list *dest, int city_id)
878{
879 struct packet_investigate_started packet, *real_packet = &packet;
880
881 real_packet->city_id = city_id;
882
883 lsend_packet_investigate_started(dest, real_packet);
884}
885
886 static inline void init_packet_investigate_finished(struct packet_investigate_finished *packet)
887{
888 memset(packet, 0, sizeof(*packet));
889}
890
891#define free_packet_investigate_finished(_packet) (void) 0
892#define destroy_packet_investigate_finished free
893
894#ifdef FREECIV_DELTA_PROTOCOL
895#define hash_packet_investigate_finished_100 hash_const
896#define cmp_packet_investigate_finished_100 cmp_const
897 BV_DEFINE(packet_investigate_finished_100_fields, 1);
898#endif /* FREECIV_DELTA_PROTOCOL */
899
900 static struct packet_investigate_finished *receive_packet_investigate_finished_100(struct connection *pc)
901{
902#define FREE_PACKET_STRUCT(_packet) free_packet_investigate_finished(_packet)
903 RECEIVE_PACKET_START(packet_investigate_finished, real_packet);
904
905#ifdef FREECIV_JSON_CONNECTION
906 struct plocation field_addr;
907 {
908 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
909 field_addr = *field_addr_tmp;
910 FC_FREE(field_addr_tmp);
911 }
912#endif /* FREECIV_JSON_CONNECTION */
913
914 log_packet_detailed("packet_investigate_finished_100: got info about ()");
915
916#ifdef FREECIV_DELTA_PROTOCOL
917 packet_investigate_finished_100_fields fields;
918 struct packet_investigate_finished *old;
919 struct genhash **hash = pc->phs.received + PACKET_INVESTIGATE_FINISHED;
920
921 if (nullptr == *hash) {
922 *hash = genhash_new_full(hash_packet_investigate_finished_100, cmp_packet_investigate_finished_100,
923 nullptr, nullptr, nullptr, destroy_packet_investigate_finished);
924 }
925
926 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
927 *real_packet = *old;
928 } else {
929 /* packet is already initialized empty */
930 log_packet_detailed(" no old info");
931 }
932
933#ifdef FREECIV_JSON_CONNECTION
934 field_addr.name = "fields";
935#endif /* FREECIV_JSON_CONNECTION */
936 DIO_BV_GET(&din, &field_addr, fields);
937
938 if (BV_ISSET(fields, 0)) {
939 log_packet_detailed(" got field 'city_id'");
940
941#ifdef FREECIV_JSON_CONNECTION
942 field_addr.name = "city_id";
943#endif /* FREECIV_JSON_CONNECTION */
944
945 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
946 RECEIVE_PACKET_FIELD_ERROR(city_id);
947 }
948 }
949
950 if (nullptr == old) {
951 old = fc_malloc(sizeof(*old));
952 init_packet_investigate_finished(old);
953 *old = *real_packet;
954 genhash_insert(*hash, old, old);
955 } else {
956 *old = *real_packet;
957 }
958
959#else /* FREECIV_DELTA_PROTOCOL */
960#ifdef FREECIV_JSON_CONNECTION
961 field_addr.name = "city_id";
962#endif /* FREECIV_JSON_CONNECTION */
963
964 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
965 RECEIVE_PACKET_FIELD_ERROR(city_id);
966 }
967#endif /* FREECIV_DELTA_PROTOCOL */
968
969 RECEIVE_PACKET_END(real_packet);
970#undef FREE_PACKET_STRUCT
971}
972
973 static int send_packet_investigate_finished_100(struct connection *pc, const struct packet_investigate_finished *packet)
974{
975 const struct packet_investigate_finished *real_packet = packet;
976 int e;
977 SEND_PACKET_START(PACKET_INVESTIGATE_FINISHED);
978
979 log_packet_detailed("packet_investigate_finished_100: sending info about ()");
980
981#ifdef FREECIV_DELTA_PROTOCOL
982 packet_investigate_finished_100_fields fields;
983 struct packet_investigate_finished *old;
984 bool differ;
985 struct genhash **hash = pc->phs.sent + PACKET_INVESTIGATE_FINISHED;
986
987 if (nullptr == *hash) {
988 *hash = genhash_new_full(hash_packet_investigate_finished_100, cmp_packet_investigate_finished_100,
989 nullptr, nullptr, nullptr, destroy_packet_investigate_finished);
990 }
991 BV_CLR_ALL(fields);
992
993 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
994 old = fc_malloc(sizeof(*old));
995 /* temporary bitcopy just to insert correctly */
996 *old = *real_packet;
997 genhash_insert(*hash, old, old);
998 init_packet_investigate_finished(old);
999 }
1000
1001 differ = (old->city_id != real_packet->city_id);
1002 if (differ) {
1003 BV_SET(fields, 0);
1004 }
1005#endif /* FREECIV_DELTA_PROTOCOL */
1006
1007#ifdef FREECIV_JSON_CONNECTION
1008 struct plocation field_addr;
1009 {
1010 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1011 field_addr = *field_addr_tmp;
1012 FC_FREE(field_addr_tmp);
1013 }
1014#endif /* FREECIV_JSON_CONNECTION */
1015
1016#ifdef FREECIV_DELTA_PROTOCOL
1017#ifdef FREECIV_JSON_CONNECTION
1018 field_addr.name = "fields";
1019#endif /* FREECIV_JSON_CONNECTION */
1020 e = 0;
1021 e |= DIO_BV_PUT(&dout, &field_addr, fields);
1022 if (e) {
1023 log_packet_detailed("fields bitvector error detected");
1024 }
1025
1026 if (BV_ISSET(fields, 0)) {
1027 log_packet_detailed(" field 'city_id' has changed");
1028
1029#ifdef FREECIV_JSON_CONNECTION
1030 field_addr.name = "city_id";
1031#endif /* FREECIV_JSON_CONNECTION */
1032 e = 0;
1033
1034 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
1035
1036 if (e) {
1037 log_packet_detailed("'city_id' field error detected");
1038 }
1039 }
1040
1041 *old = *real_packet;
1042
1043#else /* FREECIV_DELTA_PROTOCOL */
1044#ifdef FREECIV_JSON_CONNECTION
1045 field_addr.name = "city_id";
1046#endif /* FREECIV_JSON_CONNECTION */
1047 e = 0;
1048
1049 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
1050
1051 if (e) {
1052 log_packet_detailed("'city_id' field error detected");
1053 }
1054#endif /* FREECIV_DELTA_PROTOCOL */
1055
1056 SEND_PACKET_END(PACKET_INVESTIGATE_FINISHED);
1057}
1058
1059 int send_packet_investigate_finished(struct connection *pc, const struct packet_investigate_finished *packet)
1060{
1061 if (!pc->used) {
1062 log_error("WARNING: trying to send data to the closed connection %s",
1063 conn_description(pc));
1064 return -1;
1065 }
1066 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_INVESTIGATE_FINISHED].packet != nullptr, -1,
1067 "Handler for PACKET_INVESTIGATE_FINISHED not installed");
1068 return pc->phs.handlers->send[PACKET_INVESTIGATE_FINISHED].packet(pc, packet);
1069}
1070
1071 void lsend_packet_investigate_finished(struct conn_list *dest, const struct packet_investigate_finished *packet)
1072{
1073 conn_list_iterate(dest, pconn) {
1074 send_packet_investigate_finished(pconn, packet);
1075 } conn_list_iterate_end;
1076}
1077
1078 int dsend_packet_investigate_finished(struct connection *pc, int city_id)
1079{
1080 struct packet_investigate_finished packet, *real_packet = &packet;
1081
1082 real_packet->city_id = city_id;
1083
1084 return send_packet_investigate_finished(pc, real_packet);
1085}
1086
1087 void dlsend_packet_investigate_finished(struct conn_list *dest, int city_id)
1088{
1089 struct packet_investigate_finished packet, *real_packet = &packet;
1090
1091 real_packet->city_id = city_id;
1092
1093 lsend_packet_investigate_finished(dest, real_packet);
1094}
1095
1096 static inline void init_packet_server_join_req(struct packet_server_join_req *packet)
1097{
1098 memset(packet, 0, sizeof(*packet));
1099}
1100
1101#define free_packet_server_join_req(_packet) (void) 0
1102#define destroy_packet_server_join_req free
1103
1104 static struct packet_server_join_req *receive_packet_server_join_req_100(struct connection *pc)
1105{
1106#define FREE_PACKET_STRUCT(_packet) free_packet_server_join_req(_packet)
1107 RECEIVE_PACKET_START(packet_server_join_req, real_packet);
1108
1109#ifdef FREECIV_JSON_CONNECTION
1110 struct plocation field_addr;
1111 {
1112 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1113 field_addr = *field_addr_tmp;
1114 FC_FREE(field_addr_tmp);
1115 }
1116#endif /* FREECIV_JSON_CONNECTION */
1117
1118 log_packet_detailed("packet_server_join_req_100: got info about ()");
1119
1120#ifdef FREECIV_JSON_CONNECTION
1121 field_addr.name = "username";
1122#endif /* FREECIV_JSON_CONNECTION */
1123
1124 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
1125 RECEIVE_PACKET_FIELD_ERROR(username);
1126 }
1127
1128#ifdef FREECIV_JSON_CONNECTION
1129 field_addr.name = "capability";
1130#endif /* FREECIV_JSON_CONNECTION */
1131
1132 if (!DIO_GET(string, &din, &field_addr, real_packet->capability, sizeof(real_packet->capability))) {
1133 RECEIVE_PACKET_FIELD_ERROR(capability);
1134 }
1135
1136#ifdef FREECIV_JSON_CONNECTION
1137 field_addr.name = "version_label";
1138#endif /* FREECIV_JSON_CONNECTION */
1139
1140 if (!DIO_GET(string, &din, &field_addr, real_packet->version_label, sizeof(real_packet->version_label))) {
1141 RECEIVE_PACKET_FIELD_ERROR(version_label);
1142 }
1143
1144#ifdef FREECIV_JSON_CONNECTION
1145 field_addr.name = "major_version";
1146#endif /* FREECIV_JSON_CONNECTION */
1147
1148 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->major_version)) {
1149 RECEIVE_PACKET_FIELD_ERROR(major_version);
1150 }
1151
1152#ifdef FREECIV_JSON_CONNECTION
1153 field_addr.name = "minor_version";
1154#endif /* FREECIV_JSON_CONNECTION */
1155
1156 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->minor_version)) {
1157 RECEIVE_PACKET_FIELD_ERROR(minor_version);
1158 }
1159
1160#ifdef FREECIV_JSON_CONNECTION
1161 field_addr.name = "patch_version";
1162#endif /* FREECIV_JSON_CONNECTION */
1163
1164 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->patch_version)) {
1165 RECEIVE_PACKET_FIELD_ERROR(patch_version);
1166 }
1167
1168 RECEIVE_PACKET_END(real_packet);
1169#undef FREE_PACKET_STRUCT
1170}
1171
1172 static int send_packet_server_join_req_100(struct connection *pc, const struct packet_server_join_req *packet)
1173{
1174 const struct packet_server_join_req *real_packet = packet;
1175 int e;
1176 SEND_PACKET_START(PACKET_SERVER_JOIN_REQ);
1177
1178 log_packet_detailed("packet_server_join_req_100: sending info about ()");
1179
1180#ifdef FREECIV_JSON_CONNECTION
1181 struct plocation field_addr;
1182 {
1183 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1184 field_addr = *field_addr_tmp;
1185 FC_FREE(field_addr_tmp);
1186 }
1187#endif /* FREECIV_JSON_CONNECTION */
1188
1189#ifdef FREECIV_JSON_CONNECTION
1190 field_addr.name = "username";
1191#endif /* FREECIV_JSON_CONNECTION */
1192 e = 0;
1193
1194 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
1195
1196 if (e) {
1197 log_packet_detailed("'username' field error detected");
1198 }
1199
1200#ifdef FREECIV_JSON_CONNECTION
1201 field_addr.name = "capability";
1202#endif /* FREECIV_JSON_CONNECTION */
1203 e = 0;
1204
1205 e |= DIO_PUT(string, &dout, &field_addr, real_packet->capability);
1206
1207 if (e) {
1208 log_packet_detailed("'capability' field error detected");
1209 }
1210
1211#ifdef FREECIV_JSON_CONNECTION
1212 field_addr.name = "version_label";
1213#endif /* FREECIV_JSON_CONNECTION */
1214 e = 0;
1215
1216 e |= DIO_PUT(string, &dout, &field_addr, real_packet->version_label);
1217
1218 if (e) {
1219 log_packet_detailed("'version_label' field error detected");
1220 }
1221
1222#ifdef FREECIV_JSON_CONNECTION
1223 field_addr.name = "major_version";
1224#endif /* FREECIV_JSON_CONNECTION */
1225 e = 0;
1226
1227 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->major_version);
1228
1229 if (e) {
1230 log_packet_detailed("'major_version' field error detected");
1231 }
1232
1233#ifdef FREECIV_JSON_CONNECTION
1234 field_addr.name = "minor_version";
1235#endif /* FREECIV_JSON_CONNECTION */
1236 e = 0;
1237
1238 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->minor_version);
1239
1240 if (e) {
1241 log_packet_detailed("'minor_version' field error detected");
1242 }
1243
1244#ifdef FREECIV_JSON_CONNECTION
1245 field_addr.name = "patch_version";
1246#endif /* FREECIV_JSON_CONNECTION */
1247 e = 0;
1248
1249 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->patch_version);
1250
1251 if (e) {
1252 log_packet_detailed("'patch_version' field error detected");
1253 }
1254
1255 SEND_PACKET_END(PACKET_SERVER_JOIN_REQ);
1256}
1257
1258 int send_packet_server_join_req(struct connection *pc, const struct packet_server_join_req *packet)
1259{
1260 if (!pc->used) {
1261 log_error("WARNING: trying to send data to the closed connection %s",
1262 conn_description(pc));
1263 return -1;
1264 }
1265 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_JOIN_REQ].packet != nullptr, -1,
1266 "Handler for PACKET_SERVER_JOIN_REQ not installed");
1267 return pc->phs.handlers->send[PACKET_SERVER_JOIN_REQ].packet(pc, packet);
1268}
1269
1270 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)
1271{
1272 struct packet_server_join_req packet, *real_packet = &packet;
1273
1274 sz_strlcpy(real_packet->username, username);
1275 sz_strlcpy(real_packet->capability, capability);
1276 sz_strlcpy(real_packet->version_label, version_label);
1277 real_packet->major_version = major_version;
1278 real_packet->minor_version = minor_version;
1279 real_packet->patch_version = patch_version;
1280
1281 return send_packet_server_join_req(pc, real_packet);
1282}
1283
1284 static inline void init_packet_server_join_reply(struct packet_server_join_reply *packet)
1285{
1286 memset(packet, 0, sizeof(*packet));
1287}
1288
1289#define free_packet_server_join_reply(_packet) (void) 0
1290#define destroy_packet_server_join_reply free
1291
1292 static struct packet_server_join_reply *receive_packet_server_join_reply_100(struct connection *pc)
1293{
1294#define FREE_PACKET_STRUCT(_packet) free_packet_server_join_reply(_packet)
1295 RECEIVE_PACKET_START(packet_server_join_reply, real_packet);
1296
1297#ifdef FREECIV_JSON_CONNECTION
1298 struct plocation field_addr;
1299 {
1300 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1301 field_addr = *field_addr_tmp;
1302 FC_FREE(field_addr_tmp);
1303 }
1304#endif /* FREECIV_JSON_CONNECTION */
1305
1306 log_packet_detailed("packet_server_join_reply_100: got info about ()");
1307
1308#ifdef FREECIV_JSON_CONNECTION
1309 field_addr.name = "you_can_join";
1310#endif /* FREECIV_JSON_CONNECTION */
1311
1312 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->you_can_join)) {
1313 RECEIVE_PACKET_FIELD_ERROR(you_can_join);
1314 }
1315
1316#ifdef FREECIV_JSON_CONNECTION
1317 field_addr.name = "message";
1318#endif /* FREECIV_JSON_CONNECTION */
1319
1320 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
1321 RECEIVE_PACKET_FIELD_ERROR(message);
1322 }
1323
1324#ifdef FREECIV_JSON_CONNECTION
1325 field_addr.name = "capability";
1326#endif /* FREECIV_JSON_CONNECTION */
1327
1328 if (!DIO_GET(string, &din, &field_addr, real_packet->capability, sizeof(real_packet->capability))) {
1329 RECEIVE_PACKET_FIELD_ERROR(capability);
1330 }
1331
1332#ifdef FREECIV_JSON_CONNECTION
1333 field_addr.name = "challenge_file";
1334#endif /* FREECIV_JSON_CONNECTION */
1335
1336 if (!DIO_GET(string, &din, &field_addr, real_packet->challenge_file, sizeof(real_packet->challenge_file))) {
1337 RECEIVE_PACKET_FIELD_ERROR(challenge_file);
1338 }
1339
1340#ifdef FREECIV_JSON_CONNECTION
1341 field_addr.name = "conn_id";
1342#endif /* FREECIV_JSON_CONNECTION */
1343
1344 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id)) {
1345 RECEIVE_PACKET_FIELD_ERROR(conn_id);
1346 }
1347
1348 post_receive_packet_server_join_reply(pc, real_packet);
1349 RECEIVE_PACKET_END(real_packet);
1350#undef FREE_PACKET_STRUCT
1351}
1352
1353 static int send_packet_server_join_reply_100(struct connection *pc, const struct packet_server_join_reply *packet)
1354{
1355 const struct packet_server_join_reply *real_packet = packet;
1356 int e;
1357 SEND_PACKET_START(PACKET_SERVER_JOIN_REPLY);
1358
1359 log_packet_detailed("packet_server_join_reply_100: sending info about ()");
1360
1361#ifdef FREECIV_JSON_CONNECTION
1362 struct plocation field_addr;
1363 {
1364 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1365 field_addr = *field_addr_tmp;
1366 FC_FREE(field_addr_tmp);
1367 }
1368#endif /* FREECIV_JSON_CONNECTION */
1369
1370#ifdef FREECIV_JSON_CONNECTION
1371 field_addr.name = "you_can_join";
1372#endif /* FREECIV_JSON_CONNECTION */
1373 e = 0;
1374
1375 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->you_can_join);
1376
1377 if (e) {
1378 log_packet_detailed("'you_can_join' field error detected");
1379 }
1380
1381#ifdef FREECIV_JSON_CONNECTION
1382 field_addr.name = "message";
1383#endif /* FREECIV_JSON_CONNECTION */
1384 e = 0;
1385
1386 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
1387
1388 if (e) {
1389 log_packet_detailed("'message' field error detected");
1390 }
1391
1392#ifdef FREECIV_JSON_CONNECTION
1393 field_addr.name = "capability";
1394#endif /* FREECIV_JSON_CONNECTION */
1395 e = 0;
1396
1397 e |= DIO_PUT(string, &dout, &field_addr, real_packet->capability);
1398
1399 if (e) {
1400 log_packet_detailed("'capability' field error detected");
1401 }
1402
1403#ifdef FREECIV_JSON_CONNECTION
1404 field_addr.name = "challenge_file";
1405#endif /* FREECIV_JSON_CONNECTION */
1406 e = 0;
1407
1408 e |= DIO_PUT(string, &dout, &field_addr, real_packet->challenge_file);
1409
1410 if (e) {
1411 log_packet_detailed("'challenge_file' field error detected");
1412 }
1413
1414#ifdef FREECIV_JSON_CONNECTION
1415 field_addr.name = "conn_id";
1416#endif /* FREECIV_JSON_CONNECTION */
1417 e = 0;
1418
1419 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id);
1420
1421 if (e) {
1422 log_packet_detailed("'conn_id' field error detected");
1423 }
1424
1425 post_send_packet_server_join_reply(pc, real_packet);
1426 SEND_PACKET_END(PACKET_SERVER_JOIN_REPLY);
1427}
1428
1429 int send_packet_server_join_reply(struct connection *pc, const struct packet_server_join_reply *packet)
1430{
1431 if (!pc->used) {
1432 log_error("WARNING: trying to send data to the closed connection %s",
1433 conn_description(pc));
1434 return -1;
1435 }
1436 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_JOIN_REPLY].packet != nullptr, -1,
1437 "Handler for PACKET_SERVER_JOIN_REPLY not installed");
1438 return pc->phs.handlers->send[PACKET_SERVER_JOIN_REPLY].packet(pc, packet);
1439}
1440
1441 static inline void init_packet_authentication_req(struct packet_authentication_req *packet)
1442{
1443 memset(packet, 0, sizeof(*packet));
1444}
1445
1446#define free_packet_authentication_req(_packet) (void) 0
1447#define destroy_packet_authentication_req free
1448
1449#ifdef FREECIV_DELTA_PROTOCOL
1450#define hash_packet_authentication_req_100 hash_const
1451#define cmp_packet_authentication_req_100 cmp_const
1452 BV_DEFINE(packet_authentication_req_100_fields, 2);
1453#endif /* FREECIV_DELTA_PROTOCOL */
1454
1455 static struct packet_authentication_req *receive_packet_authentication_req_100(struct connection *pc)
1456{
1457#define FREE_PACKET_STRUCT(_packet) free_packet_authentication_req(_packet)
1458 RECEIVE_PACKET_START(packet_authentication_req, real_packet);
1459
1460#ifdef FREECIV_JSON_CONNECTION
1461 struct plocation field_addr;
1462 {
1463 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1464 field_addr = *field_addr_tmp;
1465 FC_FREE(field_addr_tmp);
1466 }
1467#endif /* FREECIV_JSON_CONNECTION */
1468
1469 log_packet_detailed("packet_authentication_req_100: got info about ()");
1470
1471#ifdef FREECIV_DELTA_PROTOCOL
1472 packet_authentication_req_100_fields fields;
1473 struct packet_authentication_req *old;
1474 struct genhash **hash = pc->phs.received + PACKET_AUTHENTICATION_REQ;
1475
1476 if (nullptr == *hash) {
1477 *hash = genhash_new_full(hash_packet_authentication_req_100, cmp_packet_authentication_req_100,
1478 nullptr, nullptr, nullptr, destroy_packet_authentication_req);
1479 }
1480
1481 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1482 *real_packet = *old;
1483 } else {
1484 /* packet is already initialized empty */
1485 log_packet_detailed(" no old info");
1486 }
1487
1488#ifdef FREECIV_JSON_CONNECTION
1489 field_addr.name = "fields";
1490#endif /* FREECIV_JSON_CONNECTION */
1491 DIO_BV_GET(&din, &field_addr, fields);
1492
1493 if (BV_ISSET(fields, 0)) {
1494 log_packet_detailed(" got field 'type'");
1495
1496#ifdef FREECIV_JSON_CONNECTION
1497 field_addr.name = "type";
1498#endif /* FREECIV_JSON_CONNECTION */
1499
1500 {
1501 int readin;
1502
1503 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
1504 RECEIVE_PACKET_FIELD_ERROR(type);
1505 }
1506 real_packet->type = readin;
1507 }
1508 }
1509
1510 if (BV_ISSET(fields, 1)) {
1511 log_packet_detailed(" got field 'message'");
1512
1513#ifdef FREECIV_JSON_CONNECTION
1514 field_addr.name = "message";
1515#endif /* FREECIV_JSON_CONNECTION */
1516
1517 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
1518 RECEIVE_PACKET_FIELD_ERROR(message);
1519 }
1520 }
1521
1522 if (nullptr == old) {
1523 old = fc_malloc(sizeof(*old));
1524 init_packet_authentication_req(old);
1525 *old = *real_packet;
1526 genhash_insert(*hash, old, old);
1527 } else {
1528 *old = *real_packet;
1529 }
1530
1531#else /* FREECIV_DELTA_PROTOCOL */
1532#ifdef FREECIV_JSON_CONNECTION
1533 field_addr.name = "type";
1534#endif /* FREECIV_JSON_CONNECTION */
1535
1536 {
1537 int readin;
1538
1539 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
1540 RECEIVE_PACKET_FIELD_ERROR(type);
1541 }
1542 real_packet->type = readin;
1543 }
1544
1545#ifdef FREECIV_JSON_CONNECTION
1546 field_addr.name = "message";
1547#endif /* FREECIV_JSON_CONNECTION */
1548
1549 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
1550 RECEIVE_PACKET_FIELD_ERROR(message);
1551 }
1552#endif /* FREECIV_DELTA_PROTOCOL */
1553
1554 RECEIVE_PACKET_END(real_packet);
1555#undef FREE_PACKET_STRUCT
1556}
1557
1558 static int send_packet_authentication_req_100(struct connection *pc, const struct packet_authentication_req *packet)
1559{
1560 const struct packet_authentication_req *real_packet = packet;
1561 int e;
1562 SEND_PACKET_START(PACKET_AUTHENTICATION_REQ);
1563
1564 log_packet_detailed("packet_authentication_req_100: sending info about ()");
1565
1566#ifdef FREECIV_DELTA_PROTOCOL
1567 packet_authentication_req_100_fields fields;
1568 struct packet_authentication_req *old;
1569 bool differ;
1570 struct genhash **hash = pc->phs.sent + PACKET_AUTHENTICATION_REQ;
1571
1572 if (nullptr == *hash) {
1573 *hash = genhash_new_full(hash_packet_authentication_req_100, cmp_packet_authentication_req_100,
1574 nullptr, nullptr, nullptr, destroy_packet_authentication_req);
1575 }
1576 BV_CLR_ALL(fields);
1577
1578 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
1579 old = fc_malloc(sizeof(*old));
1580 /* temporary bitcopy just to insert correctly */
1581 *old = *real_packet;
1582 genhash_insert(*hash, old, old);
1583 init_packet_authentication_req(old);
1584 }
1585
1586 differ = (old->type != real_packet->type);
1587 if (differ) {
1588 BV_SET(fields, 0);
1589 }
1590
1591 differ = (strcmp(old->message, real_packet->message) != 0);
1592 if (differ) {
1593 BV_SET(fields, 1);
1594 }
1595#endif /* FREECIV_DELTA_PROTOCOL */
1596
1597#ifdef FREECIV_JSON_CONNECTION
1598 struct plocation field_addr;
1599 {
1600 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1601 field_addr = *field_addr_tmp;
1602 FC_FREE(field_addr_tmp);
1603 }
1604#endif /* FREECIV_JSON_CONNECTION */
1605
1606#ifdef FREECIV_DELTA_PROTOCOL
1607#ifdef FREECIV_JSON_CONNECTION
1608 field_addr.name = "fields";
1609#endif /* FREECIV_JSON_CONNECTION */
1610 e = 0;
1611 e |= DIO_BV_PUT(&dout, &field_addr, fields);
1612 if (e) {
1613 log_packet_detailed("fields bitvector error detected");
1614 }
1615
1616 if (BV_ISSET(fields, 0)) {
1617 log_packet_detailed(" field 'type' has changed");
1618
1619#ifdef FREECIV_JSON_CONNECTION
1620 field_addr.name = "type";
1621#endif /* FREECIV_JSON_CONNECTION */
1622 e = 0;
1623
1624 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
1625
1626 if (e) {
1627 log_packet_detailed("'type' field error detected");
1628 }
1629 }
1630
1631 if (BV_ISSET(fields, 1)) {
1632 log_packet_detailed(" field 'message' has changed");
1633
1634#ifdef FREECIV_JSON_CONNECTION
1635 field_addr.name = "message";
1636#endif /* FREECIV_JSON_CONNECTION */
1637 e = 0;
1638
1639 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
1640
1641 if (e) {
1642 log_packet_detailed("'message' field error detected");
1643 }
1644 }
1645
1646 *old = *real_packet;
1647
1648#else /* FREECIV_DELTA_PROTOCOL */
1649#ifdef FREECIV_JSON_CONNECTION
1650 field_addr.name = "type";
1651#endif /* FREECIV_JSON_CONNECTION */
1652 e = 0;
1653
1654 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
1655
1656 if (e) {
1657 log_packet_detailed("'type' field error detected");
1658 }
1659
1660#ifdef FREECIV_JSON_CONNECTION
1661 field_addr.name = "message";
1662#endif /* FREECIV_JSON_CONNECTION */
1663 e = 0;
1664
1665 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
1666
1667 if (e) {
1668 log_packet_detailed("'message' field error detected");
1669 }
1670#endif /* FREECIV_DELTA_PROTOCOL */
1671
1672 SEND_PACKET_END(PACKET_AUTHENTICATION_REQ);
1673}
1674
1675 int send_packet_authentication_req(struct connection *pc, const struct packet_authentication_req *packet)
1676{
1677 if (!pc->used) {
1678 log_error("WARNING: trying to send data to the closed connection %s",
1679 conn_description(pc));
1680 return -1;
1681 }
1682 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_AUTHENTICATION_REQ].packet != nullptr, -1,
1683 "Handler for PACKET_AUTHENTICATION_REQ not installed");
1684 return pc->phs.handlers->send[PACKET_AUTHENTICATION_REQ].packet(pc, packet);
1685}
1686
1687 int dsend_packet_authentication_req(struct connection *pc, enum authentication_type type, const char *message)
1688{
1689 struct packet_authentication_req packet, *real_packet = &packet;
1690
1691 real_packet->type = type;
1692 sz_strlcpy(real_packet->message, message);
1693
1694 return send_packet_authentication_req(pc, real_packet);
1695}
1696
1697 static inline void init_packet_authentication_reply(struct packet_authentication_reply *packet)
1698{
1699 memset(packet, 0, sizeof(*packet));
1700}
1701
1702#define free_packet_authentication_reply(_packet) (void) 0
1703#define destroy_packet_authentication_reply free
1704
1705#ifdef FREECIV_DELTA_PROTOCOL
1706#define hash_packet_authentication_reply_100 hash_const
1707#define cmp_packet_authentication_reply_100 cmp_const
1708 BV_DEFINE(packet_authentication_reply_100_fields, 1);
1709#endif /* FREECIV_DELTA_PROTOCOL */
1710
1711 static struct packet_authentication_reply *receive_packet_authentication_reply_100(struct connection *pc)
1712{
1713#define FREE_PACKET_STRUCT(_packet) free_packet_authentication_reply(_packet)
1714 RECEIVE_PACKET_START(packet_authentication_reply, real_packet);
1715
1716#ifdef FREECIV_JSON_CONNECTION
1717 struct plocation field_addr;
1718 {
1719 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1720 field_addr = *field_addr_tmp;
1721 FC_FREE(field_addr_tmp);
1722 }
1723#endif /* FREECIV_JSON_CONNECTION */
1724
1725 log_packet_detailed("packet_authentication_reply_100: got info about ()");
1726
1727#ifdef FREECIV_DELTA_PROTOCOL
1728 packet_authentication_reply_100_fields fields;
1729 struct packet_authentication_reply *old;
1730 struct genhash **hash = pc->phs.received + PACKET_AUTHENTICATION_REPLY;
1731
1732 if (nullptr == *hash) {
1733 *hash = genhash_new_full(hash_packet_authentication_reply_100, cmp_packet_authentication_reply_100,
1734 nullptr, nullptr, nullptr, destroy_packet_authentication_reply);
1735 }
1736
1737 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1738 *real_packet = *old;
1739 } else {
1740 /* packet is already initialized empty */
1741 log_packet_detailed(" no old info");
1742 }
1743
1744#ifdef FREECIV_JSON_CONNECTION
1745 field_addr.name = "fields";
1746#endif /* FREECIV_JSON_CONNECTION */
1747 DIO_BV_GET(&din, &field_addr, fields);
1748
1749 if (BV_ISSET(fields, 0)) {
1750 log_packet_detailed(" got field 'password'");
1751
1752#ifdef FREECIV_JSON_CONNECTION
1753 field_addr.name = "password";
1754#endif /* FREECIV_JSON_CONNECTION */
1755
1756 if (!DIO_GET(string, &din, &field_addr, real_packet->password, sizeof(real_packet->password))) {
1757 RECEIVE_PACKET_FIELD_ERROR(password);
1758 }
1759 }
1760
1761 if (nullptr == old) {
1762 old = fc_malloc(sizeof(*old));
1763 init_packet_authentication_reply(old);
1764 *old = *real_packet;
1765 genhash_insert(*hash, old, old);
1766 } else {
1767 *old = *real_packet;
1768 }
1769
1770#else /* FREECIV_DELTA_PROTOCOL */
1771#ifdef FREECIV_JSON_CONNECTION
1772 field_addr.name = "password";
1773#endif /* FREECIV_JSON_CONNECTION */
1774
1775 if (!DIO_GET(string, &din, &field_addr, real_packet->password, sizeof(real_packet->password))) {
1776 RECEIVE_PACKET_FIELD_ERROR(password);
1777 }
1778#endif /* FREECIV_DELTA_PROTOCOL */
1779
1780 RECEIVE_PACKET_END(real_packet);
1781#undef FREE_PACKET_STRUCT
1782}
1783
1784 static int send_packet_authentication_reply_100(struct connection *pc, const struct packet_authentication_reply *packet)
1785{
1786 const struct packet_authentication_reply *real_packet = packet;
1787 int e;
1788 SEND_PACKET_START(PACKET_AUTHENTICATION_REPLY);
1789
1790 log_packet_detailed("packet_authentication_reply_100: sending info about ()");
1791
1792#ifdef FREECIV_DELTA_PROTOCOL
1793 packet_authentication_reply_100_fields fields;
1794 struct packet_authentication_reply *old;
1795 bool differ;
1796 struct genhash **hash = pc->phs.sent + PACKET_AUTHENTICATION_REPLY;
1797
1798 if (nullptr == *hash) {
1799 *hash = genhash_new_full(hash_packet_authentication_reply_100, cmp_packet_authentication_reply_100,
1800 nullptr, nullptr, nullptr, destroy_packet_authentication_reply);
1801 }
1802 BV_CLR_ALL(fields);
1803
1804 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
1805 old = fc_malloc(sizeof(*old));
1806 /* temporary bitcopy just to insert correctly */
1807 *old = *real_packet;
1808 genhash_insert(*hash, old, old);
1809 init_packet_authentication_reply(old);
1810 }
1811
1812 differ = (strcmp(old->password, real_packet->password) != 0);
1813 if (differ) {
1814 BV_SET(fields, 0);
1815 }
1816#endif /* FREECIV_DELTA_PROTOCOL */
1817
1818#ifdef FREECIV_JSON_CONNECTION
1819 struct plocation field_addr;
1820 {
1821 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1822 field_addr = *field_addr_tmp;
1823 FC_FREE(field_addr_tmp);
1824 }
1825#endif /* FREECIV_JSON_CONNECTION */
1826
1827#ifdef FREECIV_DELTA_PROTOCOL
1828#ifdef FREECIV_JSON_CONNECTION
1829 field_addr.name = "fields";
1830#endif /* FREECIV_JSON_CONNECTION */
1831 e = 0;
1832 e |= DIO_BV_PUT(&dout, &field_addr, fields);
1833 if (e) {
1834 log_packet_detailed("fields bitvector error detected");
1835 }
1836
1837 if (BV_ISSET(fields, 0)) {
1838 log_packet_detailed(" field 'password' has changed");
1839
1840#ifdef FREECIV_JSON_CONNECTION
1841 field_addr.name = "password";
1842#endif /* FREECIV_JSON_CONNECTION */
1843 e = 0;
1844
1845 e |= DIO_PUT(string, &dout, &field_addr, real_packet->password);
1846
1847 if (e) {
1848 log_packet_detailed("'password' field error detected");
1849 }
1850 }
1851
1852 *old = *real_packet;
1853
1854#else /* FREECIV_DELTA_PROTOCOL */
1855#ifdef FREECIV_JSON_CONNECTION
1856 field_addr.name = "password";
1857#endif /* FREECIV_JSON_CONNECTION */
1858 e = 0;
1859
1860 e |= DIO_PUT(string, &dout, &field_addr, real_packet->password);
1861
1862 if (e) {
1863 log_packet_detailed("'password' field error detected");
1864 }
1865#endif /* FREECIV_DELTA_PROTOCOL */
1866
1867 SEND_PACKET_END(PACKET_AUTHENTICATION_REPLY);
1868}
1869
1870 int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
1871{
1872 if (!pc->used) {
1873 log_error("WARNING: trying to send data to the closed connection %s",
1874 conn_description(pc));
1875 return -1;
1876 }
1877 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_AUTHENTICATION_REPLY].packet != nullptr, -1,
1878 "Handler for PACKET_AUTHENTICATION_REPLY not installed");
1879 return pc->phs.handlers->send[PACKET_AUTHENTICATION_REPLY].packet(pc, packet);
1880}
1881
1882 static inline void init_packet_server_shutdown(struct packet_server_shutdown *packet)
1883{
1884 memset(packet, 0, sizeof(*packet));
1885}
1886
1887#define free_packet_server_shutdown(_packet) (void) 0
1888#define destroy_packet_server_shutdown free
1889
1890 static struct packet_server_shutdown *receive_packet_server_shutdown_100(struct connection *pc)
1891{
1892#define FREE_PACKET_STRUCT(_packet) free_packet_server_shutdown(_packet)
1893 RECEIVE_PACKET_START(packet_server_shutdown, real_packet);
1894
1895 log_packet_detailed("packet_server_shutdown_100: got info about ()");
1896
1897 real_packet->__dummy = 0xff;
1898
1899 RECEIVE_PACKET_END(real_packet);
1900#undef FREE_PACKET_STRUCT
1901}
1902
1903 static int send_packet_server_shutdown_100(struct connection *pc)
1904{
1905 SEND_PACKET_START(PACKET_SERVER_SHUTDOWN);
1906
1907 log_packet_detailed("packet_server_shutdown_100: sending info about ()");
1908
1909 SEND_PACKET_END(PACKET_SERVER_SHUTDOWN);
1910}
1911
1912 int send_packet_server_shutdown(struct connection *pc)
1913{
1914 if (!pc->used) {
1915 log_error("WARNING: trying to send data to the closed connection %s",
1916 conn_description(pc));
1917 return -1;
1918 }
1919 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SHUTDOWN].no_packet != nullptr, -1,
1920 "Handler for PACKET_SERVER_SHUTDOWN not installed");
1921 return pc->phs.handlers->send[PACKET_SERVER_SHUTDOWN].no_packet(pc);
1922}
1923
1924 void lsend_packet_server_shutdown(struct conn_list *dest)
1925{
1926 conn_list_iterate(dest, pconn) {
1927 send_packet_server_shutdown(pconn);
1928 } conn_list_iterate_end;
1929}
1930
1931 static inline void init_packet_nation_select_req(struct packet_nation_select_req *packet)
1932{
1933 memset(packet, 0, sizeof(*packet));
1934}
1935
1936#define free_packet_nation_select_req(_packet) (void) 0
1937#define destroy_packet_nation_select_req free
1938
1939#ifdef FREECIV_DELTA_PROTOCOL
1940#define hash_packet_nation_select_req_100 hash_const
1941#define cmp_packet_nation_select_req_100 cmp_const
1942 BV_DEFINE(packet_nation_select_req_100_fields, 5);
1943#endif /* FREECIV_DELTA_PROTOCOL */
1944
1945 static struct packet_nation_select_req *receive_packet_nation_select_req_100(struct connection *pc)
1946{
1947#define FREE_PACKET_STRUCT(_packet) free_packet_nation_select_req(_packet)
1948 RECEIVE_PACKET_START(packet_nation_select_req, real_packet);
1949
1950#ifdef FREECIV_JSON_CONNECTION
1951 struct plocation field_addr;
1952 {
1953 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
1954 field_addr = *field_addr_tmp;
1955 FC_FREE(field_addr_tmp);
1956 }
1957#endif /* FREECIV_JSON_CONNECTION */
1958
1959 log_packet_detailed("packet_nation_select_req_100: got info about ()");
1960
1961#ifdef FREECIV_DELTA_PROTOCOL
1962 packet_nation_select_req_100_fields fields;
1963 struct packet_nation_select_req *old;
1964 struct genhash **hash = pc->phs.received + PACKET_NATION_SELECT_REQ;
1965
1966 if (nullptr == *hash) {
1967 *hash = genhash_new_full(hash_packet_nation_select_req_100, cmp_packet_nation_select_req_100,
1968 nullptr, nullptr, nullptr, destroy_packet_nation_select_req);
1969 }
1970
1971 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
1972 *real_packet = *old;
1973 } else {
1974 /* packet is already initialized empty */
1975 log_packet_detailed(" no old info");
1976 }
1977
1978#ifdef FREECIV_JSON_CONNECTION
1979 field_addr.name = "fields";
1980#endif /* FREECIV_JSON_CONNECTION */
1981 DIO_BV_GET(&din, &field_addr, fields);
1982
1983 if (BV_ISSET(fields, 0)) {
1984 log_packet_detailed(" got field 'player_no'");
1985
1986#ifdef FREECIV_JSON_CONNECTION
1987 field_addr.name = "player_no";
1988#endif /* FREECIV_JSON_CONNECTION */
1989
1990 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_no)) {
1991 RECEIVE_PACKET_FIELD_ERROR(player_no);
1992 }
1993 }
1994
1995 if (BV_ISSET(fields, 1)) {
1996 log_packet_detailed(" got field 'nation_no'");
1997
1998#ifdef FREECIV_JSON_CONNECTION
1999 field_addr.name = "nation_no";
2000#endif /* FREECIV_JSON_CONNECTION */
2001
2002 {
2003 int readin;
2004
2005 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
2006 RECEIVE_PACKET_FIELD_ERROR(nation_no);
2007 }
2008 real_packet->nation_no = readin;
2009 }
2010 }
2011
2012 real_packet->is_male = BV_ISSET(fields, 2);
2013
2014 if (BV_ISSET(fields, 3)) {
2015 log_packet_detailed(" got field 'name'");
2016
2017#ifdef FREECIV_JSON_CONNECTION
2018 field_addr.name = "name";
2019#endif /* FREECIV_JSON_CONNECTION */
2020
2021 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
2022 RECEIVE_PACKET_FIELD_ERROR(name);
2023 }
2024 }
2025
2026 if (BV_ISSET(fields, 4)) {
2027 log_packet_detailed(" got field 'style'");
2028
2029#ifdef FREECIV_JSON_CONNECTION
2030 field_addr.name = "style";
2031#endif /* FREECIV_JSON_CONNECTION */
2032
2033 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
2034 RECEIVE_PACKET_FIELD_ERROR(style);
2035 }
2036 }
2037
2038 if (nullptr == old) {
2039 old = fc_malloc(sizeof(*old));
2040 init_packet_nation_select_req(old);
2041 *old = *real_packet;
2042 genhash_insert(*hash, old, old);
2043 } else {
2044 *old = *real_packet;
2045 }
2046
2047#else /* FREECIV_DELTA_PROTOCOL */
2048#ifdef FREECIV_JSON_CONNECTION
2049 field_addr.name = "player_no";
2050#endif /* FREECIV_JSON_CONNECTION */
2051
2052 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_no)) {
2053 RECEIVE_PACKET_FIELD_ERROR(player_no);
2054 }
2055
2056#ifdef FREECIV_JSON_CONNECTION
2057 field_addr.name = "nation_no";
2058#endif /* FREECIV_JSON_CONNECTION */
2059
2060 {
2061 int readin;
2062
2063 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
2064 RECEIVE_PACKET_FIELD_ERROR(nation_no);
2065 }
2066 real_packet->nation_no = readin;
2067 }
2068
2069#ifdef FREECIV_JSON_CONNECTION
2070 field_addr.name = "is_male";
2071#endif /* FREECIV_JSON_CONNECTION */
2072
2073 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_male)) {
2074 RECEIVE_PACKET_FIELD_ERROR(is_male);
2075 }
2076
2077#ifdef FREECIV_JSON_CONNECTION
2078 field_addr.name = "name";
2079#endif /* FREECIV_JSON_CONNECTION */
2080
2081 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
2082 RECEIVE_PACKET_FIELD_ERROR(name);
2083 }
2084
2085#ifdef FREECIV_JSON_CONNECTION
2086 field_addr.name = "style";
2087#endif /* FREECIV_JSON_CONNECTION */
2088
2089 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
2090 RECEIVE_PACKET_FIELD_ERROR(style);
2091 }
2092#endif /* FREECIV_DELTA_PROTOCOL */
2093
2094 RECEIVE_PACKET_END(real_packet);
2095#undef FREE_PACKET_STRUCT
2096}
2097
2098 static int send_packet_nation_select_req_100(struct connection *pc, const struct packet_nation_select_req *packet)
2099{
2100 const struct packet_nation_select_req *real_packet = packet;
2101 int e;
2102 SEND_PACKET_START(PACKET_NATION_SELECT_REQ);
2103
2104 log_packet_detailed("packet_nation_select_req_100: sending info about ()");
2105
2106#ifdef FREECIV_DELTA_PROTOCOL
2107 packet_nation_select_req_100_fields fields;
2108 struct packet_nation_select_req *old;
2109 bool differ;
2110 struct genhash **hash = pc->phs.sent + PACKET_NATION_SELECT_REQ;
2111
2112 if (nullptr == *hash) {
2113 *hash = genhash_new_full(hash_packet_nation_select_req_100, cmp_packet_nation_select_req_100,
2114 nullptr, nullptr, nullptr, destroy_packet_nation_select_req);
2115 }
2116 BV_CLR_ALL(fields);
2117
2118 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
2119 old = fc_malloc(sizeof(*old));
2120 /* temporary bitcopy just to insert correctly */
2121 *old = *real_packet;
2122 genhash_insert(*hash, old, old);
2123 init_packet_nation_select_req(old);
2124 }
2125
2126 differ = (old->player_no != real_packet->player_no);
2127 if (differ) {
2128 BV_SET(fields, 0);
2129 }
2130
2131 differ = (old->nation_no != real_packet->nation_no);
2132 if (differ) {
2133 BV_SET(fields, 1);
2134 }
2135
2136 /* folded into head */
2137 if (real_packet->is_male) {
2138 BV_SET(fields, 2);
2139 }
2140
2141 differ = (strcmp(old->name, real_packet->name) != 0);
2142 if (differ) {
2143 BV_SET(fields, 3);
2144 }
2145
2146 differ = (old->style != real_packet->style);
2147 if (differ) {
2148 BV_SET(fields, 4);
2149 }
2150#endif /* FREECIV_DELTA_PROTOCOL */
2151
2152#ifdef FREECIV_JSON_CONNECTION
2153 struct plocation field_addr;
2154 {
2155 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2156 field_addr = *field_addr_tmp;
2157 FC_FREE(field_addr_tmp);
2158 }
2159#endif /* FREECIV_JSON_CONNECTION */
2160
2161#ifdef FREECIV_DELTA_PROTOCOL
2162#ifdef FREECIV_JSON_CONNECTION
2163 field_addr.name = "fields";
2164#endif /* FREECIV_JSON_CONNECTION */
2165 e = 0;
2166 e |= DIO_BV_PUT(&dout, &field_addr, fields);
2167 if (e) {
2168 log_packet_detailed("fields bitvector error detected");
2169 }
2170
2171 if (BV_ISSET(fields, 0)) {
2172 log_packet_detailed(" field 'player_no' has changed");
2173
2174#ifdef FREECIV_JSON_CONNECTION
2175 field_addr.name = "player_no";
2176#endif /* FREECIV_JSON_CONNECTION */
2177 e = 0;
2178
2179 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_no);
2180
2181 if (e) {
2182 log_packet_detailed("'player_no' field error detected");
2183 }
2184 }
2185
2186 if (BV_ISSET(fields, 1)) {
2187 log_packet_detailed(" field 'nation_no' has changed");
2188
2189#ifdef FREECIV_JSON_CONNECTION
2190 field_addr.name = "nation_no";
2191#endif /* FREECIV_JSON_CONNECTION */
2192 e = 0;
2193
2194 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation_no);
2195
2196 if (e) {
2197 log_packet_detailed("'nation_no' field error detected");
2198 }
2199 }
2200
2201 /* field 2 is folded into the header */
2202
2203 if (BV_ISSET(fields, 3)) {
2204 log_packet_detailed(" field 'name' has changed");
2205
2206#ifdef FREECIV_JSON_CONNECTION
2207 field_addr.name = "name";
2208#endif /* FREECIV_JSON_CONNECTION */
2209 e = 0;
2210
2211 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
2212
2213 if (e) {
2214 log_packet_detailed("'name' field error detected");
2215 }
2216 }
2217
2218 if (BV_ISSET(fields, 4)) {
2219 log_packet_detailed(" field 'style' has changed");
2220
2221#ifdef FREECIV_JSON_CONNECTION
2222 field_addr.name = "style";
2223#endif /* FREECIV_JSON_CONNECTION */
2224 e = 0;
2225
2226 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
2227
2228 if (e) {
2229 log_packet_detailed("'style' field error detected");
2230 }
2231 }
2232
2233 *old = *real_packet;
2234
2235#else /* FREECIV_DELTA_PROTOCOL */
2236#ifdef FREECIV_JSON_CONNECTION
2237 field_addr.name = "player_no";
2238#endif /* FREECIV_JSON_CONNECTION */
2239 e = 0;
2240
2241 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_no);
2242
2243 if (e) {
2244 log_packet_detailed("'player_no' field error detected");
2245 }
2246
2247#ifdef FREECIV_JSON_CONNECTION
2248 field_addr.name = "nation_no";
2249#endif /* FREECIV_JSON_CONNECTION */
2250 e = 0;
2251
2252 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation_no);
2253
2254 if (e) {
2255 log_packet_detailed("'nation_no' field error detected");
2256 }
2257
2258#ifdef FREECIV_JSON_CONNECTION
2259 field_addr.name = "is_male";
2260#endif /* FREECIV_JSON_CONNECTION */
2261 e = 0;
2262
2263 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_male);
2264
2265 if (e) {
2266 log_packet_detailed("'is_male' field error detected");
2267 }
2268
2269#ifdef FREECIV_JSON_CONNECTION
2270 field_addr.name = "name";
2271#endif /* FREECIV_JSON_CONNECTION */
2272 e = 0;
2273
2274 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
2275
2276 if (e) {
2277 log_packet_detailed("'name' field error detected");
2278 }
2279
2280#ifdef FREECIV_JSON_CONNECTION
2281 field_addr.name = "style";
2282#endif /* FREECIV_JSON_CONNECTION */
2283 e = 0;
2284
2285 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
2286
2287 if (e) {
2288 log_packet_detailed("'style' field error detected");
2289 }
2290#endif /* FREECIV_DELTA_PROTOCOL */
2291
2292 SEND_PACKET_END(PACKET_NATION_SELECT_REQ);
2293}
2294
2295 int send_packet_nation_select_req(struct connection *pc, const struct packet_nation_select_req *packet)
2296{
2297 if (!pc->used) {
2298 log_error("WARNING: trying to send data to the closed connection %s",
2299 conn_description(pc));
2300 return -1;
2301 }
2302 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NATION_SELECT_REQ].packet != nullptr, -1,
2303 "Handler for PACKET_NATION_SELECT_REQ not installed");
2304 return pc->phs.handlers->send[PACKET_NATION_SELECT_REQ].packet(pc, packet);
2305}
2306
2307 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)
2308{
2309 struct packet_nation_select_req packet, *real_packet = &packet;
2310
2311 real_packet->player_no = player_no;
2312 real_packet->nation_no = nation_no;
2313 real_packet->is_male = is_male;
2314 sz_strlcpy(real_packet->name, name);
2315 real_packet->style = style;
2316
2317 return send_packet_nation_select_req(pc, real_packet);
2318}
2319
2320 static inline void init_packet_player_ready(struct packet_player_ready *packet)
2321{
2322 memset(packet, 0, sizeof(*packet));
2323}
2324
2325#define free_packet_player_ready(_packet) (void) 0
2326#define destroy_packet_player_ready free
2327
2328#ifdef FREECIV_DELTA_PROTOCOL
2329#define hash_packet_player_ready_100 hash_const
2330#define cmp_packet_player_ready_100 cmp_const
2331 BV_DEFINE(packet_player_ready_100_fields, 2);
2332#endif /* FREECIV_DELTA_PROTOCOL */
2333
2334 static struct packet_player_ready *receive_packet_player_ready_100(struct connection *pc)
2335{
2336#define FREE_PACKET_STRUCT(_packet) free_packet_player_ready(_packet)
2337 RECEIVE_PACKET_START(packet_player_ready, real_packet);
2338
2339#ifdef FREECIV_JSON_CONNECTION
2340 struct plocation field_addr;
2341 {
2342 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2343 field_addr = *field_addr_tmp;
2344 FC_FREE(field_addr_tmp);
2345 }
2346#endif /* FREECIV_JSON_CONNECTION */
2347
2348 log_packet_detailed("packet_player_ready_100: got info about ()");
2349
2350#ifdef FREECIV_DELTA_PROTOCOL
2351 packet_player_ready_100_fields fields;
2352 struct packet_player_ready *old;
2353 struct genhash **hash = pc->phs.received + PACKET_PLAYER_READY;
2354
2355 if (nullptr == *hash) {
2356 *hash = genhash_new_full(hash_packet_player_ready_100, cmp_packet_player_ready_100,
2357 nullptr, nullptr, nullptr, destroy_packet_player_ready);
2358 }
2359
2360 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
2361 *real_packet = *old;
2362 } else {
2363 /* packet is already initialized empty */
2364 log_packet_detailed(" no old info");
2365 }
2366
2367#ifdef FREECIV_JSON_CONNECTION
2368 field_addr.name = "fields";
2369#endif /* FREECIV_JSON_CONNECTION */
2370 DIO_BV_GET(&din, &field_addr, fields);
2371
2372 if (BV_ISSET(fields, 0)) {
2373 log_packet_detailed(" got field 'player_no'");
2374
2375#ifdef FREECIV_JSON_CONNECTION
2376 field_addr.name = "player_no";
2377#endif /* FREECIV_JSON_CONNECTION */
2378
2379 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_no)) {
2380 RECEIVE_PACKET_FIELD_ERROR(player_no);
2381 }
2382 }
2383
2384 real_packet->is_ready = BV_ISSET(fields, 1);
2385
2386 if (nullptr == old) {
2387 old = fc_malloc(sizeof(*old));
2388 init_packet_player_ready(old);
2389 *old = *real_packet;
2390 genhash_insert(*hash, old, old);
2391 } else {
2392 *old = *real_packet;
2393 }
2394
2395#else /* FREECIV_DELTA_PROTOCOL */
2396#ifdef FREECIV_JSON_CONNECTION
2397 field_addr.name = "player_no";
2398#endif /* FREECIV_JSON_CONNECTION */
2399
2400 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_no)) {
2401 RECEIVE_PACKET_FIELD_ERROR(player_no);
2402 }
2403
2404#ifdef FREECIV_JSON_CONNECTION
2405 field_addr.name = "is_ready";
2406#endif /* FREECIV_JSON_CONNECTION */
2407
2408 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_ready)) {
2409 RECEIVE_PACKET_FIELD_ERROR(is_ready);
2410 }
2411#endif /* FREECIV_DELTA_PROTOCOL */
2412
2413 RECEIVE_PACKET_END(real_packet);
2414#undef FREE_PACKET_STRUCT
2415}
2416
2417 static int send_packet_player_ready_100(struct connection *pc, const struct packet_player_ready *packet)
2418{
2419 const struct packet_player_ready *real_packet = packet;
2420 int e;
2421 SEND_PACKET_START(PACKET_PLAYER_READY);
2422
2423 log_packet_detailed("packet_player_ready_100: sending info about ()");
2424
2425#ifdef FREECIV_DELTA_PROTOCOL
2426 packet_player_ready_100_fields fields;
2427 struct packet_player_ready *old;
2428 bool differ;
2429 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_READY;
2430
2431 if (nullptr == *hash) {
2432 *hash = genhash_new_full(hash_packet_player_ready_100, cmp_packet_player_ready_100,
2433 nullptr, nullptr, nullptr, destroy_packet_player_ready);
2434 }
2435 BV_CLR_ALL(fields);
2436
2437 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
2438 old = fc_malloc(sizeof(*old));
2439 /* temporary bitcopy just to insert correctly */
2440 *old = *real_packet;
2441 genhash_insert(*hash, old, old);
2442 init_packet_player_ready(old);
2443 }
2444
2445 differ = (old->player_no != real_packet->player_no);
2446 if (differ) {
2447 BV_SET(fields, 0);
2448 }
2449
2450 /* folded into head */
2451 if (real_packet->is_ready) {
2452 BV_SET(fields, 1);
2453 }
2454#endif /* FREECIV_DELTA_PROTOCOL */
2455
2456#ifdef FREECIV_JSON_CONNECTION
2457 struct plocation field_addr;
2458 {
2459 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2460 field_addr = *field_addr_tmp;
2461 FC_FREE(field_addr_tmp);
2462 }
2463#endif /* FREECIV_JSON_CONNECTION */
2464
2465#ifdef FREECIV_DELTA_PROTOCOL
2466#ifdef FREECIV_JSON_CONNECTION
2467 field_addr.name = "fields";
2468#endif /* FREECIV_JSON_CONNECTION */
2469 e = 0;
2470 e |= DIO_BV_PUT(&dout, &field_addr, fields);
2471 if (e) {
2472 log_packet_detailed("fields bitvector error detected");
2473 }
2474
2475 if (BV_ISSET(fields, 0)) {
2476 log_packet_detailed(" field 'player_no' has changed");
2477
2478#ifdef FREECIV_JSON_CONNECTION
2479 field_addr.name = "player_no";
2480#endif /* FREECIV_JSON_CONNECTION */
2481 e = 0;
2482
2483 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_no);
2484
2485 if (e) {
2486 log_packet_detailed("'player_no' field error detected");
2487 }
2488 }
2489
2490 /* field 1 is folded into the header */
2491
2492 *old = *real_packet;
2493
2494#else /* FREECIV_DELTA_PROTOCOL */
2495#ifdef FREECIV_JSON_CONNECTION
2496 field_addr.name = "player_no";
2497#endif /* FREECIV_JSON_CONNECTION */
2498 e = 0;
2499
2500 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_no);
2501
2502 if (e) {
2503 log_packet_detailed("'player_no' field error detected");
2504 }
2505
2506#ifdef FREECIV_JSON_CONNECTION
2507 field_addr.name = "is_ready";
2508#endif /* FREECIV_JSON_CONNECTION */
2509 e = 0;
2510
2511 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_ready);
2512
2513 if (e) {
2514 log_packet_detailed("'is_ready' field error detected");
2515 }
2516#endif /* FREECIV_DELTA_PROTOCOL */
2517
2518 SEND_PACKET_END(PACKET_PLAYER_READY);
2519}
2520
2521 int send_packet_player_ready(struct connection *pc, const struct packet_player_ready *packet)
2522{
2523 if (!pc->used) {
2524 log_error("WARNING: trying to send data to the closed connection %s",
2525 conn_description(pc));
2526 return -1;
2527 }
2528 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_READY].packet != nullptr, -1,
2529 "Handler for PACKET_PLAYER_READY not installed");
2530 return pc->phs.handlers->send[PACKET_PLAYER_READY].packet(pc, packet);
2531}
2532
2533 int dsend_packet_player_ready(struct connection *pc, int player_no, bool is_ready)
2534{
2535 struct packet_player_ready packet, *real_packet = &packet;
2536
2537 real_packet->player_no = player_no;
2538 real_packet->is_ready = is_ready;
2539
2540 return send_packet_player_ready(pc, real_packet);
2541}
2542
2543 static inline void init_packet_endgame_report(struct packet_endgame_report *packet)
2544{
2545 memset(packet, 0, sizeof(*packet));
2546}
2547
2548#define free_packet_endgame_report(_packet) (void) 0
2549#define destroy_packet_endgame_report free
2550
2551 static struct packet_endgame_report *receive_packet_endgame_report_100(struct connection *pc)
2552{
2553#define FREE_PACKET_STRUCT(_packet) free_packet_endgame_report(_packet)
2554 RECEIVE_PACKET_START(packet_endgame_report, real_packet);
2555
2556#ifdef FREECIV_JSON_CONNECTION
2557 struct plocation field_addr;
2558 {
2559 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2560 field_addr = *field_addr_tmp;
2561 FC_FREE(field_addr_tmp);
2562 }
2563#endif /* FREECIV_JSON_CONNECTION */
2564
2565 log_packet_detailed("packet_endgame_report_100: got info about ()");
2566
2567#ifdef FREECIV_JSON_CONNECTION
2568 field_addr.name = "category_num";
2569#endif /* FREECIV_JSON_CONNECTION */
2570
2571 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->category_num)) {
2572 RECEIVE_PACKET_FIELD_ERROR(category_num);
2573 }
2574
2575#ifdef FREECIV_JSON_CONNECTION
2576 field_addr.name = "category_name";
2577#endif /* FREECIV_JSON_CONNECTION */
2578
2579 {
2580 int i;
2581
2582 if (real_packet->category_num > 32) {
2583 RECEIVE_PACKET_FIELD_ERROR(category_name, ": array truncated");
2584 }
2585
2586#ifdef FREECIV_JSON_CONNECTION
2587 /* Enter array. */
2588 field_addr.sub_location = plocation_elem_new(0);
2589#endif /* FREECIV_JSON_CONNECTION */
2590
2591 for (i = 0; i < real_packet->category_num; i++) {
2592#ifdef FREECIV_JSON_CONNECTION
2593 /* Next array element */
2594 field_addr.sub_location->number = i;
2595#endif /* FREECIV_JSON_CONNECTION */
2596
2597 if (!DIO_GET(string, &din, &field_addr, real_packet->category_name[i], sizeof(real_packet->category_name[i]))) {
2598 RECEIVE_PACKET_FIELD_ERROR(category_name);
2599 }
2600 }
2601
2602#ifdef FREECIV_JSON_CONNECTION
2603 /* Exit array. */
2604 FC_FREE(field_addr.sub_location);
2605#endif /* FREECIV_JSON_CONNECTION */
2606 }
2607
2608#ifdef FREECIV_JSON_CONNECTION
2609 field_addr.name = "player_num";
2610#endif /* FREECIV_JSON_CONNECTION */
2611
2612 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_num)) {
2613 RECEIVE_PACKET_FIELD_ERROR(player_num);
2614 }
2615
2616 RECEIVE_PACKET_END(real_packet);
2617#undef FREE_PACKET_STRUCT
2618}
2619
2620 static int send_packet_endgame_report_100(struct connection *pc, const struct packet_endgame_report *packet)
2621{
2622 const struct packet_endgame_report *real_packet = packet;
2623 int e;
2624 SEND_PACKET_START(PACKET_ENDGAME_REPORT);
2625
2626 log_packet_detailed("packet_endgame_report_100: sending info about ()");
2627
2628#ifdef FREECIV_JSON_CONNECTION
2629 struct plocation field_addr;
2630 {
2631 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2632 field_addr = *field_addr_tmp;
2633 FC_FREE(field_addr_tmp);
2634 }
2635#endif /* FREECIV_JSON_CONNECTION */
2636
2637#ifdef FREECIV_JSON_CONNECTION
2638 field_addr.name = "category_num";
2639#endif /* FREECIV_JSON_CONNECTION */
2640 e = 0;
2641
2642 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->category_num);
2643
2644 if (e) {
2645 log_packet_detailed("'category_num' field error detected");
2646 }
2647
2648#ifdef FREECIV_JSON_CONNECTION
2649 field_addr.name = "category_name";
2650#endif /* FREECIV_JSON_CONNECTION */
2651 e = 0;
2652
2653 {
2654 int i;
2655
2656#ifdef FREECIV_JSON_CONNECTION
2657 /* Create the array. */
2658 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->category_num);
2659
2660 /* Enter array. */
2661 field_addr.sub_location = plocation_elem_new(0);
2662#endif /* FREECIV_JSON_CONNECTION */
2663
2664 for (i = 0; i < real_packet->category_num; i++) {
2665#ifdef FREECIV_JSON_CONNECTION
2666 /* Next array element. */
2667 field_addr.sub_location->number = i;
2668#endif /* FREECIV_JSON_CONNECTION */
2669
2670 e |= DIO_PUT(string, &dout, &field_addr, real_packet->category_name[i]);
2671 }
2672
2673#ifdef FREECIV_JSON_CONNECTION
2674 /* Exit array. */
2675 FC_FREE(field_addr.sub_location);
2676#endif /* FREECIV_JSON_CONNECTION */
2677 }
2678
2679 if (e) {
2680 log_packet_detailed("'category_name' field error detected");
2681 }
2682
2683#ifdef FREECIV_JSON_CONNECTION
2684 field_addr.name = "player_num";
2685#endif /* FREECIV_JSON_CONNECTION */
2686 e = 0;
2687
2688 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_num);
2689
2690 if (e) {
2691 log_packet_detailed("'player_num' field error detected");
2692 }
2693
2694 SEND_PACKET_END(PACKET_ENDGAME_REPORT);
2695}
2696
2697 int send_packet_endgame_report(struct connection *pc, const struct packet_endgame_report *packet)
2698{
2699 if (!pc->used) {
2700 log_error("WARNING: trying to send data to the closed connection %s",
2701 conn_description(pc));
2702 return -1;
2703 }
2704 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_ENDGAME_REPORT].packet != nullptr, -1,
2705 "Handler for PACKET_ENDGAME_REPORT not installed");
2706 return pc->phs.handlers->send[PACKET_ENDGAME_REPORT].packet(pc, packet);
2707}
2708
2709 void lsend_packet_endgame_report(struct conn_list *dest, const struct packet_endgame_report *packet)
2710{
2711 conn_list_iterate(dest, pconn) {
2712 send_packet_endgame_report(pconn, packet);
2713 } conn_list_iterate_end;
2714}
2715
2716 static inline void init_packet_endgame_player(struct packet_endgame_player *packet)
2717{
2718 memset(packet, 0, sizeof(*packet));
2719}
2720
2721#define free_packet_endgame_player(_packet) (void) 0
2722#define destroy_packet_endgame_player free
2723
2724 static struct packet_endgame_player *receive_packet_endgame_player_100(struct connection *pc)
2725{
2726#define FREE_PACKET_STRUCT(_packet) free_packet_endgame_player(_packet)
2727 RECEIVE_PACKET_START(packet_endgame_player, real_packet);
2728
2729#ifdef FREECIV_JSON_CONNECTION
2730 struct plocation field_addr;
2731 {
2732 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2733 field_addr = *field_addr_tmp;
2734 FC_FREE(field_addr_tmp);
2735 }
2736#endif /* FREECIV_JSON_CONNECTION */
2737
2738 log_packet_detailed("packet_endgame_player_100: got info about ()");
2739
2740#ifdef FREECIV_JSON_CONNECTION
2741 field_addr.name = "category_num";
2742#endif /* FREECIV_JSON_CONNECTION */
2743
2744 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->category_num)) {
2745 RECEIVE_PACKET_FIELD_ERROR(category_num);
2746 }
2747
2748#ifdef FREECIV_JSON_CONNECTION
2749 field_addr.name = "player_id";
2750#endif /* FREECIV_JSON_CONNECTION */
2751
2752 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_id)) {
2753 RECEIVE_PACKET_FIELD_ERROR(player_id);
2754 }
2755
2756#ifdef FREECIV_JSON_CONNECTION
2757 field_addr.name = "score";
2758#endif /* FREECIV_JSON_CONNECTION */
2759
2760 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->score)) {
2761 RECEIVE_PACKET_FIELD_ERROR(score);
2762 }
2763
2764#ifdef FREECIV_JSON_CONNECTION
2765 field_addr.name = "category_score";
2766#endif /* FREECIV_JSON_CONNECTION */
2767
2768 {
2769 int i;
2770
2771 if (real_packet->category_num > 32) {
2772 RECEIVE_PACKET_FIELD_ERROR(category_score, ": array truncated");
2773 }
2774
2775#ifdef FREECIV_JSON_CONNECTION
2776 /* Enter array. */
2777 field_addr.sub_location = plocation_elem_new(0);
2778#endif /* FREECIV_JSON_CONNECTION */
2779
2780 for (i = 0; i < real_packet->category_num; i++) {
2781#ifdef FREECIV_JSON_CONNECTION
2782 /* Next array element */
2783 field_addr.sub_location->number = i;
2784#endif /* FREECIV_JSON_CONNECTION */
2785
2786 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->category_score[i])) {
2787 RECEIVE_PACKET_FIELD_ERROR(category_score);
2788 }
2789 }
2790
2791#ifdef FREECIV_JSON_CONNECTION
2792 /* Exit array. */
2793 FC_FREE(field_addr.sub_location);
2794#endif /* FREECIV_JSON_CONNECTION */
2795 }
2796
2797#ifdef FREECIV_JSON_CONNECTION
2798 field_addr.name = "winner";
2799#endif /* FREECIV_JSON_CONNECTION */
2800
2801 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->winner)) {
2802 RECEIVE_PACKET_FIELD_ERROR(winner);
2803 }
2804
2805 RECEIVE_PACKET_END(real_packet);
2806#undef FREE_PACKET_STRUCT
2807}
2808
2809 static int send_packet_endgame_player_100(struct connection *pc, const struct packet_endgame_player *packet)
2810{
2811 const struct packet_endgame_player *real_packet = packet;
2812 int e;
2813 SEND_PACKET_START(PACKET_ENDGAME_PLAYER);
2814
2815 log_packet_detailed("packet_endgame_player_100: sending info about ()");
2816
2817#ifdef FREECIV_JSON_CONNECTION
2818 struct plocation field_addr;
2819 {
2820 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2821 field_addr = *field_addr_tmp;
2822 FC_FREE(field_addr_tmp);
2823 }
2824#endif /* FREECIV_JSON_CONNECTION */
2825
2826#ifdef FREECIV_JSON_CONNECTION
2827 field_addr.name = "category_num";
2828#endif /* FREECIV_JSON_CONNECTION */
2829 e = 0;
2830
2831 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->category_num);
2832
2833 if (e) {
2834 log_packet_detailed("'category_num' field error detected");
2835 }
2836
2837#ifdef FREECIV_JSON_CONNECTION
2838 field_addr.name = "player_id";
2839#endif /* FREECIV_JSON_CONNECTION */
2840 e = 0;
2841
2842 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_id);
2843
2844 if (e) {
2845 log_packet_detailed("'player_id' field error detected");
2846 }
2847
2848#ifdef FREECIV_JSON_CONNECTION
2849 field_addr.name = "score";
2850#endif /* FREECIV_JSON_CONNECTION */
2851 e = 0;
2852
2853 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->score);
2854
2855 if (e) {
2856 log_packet_detailed("'score' field error detected");
2857 }
2858
2859#ifdef FREECIV_JSON_CONNECTION
2860 field_addr.name = "category_score";
2861#endif /* FREECIV_JSON_CONNECTION */
2862 e = 0;
2863
2864 {
2865 int i;
2866
2867#ifdef FREECIV_JSON_CONNECTION
2868 /* Create the array. */
2869 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->category_num);
2870
2871 /* Enter array. */
2872 field_addr.sub_location = plocation_elem_new(0);
2873#endif /* FREECIV_JSON_CONNECTION */
2874
2875 for (i = 0; i < real_packet->category_num; i++) {
2876#ifdef FREECIV_JSON_CONNECTION
2877 /* Next array element. */
2878 field_addr.sub_location->number = i;
2879#endif /* FREECIV_JSON_CONNECTION */
2880
2881 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->category_score[i]);
2882 }
2883
2884#ifdef FREECIV_JSON_CONNECTION
2885 /* Exit array. */
2886 FC_FREE(field_addr.sub_location);
2887#endif /* FREECIV_JSON_CONNECTION */
2888 }
2889
2890 if (e) {
2891 log_packet_detailed("'category_score' field error detected");
2892 }
2893
2894#ifdef FREECIV_JSON_CONNECTION
2895 field_addr.name = "winner";
2896#endif /* FREECIV_JSON_CONNECTION */
2897 e = 0;
2898
2899 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->winner);
2900
2901 if (e) {
2902 log_packet_detailed("'winner' field error detected");
2903 }
2904
2905 SEND_PACKET_END(PACKET_ENDGAME_PLAYER);
2906}
2907
2908 int send_packet_endgame_player(struct connection *pc, const struct packet_endgame_player *packet)
2909{
2910 if (!pc->used) {
2911 log_error("WARNING: trying to send data to the closed connection %s",
2912 conn_description(pc));
2913 return -1;
2914 }
2915 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_ENDGAME_PLAYER].packet != nullptr, -1,
2916 "Handler for PACKET_ENDGAME_PLAYER not installed");
2917 return pc->phs.handlers->send[PACKET_ENDGAME_PLAYER].packet(pc, packet);
2918}
2919
2920 void lsend_packet_endgame_player(struct conn_list *dest, const struct packet_endgame_player *packet)
2921{
2922 conn_list_iterate(dest, pconn) {
2923 send_packet_endgame_player(pconn, packet);
2924 } conn_list_iterate_end;
2925}
2926
2927 static inline void init_packet_tile_info(struct packet_tile_info *packet)
2928{
2929 memset(packet, 0, sizeof(*packet));
2930}
2931
2932#define free_packet_tile_info(_packet) (void) 0
2933#define destroy_packet_tile_info free
2934
2935#ifdef FREECIV_DELTA_PROTOCOL
2936static genhash_val_t hash_packet_tile_info_100(const void *vkey)
2937{
2938 const struct packet_tile_info *key = (const struct packet_tile_info *) vkey;
2939 genhash_val_t result = 0;
2940
2941 result += key->tile;
2942
2943 result &= 0xFFFFFFFF;
2944 return result;
2945}
2946
2947static bool cmp_packet_tile_info_100(const void *vkey1, const void *vkey2)
2948{
2949 const struct packet_tile_info *old = (const struct packet_tile_info *) vkey1;
2950 const struct packet_tile_info *real_packet = (const struct packet_tile_info *) vkey2;
2951 bool differ;
2952
2953 differ = (old->tile != real_packet->tile);
2954
2955 return !differ;
2956}
2957 BV_DEFINE(packet_tile_info_100_fields, 13);
2958#endif /* FREECIV_DELTA_PROTOCOL */
2959
2960 static struct packet_tile_info *receive_packet_tile_info_100(struct connection *pc)
2961{
2962#define FREE_PACKET_STRUCT(_packet) free_packet_tile_info(_packet)
2963 RECEIVE_PACKET_START(packet_tile_info, real_packet);
2964
2965#ifdef FREECIV_JSON_CONNECTION
2966 struct plocation field_addr;
2967 {
2968 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
2969 field_addr = *field_addr_tmp;
2970 FC_FREE(field_addr_tmp);
2971 }
2972#endif /* FREECIV_JSON_CONNECTION */
2973
2974#ifdef FREECIV_JSON_CONNECTION
2975 field_addr.name = "tile";
2976#endif /* FREECIV_JSON_CONNECTION */
2977
2978 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
2979 RECEIVE_PACKET_FIELD_ERROR(tile);
2980 }
2981
2982 log_packet_detailed("packet_tile_info_100: got info about (%d)",
2983 real_packet->tile);
2984
2985#ifdef FREECIV_DELTA_PROTOCOL
2986 packet_tile_info_100_fields fields;
2987 struct packet_tile_info *old;
2988 struct genhash **hash = pc->phs.received + PACKET_TILE_INFO;
2989
2990 if (nullptr == *hash) {
2991 *hash = genhash_new_full(hash_packet_tile_info_100, cmp_packet_tile_info_100,
2992 nullptr, nullptr, nullptr, destroy_packet_tile_info);
2993 }
2994
2995 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
2996 *real_packet = *old;
2997 } else {
2998 /* packet is already initialized empty */
2999 log_packet_detailed(" no old info");
3000 }
3001
3002#ifdef FREECIV_JSON_CONNECTION
3003 field_addr.name = "fields";
3004#endif /* FREECIV_JSON_CONNECTION */
3005 DIO_BV_GET(&din, &field_addr, fields);
3006
3007 if (BV_ISSET(fields, 0)) {
3008 log_packet_detailed(" got field 'continent'");
3009
3010#ifdef FREECIV_JSON_CONNECTION
3011 field_addr.name = "continent";
3012#endif /* FREECIV_JSON_CONNECTION */
3013
3014 {
3015 int readin;
3016
3017 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
3018 RECEIVE_PACKET_FIELD_ERROR(continent);
3019 }
3020 real_packet->continent = readin;
3021 }
3022 }
3023
3024 if (BV_ISSET(fields, 1)) {
3025 log_packet_detailed(" got field 'known'");
3026
3027#ifdef FREECIV_JSON_CONNECTION
3028 field_addr.name = "known";
3029#endif /* FREECIV_JSON_CONNECTION */
3030
3031 {
3032 int readin;
3033
3034 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3035 RECEIVE_PACKET_FIELD_ERROR(known);
3036 }
3037 real_packet->known = readin;
3038 }
3039 }
3040
3041 if (BV_ISSET(fields, 2)) {
3042 log_packet_detailed(" got field 'owner'");
3043
3044#ifdef FREECIV_JSON_CONNECTION
3045 field_addr.name = "owner";
3046#endif /* FREECIV_JSON_CONNECTION */
3047
3048 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
3049 RECEIVE_PACKET_FIELD_ERROR(owner);
3050 }
3051 }
3052
3053 if (BV_ISSET(fields, 3)) {
3054 log_packet_detailed(" got field 'extras_owner'");
3055
3056#ifdef FREECIV_JSON_CONNECTION
3057 field_addr.name = "extras_owner";
3058#endif /* FREECIV_JSON_CONNECTION */
3059
3060 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->extras_owner)) {
3061 RECEIVE_PACKET_FIELD_ERROR(extras_owner);
3062 }
3063 }
3064
3065 if (BV_ISSET(fields, 4)) {
3066 log_packet_detailed(" got field 'worked'");
3067
3068#ifdef FREECIV_JSON_CONNECTION
3069 field_addr.name = "worked";
3070#endif /* FREECIV_JSON_CONNECTION */
3071
3072 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->worked)) {
3073 RECEIVE_PACKET_FIELD_ERROR(worked);
3074 }
3075 }
3076
3077 if (BV_ISSET(fields, 5)) {
3078 log_packet_detailed(" got field 'terrain'");
3079
3080#ifdef FREECIV_JSON_CONNECTION
3081 field_addr.name = "terrain";
3082#endif /* FREECIV_JSON_CONNECTION */
3083
3084 {
3085 int readin;
3086
3087 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3088 RECEIVE_PACKET_FIELD_ERROR(terrain);
3089 }
3090 real_packet->terrain = readin;
3091 }
3092 }
3093
3094 if (BV_ISSET(fields, 6)) {
3095 log_packet_detailed(" got field 'resource'");
3096
3097#ifdef FREECIV_JSON_CONNECTION
3098 field_addr.name = "resource";
3099#endif /* FREECIV_JSON_CONNECTION */
3100
3101 {
3102 int readin;
3103
3104 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3105 RECEIVE_PACKET_FIELD_ERROR(resource);
3106 }
3107 real_packet->resource = readin;
3108 }
3109 }
3110
3111 if (BV_ISSET(fields, 7)) {
3112 log_packet_detailed(" got field 'extras'");
3113
3114#ifdef FREECIV_JSON_CONNECTION
3115 field_addr.name = "extras";
3116#endif /* FREECIV_JSON_CONNECTION */
3117
3118 if (!DIO_BV_GET(&din, &field_addr, real_packet->extras)) {
3119 RECEIVE_PACKET_FIELD_ERROR(extras);
3120 }
3121 }
3122
3123 if (BV_ISSET(fields, 8)) {
3124 log_packet_detailed(" got field 'placing'");
3125
3126#ifdef FREECIV_JSON_CONNECTION
3127 field_addr.name = "placing";
3128#endif /* FREECIV_JSON_CONNECTION */
3129
3130 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->placing)) {
3131 RECEIVE_PACKET_FIELD_ERROR(placing);
3132 }
3133 }
3134
3135 if (BV_ISSET(fields, 9)) {
3136 log_packet_detailed(" got field 'place_turn'");
3137
3138#ifdef FREECIV_JSON_CONNECTION
3139 field_addr.name = "place_turn";
3140#endif /* FREECIV_JSON_CONNECTION */
3141
3142 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->place_turn)) {
3143 RECEIVE_PACKET_FIELD_ERROR(place_turn);
3144 }
3145 }
3146
3147 if (BV_ISSET(fields, 10)) {
3148 log_packet_detailed(" got field 'altitude'");
3149
3150#ifdef FREECIV_JSON_CONNECTION
3151 field_addr.name = "altitude";
3152#endif /* FREECIV_JSON_CONNECTION */
3153
3154 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->altitude)) {
3155 RECEIVE_PACKET_FIELD_ERROR(altitude);
3156 }
3157 }
3158
3159 if (BV_ISSET(fields, 11)) {
3160 log_packet_detailed(" got field 'spec_sprite'");
3161
3162#ifdef FREECIV_JSON_CONNECTION
3163 field_addr.name = "spec_sprite";
3164#endif /* FREECIV_JSON_CONNECTION */
3165
3166 if (!DIO_GET(string, &din, &field_addr, real_packet->spec_sprite, sizeof(real_packet->spec_sprite))) {
3167 RECEIVE_PACKET_FIELD_ERROR(spec_sprite);
3168 }
3169 }
3170
3171 if (BV_ISSET(fields, 12)) {
3172 log_packet_detailed(" got field 'label'");
3173
3174#ifdef FREECIV_JSON_CONNECTION
3175 field_addr.name = "label";
3176#endif /* FREECIV_JSON_CONNECTION */
3177
3178 if (!DIO_GET(string, &din, &field_addr, real_packet->label, sizeof(real_packet->label))) {
3179 RECEIVE_PACKET_FIELD_ERROR(label);
3180 }
3181 }
3182
3183 if (nullptr == old) {
3184 old = fc_malloc(sizeof(*old));
3185 init_packet_tile_info(old);
3186 *old = *real_packet;
3187 genhash_insert(*hash, old, old);
3188 } else {
3189 *old = *real_packet;
3190 }
3191
3192#else /* FREECIV_DELTA_PROTOCOL */
3193#ifdef FREECIV_JSON_CONNECTION
3194 field_addr.name = "continent";
3195#endif /* FREECIV_JSON_CONNECTION */
3196
3197 {
3198 int readin;
3199
3200 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
3201 RECEIVE_PACKET_FIELD_ERROR(continent);
3202 }
3203 real_packet->continent = readin;
3204 }
3205
3206#ifdef FREECIV_JSON_CONNECTION
3207 field_addr.name = "known";
3208#endif /* FREECIV_JSON_CONNECTION */
3209
3210 {
3211 int readin;
3212
3213 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3214 RECEIVE_PACKET_FIELD_ERROR(known);
3215 }
3216 real_packet->known = readin;
3217 }
3218
3219#ifdef FREECIV_JSON_CONNECTION
3220 field_addr.name = "owner";
3221#endif /* FREECIV_JSON_CONNECTION */
3222
3223 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
3224 RECEIVE_PACKET_FIELD_ERROR(owner);
3225 }
3226
3227#ifdef FREECIV_JSON_CONNECTION
3228 field_addr.name = "extras_owner";
3229#endif /* FREECIV_JSON_CONNECTION */
3230
3231 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->extras_owner)) {
3232 RECEIVE_PACKET_FIELD_ERROR(extras_owner);
3233 }
3234
3235#ifdef FREECIV_JSON_CONNECTION
3236 field_addr.name = "worked";
3237#endif /* FREECIV_JSON_CONNECTION */
3238
3239 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->worked)) {
3240 RECEIVE_PACKET_FIELD_ERROR(worked);
3241 }
3242
3243#ifdef FREECIV_JSON_CONNECTION
3244 field_addr.name = "terrain";
3245#endif /* FREECIV_JSON_CONNECTION */
3246
3247 {
3248 int readin;
3249
3250 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3251 RECEIVE_PACKET_FIELD_ERROR(terrain);
3252 }
3253 real_packet->terrain = readin;
3254 }
3255
3256#ifdef FREECIV_JSON_CONNECTION
3257 field_addr.name = "resource";
3258#endif /* FREECIV_JSON_CONNECTION */
3259
3260 {
3261 int readin;
3262
3263 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3264 RECEIVE_PACKET_FIELD_ERROR(resource);
3265 }
3266 real_packet->resource = readin;
3267 }
3268
3269#ifdef FREECIV_JSON_CONNECTION
3270 field_addr.name = "extras";
3271#endif /* FREECIV_JSON_CONNECTION */
3272
3273 if (!DIO_BV_GET(&din, &field_addr, real_packet->extras)) {
3274 RECEIVE_PACKET_FIELD_ERROR(extras);
3275 }
3276
3277#ifdef FREECIV_JSON_CONNECTION
3278 field_addr.name = "placing";
3279#endif /* FREECIV_JSON_CONNECTION */
3280
3281 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->placing)) {
3282 RECEIVE_PACKET_FIELD_ERROR(placing);
3283 }
3284
3285#ifdef FREECIV_JSON_CONNECTION
3286 field_addr.name = "place_turn";
3287#endif /* FREECIV_JSON_CONNECTION */
3288
3289 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->place_turn)) {
3290 RECEIVE_PACKET_FIELD_ERROR(place_turn);
3291 }
3292
3293#ifdef FREECIV_JSON_CONNECTION
3294 field_addr.name = "altitude";
3295#endif /* FREECIV_JSON_CONNECTION */
3296
3297 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->altitude)) {
3298 RECEIVE_PACKET_FIELD_ERROR(altitude);
3299 }
3300
3301#ifdef FREECIV_JSON_CONNECTION
3302 field_addr.name = "spec_sprite";
3303#endif /* FREECIV_JSON_CONNECTION */
3304
3305 if (!DIO_GET(string, &din, &field_addr, real_packet->spec_sprite, sizeof(real_packet->spec_sprite))) {
3306 RECEIVE_PACKET_FIELD_ERROR(spec_sprite);
3307 }
3308
3309#ifdef FREECIV_JSON_CONNECTION
3310 field_addr.name = "label";
3311#endif /* FREECIV_JSON_CONNECTION */
3312
3313 if (!DIO_GET(string, &din, &field_addr, real_packet->label, sizeof(real_packet->label))) {
3314 RECEIVE_PACKET_FIELD_ERROR(label);
3315 }
3316#endif /* FREECIV_DELTA_PROTOCOL */
3317
3318 RECEIVE_PACKET_END(real_packet);
3319#undef FREE_PACKET_STRUCT
3320}
3321
3322 static int send_packet_tile_info_100(struct connection *pc, const struct packet_tile_info *packet)
3323{
3324 const struct packet_tile_info *real_packet = packet;
3325 int e;
3326 SEND_PACKET_START(PACKET_TILE_INFO);
3327
3328 log_packet_detailed("packet_tile_info_100: sending info about (%d)",
3329 real_packet->tile);
3330
3331#ifdef FREECIV_DELTA_PROTOCOL
3332 packet_tile_info_100_fields fields;
3333 struct packet_tile_info *old;
3334 bool differ;
3335 int different = 0;
3336 struct genhash **hash = pc->phs.sent + PACKET_TILE_INFO;
3337
3338 if (nullptr == *hash) {
3339 *hash = genhash_new_full(hash_packet_tile_info_100, cmp_packet_tile_info_100,
3340 nullptr, nullptr, nullptr, destroy_packet_tile_info);
3341 }
3342 BV_CLR_ALL(fields);
3343
3344 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
3345 old = fc_malloc(sizeof(*old));
3346 /* temporary bitcopy just to insert correctly */
3347 *old = *real_packet;
3348 genhash_insert(*hash, old, old);
3349 init_packet_tile_info(old);
3350 different = 1; /* Force to send. */
3351 }
3352
3353 differ = (old->continent != real_packet->continent);
3354 if (differ) {
3355 different++;
3356 BV_SET(fields, 0);
3357 }
3358
3359 differ = (old->known != real_packet->known);
3360 if (differ) {
3361 different++;
3362 BV_SET(fields, 1);
3363 }
3364
3365 differ = (old->owner != real_packet->owner);
3366 if (differ) {
3367 different++;
3368 BV_SET(fields, 2);
3369 }
3370
3371 differ = (old->extras_owner != real_packet->extras_owner);
3372 if (differ) {
3373 different++;
3374 BV_SET(fields, 3);
3375 }
3376
3377 differ = (old->worked != real_packet->worked);
3378 if (differ) {
3379 different++;
3380 BV_SET(fields, 4);
3381 }
3382
3383 differ = (old->terrain != real_packet->terrain);
3384 if (differ) {
3385 different++;
3386 BV_SET(fields, 5);
3387 }
3388
3389 differ = (old->resource != real_packet->resource);
3390 if (differ) {
3391 different++;
3392 BV_SET(fields, 6);
3393 }
3394
3395 differ = !BV_ARE_EQUAL(old->extras, real_packet->extras);
3396 if (differ) {
3397 different++;
3398 BV_SET(fields, 7);
3399 }
3400
3401 differ = (old->placing != real_packet->placing);
3402 if (differ) {
3403 different++;
3404 BV_SET(fields, 8);
3405 }
3406
3407 differ = (old->place_turn != real_packet->place_turn);
3408 if (differ) {
3409 different++;
3410 BV_SET(fields, 9);
3411 }
3412
3413 differ = (old->altitude != real_packet->altitude);
3414 if (differ) {
3415 different++;
3416 BV_SET(fields, 10);
3417 }
3418
3419 differ = (strcmp(old->spec_sprite, real_packet->spec_sprite) != 0);
3420 if (differ) {
3421 different++;
3422 BV_SET(fields, 11);
3423 }
3424
3425 differ = (strcmp(old->label, real_packet->label) != 0);
3426 if (differ) {
3427 different++;
3428 BV_SET(fields, 12);
3429 }
3430
3431 if (different == 0) {
3432 log_packet_detailed(" no change -> discard");
3433 SEND_PACKET_DISCARD();
3434 }
3435#endif /* FREECIV_DELTA_PROTOCOL */
3436
3437#ifdef FREECIV_JSON_CONNECTION
3438 struct plocation field_addr;
3439 {
3440 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
3441 field_addr = *field_addr_tmp;
3442 FC_FREE(field_addr_tmp);
3443 }
3444#endif /* FREECIV_JSON_CONNECTION */
3445
3446#ifdef FREECIV_JSON_CONNECTION
3447 field_addr.name = "tile";
3448#endif /* FREECIV_JSON_CONNECTION */
3449 e = 0;
3450
3451 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
3452
3453 if (e) {
3454 log_packet_detailed("'tile' field error detected");
3455 }
3456
3457#ifdef FREECIV_DELTA_PROTOCOL
3458#ifdef FREECIV_JSON_CONNECTION
3459 field_addr.name = "fields";
3460#endif /* FREECIV_JSON_CONNECTION */
3461 e = 0;
3462 e |= DIO_BV_PUT(&dout, &field_addr, fields);
3463 if (e) {
3464 log_packet_detailed("fields bitvector error detected");
3465 }
3466
3467 if (BV_ISSET(fields, 0)) {
3468 log_packet_detailed(" field 'continent' has changed");
3469
3470#ifdef FREECIV_JSON_CONNECTION
3471 field_addr.name = "continent";
3472#endif /* FREECIV_JSON_CONNECTION */
3473 e = 0;
3474
3475 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->continent);
3476
3477 if (e) {
3478 log_packet_detailed("'continent' field error detected");
3479 }
3480 }
3481
3482 if (BV_ISSET(fields, 1)) {
3483 log_packet_detailed(" field 'known' has changed");
3484
3485#ifdef FREECIV_JSON_CONNECTION
3486 field_addr.name = "known";
3487#endif /* FREECIV_JSON_CONNECTION */
3488 e = 0;
3489
3490 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->known);
3491
3492 if (e) {
3493 log_packet_detailed("'known' field error detected");
3494 }
3495 }
3496
3497 if (BV_ISSET(fields, 2)) {
3498 log_packet_detailed(" field 'owner' has changed");
3499
3500#ifdef FREECIV_JSON_CONNECTION
3501 field_addr.name = "owner";
3502#endif /* FREECIV_JSON_CONNECTION */
3503 e = 0;
3504
3505 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
3506
3507 if (e) {
3508 log_packet_detailed("'owner' field error detected");
3509 }
3510 }
3511
3512 if (BV_ISSET(fields, 3)) {
3513 log_packet_detailed(" field 'extras_owner' has changed");
3514
3515#ifdef FREECIV_JSON_CONNECTION
3516 field_addr.name = "extras_owner";
3517#endif /* FREECIV_JSON_CONNECTION */
3518 e = 0;
3519
3520 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->extras_owner);
3521
3522 if (e) {
3523 log_packet_detailed("'extras_owner' field error detected");
3524 }
3525 }
3526
3527 if (BV_ISSET(fields, 4)) {
3528 log_packet_detailed(" field 'worked' has changed");
3529
3530#ifdef FREECIV_JSON_CONNECTION
3531 field_addr.name = "worked";
3532#endif /* FREECIV_JSON_CONNECTION */
3533 e = 0;
3534
3535 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->worked);
3536
3537 if (e) {
3538 log_packet_detailed("'worked' field error detected");
3539 }
3540 }
3541
3542 if (BV_ISSET(fields, 5)) {
3543 log_packet_detailed(" field 'terrain' has changed");
3544
3545#ifdef FREECIV_JSON_CONNECTION
3546 field_addr.name = "terrain";
3547#endif /* FREECIV_JSON_CONNECTION */
3548 e = 0;
3549
3550 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain);
3551
3552 if (e) {
3553 log_packet_detailed("'terrain' field error detected");
3554 }
3555 }
3556
3557 if (BV_ISSET(fields, 6)) {
3558 log_packet_detailed(" field 'resource' has changed");
3559
3560#ifdef FREECIV_JSON_CONNECTION
3561 field_addr.name = "resource";
3562#endif /* FREECIV_JSON_CONNECTION */
3563 e = 0;
3564
3565 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resource);
3566
3567 if (e) {
3568 log_packet_detailed("'resource' field error detected");
3569 }
3570 }
3571
3572 if (BV_ISSET(fields, 7)) {
3573 log_packet_detailed(" field 'extras' has changed");
3574
3575#ifdef FREECIV_JSON_CONNECTION
3576 field_addr.name = "extras";
3577#endif /* FREECIV_JSON_CONNECTION */
3578 e = 0;
3579
3580 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->extras);
3581
3582 if (e) {
3583 log_packet_detailed("'extras' field error detected");
3584 }
3585 }
3586
3587 if (BV_ISSET(fields, 8)) {
3588 log_packet_detailed(" field 'placing' has changed");
3589
3590#ifdef FREECIV_JSON_CONNECTION
3591 field_addr.name = "placing";
3592#endif /* FREECIV_JSON_CONNECTION */
3593 e = 0;
3594
3595 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->placing);
3596
3597 if (e) {
3598 log_packet_detailed("'placing' field error detected");
3599 }
3600 }
3601
3602 if (BV_ISSET(fields, 9)) {
3603 log_packet_detailed(" field 'place_turn' has changed");
3604
3605#ifdef FREECIV_JSON_CONNECTION
3606 field_addr.name = "place_turn";
3607#endif /* FREECIV_JSON_CONNECTION */
3608 e = 0;
3609
3610 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->place_turn);
3611
3612 if (e) {
3613 log_packet_detailed("'place_turn' field error detected");
3614 }
3615 }
3616
3617 if (BV_ISSET(fields, 10)) {
3618 log_packet_detailed(" field 'altitude' has changed");
3619
3620#ifdef FREECIV_JSON_CONNECTION
3621 field_addr.name = "altitude";
3622#endif /* FREECIV_JSON_CONNECTION */
3623 e = 0;
3624
3625 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->altitude);
3626
3627 if (e) {
3628 log_packet_detailed("'altitude' field error detected");
3629 }
3630 }
3631
3632 if (BV_ISSET(fields, 11)) {
3633 log_packet_detailed(" field 'spec_sprite' has changed");
3634
3635#ifdef FREECIV_JSON_CONNECTION
3636 field_addr.name = "spec_sprite";
3637#endif /* FREECIV_JSON_CONNECTION */
3638 e = 0;
3639
3640 e |= DIO_PUT(string, &dout, &field_addr, real_packet->spec_sprite);
3641
3642 if (e) {
3643 log_packet_detailed("'spec_sprite' field error detected");
3644 }
3645 }
3646
3647 if (BV_ISSET(fields, 12)) {
3648 log_packet_detailed(" field 'label' has changed");
3649
3650#ifdef FREECIV_JSON_CONNECTION
3651 field_addr.name = "label";
3652#endif /* FREECIV_JSON_CONNECTION */
3653 e = 0;
3654
3655 e |= DIO_PUT(string, &dout, &field_addr, real_packet->label);
3656
3657 if (e) {
3658 log_packet_detailed("'label' field error detected");
3659 }
3660 }
3661
3662 *old = *real_packet;
3663
3664#else /* FREECIV_DELTA_PROTOCOL */
3665#ifdef FREECIV_JSON_CONNECTION
3666 field_addr.name = "continent";
3667#endif /* FREECIV_JSON_CONNECTION */
3668 e = 0;
3669
3670 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->continent);
3671
3672 if (e) {
3673 log_packet_detailed("'continent' field error detected");
3674 }
3675
3676#ifdef FREECIV_JSON_CONNECTION
3677 field_addr.name = "known";
3678#endif /* FREECIV_JSON_CONNECTION */
3679 e = 0;
3680
3681 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->known);
3682
3683 if (e) {
3684 log_packet_detailed("'known' field error detected");
3685 }
3686
3687#ifdef FREECIV_JSON_CONNECTION
3688 field_addr.name = "owner";
3689#endif /* FREECIV_JSON_CONNECTION */
3690 e = 0;
3691
3692 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
3693
3694 if (e) {
3695 log_packet_detailed("'owner' field error detected");
3696 }
3697
3698#ifdef FREECIV_JSON_CONNECTION
3699 field_addr.name = "extras_owner";
3700#endif /* FREECIV_JSON_CONNECTION */
3701 e = 0;
3702
3703 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->extras_owner);
3704
3705 if (e) {
3706 log_packet_detailed("'extras_owner' field error detected");
3707 }
3708
3709#ifdef FREECIV_JSON_CONNECTION
3710 field_addr.name = "worked";
3711#endif /* FREECIV_JSON_CONNECTION */
3712 e = 0;
3713
3714 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->worked);
3715
3716 if (e) {
3717 log_packet_detailed("'worked' field error detected");
3718 }
3719
3720#ifdef FREECIV_JSON_CONNECTION
3721 field_addr.name = "terrain";
3722#endif /* FREECIV_JSON_CONNECTION */
3723 e = 0;
3724
3725 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain);
3726
3727 if (e) {
3728 log_packet_detailed("'terrain' field error detected");
3729 }
3730
3731#ifdef FREECIV_JSON_CONNECTION
3732 field_addr.name = "resource";
3733#endif /* FREECIV_JSON_CONNECTION */
3734 e = 0;
3735
3736 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resource);
3737
3738 if (e) {
3739 log_packet_detailed("'resource' field error detected");
3740 }
3741
3742#ifdef FREECIV_JSON_CONNECTION
3743 field_addr.name = "extras";
3744#endif /* FREECIV_JSON_CONNECTION */
3745 e = 0;
3746
3747 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->extras);
3748
3749 if (e) {
3750 log_packet_detailed("'extras' field error detected");
3751 }
3752
3753#ifdef FREECIV_JSON_CONNECTION
3754 field_addr.name = "placing";
3755#endif /* FREECIV_JSON_CONNECTION */
3756 e = 0;
3757
3758 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->placing);
3759
3760 if (e) {
3761 log_packet_detailed("'placing' field error detected");
3762 }
3763
3764#ifdef FREECIV_JSON_CONNECTION
3765 field_addr.name = "place_turn";
3766#endif /* FREECIV_JSON_CONNECTION */
3767 e = 0;
3768
3769 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->place_turn);
3770
3771 if (e) {
3772 log_packet_detailed("'place_turn' field error detected");
3773 }
3774
3775#ifdef FREECIV_JSON_CONNECTION
3776 field_addr.name = "altitude";
3777#endif /* FREECIV_JSON_CONNECTION */
3778 e = 0;
3779
3780 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->altitude);
3781
3782 if (e) {
3783 log_packet_detailed("'altitude' field error detected");
3784 }
3785
3786#ifdef FREECIV_JSON_CONNECTION
3787 field_addr.name = "spec_sprite";
3788#endif /* FREECIV_JSON_CONNECTION */
3789 e = 0;
3790
3791 e |= DIO_PUT(string, &dout, &field_addr, real_packet->spec_sprite);
3792
3793 if (e) {
3794 log_packet_detailed("'spec_sprite' field error detected");
3795 }
3796
3797#ifdef FREECIV_JSON_CONNECTION
3798 field_addr.name = "label";
3799#endif /* FREECIV_JSON_CONNECTION */
3800 e = 0;
3801
3802 e |= DIO_PUT(string, &dout, &field_addr, real_packet->label);
3803
3804 if (e) {
3805 log_packet_detailed("'label' field error detected");
3806 }
3807#endif /* FREECIV_DELTA_PROTOCOL */
3808
3809 SEND_PACKET_END(PACKET_TILE_INFO);
3810}
3811
3812 int send_packet_tile_info(struct connection *pc, const struct packet_tile_info *packet)
3813{
3814 if (!pc->used) {
3815 log_error("WARNING: trying to send data to the closed connection %s",
3816 conn_description(pc));
3817 return -1;
3818 }
3819 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_TILE_INFO].packet != nullptr, -1,
3820 "Handler for PACKET_TILE_INFO not installed");
3821 return pc->phs.handlers->send[PACKET_TILE_INFO].packet(pc, packet);
3822}
3823
3824 void lsend_packet_tile_info(struct conn_list *dest, const struct packet_tile_info *packet)
3825{
3826 conn_list_iterate(dest, pconn) {
3827 send_packet_tile_info(pconn, packet);
3828 } conn_list_iterate_end;
3829}
3830
3831 static inline void init_packet_game_info(struct packet_game_info *packet)
3832{
3833 memset(packet, 0, sizeof(*packet));
3834}
3835
3836#define free_packet_game_info(_packet) (void) 0
3837#define destroy_packet_game_info free
3838
3839#ifdef FREECIV_DELTA_PROTOCOL
3840#define hash_packet_game_info_100 hash_const
3841#define cmp_packet_game_info_100 cmp_const
3842 BV_DEFINE(packet_game_info_100_fields, 137);
3843#endif /* FREECIV_DELTA_PROTOCOL */
3844
3845 static struct packet_game_info *receive_packet_game_info_100(struct connection *pc)
3846{
3847#define FREE_PACKET_STRUCT(_packet) free_packet_game_info(_packet)
3848 RECEIVE_PACKET_START(packet_game_info, real_packet);
3849
3850#ifdef FREECIV_JSON_CONNECTION
3851 struct plocation field_addr;
3852 {
3853 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
3854 field_addr = *field_addr_tmp;
3855 FC_FREE(field_addr_tmp);
3856 }
3857#endif /* FREECIV_JSON_CONNECTION */
3858
3859 log_packet_detailed("packet_game_info_100: got info about ()");
3860
3861#ifdef FREECIV_DELTA_PROTOCOL
3862 packet_game_info_100_fields fields;
3863 struct packet_game_info *old;
3864 struct genhash **hash = pc->phs.received + PACKET_GAME_INFO;
3865
3866 if (nullptr == *hash) {
3867 *hash = genhash_new_full(hash_packet_game_info_100, cmp_packet_game_info_100,
3868 nullptr, nullptr, nullptr, destroy_packet_game_info);
3869 }
3870
3871 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
3872 *real_packet = *old;
3873 } else {
3874 /* packet is already initialized empty */
3875 log_packet_detailed(" no old info");
3876 }
3877
3878#ifdef FREECIV_JSON_CONNECTION
3879 field_addr.name = "fields";
3880#endif /* FREECIV_JSON_CONNECTION */
3881 DIO_BV_GET(&din, &field_addr, fields);
3882
3883 if (BV_ISSET(fields, 0)) {
3884 log_packet_detailed(" got field 'add_to_size_limit'");
3885
3886#ifdef FREECIV_JSON_CONNECTION
3887 field_addr.name = "add_to_size_limit";
3888#endif /* FREECIV_JSON_CONNECTION */
3889
3890 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->add_to_size_limit)) {
3891 RECEIVE_PACKET_FIELD_ERROR(add_to_size_limit);
3892 }
3893 }
3894
3895 if (BV_ISSET(fields, 1)) {
3896 log_packet_detailed(" got field 'aifill'");
3897
3898#ifdef FREECIV_JSON_CONNECTION
3899 field_addr.name = "aifill";
3900#endif /* FREECIV_JSON_CONNECTION */
3901
3902 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->aifill)) {
3903 RECEIVE_PACKET_FIELD_ERROR(aifill);
3904 }
3905 }
3906
3907 if (BV_ISSET(fields, 2)) {
3908 log_packet_detailed(" got field 'persistent_ready'");
3909
3910#ifdef FREECIV_JSON_CONNECTION
3911 field_addr.name = "persistent_ready";
3912#endif /* FREECIV_JSON_CONNECTION */
3913
3914 {
3915 int readin;
3916
3917 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3918 RECEIVE_PACKET_FIELD_ERROR(persistent_ready);
3919 }
3920 real_packet->persistent_ready = readin;
3921 }
3922 }
3923
3924 if (BV_ISSET(fields, 3)) {
3925 log_packet_detailed(" got field 'airlifting_style'");
3926
3927#ifdef FREECIV_JSON_CONNECTION
3928 field_addr.name = "airlifting_style";
3929#endif /* FREECIV_JSON_CONNECTION */
3930
3931 {
3932 int readin;
3933
3934 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
3935 RECEIVE_PACKET_FIELD_ERROR(airlifting_style);
3936 }
3937 real_packet->airlifting_style = readin;
3938 }
3939 }
3940
3941 real_packet->airlift_from_always_enabled = BV_ISSET(fields, 4);
3942
3943 real_packet->airlift_to_always_enabled = BV_ISSET(fields, 5);
3944
3945 if (BV_ISSET(fields, 6)) {
3946 log_packet_detailed(" got field 'angrycitizen'");
3947
3948#ifdef FREECIV_JSON_CONNECTION
3949 field_addr.name = "angrycitizen";
3950#endif /* FREECIV_JSON_CONNECTION */
3951
3952 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->angrycitizen)) {
3953 RECEIVE_PACKET_FIELD_ERROR(angrycitizen);
3954 }
3955 }
3956
3957 if (BV_ISSET(fields, 7)) {
3958 log_packet_detailed(" got field 'base_pollution'");
3959
3960#ifdef FREECIV_JSON_CONNECTION
3961 field_addr.name = "base_pollution";
3962#endif /* FREECIV_JSON_CONNECTION */
3963
3964 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->base_pollution)) {
3965 RECEIVE_PACKET_FIELD_ERROR(base_pollution);
3966 }
3967 }
3968
3969 if (BV_ISSET(fields, 8)) {
3970 log_packet_detailed(" got field 'base_tech_cost'");
3971
3972#ifdef FREECIV_JSON_CONNECTION
3973 field_addr.name = "base_tech_cost";
3974#endif /* FREECIV_JSON_CONNECTION */
3975
3976 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->base_tech_cost)) {
3977 RECEIVE_PACKET_FIELD_ERROR(base_tech_cost);
3978 }
3979 }
3980
3981 if (BV_ISSET(fields, 9)) {
3982 log_packet_detailed(" got field 'min_tech_cost'");
3983
3984#ifdef FREECIV_JSON_CONNECTION
3985 field_addr.name = "min_tech_cost";
3986#endif /* FREECIV_JSON_CONNECTION */
3987
3988 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->min_tech_cost)) {
3989 RECEIVE_PACKET_FIELD_ERROR(min_tech_cost);
3990 }
3991 }
3992
3993 if (BV_ISSET(fields, 10)) {
3994 log_packet_detailed(" got field 'tech_leak_pct'");
3995
3996#ifdef FREECIV_JSON_CONNECTION
3997 field_addr.name = "tech_leak_pct";
3998#endif /* FREECIV_JSON_CONNECTION */
3999
4000 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tech_leak_pct)) {
4001 RECEIVE_PACKET_FIELD_ERROR(tech_leak_pct);
4002 }
4003 }
4004
4005 if (BV_ISSET(fields, 11)) {
4006 log_packet_detailed(" got field 'border_city_radius_sq'");
4007
4008#ifdef FREECIV_JSON_CONNECTION
4009 field_addr.name = "border_city_radius_sq";
4010#endif /* FREECIV_JSON_CONNECTION */
4011
4012 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->border_city_radius_sq)) {
4013 RECEIVE_PACKET_FIELD_ERROR(border_city_radius_sq);
4014 }
4015 }
4016
4017 if (BV_ISSET(fields, 12)) {
4018 log_packet_detailed(" got field 'border_size_effect'");
4019
4020#ifdef FREECIV_JSON_CONNECTION
4021 field_addr.name = "border_size_effect";
4022#endif /* FREECIV_JSON_CONNECTION */
4023
4024 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->border_size_effect)) {
4025 RECEIVE_PACKET_FIELD_ERROR(border_size_effect);
4026 }
4027 }
4028
4029 if (BV_ISSET(fields, 13)) {
4030 log_packet_detailed(" got field 'border_city_permanent_radius_sq'");
4031
4032#ifdef FREECIV_JSON_CONNECTION
4033 field_addr.name = "border_city_permanent_radius_sq";
4034#endif /* FREECIV_JSON_CONNECTION */
4035
4036 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->border_city_permanent_radius_sq)) {
4037 RECEIVE_PACKET_FIELD_ERROR(border_city_permanent_radius_sq);
4038 }
4039 }
4040
4041 if (BV_ISSET(fields, 14)) {
4042 log_packet_detailed(" got field 'borders'");
4043
4044#ifdef FREECIV_JSON_CONNECTION
4045 field_addr.name = "borders";
4046#endif /* FREECIV_JSON_CONNECTION */
4047
4048 {
4049 int readin;
4050
4051 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4052 RECEIVE_PACKET_FIELD_ERROR(borders);
4053 }
4054 real_packet->borders = readin;
4055 }
4056 }
4057
4058 if (BV_ISSET(fields, 15)) {
4059 log_packet_detailed(" got field 'base_bribe_cost'");
4060
4061#ifdef FREECIV_JSON_CONNECTION
4062 field_addr.name = "base_bribe_cost";
4063#endif /* FREECIV_JSON_CONNECTION */
4064
4065 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->base_bribe_cost)) {
4066 RECEIVE_PACKET_FIELD_ERROR(base_bribe_cost);
4067 }
4068 }
4069
4070 if (BV_ISSET(fields, 16)) {
4071 log_packet_detailed(" got field 'caravan_bonus_style'");
4072
4073#ifdef FREECIV_JSON_CONNECTION
4074 field_addr.name = "caravan_bonus_style";
4075#endif /* FREECIV_JSON_CONNECTION */
4076
4077 {
4078 int readin;
4079
4080 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4081 RECEIVE_PACKET_FIELD_ERROR(caravan_bonus_style);
4082 }
4083 real_packet->caravan_bonus_style = readin;
4084 }
4085 }
4086
4087 if (BV_ISSET(fields, 17)) {
4088 log_packet_detailed(" got field 'culture_vic_points'");
4089
4090#ifdef FREECIV_JSON_CONNECTION
4091 field_addr.name = "culture_vic_points";
4092#endif /* FREECIV_JSON_CONNECTION */
4093
4094 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->culture_vic_points)) {
4095 RECEIVE_PACKET_FIELD_ERROR(culture_vic_points);
4096 }
4097 }
4098
4099 if (BV_ISSET(fields, 18)) {
4100 log_packet_detailed(" got field 'culture_vic_lead'");
4101
4102#ifdef FREECIV_JSON_CONNECTION
4103 field_addr.name = "culture_vic_lead";
4104#endif /* FREECIV_JSON_CONNECTION */
4105
4106 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->culture_vic_lead)) {
4107 RECEIVE_PACKET_FIELD_ERROR(culture_vic_lead);
4108 }
4109 }
4110
4111 if (BV_ISSET(fields, 19)) {
4112 log_packet_detailed(" got field 'culture_migration_pml'");
4113
4114#ifdef FREECIV_JSON_CONNECTION
4115 field_addr.name = "culture_migration_pml";
4116#endif /* FREECIV_JSON_CONNECTION */
4117
4118 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->culture_migration_pml)) {
4119 RECEIVE_PACKET_FIELD_ERROR(culture_migration_pml);
4120 }
4121 }
4122
4123 if (BV_ISSET(fields, 20)) {
4124 log_packet_detailed(" got field 'history_interest_pml'");
4125
4126#ifdef FREECIV_JSON_CONNECTION
4127 field_addr.name = "history_interest_pml";
4128#endif /* FREECIV_JSON_CONNECTION */
4129
4130 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->history_interest_pml)) {
4131 RECEIVE_PACKET_FIELD_ERROR(history_interest_pml);
4132 }
4133 }
4134
4135 if (BV_ISSET(fields, 21)) {
4136 log_packet_detailed(" got field 'world_peace_turns'");
4137
4138#ifdef FREECIV_JSON_CONNECTION
4139 field_addr.name = "world_peace_turns";
4140#endif /* FREECIV_JSON_CONNECTION */
4141
4142 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->world_peace_turns)) {
4143 RECEIVE_PACKET_FIELD_ERROR(world_peace_turns);
4144 }
4145 }
4146
4147 if (BV_ISSET(fields, 22)) {
4148 log_packet_detailed(" got field 'celebratesize'");
4149
4150#ifdef FREECIV_JSON_CONNECTION
4151 field_addr.name = "celebratesize";
4152#endif /* FREECIV_JSON_CONNECTION */
4153
4154 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->celebratesize)) {
4155 RECEIVE_PACKET_FIELD_ERROR(celebratesize);
4156 }
4157 }
4158
4159 real_packet->changable_tax = BV_ISSET(fields, 23);
4160
4161 if (BV_ISSET(fields, 24)) {
4162 log_packet_detailed(" got field 'pop_report_zeroes'");
4163
4164#ifdef FREECIV_JSON_CONNECTION
4165 field_addr.name = "pop_report_zeroes";
4166#endif /* FREECIV_JSON_CONNECTION */
4167
4168 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->pop_report_zeroes)) {
4169 RECEIVE_PACKET_FIELD_ERROR(pop_report_zeroes);
4170 }
4171 }
4172
4173 real_packet->citizen_nationality = BV_ISSET(fields, 25);
4174
4175 real_packet->unit_builders_nationality = BV_ISSET(fields, 26);
4176
4177 if (BV_ISSET(fields, 27)) {
4178 log_packet_detailed(" got field 'citizen_convert_speed'");
4179
4180#ifdef FREECIV_JSON_CONNECTION
4181 field_addr.name = "citizen_convert_speed";
4182#endif /* FREECIV_JSON_CONNECTION */
4183
4184 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->citizen_convert_speed)) {
4185 RECEIVE_PACKET_FIELD_ERROR(citizen_convert_speed);
4186 }
4187 }
4188
4189 if (BV_ISSET(fields, 28)) {
4190 log_packet_detailed(" got field 'conquest_convert_pct'");
4191
4192#ifdef FREECIV_JSON_CONNECTION
4193 field_addr.name = "conquest_convert_pct";
4194#endif /* FREECIV_JSON_CONNECTION */
4195
4196 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->conquest_convert_pct)) {
4197 RECEIVE_PACKET_FIELD_ERROR(conquest_convert_pct);
4198 }
4199 }
4200
4201 if (BV_ISSET(fields, 29)) {
4202 log_packet_detailed(" got field 'citizen_partisans_pct'");
4203
4204#ifdef FREECIV_JSON_CONNECTION
4205 field_addr.name = "citizen_partisans_pct";
4206#endif /* FREECIV_JSON_CONNECTION */
4207
4208 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->citizen_partisans_pct)) {
4209 RECEIVE_PACKET_FIELD_ERROR(citizen_partisans_pct);
4210 }
4211 }
4212
4213 if (BV_ISSET(fields, 30)) {
4214 log_packet_detailed(" got field 'citymindist'");
4215
4216#ifdef FREECIV_JSON_CONNECTION
4217 field_addr.name = "citymindist";
4218#endif /* FREECIV_JSON_CONNECTION */
4219
4220 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->citymindist)) {
4221 RECEIVE_PACKET_FIELD_ERROR(citymindist);
4222 }
4223 }
4224
4225 if (BV_ISSET(fields, 31)) {
4226 log_packet_detailed(" got field 'cooling'");
4227
4228#ifdef FREECIV_JSON_CONNECTION
4229 field_addr.name = "cooling";
4230#endif /* FREECIV_JSON_CONNECTION */
4231
4232 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->cooling)) {
4233 RECEIVE_PACKET_FIELD_ERROR(cooling);
4234 }
4235 }
4236
4237 if (BV_ISSET(fields, 32)) {
4238 log_packet_detailed(" got field 'coolinglevel'");
4239
4240#ifdef FREECIV_JSON_CONNECTION
4241 field_addr.name = "coolinglevel";
4242#endif /* FREECIV_JSON_CONNECTION */
4243
4244 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->coolinglevel)) {
4245 RECEIVE_PACKET_FIELD_ERROR(coolinglevel);
4246 }
4247 }
4248
4249 if (BV_ISSET(fields, 33)) {
4250 log_packet_detailed(" got field 'diplchance_initial_odds'");
4251
4252#ifdef FREECIV_JSON_CONNECTION
4253 field_addr.name = "diplchance_initial_odds";
4254#endif /* FREECIV_JSON_CONNECTION */
4255
4256 if (!DIO_BV_GET(&din, &field_addr, real_packet->diplchance_initial_odds)) {
4257 RECEIVE_PACKET_FIELD_ERROR(diplchance_initial_odds);
4258 }
4259 }
4260
4261 if (BV_ISSET(fields, 34)) {
4262 log_packet_detailed(" got field 'diplomacy'");
4263
4264#ifdef FREECIV_JSON_CONNECTION
4265 field_addr.name = "diplomacy";
4266#endif /* FREECIV_JSON_CONNECTION */
4267
4268 {
4269 int readin;
4270
4271 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4272 RECEIVE_PACKET_FIELD_ERROR(diplomacy);
4273 }
4274 real_packet->diplomacy = readin;
4275 }
4276 }
4277
4278 real_packet->fogofwar = BV_ISSET(fields, 35);
4279
4280 if (BV_ISSET(fields, 36)) {
4281 log_packet_detailed(" got field 'food_cost'");
4282
4283#ifdef FREECIV_JSON_CONNECTION
4284 field_addr.name = "food_cost";
4285#endif /* FREECIV_JSON_CONNECTION */
4286
4287 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->food_cost)) {
4288 RECEIVE_PACKET_FIELD_ERROR(food_cost);
4289 }
4290 }
4291
4292 if (BV_ISSET(fields, 37)) {
4293 log_packet_detailed(" got field 'foodbox'");
4294
4295#ifdef FREECIV_JSON_CONNECTION
4296 field_addr.name = "foodbox";
4297#endif /* FREECIV_JSON_CONNECTION */
4298
4299 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->foodbox)) {
4300 RECEIVE_PACKET_FIELD_ERROR(foodbox);
4301 }
4302 }
4303
4304 if (BV_ISSET(fields, 38)) {
4305 log_packet_detailed(" got field 'forced_gold'");
4306
4307#ifdef FREECIV_JSON_CONNECTION
4308 field_addr.name = "forced_gold";
4309#endif /* FREECIV_JSON_CONNECTION */
4310
4311 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->forced_gold)) {
4312 RECEIVE_PACKET_FIELD_ERROR(forced_gold);
4313 }
4314 }
4315
4316 if (BV_ISSET(fields, 39)) {
4317 log_packet_detailed(" got field 'forced_luxury'");
4318
4319#ifdef FREECIV_JSON_CONNECTION
4320 field_addr.name = "forced_luxury";
4321#endif /* FREECIV_JSON_CONNECTION */
4322
4323 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->forced_luxury)) {
4324 RECEIVE_PACKET_FIELD_ERROR(forced_luxury);
4325 }
4326 }
4327
4328 if (BV_ISSET(fields, 40)) {
4329 log_packet_detailed(" got field 'forced_science'");
4330
4331#ifdef FREECIV_JSON_CONNECTION
4332 field_addr.name = "forced_science";
4333#endif /* FREECIV_JSON_CONNECTION */
4334
4335 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->forced_science)) {
4336 RECEIVE_PACKET_FIELD_ERROR(forced_science);
4337 }
4338 }
4339
4340 if (BV_ISSET(fields, 41)) {
4341 log_packet_detailed(" got field 'fulltradesize'");
4342
4343#ifdef FREECIV_JSON_CONNECTION
4344 field_addr.name = "fulltradesize";
4345#endif /* FREECIV_JSON_CONNECTION */
4346
4347 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fulltradesize)) {
4348 RECEIVE_PACKET_FIELD_ERROR(fulltradesize);
4349 }
4350 }
4351
4352 if (BV_ISSET(fields, 42)) {
4353 log_packet_detailed(" got field 'trade_world_rel_pct'");
4354
4355#ifdef FREECIV_JSON_CONNECTION
4356 field_addr.name = "trade_world_rel_pct";
4357#endif /* FREECIV_JSON_CONNECTION */
4358
4359 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->trade_world_rel_pct)) {
4360 RECEIVE_PACKET_FIELD_ERROR(trade_world_rel_pct);
4361 }
4362 }
4363
4364 if (BV_ISSET(fields, 43)) {
4365 log_packet_detailed(" got field 'min_trade_route_val'");
4366
4367#ifdef FREECIV_JSON_CONNECTION
4368 field_addr.name = "min_trade_route_val";
4369#endif /* FREECIV_JSON_CONNECTION */
4370
4371 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->min_trade_route_val)) {
4372 RECEIVE_PACKET_FIELD_ERROR(min_trade_route_val);
4373 }
4374 }
4375
4376 real_packet->reveal_trade_partner = BV_ISSET(fields, 44);
4377
4378 if (BV_ISSET(fields, 45)) {
4379 log_packet_detailed(" got field 'goods_selection'");
4380
4381#ifdef FREECIV_JSON_CONNECTION
4382 field_addr.name = "goods_selection";
4383#endif /* FREECIV_JSON_CONNECTION */
4384
4385 {
4386 int readin;
4387
4388 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4389 RECEIVE_PACKET_FIELD_ERROR(goods_selection);
4390 }
4391 real_packet->goods_selection = readin;
4392 }
4393 }
4394
4395 if (BV_ISSET(fields, 46)) {
4396 log_packet_detailed(" got field 'global_advance_count'");
4397
4398#ifdef FREECIV_JSON_CONNECTION
4399 field_addr.name = "global_advance_count";
4400#endif /* FREECIV_JSON_CONNECTION */
4401
4402 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->global_advance_count)) {
4403 RECEIVE_PACKET_FIELD_ERROR(global_advance_count);
4404 }
4405 }
4406
4407 if (BV_ISSET(fields, 47)) {
4408 log_packet_detailed(" got field 'global_advances'");
4409
4410#ifdef FREECIV_JSON_CONNECTION
4411 field_addr.name = "global_advances";
4412#endif /* FREECIV_JSON_CONNECTION */
4413
4414 FC_STATIC_ASSERT(A_LAST <= MAX_UINT16, packet_array_too_long_global_advances);
4415#ifdef FREECIV_JSON_CONNECTION
4416 /* Enter array (start at initial element). */
4417 field_addr.sub_location = plocation_elem_new(0);
4418 /* Enter diff array element (start at the index address). */
4419 field_addr.sub_location->sub_location = plocation_field_new("index");
4420#endif /* FREECIV_JSON_CONNECTION */
4421
4422 while (TRUE) {
4423 int i;
4424
4425 /* Read next index */
4426#if A_LAST <= MAX_UINT8
4427 if (!DIO_GET(uint8, &din, &field_addr, &i)) {
4428#else
4429 if (!DIO_GET(uint16, &din, &field_addr, &i)) {
4430#endif
4431 RECEIVE_PACKET_FIELD_ERROR(global_advances);
4432 }
4433
4434 if (i == A_LAST) {
4435 break;
4436 }
4437 if (i > A_LAST) {
4438 RECEIVE_PACKET_FIELD_ERROR(global_advances,
4439 ": unexpected index %d "
4440 "> length %d in array diff",
4441 i,
4442 A_LAST);
4443 }
4444
4445#ifdef FREECIV_JSON_CONNECTION
4446 /* Content address. */
4447 field_addr.sub_location->sub_location->name = "data";
4448#endif /* FREECIV_JSON_CONNECTION */
4449
4450 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->global_advances[i])) {
4451 RECEIVE_PACKET_FIELD_ERROR(global_advances);
4452 }
4453
4454#ifdef FREECIV_JSON_CONNECTION
4455 /* Move to the next diff array element. */
4456 field_addr.sub_location->number++;
4457 /* Back to the index address. */
4458 field_addr.sub_location->sub_location->name = "index";
4459#endif /* FREECIV_JSON_CONNECTION */
4460 }
4461
4462#ifdef FREECIV_JSON_CONNECTION
4463 /* Exit diff array element. */
4464 FC_FREE(field_addr.sub_location->sub_location);
4465 /* Exit array. */
4466 FC_FREE(field_addr.sub_location);
4467#endif /* FREECIV_JSON_CONNECTION */
4468 }
4469
4470 real_packet->global_warming = BV_ISSET(fields, 48);
4471
4472 if (BV_ISSET(fields, 49)) {
4473 log_packet_detailed(" got field 'globalwarming'");
4474
4475#ifdef FREECIV_JSON_CONNECTION
4476 field_addr.name = "globalwarming";
4477#endif /* FREECIV_JSON_CONNECTION */
4478
4479 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->globalwarming)) {
4480 RECEIVE_PACKET_FIELD_ERROR(globalwarming);
4481 }
4482 }
4483
4484 if (BV_ISSET(fields, 50)) {
4485 log_packet_detailed(" got field 'gold'");
4486
4487#ifdef FREECIV_JSON_CONNECTION
4488 field_addr.name = "gold";
4489#endif /* FREECIV_JSON_CONNECTION */
4490
4491 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->gold)) {
4492 RECEIVE_PACKET_FIELD_ERROR(gold);
4493 }
4494 }
4495
4496 if (BV_ISSET(fields, 51)) {
4497 log_packet_detailed(" got field 'gold_upkeep_style'");
4498
4499#ifdef FREECIV_JSON_CONNECTION
4500 field_addr.name = "gold_upkeep_style";
4501#endif /* FREECIV_JSON_CONNECTION */
4502
4503 {
4504 int readin;
4505
4506 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4507 RECEIVE_PACKET_FIELD_ERROR(gold_upkeep_style);
4508 }
4509 real_packet->gold_upkeep_style = readin;
4510 }
4511 }
4512
4513 real_packet->homeless_gold_upkeep = BV_ISSET(fields, 52);
4514
4515 if (BV_ISSET(fields, 53)) {
4516 log_packet_detailed(" got field 'infrapoints'");
4517
4518#ifdef FREECIV_JSON_CONNECTION
4519 field_addr.name = "infrapoints";
4520#endif /* FREECIV_JSON_CONNECTION */
4521
4522 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->infrapoints)) {
4523 RECEIVE_PACKET_FIELD_ERROR(infrapoints);
4524 }
4525 }
4526
4527 if (BV_ISSET(fields, 54)) {
4528 log_packet_detailed(" got field 'revolentype'");
4529
4530#ifdef FREECIV_JSON_CONNECTION
4531 field_addr.name = "revolentype";
4532#endif /* FREECIV_JSON_CONNECTION */
4533
4534 {
4535 int readin;
4536
4537 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4538 RECEIVE_PACKET_FIELD_ERROR(revolentype);
4539 }
4540 real_packet->revolentype = readin;
4541 }
4542 }
4543
4544 if (BV_ISSET(fields, 55)) {
4545 log_packet_detailed(" got field 'default_government_id'");
4546
4547#ifdef FREECIV_JSON_CONNECTION
4548 field_addr.name = "default_government_id";
4549#endif /* FREECIV_JSON_CONNECTION */
4550
4551 {
4552 int readin;
4553
4554 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
4555 RECEIVE_PACKET_FIELD_ERROR(default_government_id);
4556 }
4557 real_packet->default_government_id = readin;
4558 }
4559 }
4560
4561 if (BV_ISSET(fields, 56)) {
4562 log_packet_detailed(" got field 'government_during_revolution_id'");
4563
4564#ifdef FREECIV_JSON_CONNECTION
4565 field_addr.name = "government_during_revolution_id";
4566#endif /* FREECIV_JSON_CONNECTION */
4567
4568 {
4569 int readin;
4570
4571 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
4572 RECEIVE_PACKET_FIELD_ERROR(government_during_revolution_id);
4573 }
4574 real_packet->government_during_revolution_id = readin;
4575 }
4576 }
4577
4578 if (BV_ISSET(fields, 57)) {
4579 log_packet_detailed(" got field 'granary_food_inc'");
4580
4581#ifdef FREECIV_JSON_CONNECTION
4582 field_addr.name = "granary_food_inc";
4583#endif /* FREECIV_JSON_CONNECTION */
4584
4585 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granary_food_inc)) {
4586 RECEIVE_PACKET_FIELD_ERROR(granary_food_inc);
4587 }
4588 }
4589
4590 if (BV_ISSET(fields, 58)) {
4591 log_packet_detailed(" got field 'granary_food_ini'");
4592
4593#ifdef FREECIV_JSON_CONNECTION
4594 field_addr.name = "granary_food_ini";
4595#endif /* FREECIV_JSON_CONNECTION */
4596
4597 {
4598 int i;
4599
4600
4601#ifdef FREECIV_JSON_CONNECTION
4602 /* Enter array. */
4603 field_addr.sub_location = plocation_elem_new(0);
4604#endif /* FREECIV_JSON_CONNECTION */
4605
4606 for (i = 0; i < MAX_GRANARY_INIS; i++) {
4607#ifdef FREECIV_JSON_CONNECTION
4608 /* Next array element */
4609 field_addr.sub_location->number = i;
4610#endif /* FREECIV_JSON_CONNECTION */
4611
4612 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granary_food_ini[i])) {
4613 RECEIVE_PACKET_FIELD_ERROR(granary_food_ini);
4614 }
4615 }
4616
4617#ifdef FREECIV_JSON_CONNECTION
4618 /* Exit array. */
4619 FC_FREE(field_addr.sub_location);
4620#endif /* FREECIV_JSON_CONNECTION */
4621 }
4622 }
4623
4624 if (BV_ISSET(fields, 59)) {
4625 log_packet_detailed(" got field 'granary_num_inis'");
4626
4627#ifdef FREECIV_JSON_CONNECTION
4628 field_addr.name = "granary_num_inis";
4629#endif /* FREECIV_JSON_CONNECTION */
4630
4631 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->granary_num_inis)) {
4632 RECEIVE_PACKET_FIELD_ERROR(granary_num_inis);
4633 }
4634 }
4635
4636 if (BV_ISSET(fields, 60)) {
4637 log_packet_detailed(" got field 'great_wonder_owners'");
4638
4639#ifdef FREECIV_JSON_CONNECTION
4640 field_addr.name = "great_wonder_owners";
4641#endif /* FREECIV_JSON_CONNECTION */
4642
4643 FC_STATIC_ASSERT(B_LAST <= MAX_UINT16, packet_array_too_long_great_wonder_owners);
4644#ifdef FREECIV_JSON_CONNECTION
4645 /* Enter array (start at initial element). */
4646 field_addr.sub_location = plocation_elem_new(0);
4647 /* Enter diff array element (start at the index address). */
4648 field_addr.sub_location->sub_location = plocation_field_new("index");
4649#endif /* FREECIV_JSON_CONNECTION */
4650
4651 while (TRUE) {
4652 int i;
4653
4654 /* Read next index */
4655#if B_LAST <= MAX_UINT8
4656 if (!DIO_GET(uint8, &din, &field_addr, &i)) {
4657#else
4658 if (!DIO_GET(uint16, &din, &field_addr, &i)) {
4659#endif
4660 RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
4661 }
4662
4663 if (i == B_LAST) {
4664 break;
4665 }
4666 if (i > B_LAST) {
4667 RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners,
4668 ": unexpected index %d "
4669 "> length %d in array diff",
4670 i,
4671 B_LAST);
4672 }
4673
4674#ifdef FREECIV_JSON_CONNECTION
4675 /* Content address. */
4676 field_addr.sub_location->sub_location->name = "data";
4677#endif /* FREECIV_JSON_CONNECTION */
4678
4679 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->great_wonder_owners[i])) {
4680 RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
4681 }
4682
4683#ifdef FREECIV_JSON_CONNECTION
4684 /* Move to the next diff array element. */
4685 field_addr.sub_location->number++;
4686 /* Back to the index address. */
4687 field_addr.sub_location->sub_location->name = "index";
4688#endif /* FREECIV_JSON_CONNECTION */
4689 }
4690
4691#ifdef FREECIV_JSON_CONNECTION
4692 /* Exit diff array element. */
4693 FC_FREE(field_addr.sub_location->sub_location);
4694 /* Exit array. */
4695 FC_FREE(field_addr.sub_location);
4696#endif /* FREECIV_JSON_CONNECTION */
4697 }
4698
4699 if (BV_ISSET(fields, 61)) {
4700 log_packet_detailed(" got field 'happy_cost'");
4701
4702#ifdef FREECIV_JSON_CONNECTION
4703 field_addr.name = "happy_cost";
4704#endif /* FREECIV_JSON_CONNECTION */
4705
4706 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->happy_cost)) {
4707 RECEIVE_PACKET_FIELD_ERROR(happy_cost);
4708 }
4709 }
4710
4711 if (BV_ISSET(fields, 62)) {
4712 log_packet_detailed(" got field 'happyborders'");
4713
4714#ifdef FREECIV_JSON_CONNECTION
4715 field_addr.name = "happyborders";
4716#endif /* FREECIV_JSON_CONNECTION */
4717
4718 {
4719 int readin;
4720
4721 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4722 RECEIVE_PACKET_FIELD_ERROR(happyborders);
4723 }
4724 real_packet->happyborders = readin;
4725 }
4726 }
4727
4728 if (BV_ISSET(fields, 63)) {
4729 log_packet_detailed(" got field 'heating'");
4730
4731#ifdef FREECIV_JSON_CONNECTION
4732 field_addr.name = "heating";
4733#endif /* FREECIV_JSON_CONNECTION */
4734
4735 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->heating)) {
4736 RECEIVE_PACKET_FIELD_ERROR(heating);
4737 }
4738 }
4739
4740 if (BV_ISSET(fields, 64)) {
4741 log_packet_detailed(" got field 'illness_base_factor'");
4742
4743#ifdef FREECIV_JSON_CONNECTION
4744 field_addr.name = "illness_base_factor";
4745#endif /* FREECIV_JSON_CONNECTION */
4746
4747 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_base_factor)) {
4748 RECEIVE_PACKET_FIELD_ERROR(illness_base_factor);
4749 }
4750 }
4751
4752 if (BV_ISSET(fields, 65)) {
4753 log_packet_detailed(" got field 'illness_min_size'");
4754
4755#ifdef FREECIV_JSON_CONNECTION
4756 field_addr.name = "illness_min_size";
4757#endif /* FREECIV_JSON_CONNECTION */
4758
4759 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->illness_min_size)) {
4760 RECEIVE_PACKET_FIELD_ERROR(illness_min_size);
4761 }
4762 }
4763
4764 real_packet->illness_on = BV_ISSET(fields, 66);
4765
4766 if (BV_ISSET(fields, 67)) {
4767 log_packet_detailed(" got field 'illness_pollution_factor'");
4768
4769#ifdef FREECIV_JSON_CONNECTION
4770 field_addr.name = "illness_pollution_factor";
4771#endif /* FREECIV_JSON_CONNECTION */
4772
4773 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_pollution_factor)) {
4774 RECEIVE_PACKET_FIELD_ERROR(illness_pollution_factor);
4775 }
4776 }
4777
4778 if (BV_ISSET(fields, 68)) {
4779 log_packet_detailed(" got field 'illness_trade_infection'");
4780
4781#ifdef FREECIV_JSON_CONNECTION
4782 field_addr.name = "illness_trade_infection";
4783#endif /* FREECIV_JSON_CONNECTION */
4784
4785 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_trade_infection)) {
4786 RECEIVE_PACKET_FIELD_ERROR(illness_trade_infection);
4787 }
4788 }
4789
4790 if (BV_ISSET(fields, 69)) {
4791 log_packet_detailed(" got field 'init_city_radius_sq'");
4792
4793#ifdef FREECIV_JSON_CONNECTION
4794 field_addr.name = "init_city_radius_sq";
4795#endif /* FREECIV_JSON_CONNECTION */
4796
4797 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_city_radius_sq)) {
4798 RECEIVE_PACKET_FIELD_ERROR(init_city_radius_sq);
4799 }
4800 }
4801
4802 real_packet->is_edit_mode = BV_ISSET(fields, 70);
4803
4804 real_packet->is_new_game = BV_ISSET(fields, 71);
4805
4806 real_packet->killcitizen = BV_ISSET(fields, 72);
4807
4808 real_packet->killstack = BV_ISSET(fields, 73);
4809
4810 real_packet->only_killing_makes_veteran = BV_ISSET(fields, 74);
4811
4812 real_packet->only_real_fight_makes_veteran = BV_ISSET(fields, 75);
4813
4814 real_packet->combat_odds_scaled_veterancy = BV_ISSET(fields, 76);
4815
4816 real_packet->damage_reduces_bombard_rate = BV_ISSET(fields, 77);
4817
4818 if (BV_ISSET(fields, 78)) {
4819 log_packet_detailed(" got field 'low_firepower_badwallattacker'");
4820
4821#ifdef FREECIV_JSON_CONNECTION
4822 field_addr.name = "low_firepower_badwallattacker";
4823#endif /* FREECIV_JSON_CONNECTION */
4824
4825 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_badwallattacker)) {
4826 RECEIVE_PACKET_FIELD_ERROR(low_firepower_badwallattacker);
4827 }
4828 }
4829
4830 if (BV_ISSET(fields, 79)) {
4831 log_packet_detailed(" got field 'low_firepower_pearl_harbour'");
4832
4833#ifdef FREECIV_JSON_CONNECTION
4834 field_addr.name = "low_firepower_pearl_harbour";
4835#endif /* FREECIV_JSON_CONNECTION */
4836
4837 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_pearl_harbour)) {
4838 RECEIVE_PACKET_FIELD_ERROR(low_firepower_pearl_harbour);
4839 }
4840 }
4841
4842 if (BV_ISSET(fields, 80)) {
4843 log_packet_detailed(" got field 'low_firepower_combat_bonus'");
4844
4845#ifdef FREECIV_JSON_CONNECTION
4846 field_addr.name = "low_firepower_combat_bonus";
4847#endif /* FREECIV_JSON_CONNECTION */
4848
4849 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_combat_bonus)) {
4850 RECEIVE_PACKET_FIELD_ERROR(low_firepower_combat_bonus);
4851 }
4852 }
4853
4854 if (BV_ISSET(fields, 81)) {
4855 log_packet_detailed(" got field 'low_firepower_nonnat_bombard'");
4856
4857#ifdef FREECIV_JSON_CONNECTION
4858 field_addr.name = "low_firepower_nonnat_bombard";
4859#endif /* FREECIV_JSON_CONNECTION */
4860
4861 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_nonnat_bombard)) {
4862 RECEIVE_PACKET_FIELD_ERROR(low_firepower_nonnat_bombard);
4863 }
4864 }
4865
4866 if (BV_ISSET(fields, 82)) {
4867 log_packet_detailed(" got field 'nuke_pop_loss_pct'");
4868
4869#ifdef FREECIV_JSON_CONNECTION
4870 field_addr.name = "nuke_pop_loss_pct";
4871#endif /* FREECIV_JSON_CONNECTION */
4872
4873 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nuke_pop_loss_pct)) {
4874 RECEIVE_PACKET_FIELD_ERROR(nuke_pop_loss_pct);
4875 }
4876 }
4877
4878 if (BV_ISSET(fields, 83)) {
4879 log_packet_detailed(" got field 'nuke_defender_survival_chance_pct'");
4880
4881#ifdef FREECIV_JSON_CONNECTION
4882 field_addr.name = "nuke_defender_survival_chance_pct";
4883#endif /* FREECIV_JSON_CONNECTION */
4884
4885 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nuke_defender_survival_chance_pct)) {
4886 RECEIVE_PACKET_FIELD_ERROR(nuke_defender_survival_chance_pct);
4887 }
4888 }
4889
4890 if (BV_ISSET(fields, 84)) {
4891 log_packet_detailed(" got field 'min_city_center_output'");
4892
4893#ifdef FREECIV_JSON_CONNECTION
4894 field_addr.name = "min_city_center_output";
4895#endif /* FREECIV_JSON_CONNECTION */
4896
4897 {
4898 int i;
4899
4900
4901#ifdef FREECIV_JSON_CONNECTION
4902 /* Enter array. */
4903 field_addr.sub_location = plocation_elem_new(0);
4904#endif /* FREECIV_JSON_CONNECTION */
4905
4906 for (i = 0; i < O_LAST; i++) {
4907#ifdef FREECIV_JSON_CONNECTION
4908 /* Next array element */
4909 field_addr.sub_location->number = i;
4910#endif /* FREECIV_JSON_CONNECTION */
4911
4912 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->min_city_center_output[i])) {
4913 RECEIVE_PACKET_FIELD_ERROR(min_city_center_output);
4914 }
4915 }
4916
4917#ifdef FREECIV_JSON_CONNECTION
4918 /* Exit array. */
4919 FC_FREE(field_addr.sub_location);
4920#endif /* FREECIV_JSON_CONNECTION */
4921 }
4922 }
4923
4924 real_packet->muuk_food_wipe = BV_ISSET(fields, 85);
4925
4926 real_packet->muuk_gold_wipe = BV_ISSET(fields, 86);
4927
4928 real_packet->muuk_shield_wipe = BV_ISSET(fields, 87);
4929
4930 if (BV_ISSET(fields, 88)) {
4931 log_packet_detailed(" got field 'notradesize'");
4932
4933#ifdef FREECIV_JSON_CONNECTION
4934 field_addr.name = "notradesize";
4935#endif /* FREECIV_JSON_CONNECTION */
4936
4937 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->notradesize)) {
4938 RECEIVE_PACKET_FIELD_ERROR(notradesize);
4939 }
4940 }
4941
4942 real_packet->nuclear_winter = BV_ISSET(fields, 89);
4943
4944 if (BV_ISSET(fields, 90)) {
4945 log_packet_detailed(" got field 'nuclearwinter'");
4946
4947#ifdef FREECIV_JSON_CONNECTION
4948 field_addr.name = "nuclearwinter";
4949#endif /* FREECIV_JSON_CONNECTION */
4950
4951 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->nuclearwinter)) {
4952 RECEIVE_PACKET_FIELD_ERROR(nuclearwinter);
4953 }
4954 }
4955
4956 if (BV_ISSET(fields, 91)) {
4957 log_packet_detailed(" got field 'phase'");
4958
4959#ifdef FREECIV_JSON_CONNECTION
4960 field_addr.name = "phase";
4961#endif /* FREECIV_JSON_CONNECTION */
4962
4963 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
4964 RECEIVE_PACKET_FIELD_ERROR(phase);
4965 }
4966 }
4967
4968 if (BV_ISSET(fields, 92)) {
4969 log_packet_detailed(" got field 'phase_mode'");
4970
4971#ifdef FREECIV_JSON_CONNECTION
4972 field_addr.name = "phase_mode";
4973#endif /* FREECIV_JSON_CONNECTION */
4974
4975 {
4976 int readin;
4977
4978 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
4979 RECEIVE_PACKET_FIELD_ERROR(phase_mode);
4980 }
4981 real_packet->phase_mode = readin;
4982 }
4983 }
4984
4985 real_packet->pillage_select = BV_ISSET(fields, 93);
4986
4987 real_packet->steal_maps_reveals_all_cities = BV_ISSET(fields, 94);
4988
4989 real_packet->poison_empties_food_stock = BV_ISSET(fields, 95);
4990
4991 real_packet->tech_steal_allow_holes = BV_ISSET(fields, 96);
4992
4993 real_packet->tech_trade_allow_holes = BV_ISSET(fields, 97);
4994
4995 real_packet->tech_trade_loss_allow_holes = BV_ISSET(fields, 98);
4996
4997 real_packet->tech_parasite_allow_holes = BV_ISSET(fields, 99);
4998
4999 real_packet->tech_loss_allow_holes = BV_ISSET(fields, 100);
5000
5001 if (BV_ISSET(fields, 101)) {
5002 log_packet_detailed(" got field 'rapturedelay'");
5003
5004#ifdef FREECIV_JSON_CONNECTION
5005 field_addr.name = "rapturedelay";
5006#endif /* FREECIV_JSON_CONNECTION */
5007
5008 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->rapturedelay)) {
5009 RECEIVE_PACKET_FIELD_ERROR(rapturedelay);
5010 }
5011 }
5012
5013 if (BV_ISSET(fields, 102)) {
5014 log_packet_detailed(" got field 'disasters'");
5015
5016#ifdef FREECIV_JSON_CONNECTION
5017 field_addr.name = "disasters";
5018#endif /* FREECIV_JSON_CONNECTION */
5019
5020 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->disasters)) {
5021 RECEIVE_PACKET_FIELD_ERROR(disasters);
5022 }
5023 }
5024
5025 real_packet->restrictinfra = BV_ISSET(fields, 103);
5026
5027 real_packet->unreachable_protects = BV_ISSET(fields, 104);
5028
5029 if (BV_ISSET(fields, 105)) {
5030 log_packet_detailed(" got field 'sciencebox'");
5031
5032#ifdef FREECIV_JSON_CONNECTION
5033 field_addr.name = "sciencebox";
5034#endif /* FREECIV_JSON_CONNECTION */
5035
5036 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->sciencebox)) {
5037 RECEIVE_PACKET_FIELD_ERROR(sciencebox);
5038 }
5039 }
5040
5041 if (BV_ISSET(fields, 106)) {
5042 log_packet_detailed(" got field 'shieldbox'");
5043
5044#ifdef FREECIV_JSON_CONNECTION
5045 field_addr.name = "shieldbox";
5046#endif /* FREECIV_JSON_CONNECTION */
5047
5048 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->shieldbox)) {
5049 RECEIVE_PACKET_FIELD_ERROR(shieldbox);
5050 }
5051 }
5052
5053 if (BV_ISSET(fields, 107)) {
5054 log_packet_detailed(" got field 'skill_level'");
5055
5056#ifdef FREECIV_JSON_CONNECTION
5057 field_addr.name = "skill_level";
5058#endif /* FREECIV_JSON_CONNECTION */
5059
5060 {
5061 int readin;
5062
5063 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5064 RECEIVE_PACKET_FIELD_ERROR(skill_level);
5065 }
5066 real_packet->skill_level = readin;
5067 }
5068 }
5069
5070 if (BV_ISSET(fields, 108)) {
5071 log_packet_detailed(" got field 'victory_conditions'");
5072
5073#ifdef FREECIV_JSON_CONNECTION
5074 field_addr.name = "victory_conditions";
5075#endif /* FREECIV_JSON_CONNECTION */
5076
5077 {
5078 int readin;
5079
5080 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5081 RECEIVE_PACKET_FIELD_ERROR(victory_conditions);
5082 }
5083 real_packet->victory_conditions = readin;
5084 }
5085 }
5086
5087 real_packet->team_pooled_research = BV_ISSET(fields, 109);
5088
5089 if (BV_ISSET(fields, 110)) {
5090 log_packet_detailed(" got field 'tech'");
5091
5092#ifdef FREECIV_JSON_CONNECTION
5093 field_addr.name = "tech";
5094#endif /* FREECIV_JSON_CONNECTION */
5095
5096 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->tech)) {
5097 RECEIVE_PACKET_FIELD_ERROR(tech);
5098 }
5099 }
5100
5101 if (BV_ISSET(fields, 111)) {
5102 log_packet_detailed(" got field 'tech_cost_style'");
5103
5104#ifdef FREECIV_JSON_CONNECTION
5105 field_addr.name = "tech_cost_style";
5106#endif /* FREECIV_JSON_CONNECTION */
5107
5108 {
5109 int readin;
5110
5111 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5112 RECEIVE_PACKET_FIELD_ERROR(tech_cost_style);
5113 }
5114 real_packet->tech_cost_style = readin;
5115 }
5116 }
5117
5118 if (BV_ISSET(fields, 112)) {
5119 log_packet_detailed(" got field 'tech_leakage'");
5120
5121#ifdef FREECIV_JSON_CONNECTION
5122 field_addr.name = "tech_leakage";
5123#endif /* FREECIV_JSON_CONNECTION */
5124
5125 {
5126 int readin;
5127
5128 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5129 RECEIVE_PACKET_FIELD_ERROR(tech_leakage);
5130 }
5131 real_packet->tech_leakage = readin;
5132 }
5133 }
5134
5135 if (BV_ISSET(fields, 113)) {
5136 log_packet_detailed(" got field 'tech_upkeep_divider'");
5137
5138#ifdef FREECIV_JSON_CONNECTION
5139 field_addr.name = "tech_upkeep_divider";
5140#endif /* FREECIV_JSON_CONNECTION */
5141
5142 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech_upkeep_divider)) {
5143 RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_divider);
5144 }
5145 }
5146
5147 if (BV_ISSET(fields, 114)) {
5148 log_packet_detailed(" got field 'tech_upkeep_style'");
5149
5150#ifdef FREECIV_JSON_CONNECTION
5151 field_addr.name = "tech_upkeep_style";
5152#endif /* FREECIV_JSON_CONNECTION */
5153
5154 {
5155 int readin;
5156
5157 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5158 RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_style);
5159 }
5160 real_packet->tech_upkeep_style = readin;
5161 }
5162 }
5163
5164 if (BV_ISSET(fields, 115)) {
5165 log_packet_detailed(" got field 'techloss_forgiveness'");
5166
5167#ifdef FREECIV_JSON_CONNECTION
5168 field_addr.name = "techloss_forgiveness";
5169#endif /* FREECIV_JSON_CONNECTION */
5170
5171 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->techloss_forgiveness)) {
5172 RECEIVE_PACKET_FIELD_ERROR(techloss_forgiveness);
5173 }
5174 }
5175
5176 if (BV_ISSET(fields, 116)) {
5177 log_packet_detailed(" got field 'free_tech_method'");
5178
5179#ifdef FREECIV_JSON_CONNECTION
5180 field_addr.name = "free_tech_method";
5181#endif /* FREECIV_JSON_CONNECTION */
5182
5183 {
5184 int readin;
5185
5186 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5187 RECEIVE_PACKET_FIELD_ERROR(free_tech_method);
5188 }
5189 real_packet->free_tech_method = readin;
5190 }
5191 }
5192
5193 if (BV_ISSET(fields, 117)) {
5194 log_packet_detailed(" got field 'gameloss_style'");
5195
5196#ifdef FREECIV_JSON_CONNECTION
5197 field_addr.name = "gameloss_style";
5198#endif /* FREECIV_JSON_CONNECTION */
5199
5200 {
5201 int readin;
5202
5203 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5204 RECEIVE_PACKET_FIELD_ERROR(gameloss_style);
5205 }
5206 real_packet->gameloss_style = readin;
5207 }
5208 }
5209
5210 if (BV_ISSET(fields, 118)) {
5211 log_packet_detailed(" got field 'timeout'");
5212
5213#ifdef FREECIV_JSON_CONNECTION
5214 field_addr.name = "timeout";
5215#endif /* FREECIV_JSON_CONNECTION */
5216
5217 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->timeout)) {
5218 RECEIVE_PACKET_FIELD_ERROR(timeout);
5219 }
5220 }
5221
5222 if (BV_ISSET(fields, 119)) {
5223 log_packet_detailed(" got field 'first_timeout'");
5224
5225#ifdef FREECIV_JSON_CONNECTION
5226 field_addr.name = "first_timeout";
5227#endif /* FREECIV_JSON_CONNECTION */
5228
5229 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->first_timeout)) {
5230 RECEIVE_PACKET_FIELD_ERROR(first_timeout);
5231 }
5232 }
5233
5234 real_packet->tired_attack = BV_ISSET(fields, 120);
5235
5236 if (BV_ISSET(fields, 121)) {
5237 log_packet_detailed(" got field 'trademindist'");
5238
5239#ifdef FREECIV_JSON_CONNECTION
5240 field_addr.name = "trademindist";
5241#endif /* FREECIV_JSON_CONNECTION */
5242
5243 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->trademindist)) {
5244 RECEIVE_PACKET_FIELD_ERROR(trademindist);
5245 }
5246 }
5247
5248 if (BV_ISSET(fields, 122)) {
5249 log_packet_detailed(" got field 'trade_revenue_style'");
5250
5251#ifdef FREECIV_JSON_CONNECTION
5252 field_addr.name = "trade_revenue_style";
5253#endif /* FREECIV_JSON_CONNECTION */
5254
5255 {
5256 int readin;
5257
5258 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5259 RECEIVE_PACKET_FIELD_ERROR(trade_revenue_style);
5260 }
5261 real_packet->trade_revenue_style = readin;
5262 }
5263 }
5264
5265 real_packet->trading_city = BV_ISSET(fields, 123);
5266
5267 real_packet->trading_gold = BV_ISSET(fields, 124);
5268
5269 real_packet->trading_tech = BV_ISSET(fields, 125);
5270
5271 if (BV_ISSET(fields, 126)) {
5272 log_packet_detailed(" got field 'turn'");
5273
5274#ifdef FREECIV_JSON_CONNECTION
5275 field_addr.name = "turn";
5276#endif /* FREECIV_JSON_CONNECTION */
5277
5278 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
5279 RECEIVE_PACKET_FIELD_ERROR(turn);
5280 }
5281 }
5282
5283 if (BV_ISSET(fields, 127)) {
5284 log_packet_detailed(" got field 'warminglevel'");
5285
5286#ifdef FREECIV_JSON_CONNECTION
5287 field_addr.name = "warminglevel";
5288#endif /* FREECIV_JSON_CONNECTION */
5289
5290 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->warminglevel)) {
5291 RECEIVE_PACKET_FIELD_ERROR(warminglevel);
5292 }
5293 }
5294
5295 if (BV_ISSET(fields, 128)) {
5296 log_packet_detailed(" got field 'year'");
5297
5298#ifdef FREECIV_JSON_CONNECTION
5299 field_addr.name = "year";
5300#endif /* FREECIV_JSON_CONNECTION */
5301
5302 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->year)) {
5303 RECEIVE_PACKET_FIELD_ERROR(year);
5304 }
5305 }
5306
5307 real_packet->year_0_hack = BV_ISSET(fields, 129);
5308
5309 if (BV_ISSET(fields, 130)) {
5310 log_packet_detailed(" got field 'top_cities_count'");
5311
5312#ifdef FREECIV_JSON_CONNECTION
5313 field_addr.name = "top_cities_count";
5314#endif /* FREECIV_JSON_CONNECTION */
5315
5316 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->top_cities_count)) {
5317 RECEIVE_PACKET_FIELD_ERROR(top_cities_count);
5318 }
5319 }
5320
5321 if (BV_ISSET(fields, 131)) {
5322 log_packet_detailed(" got field 'fragment_count'");
5323
5324#ifdef FREECIV_JSON_CONNECTION
5325 field_addr.name = "fragment_count";
5326#endif /* FREECIV_JSON_CONNECTION */
5327
5328 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->fragment_count)) {
5329 RECEIVE_PACKET_FIELD_ERROR(fragment_count);
5330 }
5331 }
5332
5333 real_packet->civil_war_enabled = BV_ISSET(fields, 132);
5334
5335 if (BV_ISSET(fields, 133)) {
5336 log_packet_detailed(" got field 'civil_war_bonus_celebrating'");
5337
5338#ifdef FREECIV_JSON_CONNECTION
5339 field_addr.name = "civil_war_bonus_celebrating";
5340#endif /* FREECIV_JSON_CONNECTION */
5341
5342 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->civil_war_bonus_celebrating)) {
5343 RECEIVE_PACKET_FIELD_ERROR(civil_war_bonus_celebrating);
5344 }
5345 }
5346
5347 if (BV_ISSET(fields, 134)) {
5348 log_packet_detailed(" got field 'civil_war_bonus_unhappy'");
5349
5350#ifdef FREECIV_JSON_CONNECTION
5351 field_addr.name = "civil_war_bonus_unhappy";
5352#endif /* FREECIV_JSON_CONNECTION */
5353
5354 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->civil_war_bonus_unhappy)) {
5355 RECEIVE_PACKET_FIELD_ERROR(civil_war_bonus_unhappy);
5356 }
5357 }
5358
5359 if (BV_ISSET(fields, 135)) {
5360 log_packet_detailed(" got field 'granularity'");
5361
5362#ifdef FREECIV_JSON_CONNECTION
5363 field_addr.name = "granularity";
5364#endif /* FREECIV_JSON_CONNECTION */
5365
5366 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granularity)) {
5367 RECEIVE_PACKET_FIELD_ERROR(granularity);
5368 }
5369 }
5370
5371 if (BV_ISSET(fields, 136)) {
5372 log_packet_detailed(" got field 'small_wonder_visibility'");
5373
5374#ifdef FREECIV_JSON_CONNECTION
5375 field_addr.name = "small_wonder_visibility";
5376#endif /* FREECIV_JSON_CONNECTION */
5377
5378 {
5379 int readin;
5380
5381 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5382 RECEIVE_PACKET_FIELD_ERROR(small_wonder_visibility);
5383 }
5384 real_packet->small_wonder_visibility = readin;
5385 }
5386 }
5387
5388 if (nullptr == old) {
5389 old = fc_malloc(sizeof(*old));
5390 init_packet_game_info(old);
5391 *old = *real_packet;
5392 genhash_insert(*hash, old, old);
5393 } else {
5394 *old = *real_packet;
5395 }
5396
5397#else /* FREECIV_DELTA_PROTOCOL */
5398#ifdef FREECIV_JSON_CONNECTION
5399 field_addr.name = "add_to_size_limit";
5400#endif /* FREECIV_JSON_CONNECTION */
5401
5402 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->add_to_size_limit)) {
5403 RECEIVE_PACKET_FIELD_ERROR(add_to_size_limit);
5404 }
5405
5406#ifdef FREECIV_JSON_CONNECTION
5407 field_addr.name = "aifill";
5408#endif /* FREECIV_JSON_CONNECTION */
5409
5410 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->aifill)) {
5411 RECEIVE_PACKET_FIELD_ERROR(aifill);
5412 }
5413
5414#ifdef FREECIV_JSON_CONNECTION
5415 field_addr.name = "persistent_ready";
5416#endif /* FREECIV_JSON_CONNECTION */
5417
5418 {
5419 int readin;
5420
5421 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5422 RECEIVE_PACKET_FIELD_ERROR(persistent_ready);
5423 }
5424 real_packet->persistent_ready = readin;
5425 }
5426
5427#ifdef FREECIV_JSON_CONNECTION
5428 field_addr.name = "airlifting_style";
5429#endif /* FREECIV_JSON_CONNECTION */
5430
5431 {
5432 int readin;
5433
5434 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5435 RECEIVE_PACKET_FIELD_ERROR(airlifting_style);
5436 }
5437 real_packet->airlifting_style = readin;
5438 }
5439
5440#ifdef FREECIV_JSON_CONNECTION
5441 field_addr.name = "airlift_from_always_enabled";
5442#endif /* FREECIV_JSON_CONNECTION */
5443
5444 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->airlift_from_always_enabled)) {
5445 RECEIVE_PACKET_FIELD_ERROR(airlift_from_always_enabled);
5446 }
5447
5448#ifdef FREECIV_JSON_CONNECTION
5449 field_addr.name = "airlift_to_always_enabled";
5450#endif /* FREECIV_JSON_CONNECTION */
5451
5452 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->airlift_to_always_enabled)) {
5453 RECEIVE_PACKET_FIELD_ERROR(airlift_to_always_enabled);
5454 }
5455
5456#ifdef FREECIV_JSON_CONNECTION
5457 field_addr.name = "angrycitizen";
5458#endif /* FREECIV_JSON_CONNECTION */
5459
5460 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->angrycitizen)) {
5461 RECEIVE_PACKET_FIELD_ERROR(angrycitizen);
5462 }
5463
5464#ifdef FREECIV_JSON_CONNECTION
5465 field_addr.name = "base_pollution";
5466#endif /* FREECIV_JSON_CONNECTION */
5467
5468 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->base_pollution)) {
5469 RECEIVE_PACKET_FIELD_ERROR(base_pollution);
5470 }
5471
5472#ifdef FREECIV_JSON_CONNECTION
5473 field_addr.name = "base_tech_cost";
5474#endif /* FREECIV_JSON_CONNECTION */
5475
5476 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->base_tech_cost)) {
5477 RECEIVE_PACKET_FIELD_ERROR(base_tech_cost);
5478 }
5479
5480#ifdef FREECIV_JSON_CONNECTION
5481 field_addr.name = "min_tech_cost";
5482#endif /* FREECIV_JSON_CONNECTION */
5483
5484 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->min_tech_cost)) {
5485 RECEIVE_PACKET_FIELD_ERROR(min_tech_cost);
5486 }
5487
5488#ifdef FREECIV_JSON_CONNECTION
5489 field_addr.name = "tech_leak_pct";
5490#endif /* FREECIV_JSON_CONNECTION */
5491
5492 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tech_leak_pct)) {
5493 RECEIVE_PACKET_FIELD_ERROR(tech_leak_pct);
5494 }
5495
5496#ifdef FREECIV_JSON_CONNECTION
5497 field_addr.name = "border_city_radius_sq";
5498#endif /* FREECIV_JSON_CONNECTION */
5499
5500 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->border_city_radius_sq)) {
5501 RECEIVE_PACKET_FIELD_ERROR(border_city_radius_sq);
5502 }
5503
5504#ifdef FREECIV_JSON_CONNECTION
5505 field_addr.name = "border_size_effect";
5506#endif /* FREECIV_JSON_CONNECTION */
5507
5508 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->border_size_effect)) {
5509 RECEIVE_PACKET_FIELD_ERROR(border_size_effect);
5510 }
5511
5512#ifdef FREECIV_JSON_CONNECTION
5513 field_addr.name = "border_city_permanent_radius_sq";
5514#endif /* FREECIV_JSON_CONNECTION */
5515
5516 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->border_city_permanent_radius_sq)) {
5517 RECEIVE_PACKET_FIELD_ERROR(border_city_permanent_radius_sq);
5518 }
5519
5520#ifdef FREECIV_JSON_CONNECTION
5521 field_addr.name = "borders";
5522#endif /* FREECIV_JSON_CONNECTION */
5523
5524 {
5525 int readin;
5526
5527 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5528 RECEIVE_PACKET_FIELD_ERROR(borders);
5529 }
5530 real_packet->borders = readin;
5531 }
5532
5533#ifdef FREECIV_JSON_CONNECTION
5534 field_addr.name = "base_bribe_cost";
5535#endif /* FREECIV_JSON_CONNECTION */
5536
5537 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->base_bribe_cost)) {
5538 RECEIVE_PACKET_FIELD_ERROR(base_bribe_cost);
5539 }
5540
5541#ifdef FREECIV_JSON_CONNECTION
5542 field_addr.name = "caravan_bonus_style";
5543#endif /* FREECIV_JSON_CONNECTION */
5544
5545 {
5546 int readin;
5547
5548 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5549 RECEIVE_PACKET_FIELD_ERROR(caravan_bonus_style);
5550 }
5551 real_packet->caravan_bonus_style = readin;
5552 }
5553
5554#ifdef FREECIV_JSON_CONNECTION
5555 field_addr.name = "culture_vic_points";
5556#endif /* FREECIV_JSON_CONNECTION */
5557
5558 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->culture_vic_points)) {
5559 RECEIVE_PACKET_FIELD_ERROR(culture_vic_points);
5560 }
5561
5562#ifdef FREECIV_JSON_CONNECTION
5563 field_addr.name = "culture_vic_lead";
5564#endif /* FREECIV_JSON_CONNECTION */
5565
5566 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->culture_vic_lead)) {
5567 RECEIVE_PACKET_FIELD_ERROR(culture_vic_lead);
5568 }
5569
5570#ifdef FREECIV_JSON_CONNECTION
5571 field_addr.name = "culture_migration_pml";
5572#endif /* FREECIV_JSON_CONNECTION */
5573
5574 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->culture_migration_pml)) {
5575 RECEIVE_PACKET_FIELD_ERROR(culture_migration_pml);
5576 }
5577
5578#ifdef FREECIV_JSON_CONNECTION
5579 field_addr.name = "history_interest_pml";
5580#endif /* FREECIV_JSON_CONNECTION */
5581
5582 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->history_interest_pml)) {
5583 RECEIVE_PACKET_FIELD_ERROR(history_interest_pml);
5584 }
5585
5586#ifdef FREECIV_JSON_CONNECTION
5587 field_addr.name = "world_peace_turns";
5588#endif /* FREECIV_JSON_CONNECTION */
5589
5590 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->world_peace_turns)) {
5591 RECEIVE_PACKET_FIELD_ERROR(world_peace_turns);
5592 }
5593
5594#ifdef FREECIV_JSON_CONNECTION
5595 field_addr.name = "celebratesize";
5596#endif /* FREECIV_JSON_CONNECTION */
5597
5598 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->celebratesize)) {
5599 RECEIVE_PACKET_FIELD_ERROR(celebratesize);
5600 }
5601
5602#ifdef FREECIV_JSON_CONNECTION
5603 field_addr.name = "changable_tax";
5604#endif /* FREECIV_JSON_CONNECTION */
5605
5606 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->changable_tax)) {
5607 RECEIVE_PACKET_FIELD_ERROR(changable_tax);
5608 }
5609
5610#ifdef FREECIV_JSON_CONNECTION
5611 field_addr.name = "pop_report_zeroes";
5612#endif /* FREECIV_JSON_CONNECTION */
5613
5614 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->pop_report_zeroes)) {
5615 RECEIVE_PACKET_FIELD_ERROR(pop_report_zeroes);
5616 }
5617
5618#ifdef FREECIV_JSON_CONNECTION
5619 field_addr.name = "citizen_nationality";
5620#endif /* FREECIV_JSON_CONNECTION */
5621
5622 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->citizen_nationality)) {
5623 RECEIVE_PACKET_FIELD_ERROR(citizen_nationality);
5624 }
5625
5626#ifdef FREECIV_JSON_CONNECTION
5627 field_addr.name = "unit_builders_nationality";
5628#endif /* FREECIV_JSON_CONNECTION */
5629
5630 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->unit_builders_nationality)) {
5631 RECEIVE_PACKET_FIELD_ERROR(unit_builders_nationality);
5632 }
5633
5634#ifdef FREECIV_JSON_CONNECTION
5635 field_addr.name = "citizen_convert_speed";
5636#endif /* FREECIV_JSON_CONNECTION */
5637
5638 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->citizen_convert_speed)) {
5639 RECEIVE_PACKET_FIELD_ERROR(citizen_convert_speed);
5640 }
5641
5642#ifdef FREECIV_JSON_CONNECTION
5643 field_addr.name = "conquest_convert_pct";
5644#endif /* FREECIV_JSON_CONNECTION */
5645
5646 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->conquest_convert_pct)) {
5647 RECEIVE_PACKET_FIELD_ERROR(conquest_convert_pct);
5648 }
5649
5650#ifdef FREECIV_JSON_CONNECTION
5651 field_addr.name = "citizen_partisans_pct";
5652#endif /* FREECIV_JSON_CONNECTION */
5653
5654 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->citizen_partisans_pct)) {
5655 RECEIVE_PACKET_FIELD_ERROR(citizen_partisans_pct);
5656 }
5657
5658#ifdef FREECIV_JSON_CONNECTION
5659 field_addr.name = "citymindist";
5660#endif /* FREECIV_JSON_CONNECTION */
5661
5662 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->citymindist)) {
5663 RECEIVE_PACKET_FIELD_ERROR(citymindist);
5664 }
5665
5666#ifdef FREECIV_JSON_CONNECTION
5667 field_addr.name = "cooling";
5668#endif /* FREECIV_JSON_CONNECTION */
5669
5670 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->cooling)) {
5671 RECEIVE_PACKET_FIELD_ERROR(cooling);
5672 }
5673
5674#ifdef FREECIV_JSON_CONNECTION
5675 field_addr.name = "coolinglevel";
5676#endif /* FREECIV_JSON_CONNECTION */
5677
5678 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->coolinglevel)) {
5679 RECEIVE_PACKET_FIELD_ERROR(coolinglevel);
5680 }
5681
5682#ifdef FREECIV_JSON_CONNECTION
5683 field_addr.name = "diplchance_initial_odds";
5684#endif /* FREECIV_JSON_CONNECTION */
5685
5686 if (!DIO_BV_GET(&din, &field_addr, real_packet->diplchance_initial_odds)) {
5687 RECEIVE_PACKET_FIELD_ERROR(diplchance_initial_odds);
5688 }
5689
5690#ifdef FREECIV_JSON_CONNECTION
5691 field_addr.name = "diplomacy";
5692#endif /* FREECIV_JSON_CONNECTION */
5693
5694 {
5695 int readin;
5696
5697 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5698 RECEIVE_PACKET_FIELD_ERROR(diplomacy);
5699 }
5700 real_packet->diplomacy = readin;
5701 }
5702
5703#ifdef FREECIV_JSON_CONNECTION
5704 field_addr.name = "fogofwar";
5705#endif /* FREECIV_JSON_CONNECTION */
5706
5707 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->fogofwar)) {
5708 RECEIVE_PACKET_FIELD_ERROR(fogofwar);
5709 }
5710
5711#ifdef FREECIV_JSON_CONNECTION
5712 field_addr.name = "food_cost";
5713#endif /* FREECIV_JSON_CONNECTION */
5714
5715 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->food_cost)) {
5716 RECEIVE_PACKET_FIELD_ERROR(food_cost);
5717 }
5718
5719#ifdef FREECIV_JSON_CONNECTION
5720 field_addr.name = "foodbox";
5721#endif /* FREECIV_JSON_CONNECTION */
5722
5723 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->foodbox)) {
5724 RECEIVE_PACKET_FIELD_ERROR(foodbox);
5725 }
5726
5727#ifdef FREECIV_JSON_CONNECTION
5728 field_addr.name = "forced_gold";
5729#endif /* FREECIV_JSON_CONNECTION */
5730
5731 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->forced_gold)) {
5732 RECEIVE_PACKET_FIELD_ERROR(forced_gold);
5733 }
5734
5735#ifdef FREECIV_JSON_CONNECTION
5736 field_addr.name = "forced_luxury";
5737#endif /* FREECIV_JSON_CONNECTION */
5738
5739 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->forced_luxury)) {
5740 RECEIVE_PACKET_FIELD_ERROR(forced_luxury);
5741 }
5742
5743#ifdef FREECIV_JSON_CONNECTION
5744 field_addr.name = "forced_science";
5745#endif /* FREECIV_JSON_CONNECTION */
5746
5747 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->forced_science)) {
5748 RECEIVE_PACKET_FIELD_ERROR(forced_science);
5749 }
5750
5751#ifdef FREECIV_JSON_CONNECTION
5752 field_addr.name = "fulltradesize";
5753#endif /* FREECIV_JSON_CONNECTION */
5754
5755 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fulltradesize)) {
5756 RECEIVE_PACKET_FIELD_ERROR(fulltradesize);
5757 }
5758
5759#ifdef FREECIV_JSON_CONNECTION
5760 field_addr.name = "trade_world_rel_pct";
5761#endif /* FREECIV_JSON_CONNECTION */
5762
5763 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->trade_world_rel_pct)) {
5764 RECEIVE_PACKET_FIELD_ERROR(trade_world_rel_pct);
5765 }
5766
5767#ifdef FREECIV_JSON_CONNECTION
5768 field_addr.name = "min_trade_route_val";
5769#endif /* FREECIV_JSON_CONNECTION */
5770
5771 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->min_trade_route_val)) {
5772 RECEIVE_PACKET_FIELD_ERROR(min_trade_route_val);
5773 }
5774
5775#ifdef FREECIV_JSON_CONNECTION
5776 field_addr.name = "reveal_trade_partner";
5777#endif /* FREECIV_JSON_CONNECTION */
5778
5779 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->reveal_trade_partner)) {
5780 RECEIVE_PACKET_FIELD_ERROR(reveal_trade_partner);
5781 }
5782
5783#ifdef FREECIV_JSON_CONNECTION
5784 field_addr.name = "goods_selection";
5785#endif /* FREECIV_JSON_CONNECTION */
5786
5787 {
5788 int readin;
5789
5790 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5791 RECEIVE_PACKET_FIELD_ERROR(goods_selection);
5792 }
5793 real_packet->goods_selection = readin;
5794 }
5795
5796#ifdef FREECIV_JSON_CONNECTION
5797 field_addr.name = "global_advance_count";
5798#endif /* FREECIV_JSON_CONNECTION */
5799
5800 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->global_advance_count)) {
5801 RECEIVE_PACKET_FIELD_ERROR(global_advance_count);
5802 }
5803
5804#ifdef FREECIV_JSON_CONNECTION
5805 field_addr.name = "global_advances";
5806#endif /* FREECIV_JSON_CONNECTION */
5807
5808 {
5809 int i;
5810
5811
5812#ifdef FREECIV_JSON_CONNECTION
5813 /* Enter array. */
5814 field_addr.sub_location = plocation_elem_new(0);
5815#endif /* FREECIV_JSON_CONNECTION */
5816
5817 for (i = 0; i < A_LAST; i++) {
5818#ifdef FREECIV_JSON_CONNECTION
5819 /* Next array element */
5820 field_addr.sub_location->number = i;
5821#endif /* FREECIV_JSON_CONNECTION */
5822
5823 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->global_advances[i])) {
5824 RECEIVE_PACKET_FIELD_ERROR(global_advances);
5825 }
5826 }
5827
5828#ifdef FREECIV_JSON_CONNECTION
5829 /* Exit array. */
5830 FC_FREE(field_addr.sub_location);
5831#endif /* FREECIV_JSON_CONNECTION */
5832 }
5833
5834#ifdef FREECIV_JSON_CONNECTION
5835 field_addr.name = "global_warming";
5836#endif /* FREECIV_JSON_CONNECTION */
5837
5838 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->global_warming)) {
5839 RECEIVE_PACKET_FIELD_ERROR(global_warming);
5840 }
5841
5842#ifdef FREECIV_JSON_CONNECTION
5843 field_addr.name = "globalwarming";
5844#endif /* FREECIV_JSON_CONNECTION */
5845
5846 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->globalwarming)) {
5847 RECEIVE_PACKET_FIELD_ERROR(globalwarming);
5848 }
5849
5850#ifdef FREECIV_JSON_CONNECTION
5851 field_addr.name = "gold";
5852#endif /* FREECIV_JSON_CONNECTION */
5853
5854 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->gold)) {
5855 RECEIVE_PACKET_FIELD_ERROR(gold);
5856 }
5857
5858#ifdef FREECIV_JSON_CONNECTION
5859 field_addr.name = "gold_upkeep_style";
5860#endif /* FREECIV_JSON_CONNECTION */
5861
5862 {
5863 int readin;
5864
5865 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5866 RECEIVE_PACKET_FIELD_ERROR(gold_upkeep_style);
5867 }
5868 real_packet->gold_upkeep_style = readin;
5869 }
5870
5871#ifdef FREECIV_JSON_CONNECTION
5872 field_addr.name = "homeless_gold_upkeep";
5873#endif /* FREECIV_JSON_CONNECTION */
5874
5875 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->homeless_gold_upkeep)) {
5876 RECEIVE_PACKET_FIELD_ERROR(homeless_gold_upkeep);
5877 }
5878
5879#ifdef FREECIV_JSON_CONNECTION
5880 field_addr.name = "infrapoints";
5881#endif /* FREECIV_JSON_CONNECTION */
5882
5883 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->infrapoints)) {
5884 RECEIVE_PACKET_FIELD_ERROR(infrapoints);
5885 }
5886
5887#ifdef FREECIV_JSON_CONNECTION
5888 field_addr.name = "revolentype";
5889#endif /* FREECIV_JSON_CONNECTION */
5890
5891 {
5892 int readin;
5893
5894 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
5895 RECEIVE_PACKET_FIELD_ERROR(revolentype);
5896 }
5897 real_packet->revolentype = readin;
5898 }
5899
5900#ifdef FREECIV_JSON_CONNECTION
5901 field_addr.name = "default_government_id";
5902#endif /* FREECIV_JSON_CONNECTION */
5903
5904 {
5905 int readin;
5906
5907 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
5908 RECEIVE_PACKET_FIELD_ERROR(default_government_id);
5909 }
5910 real_packet->default_government_id = readin;
5911 }
5912
5913#ifdef FREECIV_JSON_CONNECTION
5914 field_addr.name = "government_during_revolution_id";
5915#endif /* FREECIV_JSON_CONNECTION */
5916
5917 {
5918 int readin;
5919
5920 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
5921 RECEIVE_PACKET_FIELD_ERROR(government_during_revolution_id);
5922 }
5923 real_packet->government_during_revolution_id = readin;
5924 }
5925
5926#ifdef FREECIV_JSON_CONNECTION
5927 field_addr.name = "granary_food_inc";
5928#endif /* FREECIV_JSON_CONNECTION */
5929
5930 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granary_food_inc)) {
5931 RECEIVE_PACKET_FIELD_ERROR(granary_food_inc);
5932 }
5933
5934#ifdef FREECIV_JSON_CONNECTION
5935 field_addr.name = "granary_food_ini";
5936#endif /* FREECIV_JSON_CONNECTION */
5937
5938 {
5939 int i;
5940
5941
5942#ifdef FREECIV_JSON_CONNECTION
5943 /* Enter array. */
5944 field_addr.sub_location = plocation_elem_new(0);
5945#endif /* FREECIV_JSON_CONNECTION */
5946
5947 for (i = 0; i < MAX_GRANARY_INIS; i++) {
5948#ifdef FREECIV_JSON_CONNECTION
5949 /* Next array element */
5950 field_addr.sub_location->number = i;
5951#endif /* FREECIV_JSON_CONNECTION */
5952
5953 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granary_food_ini[i])) {
5954 RECEIVE_PACKET_FIELD_ERROR(granary_food_ini);
5955 }
5956 }
5957
5958#ifdef FREECIV_JSON_CONNECTION
5959 /* Exit array. */
5960 FC_FREE(field_addr.sub_location);
5961#endif /* FREECIV_JSON_CONNECTION */
5962 }
5963
5964#ifdef FREECIV_JSON_CONNECTION
5965 field_addr.name = "granary_num_inis";
5966#endif /* FREECIV_JSON_CONNECTION */
5967
5968 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->granary_num_inis)) {
5969 RECEIVE_PACKET_FIELD_ERROR(granary_num_inis);
5970 }
5971
5972#ifdef FREECIV_JSON_CONNECTION
5973 field_addr.name = "great_wonder_owners";
5974#endif /* FREECIV_JSON_CONNECTION */
5975
5976 {
5977 int i;
5978
5979
5980#ifdef FREECIV_JSON_CONNECTION
5981 /* Enter array. */
5982 field_addr.sub_location = plocation_elem_new(0);
5983#endif /* FREECIV_JSON_CONNECTION */
5984
5985 for (i = 0; i < B_LAST; i++) {
5986#ifdef FREECIV_JSON_CONNECTION
5987 /* Next array element */
5988 field_addr.sub_location->number = i;
5989#endif /* FREECIV_JSON_CONNECTION */
5990
5991 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->great_wonder_owners[i])) {
5992 RECEIVE_PACKET_FIELD_ERROR(great_wonder_owners);
5993 }
5994 }
5995
5996#ifdef FREECIV_JSON_CONNECTION
5997 /* Exit array. */
5998 FC_FREE(field_addr.sub_location);
5999#endif /* FREECIV_JSON_CONNECTION */
6000 }
6001
6002#ifdef FREECIV_JSON_CONNECTION
6003 field_addr.name = "happy_cost";
6004#endif /* FREECIV_JSON_CONNECTION */
6005
6006 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->happy_cost)) {
6007 RECEIVE_PACKET_FIELD_ERROR(happy_cost);
6008 }
6009
6010#ifdef FREECIV_JSON_CONNECTION
6011 field_addr.name = "happyborders";
6012#endif /* FREECIV_JSON_CONNECTION */
6013
6014 {
6015 int readin;
6016
6017 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6018 RECEIVE_PACKET_FIELD_ERROR(happyborders);
6019 }
6020 real_packet->happyborders = readin;
6021 }
6022
6023#ifdef FREECIV_JSON_CONNECTION
6024 field_addr.name = "heating";
6025#endif /* FREECIV_JSON_CONNECTION */
6026
6027 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->heating)) {
6028 RECEIVE_PACKET_FIELD_ERROR(heating);
6029 }
6030
6031#ifdef FREECIV_JSON_CONNECTION
6032 field_addr.name = "illness_base_factor";
6033#endif /* FREECIV_JSON_CONNECTION */
6034
6035 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_base_factor)) {
6036 RECEIVE_PACKET_FIELD_ERROR(illness_base_factor);
6037 }
6038
6039#ifdef FREECIV_JSON_CONNECTION
6040 field_addr.name = "illness_min_size";
6041#endif /* FREECIV_JSON_CONNECTION */
6042
6043 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->illness_min_size)) {
6044 RECEIVE_PACKET_FIELD_ERROR(illness_min_size);
6045 }
6046
6047#ifdef FREECIV_JSON_CONNECTION
6048 field_addr.name = "illness_on";
6049#endif /* FREECIV_JSON_CONNECTION */
6050
6051 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->illness_on)) {
6052 RECEIVE_PACKET_FIELD_ERROR(illness_on);
6053 }
6054
6055#ifdef FREECIV_JSON_CONNECTION
6056 field_addr.name = "illness_pollution_factor";
6057#endif /* FREECIV_JSON_CONNECTION */
6058
6059 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_pollution_factor)) {
6060 RECEIVE_PACKET_FIELD_ERROR(illness_pollution_factor);
6061 }
6062
6063#ifdef FREECIV_JSON_CONNECTION
6064 field_addr.name = "illness_trade_infection";
6065#endif /* FREECIV_JSON_CONNECTION */
6066
6067 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_trade_infection)) {
6068 RECEIVE_PACKET_FIELD_ERROR(illness_trade_infection);
6069 }
6070
6071#ifdef FREECIV_JSON_CONNECTION
6072 field_addr.name = "init_city_radius_sq";
6073#endif /* FREECIV_JSON_CONNECTION */
6074
6075 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_city_radius_sq)) {
6076 RECEIVE_PACKET_FIELD_ERROR(init_city_radius_sq);
6077 }
6078
6079#ifdef FREECIV_JSON_CONNECTION
6080 field_addr.name = "is_edit_mode";
6081#endif /* FREECIV_JSON_CONNECTION */
6082
6083 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_edit_mode)) {
6084 RECEIVE_PACKET_FIELD_ERROR(is_edit_mode);
6085 }
6086
6087#ifdef FREECIV_JSON_CONNECTION
6088 field_addr.name = "is_new_game";
6089#endif /* FREECIV_JSON_CONNECTION */
6090
6091 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_new_game)) {
6092 RECEIVE_PACKET_FIELD_ERROR(is_new_game);
6093 }
6094
6095#ifdef FREECIV_JSON_CONNECTION
6096 field_addr.name = "killcitizen";
6097#endif /* FREECIV_JSON_CONNECTION */
6098
6099 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->killcitizen)) {
6100 RECEIVE_PACKET_FIELD_ERROR(killcitizen);
6101 }
6102
6103#ifdef FREECIV_JSON_CONNECTION
6104 field_addr.name = "killstack";
6105#endif /* FREECIV_JSON_CONNECTION */
6106
6107 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->killstack)) {
6108 RECEIVE_PACKET_FIELD_ERROR(killstack);
6109 }
6110
6111#ifdef FREECIV_JSON_CONNECTION
6112 field_addr.name = "only_killing_makes_veteran";
6113#endif /* FREECIV_JSON_CONNECTION */
6114
6115 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->only_killing_makes_veteran)) {
6116 RECEIVE_PACKET_FIELD_ERROR(only_killing_makes_veteran);
6117 }
6118
6119#ifdef FREECIV_JSON_CONNECTION
6120 field_addr.name = "only_real_fight_makes_veteran";
6121#endif /* FREECIV_JSON_CONNECTION */
6122
6123 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->only_real_fight_makes_veteran)) {
6124 RECEIVE_PACKET_FIELD_ERROR(only_real_fight_makes_veteran);
6125 }
6126
6127#ifdef FREECIV_JSON_CONNECTION
6128 field_addr.name = "combat_odds_scaled_veterancy";
6129#endif /* FREECIV_JSON_CONNECTION */
6130
6131 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->combat_odds_scaled_veterancy)) {
6132 RECEIVE_PACKET_FIELD_ERROR(combat_odds_scaled_veterancy);
6133 }
6134
6135#ifdef FREECIV_JSON_CONNECTION
6136 field_addr.name = "damage_reduces_bombard_rate";
6137#endif /* FREECIV_JSON_CONNECTION */
6138
6139 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->damage_reduces_bombard_rate)) {
6140 RECEIVE_PACKET_FIELD_ERROR(damage_reduces_bombard_rate);
6141 }
6142
6143#ifdef FREECIV_JSON_CONNECTION
6144 field_addr.name = "low_firepower_badwallattacker";
6145#endif /* FREECIV_JSON_CONNECTION */
6146
6147 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_badwallattacker)) {
6148 RECEIVE_PACKET_FIELD_ERROR(low_firepower_badwallattacker);
6149 }
6150
6151#ifdef FREECIV_JSON_CONNECTION
6152 field_addr.name = "low_firepower_pearl_harbour";
6153#endif /* FREECIV_JSON_CONNECTION */
6154
6155 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_pearl_harbour)) {
6156 RECEIVE_PACKET_FIELD_ERROR(low_firepower_pearl_harbour);
6157 }
6158
6159#ifdef FREECIV_JSON_CONNECTION
6160 field_addr.name = "low_firepower_combat_bonus";
6161#endif /* FREECIV_JSON_CONNECTION */
6162
6163 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_combat_bonus)) {
6164 RECEIVE_PACKET_FIELD_ERROR(low_firepower_combat_bonus);
6165 }
6166
6167#ifdef FREECIV_JSON_CONNECTION
6168 field_addr.name = "low_firepower_nonnat_bombard";
6169#endif /* FREECIV_JSON_CONNECTION */
6170
6171 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->low_firepower_nonnat_bombard)) {
6172 RECEIVE_PACKET_FIELD_ERROR(low_firepower_nonnat_bombard);
6173 }
6174
6175#ifdef FREECIV_JSON_CONNECTION
6176 field_addr.name = "nuke_pop_loss_pct";
6177#endif /* FREECIV_JSON_CONNECTION */
6178
6179 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nuke_pop_loss_pct)) {
6180 RECEIVE_PACKET_FIELD_ERROR(nuke_pop_loss_pct);
6181 }
6182
6183#ifdef FREECIV_JSON_CONNECTION
6184 field_addr.name = "nuke_defender_survival_chance_pct";
6185#endif /* FREECIV_JSON_CONNECTION */
6186
6187 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nuke_defender_survival_chance_pct)) {
6188 RECEIVE_PACKET_FIELD_ERROR(nuke_defender_survival_chance_pct);
6189 }
6190
6191#ifdef FREECIV_JSON_CONNECTION
6192 field_addr.name = "min_city_center_output";
6193#endif /* FREECIV_JSON_CONNECTION */
6194
6195 {
6196 int i;
6197
6198
6199#ifdef FREECIV_JSON_CONNECTION
6200 /* Enter array. */
6201 field_addr.sub_location = plocation_elem_new(0);
6202#endif /* FREECIV_JSON_CONNECTION */
6203
6204 for (i = 0; i < O_LAST; i++) {
6205#ifdef FREECIV_JSON_CONNECTION
6206 /* Next array element */
6207 field_addr.sub_location->number = i;
6208#endif /* FREECIV_JSON_CONNECTION */
6209
6210 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->min_city_center_output[i])) {
6211 RECEIVE_PACKET_FIELD_ERROR(min_city_center_output);
6212 }
6213 }
6214
6215#ifdef FREECIV_JSON_CONNECTION
6216 /* Exit array. */
6217 FC_FREE(field_addr.sub_location);
6218#endif /* FREECIV_JSON_CONNECTION */
6219 }
6220
6221#ifdef FREECIV_JSON_CONNECTION
6222 field_addr.name = "muuk_food_wipe";
6223#endif /* FREECIV_JSON_CONNECTION */
6224
6225 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->muuk_food_wipe)) {
6226 RECEIVE_PACKET_FIELD_ERROR(muuk_food_wipe);
6227 }
6228
6229#ifdef FREECIV_JSON_CONNECTION
6230 field_addr.name = "muuk_gold_wipe";
6231#endif /* FREECIV_JSON_CONNECTION */
6232
6233 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->muuk_gold_wipe)) {
6234 RECEIVE_PACKET_FIELD_ERROR(muuk_gold_wipe);
6235 }
6236
6237#ifdef FREECIV_JSON_CONNECTION
6238 field_addr.name = "muuk_shield_wipe";
6239#endif /* FREECIV_JSON_CONNECTION */
6240
6241 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->muuk_shield_wipe)) {
6242 RECEIVE_PACKET_FIELD_ERROR(muuk_shield_wipe);
6243 }
6244
6245#ifdef FREECIV_JSON_CONNECTION
6246 field_addr.name = "notradesize";
6247#endif /* FREECIV_JSON_CONNECTION */
6248
6249 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->notradesize)) {
6250 RECEIVE_PACKET_FIELD_ERROR(notradesize);
6251 }
6252
6253#ifdef FREECIV_JSON_CONNECTION
6254 field_addr.name = "nuclear_winter";
6255#endif /* FREECIV_JSON_CONNECTION */
6256
6257 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->nuclear_winter)) {
6258 RECEIVE_PACKET_FIELD_ERROR(nuclear_winter);
6259 }
6260
6261#ifdef FREECIV_JSON_CONNECTION
6262 field_addr.name = "nuclearwinter";
6263#endif /* FREECIV_JSON_CONNECTION */
6264
6265 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->nuclearwinter)) {
6266 RECEIVE_PACKET_FIELD_ERROR(nuclearwinter);
6267 }
6268
6269#ifdef FREECIV_JSON_CONNECTION
6270 field_addr.name = "phase";
6271#endif /* FREECIV_JSON_CONNECTION */
6272
6273 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
6274 RECEIVE_PACKET_FIELD_ERROR(phase);
6275 }
6276
6277#ifdef FREECIV_JSON_CONNECTION
6278 field_addr.name = "phase_mode";
6279#endif /* FREECIV_JSON_CONNECTION */
6280
6281 {
6282 int readin;
6283
6284 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6285 RECEIVE_PACKET_FIELD_ERROR(phase_mode);
6286 }
6287 real_packet->phase_mode = readin;
6288 }
6289
6290#ifdef FREECIV_JSON_CONNECTION
6291 field_addr.name = "pillage_select";
6292#endif /* FREECIV_JSON_CONNECTION */
6293
6294 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->pillage_select)) {
6295 RECEIVE_PACKET_FIELD_ERROR(pillage_select);
6296 }
6297
6298#ifdef FREECIV_JSON_CONNECTION
6299 field_addr.name = "steal_maps_reveals_all_cities";
6300#endif /* FREECIV_JSON_CONNECTION */
6301
6302 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->steal_maps_reveals_all_cities)) {
6303 RECEIVE_PACKET_FIELD_ERROR(steal_maps_reveals_all_cities);
6304 }
6305
6306#ifdef FREECIV_JSON_CONNECTION
6307 field_addr.name = "poison_empties_food_stock";
6308#endif /* FREECIV_JSON_CONNECTION */
6309
6310 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->poison_empties_food_stock)) {
6311 RECEIVE_PACKET_FIELD_ERROR(poison_empties_food_stock);
6312 }
6313
6314#ifdef FREECIV_JSON_CONNECTION
6315 field_addr.name = "tech_steal_allow_holes";
6316#endif /* FREECIV_JSON_CONNECTION */
6317
6318 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->tech_steal_allow_holes)) {
6319 RECEIVE_PACKET_FIELD_ERROR(tech_steal_allow_holes);
6320 }
6321
6322#ifdef FREECIV_JSON_CONNECTION
6323 field_addr.name = "tech_trade_allow_holes";
6324#endif /* FREECIV_JSON_CONNECTION */
6325
6326 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->tech_trade_allow_holes)) {
6327 RECEIVE_PACKET_FIELD_ERROR(tech_trade_allow_holes);
6328 }
6329
6330#ifdef FREECIV_JSON_CONNECTION
6331 field_addr.name = "tech_trade_loss_allow_holes";
6332#endif /* FREECIV_JSON_CONNECTION */
6333
6334 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->tech_trade_loss_allow_holes)) {
6335 RECEIVE_PACKET_FIELD_ERROR(tech_trade_loss_allow_holes);
6336 }
6337
6338#ifdef FREECIV_JSON_CONNECTION
6339 field_addr.name = "tech_parasite_allow_holes";
6340#endif /* FREECIV_JSON_CONNECTION */
6341
6342 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->tech_parasite_allow_holes)) {
6343 RECEIVE_PACKET_FIELD_ERROR(tech_parasite_allow_holes);
6344 }
6345
6346#ifdef FREECIV_JSON_CONNECTION
6347 field_addr.name = "tech_loss_allow_holes";
6348#endif /* FREECIV_JSON_CONNECTION */
6349
6350 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->tech_loss_allow_holes)) {
6351 RECEIVE_PACKET_FIELD_ERROR(tech_loss_allow_holes);
6352 }
6353
6354#ifdef FREECIV_JSON_CONNECTION
6355 field_addr.name = "rapturedelay";
6356#endif /* FREECIV_JSON_CONNECTION */
6357
6358 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->rapturedelay)) {
6359 RECEIVE_PACKET_FIELD_ERROR(rapturedelay);
6360 }
6361
6362#ifdef FREECIV_JSON_CONNECTION
6363 field_addr.name = "disasters";
6364#endif /* FREECIV_JSON_CONNECTION */
6365
6366 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->disasters)) {
6367 RECEIVE_PACKET_FIELD_ERROR(disasters);
6368 }
6369
6370#ifdef FREECIV_JSON_CONNECTION
6371 field_addr.name = "restrictinfra";
6372#endif /* FREECIV_JSON_CONNECTION */
6373
6374 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->restrictinfra)) {
6375 RECEIVE_PACKET_FIELD_ERROR(restrictinfra);
6376 }
6377
6378#ifdef FREECIV_JSON_CONNECTION
6379 field_addr.name = "unreachable_protects";
6380#endif /* FREECIV_JSON_CONNECTION */
6381
6382 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->unreachable_protects)) {
6383 RECEIVE_PACKET_FIELD_ERROR(unreachable_protects);
6384 }
6385
6386#ifdef FREECIV_JSON_CONNECTION
6387 field_addr.name = "sciencebox";
6388#endif /* FREECIV_JSON_CONNECTION */
6389
6390 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->sciencebox)) {
6391 RECEIVE_PACKET_FIELD_ERROR(sciencebox);
6392 }
6393
6394#ifdef FREECIV_JSON_CONNECTION
6395 field_addr.name = "shieldbox";
6396#endif /* FREECIV_JSON_CONNECTION */
6397
6398 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->shieldbox)) {
6399 RECEIVE_PACKET_FIELD_ERROR(shieldbox);
6400 }
6401
6402#ifdef FREECIV_JSON_CONNECTION
6403 field_addr.name = "skill_level";
6404#endif /* FREECIV_JSON_CONNECTION */
6405
6406 {
6407 int readin;
6408
6409 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6410 RECEIVE_PACKET_FIELD_ERROR(skill_level);
6411 }
6412 real_packet->skill_level = readin;
6413 }
6414
6415#ifdef FREECIV_JSON_CONNECTION
6416 field_addr.name = "victory_conditions";
6417#endif /* FREECIV_JSON_CONNECTION */
6418
6419 {
6420 int readin;
6421
6422 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6423 RECEIVE_PACKET_FIELD_ERROR(victory_conditions);
6424 }
6425 real_packet->victory_conditions = readin;
6426 }
6427
6428#ifdef FREECIV_JSON_CONNECTION
6429 field_addr.name = "team_pooled_research";
6430#endif /* FREECIV_JSON_CONNECTION */
6431
6432 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->team_pooled_research)) {
6433 RECEIVE_PACKET_FIELD_ERROR(team_pooled_research);
6434 }
6435
6436#ifdef FREECIV_JSON_CONNECTION
6437 field_addr.name = "tech";
6438#endif /* FREECIV_JSON_CONNECTION */
6439
6440 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->tech)) {
6441 RECEIVE_PACKET_FIELD_ERROR(tech);
6442 }
6443
6444#ifdef FREECIV_JSON_CONNECTION
6445 field_addr.name = "tech_cost_style";
6446#endif /* FREECIV_JSON_CONNECTION */
6447
6448 {
6449 int readin;
6450
6451 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6452 RECEIVE_PACKET_FIELD_ERROR(tech_cost_style);
6453 }
6454 real_packet->tech_cost_style = readin;
6455 }
6456
6457#ifdef FREECIV_JSON_CONNECTION
6458 field_addr.name = "tech_leakage";
6459#endif /* FREECIV_JSON_CONNECTION */
6460
6461 {
6462 int readin;
6463
6464 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6465 RECEIVE_PACKET_FIELD_ERROR(tech_leakage);
6466 }
6467 real_packet->tech_leakage = readin;
6468 }
6469
6470#ifdef FREECIV_JSON_CONNECTION
6471 field_addr.name = "tech_upkeep_divider";
6472#endif /* FREECIV_JSON_CONNECTION */
6473
6474 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech_upkeep_divider)) {
6475 RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_divider);
6476 }
6477
6478#ifdef FREECIV_JSON_CONNECTION
6479 field_addr.name = "tech_upkeep_style";
6480#endif /* FREECIV_JSON_CONNECTION */
6481
6482 {
6483 int readin;
6484
6485 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6486 RECEIVE_PACKET_FIELD_ERROR(tech_upkeep_style);
6487 }
6488 real_packet->tech_upkeep_style = readin;
6489 }
6490
6491#ifdef FREECIV_JSON_CONNECTION
6492 field_addr.name = "techloss_forgiveness";
6493#endif /* FREECIV_JSON_CONNECTION */
6494
6495 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->techloss_forgiveness)) {
6496 RECEIVE_PACKET_FIELD_ERROR(techloss_forgiveness);
6497 }
6498
6499#ifdef FREECIV_JSON_CONNECTION
6500 field_addr.name = "free_tech_method";
6501#endif /* FREECIV_JSON_CONNECTION */
6502
6503 {
6504 int readin;
6505
6506 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6507 RECEIVE_PACKET_FIELD_ERROR(free_tech_method);
6508 }
6509 real_packet->free_tech_method = readin;
6510 }
6511
6512#ifdef FREECIV_JSON_CONNECTION
6513 field_addr.name = "gameloss_style";
6514#endif /* FREECIV_JSON_CONNECTION */
6515
6516 {
6517 int readin;
6518
6519 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6520 RECEIVE_PACKET_FIELD_ERROR(gameloss_style);
6521 }
6522 real_packet->gameloss_style = readin;
6523 }
6524
6525#ifdef FREECIV_JSON_CONNECTION
6526 field_addr.name = "timeout";
6527#endif /* FREECIV_JSON_CONNECTION */
6528
6529 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->timeout)) {
6530 RECEIVE_PACKET_FIELD_ERROR(timeout);
6531 }
6532
6533#ifdef FREECIV_JSON_CONNECTION
6534 field_addr.name = "first_timeout";
6535#endif /* FREECIV_JSON_CONNECTION */
6536
6537 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->first_timeout)) {
6538 RECEIVE_PACKET_FIELD_ERROR(first_timeout);
6539 }
6540
6541#ifdef FREECIV_JSON_CONNECTION
6542 field_addr.name = "tired_attack";
6543#endif /* FREECIV_JSON_CONNECTION */
6544
6545 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->tired_attack)) {
6546 RECEIVE_PACKET_FIELD_ERROR(tired_attack);
6547 }
6548
6549#ifdef FREECIV_JSON_CONNECTION
6550 field_addr.name = "trademindist";
6551#endif /* FREECIV_JSON_CONNECTION */
6552
6553 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->trademindist)) {
6554 RECEIVE_PACKET_FIELD_ERROR(trademindist);
6555 }
6556
6557#ifdef FREECIV_JSON_CONNECTION
6558 field_addr.name = "trade_revenue_style";
6559#endif /* FREECIV_JSON_CONNECTION */
6560
6561 {
6562 int readin;
6563
6564 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6565 RECEIVE_PACKET_FIELD_ERROR(trade_revenue_style);
6566 }
6567 real_packet->trade_revenue_style = readin;
6568 }
6569
6570#ifdef FREECIV_JSON_CONNECTION
6571 field_addr.name = "trading_city";
6572#endif /* FREECIV_JSON_CONNECTION */
6573
6574 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->trading_city)) {
6575 RECEIVE_PACKET_FIELD_ERROR(trading_city);
6576 }
6577
6578#ifdef FREECIV_JSON_CONNECTION
6579 field_addr.name = "trading_gold";
6580#endif /* FREECIV_JSON_CONNECTION */
6581
6582 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->trading_gold)) {
6583 RECEIVE_PACKET_FIELD_ERROR(trading_gold);
6584 }
6585
6586#ifdef FREECIV_JSON_CONNECTION
6587 field_addr.name = "trading_tech";
6588#endif /* FREECIV_JSON_CONNECTION */
6589
6590 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->trading_tech)) {
6591 RECEIVE_PACKET_FIELD_ERROR(trading_tech);
6592 }
6593
6594#ifdef FREECIV_JSON_CONNECTION
6595 field_addr.name = "turn";
6596#endif /* FREECIV_JSON_CONNECTION */
6597
6598 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
6599 RECEIVE_PACKET_FIELD_ERROR(turn);
6600 }
6601
6602#ifdef FREECIV_JSON_CONNECTION
6603 field_addr.name = "warminglevel";
6604#endif /* FREECIV_JSON_CONNECTION */
6605
6606 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->warminglevel)) {
6607 RECEIVE_PACKET_FIELD_ERROR(warminglevel);
6608 }
6609
6610#ifdef FREECIV_JSON_CONNECTION
6611 field_addr.name = "year";
6612#endif /* FREECIV_JSON_CONNECTION */
6613
6614 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->year)) {
6615 RECEIVE_PACKET_FIELD_ERROR(year);
6616 }
6617
6618#ifdef FREECIV_JSON_CONNECTION
6619 field_addr.name = "year_0_hack";
6620#endif /* FREECIV_JSON_CONNECTION */
6621
6622 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->year_0_hack)) {
6623 RECEIVE_PACKET_FIELD_ERROR(year_0_hack);
6624 }
6625
6626#ifdef FREECIV_JSON_CONNECTION
6627 field_addr.name = "top_cities_count";
6628#endif /* FREECIV_JSON_CONNECTION */
6629
6630 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->top_cities_count)) {
6631 RECEIVE_PACKET_FIELD_ERROR(top_cities_count);
6632 }
6633
6634#ifdef FREECIV_JSON_CONNECTION
6635 field_addr.name = "fragment_count";
6636#endif /* FREECIV_JSON_CONNECTION */
6637
6638 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->fragment_count)) {
6639 RECEIVE_PACKET_FIELD_ERROR(fragment_count);
6640 }
6641
6642#ifdef FREECIV_JSON_CONNECTION
6643 field_addr.name = "civil_war_enabled";
6644#endif /* FREECIV_JSON_CONNECTION */
6645
6646 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->civil_war_enabled)) {
6647 RECEIVE_PACKET_FIELD_ERROR(civil_war_enabled);
6648 }
6649
6650#ifdef FREECIV_JSON_CONNECTION
6651 field_addr.name = "civil_war_bonus_celebrating";
6652#endif /* FREECIV_JSON_CONNECTION */
6653
6654 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->civil_war_bonus_celebrating)) {
6655 RECEIVE_PACKET_FIELD_ERROR(civil_war_bonus_celebrating);
6656 }
6657
6658#ifdef FREECIV_JSON_CONNECTION
6659 field_addr.name = "civil_war_bonus_unhappy";
6660#endif /* FREECIV_JSON_CONNECTION */
6661
6662 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->civil_war_bonus_unhappy)) {
6663 RECEIVE_PACKET_FIELD_ERROR(civil_war_bonus_unhappy);
6664 }
6665
6666#ifdef FREECIV_JSON_CONNECTION
6667 field_addr.name = "granularity";
6668#endif /* FREECIV_JSON_CONNECTION */
6669
6670 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granularity)) {
6671 RECEIVE_PACKET_FIELD_ERROR(granularity);
6672 }
6673
6674#ifdef FREECIV_JSON_CONNECTION
6675 field_addr.name = "small_wonder_visibility";
6676#endif /* FREECIV_JSON_CONNECTION */
6677
6678 {
6679 int readin;
6680
6681 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
6682 RECEIVE_PACKET_FIELD_ERROR(small_wonder_visibility);
6683 }
6684 real_packet->small_wonder_visibility = readin;
6685 }
6686#endif /* FREECIV_DELTA_PROTOCOL */
6687
6688 RECEIVE_PACKET_END(real_packet);
6689#undef FREE_PACKET_STRUCT
6690}
6691
6692 static int send_packet_game_info_100(struct connection *pc, const struct packet_game_info *packet)
6693{
6694 const struct packet_game_info *real_packet = packet;
6695 int e;
6696 SEND_PACKET_START(PACKET_GAME_INFO);
6697
6698 log_packet_detailed("packet_game_info_100: sending info about ()");
6699
6700#ifdef FREECIV_DELTA_PROTOCOL
6701 packet_game_info_100_fields fields;
6702 struct packet_game_info *old;
6703 bool differ;
6704 int different = 0;
6705 struct genhash **hash = pc->phs.sent + PACKET_GAME_INFO;
6706
6707 if (nullptr == *hash) {
6708 *hash = genhash_new_full(hash_packet_game_info_100, cmp_packet_game_info_100,
6709 nullptr, nullptr, nullptr, destroy_packet_game_info);
6710 }
6711 BV_CLR_ALL(fields);
6712
6713 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
6714 old = fc_malloc(sizeof(*old));
6715 /* temporary bitcopy just to insert correctly */
6716 *old = *real_packet;
6717 genhash_insert(*hash, old, old);
6718 init_packet_game_info(old);
6719 different = 1; /* Force to send. */
6720 }
6721
6722 differ = (old->add_to_size_limit != real_packet->add_to_size_limit);
6723 if (differ) {
6724 different++;
6725 BV_SET(fields, 0);
6726 }
6727
6728 differ = (old->aifill != real_packet->aifill);
6729 if (differ) {
6730 different++;
6731 BV_SET(fields, 1);
6732 }
6733
6734 differ = (old->persistent_ready != real_packet->persistent_ready);
6735 if (differ) {
6736 different++;
6737 BV_SET(fields, 2);
6738 }
6739
6740 differ = (old->airlifting_style != real_packet->airlifting_style);
6741 if (differ) {
6742 different++;
6743 BV_SET(fields, 3);
6744 }
6745
6746 differ = (old->airlift_from_always_enabled != real_packet->airlift_from_always_enabled);
6747 if (differ) {
6748 different++;
6749 }
6750 /* folded into head */
6751 if (real_packet->airlift_from_always_enabled) {
6752 BV_SET(fields, 4);
6753 }
6754
6755 differ = (old->airlift_to_always_enabled != real_packet->airlift_to_always_enabled);
6756 if (differ) {
6757 different++;
6758 }
6759 /* folded into head */
6760 if (real_packet->airlift_to_always_enabled) {
6761 BV_SET(fields, 5);
6762 }
6763
6764 differ = (old->angrycitizen != real_packet->angrycitizen);
6765 if (differ) {
6766 different++;
6767 BV_SET(fields, 6);
6768 }
6769
6770 differ = (old->base_pollution != real_packet->base_pollution);
6771 if (differ) {
6772 different++;
6773 BV_SET(fields, 7);
6774 }
6775
6776 differ = (old->base_tech_cost != real_packet->base_tech_cost);
6777 if (differ) {
6778 different++;
6779 BV_SET(fields, 8);
6780 }
6781
6782 differ = (old->min_tech_cost != real_packet->min_tech_cost);
6783 if (differ) {
6784 different++;
6785 BV_SET(fields, 9);
6786 }
6787
6788 differ = (old->tech_leak_pct != real_packet->tech_leak_pct);
6789 if (differ) {
6790 different++;
6791 BV_SET(fields, 10);
6792 }
6793
6794 differ = (old->border_city_radius_sq != real_packet->border_city_radius_sq);
6795 if (differ) {
6796 different++;
6797 BV_SET(fields, 11);
6798 }
6799
6800 differ = (old->border_size_effect != real_packet->border_size_effect);
6801 if (differ) {
6802 different++;
6803 BV_SET(fields, 12);
6804 }
6805
6806 differ = (old->border_city_permanent_radius_sq != real_packet->border_city_permanent_radius_sq);
6807 if (differ) {
6808 different++;
6809 BV_SET(fields, 13);
6810 }
6811
6812 differ = (old->borders != real_packet->borders);
6813 if (differ) {
6814 different++;
6815 BV_SET(fields, 14);
6816 }
6817
6818 differ = (old->base_bribe_cost != real_packet->base_bribe_cost);
6819 if (differ) {
6820 different++;
6821 BV_SET(fields, 15);
6822 }
6823
6824 differ = (old->caravan_bonus_style != real_packet->caravan_bonus_style);
6825 if (differ) {
6826 different++;
6827 BV_SET(fields, 16);
6828 }
6829
6830 differ = (old->culture_vic_points != real_packet->culture_vic_points);
6831 if (differ) {
6832 different++;
6833 BV_SET(fields, 17);
6834 }
6835
6836 differ = (old->culture_vic_lead != real_packet->culture_vic_lead);
6837 if (differ) {
6838 different++;
6839 BV_SET(fields, 18);
6840 }
6841
6842 differ = (old->culture_migration_pml != real_packet->culture_migration_pml);
6843 if (differ) {
6844 different++;
6845 BV_SET(fields, 19);
6846 }
6847
6848 differ = (old->history_interest_pml != real_packet->history_interest_pml);
6849 if (differ) {
6850 different++;
6851 BV_SET(fields, 20);
6852 }
6853
6854 differ = (old->world_peace_turns != real_packet->world_peace_turns);
6855 if (differ) {
6856 different++;
6857 BV_SET(fields, 21);
6858 }
6859
6860 differ = (old->celebratesize != real_packet->celebratesize);
6861 if (differ) {
6862 different++;
6863 BV_SET(fields, 22);
6864 }
6865
6866 differ = (old->changable_tax != real_packet->changable_tax);
6867 if (differ) {
6868 different++;
6869 }
6870 /* folded into head */
6871 if (real_packet->changable_tax) {
6872 BV_SET(fields, 23);
6873 }
6874
6875 differ = (old->pop_report_zeroes != real_packet->pop_report_zeroes);
6876 if (differ) {
6877 different++;
6878 BV_SET(fields, 24);
6879 }
6880
6881 differ = (old->citizen_nationality != real_packet->citizen_nationality);
6882 if (differ) {
6883 different++;
6884 }
6885 /* folded into head */
6886 if (real_packet->citizen_nationality) {
6887 BV_SET(fields, 25);
6888 }
6889
6890 differ = (old->unit_builders_nationality != real_packet->unit_builders_nationality);
6891 if (differ) {
6892 different++;
6893 }
6894 /* folded into head */
6895 if (real_packet->unit_builders_nationality) {
6896 BV_SET(fields, 26);
6897 }
6898
6899 differ = (old->citizen_convert_speed != real_packet->citizen_convert_speed);
6900 if (differ) {
6901 different++;
6902 BV_SET(fields, 27);
6903 }
6904
6905 differ = (old->conquest_convert_pct != real_packet->conquest_convert_pct);
6906 if (differ) {
6907 different++;
6908 BV_SET(fields, 28);
6909 }
6910
6911 differ = (old->citizen_partisans_pct != real_packet->citizen_partisans_pct);
6912 if (differ) {
6913 different++;
6914 BV_SET(fields, 29);
6915 }
6916
6917 differ = (old->citymindist != real_packet->citymindist);
6918 if (differ) {
6919 different++;
6920 BV_SET(fields, 30);
6921 }
6922
6923 differ = (old->cooling != real_packet->cooling);
6924 if (differ) {
6925 different++;
6926 BV_SET(fields, 31);
6927 }
6928
6929 differ = (old->coolinglevel != real_packet->coolinglevel);
6930 if (differ) {
6931 different++;
6932 BV_SET(fields, 32);
6933 }
6934
6935 differ = !BV_ARE_EQUAL(old->diplchance_initial_odds, real_packet->diplchance_initial_odds);
6936 if (differ) {
6937 different++;
6938 BV_SET(fields, 33);
6939 }
6940
6941 differ = (old->diplomacy != real_packet->diplomacy);
6942 if (differ) {
6943 different++;
6944 BV_SET(fields, 34);
6945 }
6946
6947 differ = (old->fogofwar != real_packet->fogofwar);
6948 if (differ) {
6949 different++;
6950 }
6951 /* folded into head */
6952 if (real_packet->fogofwar) {
6953 BV_SET(fields, 35);
6954 }
6955
6956 differ = (old->food_cost != real_packet->food_cost);
6957 if (differ) {
6958 different++;
6959 BV_SET(fields, 36);
6960 }
6961
6962 differ = (old->foodbox != real_packet->foodbox);
6963 if (differ) {
6964 different++;
6965 BV_SET(fields, 37);
6966 }
6967
6968 differ = (old->forced_gold != real_packet->forced_gold);
6969 if (differ) {
6970 different++;
6971 BV_SET(fields, 38);
6972 }
6973
6974 differ = (old->forced_luxury != real_packet->forced_luxury);
6975 if (differ) {
6976 different++;
6977 BV_SET(fields, 39);
6978 }
6979
6980 differ = (old->forced_science != real_packet->forced_science);
6981 if (differ) {
6982 different++;
6983 BV_SET(fields, 40);
6984 }
6985
6986 differ = (old->fulltradesize != real_packet->fulltradesize);
6987 if (differ) {
6988 different++;
6989 BV_SET(fields, 41);
6990 }
6991
6992 differ = (old->trade_world_rel_pct != real_packet->trade_world_rel_pct);
6993 if (differ) {
6994 different++;
6995 BV_SET(fields, 42);
6996 }
6997
6998 differ = (old->min_trade_route_val != real_packet->min_trade_route_val);
6999 if (differ) {
7000 different++;
7001 BV_SET(fields, 43);
7002 }
7003
7004 differ = (old->reveal_trade_partner != real_packet->reveal_trade_partner);
7005 if (differ) {
7006 different++;
7007 }
7008 /* folded into head */
7009 if (real_packet->reveal_trade_partner) {
7010 BV_SET(fields, 44);
7011 }
7012
7013 differ = (old->goods_selection != real_packet->goods_selection);
7014 if (differ) {
7015 different++;
7016 BV_SET(fields, 45);
7017 }
7018
7019 differ = (old->global_advance_count != real_packet->global_advance_count);
7020 if (differ) {
7021 different++;
7022 BV_SET(fields, 46);
7023 }
7024
7025 differ = FALSE;
7026 {
7027 int i;
7028
7029 for (i = 0; i < A_LAST; i++) {
7030 differ = (old->global_advances[i] != real_packet->global_advances[i]);
7031 if (differ) {
7032 break;
7033 }
7034 }
7035 }
7036 if (differ) {
7037 different++;
7038 BV_SET(fields, 47);
7039 }
7040
7041 differ = (old->global_warming != real_packet->global_warming);
7042 if (differ) {
7043 different++;
7044 }
7045 /* folded into head */
7046 if (real_packet->global_warming) {
7047 BV_SET(fields, 48);
7048 }
7049
7050 differ = (old->globalwarming != real_packet->globalwarming);
7051 if (differ) {
7052 different++;
7053 BV_SET(fields, 49);
7054 }
7055
7056 differ = (old->gold != real_packet->gold);
7057 if (differ) {
7058 different++;
7059 BV_SET(fields, 50);
7060 }
7061
7062 differ = (old->gold_upkeep_style != real_packet->gold_upkeep_style);
7063 if (differ) {
7064 different++;
7065 BV_SET(fields, 51);
7066 }
7067
7068 differ = (old->homeless_gold_upkeep != real_packet->homeless_gold_upkeep);
7069 if (differ) {
7070 different++;
7071 }
7072 /* folded into head */
7073 if (real_packet->homeless_gold_upkeep) {
7074 BV_SET(fields, 52);
7075 }
7076
7077 differ = (old->infrapoints != real_packet->infrapoints);
7078 if (differ) {
7079 different++;
7080 BV_SET(fields, 53);
7081 }
7082
7083 differ = (old->revolentype != real_packet->revolentype);
7084 if (differ) {
7085 different++;
7086 BV_SET(fields, 54);
7087 }
7088
7089 differ = (old->default_government_id != real_packet->default_government_id);
7090 if (differ) {
7091 different++;
7092 BV_SET(fields, 55);
7093 }
7094
7095 differ = (old->government_during_revolution_id != real_packet->government_during_revolution_id);
7096 if (differ) {
7097 different++;
7098 BV_SET(fields, 56);
7099 }
7100
7101 differ = (old->granary_food_inc != real_packet->granary_food_inc);
7102 if (differ) {
7103 different++;
7104 BV_SET(fields, 57);
7105 }
7106
7107 differ = FALSE;
7108 {
7109 int i;
7110
7111 for (i = 0; i < MAX_GRANARY_INIS; i++) {
7112 differ = (old->granary_food_ini[i] != real_packet->granary_food_ini[i]);
7113 if (differ) {
7114 break;
7115 }
7116 }
7117 }
7118 if (differ) {
7119 different++;
7120 BV_SET(fields, 58);
7121 }
7122
7123 differ = (old->granary_num_inis != real_packet->granary_num_inis);
7124 if (differ) {
7125 different++;
7126 BV_SET(fields, 59);
7127 }
7128
7129 differ = FALSE;
7130 {
7131 int i;
7132
7133 for (i = 0; i < B_LAST; i++) {
7134 differ = (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]);
7135 if (differ) {
7136 break;
7137 }
7138 }
7139 }
7140 if (differ) {
7141 different++;
7142 BV_SET(fields, 60);
7143 }
7144
7145 differ = (old->happy_cost != real_packet->happy_cost);
7146 if (differ) {
7147 different++;
7148 BV_SET(fields, 61);
7149 }
7150
7151 differ = (old->happyborders != real_packet->happyborders);
7152 if (differ) {
7153 different++;
7154 BV_SET(fields, 62);
7155 }
7156
7157 differ = (old->heating != real_packet->heating);
7158 if (differ) {
7159 different++;
7160 BV_SET(fields, 63);
7161 }
7162
7163 differ = (old->illness_base_factor != real_packet->illness_base_factor);
7164 if (differ) {
7165 different++;
7166 BV_SET(fields, 64);
7167 }
7168
7169 differ = (old->illness_min_size != real_packet->illness_min_size);
7170 if (differ) {
7171 different++;
7172 BV_SET(fields, 65);
7173 }
7174
7175 differ = (old->illness_on != real_packet->illness_on);
7176 if (differ) {
7177 different++;
7178 }
7179 /* folded into head */
7180 if (real_packet->illness_on) {
7181 BV_SET(fields, 66);
7182 }
7183
7184 differ = (old->illness_pollution_factor != real_packet->illness_pollution_factor);
7185 if (differ) {
7186 different++;
7187 BV_SET(fields, 67);
7188 }
7189
7190 differ = (old->illness_trade_infection != real_packet->illness_trade_infection);
7191 if (differ) {
7192 different++;
7193 BV_SET(fields, 68);
7194 }
7195
7196 differ = (old->init_city_radius_sq != real_packet->init_city_radius_sq);
7197 if (differ) {
7198 different++;
7199 BV_SET(fields, 69);
7200 }
7201
7202 differ = (old->is_edit_mode != real_packet->is_edit_mode);
7203 if (differ) {
7204 different++;
7205 }
7206 /* folded into head */
7207 if (real_packet->is_edit_mode) {
7208 BV_SET(fields, 70);
7209 }
7210
7211 differ = (old->is_new_game != real_packet->is_new_game);
7212 if (differ) {
7213 different++;
7214 }
7215 /* folded into head */
7216 if (real_packet->is_new_game) {
7217 BV_SET(fields, 71);
7218 }
7219
7220 differ = (old->killcitizen != real_packet->killcitizen);
7221 if (differ) {
7222 different++;
7223 }
7224 /* folded into head */
7225 if (real_packet->killcitizen) {
7226 BV_SET(fields, 72);
7227 }
7228
7229 differ = (old->killstack != real_packet->killstack);
7230 if (differ) {
7231 different++;
7232 }
7233 /* folded into head */
7234 if (real_packet->killstack) {
7235 BV_SET(fields, 73);
7236 }
7237
7238 differ = (old->only_killing_makes_veteran != real_packet->only_killing_makes_veteran);
7239 if (differ) {
7240 different++;
7241 }
7242 /* folded into head */
7243 if (real_packet->only_killing_makes_veteran) {
7244 BV_SET(fields, 74);
7245 }
7246
7247 differ = (old->only_real_fight_makes_veteran != real_packet->only_real_fight_makes_veteran);
7248 if (differ) {
7249 different++;
7250 }
7251 /* folded into head */
7252 if (real_packet->only_real_fight_makes_veteran) {
7253 BV_SET(fields, 75);
7254 }
7255
7256 differ = (old->combat_odds_scaled_veterancy != real_packet->combat_odds_scaled_veterancy);
7257 if (differ) {
7258 different++;
7259 }
7260 /* folded into head */
7261 if (real_packet->combat_odds_scaled_veterancy) {
7262 BV_SET(fields, 76);
7263 }
7264
7265 differ = (old->damage_reduces_bombard_rate != real_packet->damage_reduces_bombard_rate);
7266 if (differ) {
7267 different++;
7268 }
7269 /* folded into head */
7270 if (real_packet->damage_reduces_bombard_rate) {
7271 BV_SET(fields, 77);
7272 }
7273
7274 differ = (old->low_firepower_badwallattacker != real_packet->low_firepower_badwallattacker);
7275 if (differ) {
7276 different++;
7277 BV_SET(fields, 78);
7278 }
7279
7280 differ = (old->low_firepower_pearl_harbour != real_packet->low_firepower_pearl_harbour);
7281 if (differ) {
7282 different++;
7283 BV_SET(fields, 79);
7284 }
7285
7286 differ = (old->low_firepower_combat_bonus != real_packet->low_firepower_combat_bonus);
7287 if (differ) {
7288 different++;
7289 BV_SET(fields, 80);
7290 }
7291
7292 differ = (old->low_firepower_nonnat_bombard != real_packet->low_firepower_nonnat_bombard);
7293 if (differ) {
7294 different++;
7295 BV_SET(fields, 81);
7296 }
7297
7298 differ = (old->nuke_pop_loss_pct != real_packet->nuke_pop_loss_pct);
7299 if (differ) {
7300 different++;
7301 BV_SET(fields, 82);
7302 }
7303
7304 differ = (old->nuke_defender_survival_chance_pct != real_packet->nuke_defender_survival_chance_pct);
7305 if (differ) {
7306 different++;
7307 BV_SET(fields, 83);
7308 }
7309
7310 differ = FALSE;
7311 {
7312 int i;
7313
7314 for (i = 0; i < O_LAST; i++) {
7315 differ = (old->min_city_center_output[i] != real_packet->min_city_center_output[i]);
7316 if (differ) {
7317 break;
7318 }
7319 }
7320 }
7321 if (differ) {
7322 different++;
7323 BV_SET(fields, 84);
7324 }
7325
7326 differ = (old->muuk_food_wipe != real_packet->muuk_food_wipe);
7327 if (differ) {
7328 different++;
7329 }
7330 /* folded into head */
7331 if (real_packet->muuk_food_wipe) {
7332 BV_SET(fields, 85);
7333 }
7334
7335 differ = (old->muuk_gold_wipe != real_packet->muuk_gold_wipe);
7336 if (differ) {
7337 different++;
7338 }
7339 /* folded into head */
7340 if (real_packet->muuk_gold_wipe) {
7341 BV_SET(fields, 86);
7342 }
7343
7344 differ = (old->muuk_shield_wipe != real_packet->muuk_shield_wipe);
7345 if (differ) {
7346 different++;
7347 }
7348 /* folded into head */
7349 if (real_packet->muuk_shield_wipe) {
7350 BV_SET(fields, 87);
7351 }
7352
7353 differ = (old->notradesize != real_packet->notradesize);
7354 if (differ) {
7355 different++;
7356 BV_SET(fields, 88);
7357 }
7358
7359 differ = (old->nuclear_winter != real_packet->nuclear_winter);
7360 if (differ) {
7361 different++;
7362 }
7363 /* folded into head */
7364 if (real_packet->nuclear_winter) {
7365 BV_SET(fields, 89);
7366 }
7367
7368 differ = (old->nuclearwinter != real_packet->nuclearwinter);
7369 if (differ) {
7370 different++;
7371 BV_SET(fields, 90);
7372 }
7373
7374 differ = (old->phase != real_packet->phase);
7375 if (differ) {
7376 different++;
7377 BV_SET(fields, 91);
7378 }
7379
7380 differ = (old->phase_mode != real_packet->phase_mode);
7381 if (differ) {
7382 different++;
7383 BV_SET(fields, 92);
7384 }
7385
7386 differ = (old->pillage_select != real_packet->pillage_select);
7387 if (differ) {
7388 different++;
7389 }
7390 /* folded into head */
7391 if (real_packet->pillage_select) {
7392 BV_SET(fields, 93);
7393 }
7394
7395 differ = (old->steal_maps_reveals_all_cities != real_packet->steal_maps_reveals_all_cities);
7396 if (differ) {
7397 different++;
7398 }
7399 /* folded into head */
7400 if (real_packet->steal_maps_reveals_all_cities) {
7401 BV_SET(fields, 94);
7402 }
7403
7404 differ = (old->poison_empties_food_stock != real_packet->poison_empties_food_stock);
7405 if (differ) {
7406 different++;
7407 }
7408 /* folded into head */
7409 if (real_packet->poison_empties_food_stock) {
7410 BV_SET(fields, 95);
7411 }
7412
7413 differ = (old->tech_steal_allow_holes != real_packet->tech_steal_allow_holes);
7414 if (differ) {
7415 different++;
7416 }
7417 /* folded into head */
7418 if (real_packet->tech_steal_allow_holes) {
7419 BV_SET(fields, 96);
7420 }
7421
7422 differ = (old->tech_trade_allow_holes != real_packet->tech_trade_allow_holes);
7423 if (differ) {
7424 different++;
7425 }
7426 /* folded into head */
7427 if (real_packet->tech_trade_allow_holes) {
7428 BV_SET(fields, 97);
7429 }
7430
7431 differ = (old->tech_trade_loss_allow_holes != real_packet->tech_trade_loss_allow_holes);
7432 if (differ) {
7433 different++;
7434 }
7435 /* folded into head */
7436 if (real_packet->tech_trade_loss_allow_holes) {
7437 BV_SET(fields, 98);
7438 }
7439
7440 differ = (old->tech_parasite_allow_holes != real_packet->tech_parasite_allow_holes);
7441 if (differ) {
7442 different++;
7443 }
7444 /* folded into head */
7445 if (real_packet->tech_parasite_allow_holes) {
7446 BV_SET(fields, 99);
7447 }
7448
7449 differ = (old->tech_loss_allow_holes != real_packet->tech_loss_allow_holes);
7450 if (differ) {
7451 different++;
7452 }
7453 /* folded into head */
7454 if (real_packet->tech_loss_allow_holes) {
7455 BV_SET(fields, 100);
7456 }
7457
7458 differ = (old->rapturedelay != real_packet->rapturedelay);
7459 if (differ) {
7460 different++;
7461 BV_SET(fields, 101);
7462 }
7463
7464 differ = (old->disasters != real_packet->disasters);
7465 if (differ) {
7466 different++;
7467 BV_SET(fields, 102);
7468 }
7469
7470 differ = (old->restrictinfra != real_packet->restrictinfra);
7471 if (differ) {
7472 different++;
7473 }
7474 /* folded into head */
7475 if (real_packet->restrictinfra) {
7476 BV_SET(fields, 103);
7477 }
7478
7479 differ = (old->unreachable_protects != real_packet->unreachable_protects);
7480 if (differ) {
7481 different++;
7482 }
7483 /* folded into head */
7484 if (real_packet->unreachable_protects) {
7485 BV_SET(fields, 104);
7486 }
7487
7488 differ = (old->sciencebox != real_packet->sciencebox);
7489 if (differ) {
7490 different++;
7491 BV_SET(fields, 105);
7492 }
7493
7494 differ = (old->shieldbox != real_packet->shieldbox);
7495 if (differ) {
7496 different++;
7497 BV_SET(fields, 106);
7498 }
7499
7500 differ = (old->skill_level != real_packet->skill_level);
7501 if (differ) {
7502 different++;
7503 BV_SET(fields, 107);
7504 }
7505
7506 differ = (old->victory_conditions != real_packet->victory_conditions);
7507 if (differ) {
7508 different++;
7509 BV_SET(fields, 108);
7510 }
7511
7512 differ = (old->team_pooled_research != real_packet->team_pooled_research);
7513 if (differ) {
7514 different++;
7515 }
7516 /* folded into head */
7517 if (real_packet->team_pooled_research) {
7518 BV_SET(fields, 109);
7519 }
7520
7521 differ = (old->tech != real_packet->tech);
7522 if (differ) {
7523 different++;
7524 BV_SET(fields, 110);
7525 }
7526
7527 differ = (old->tech_cost_style != real_packet->tech_cost_style);
7528 if (differ) {
7529 different++;
7530 BV_SET(fields, 111);
7531 }
7532
7533 differ = (old->tech_leakage != real_packet->tech_leakage);
7534 if (differ) {
7535 different++;
7536 BV_SET(fields, 112);
7537 }
7538
7539 differ = (old->tech_upkeep_divider != real_packet->tech_upkeep_divider);
7540 if (differ) {
7541 different++;
7542 BV_SET(fields, 113);
7543 }
7544
7545 differ = (old->tech_upkeep_style != real_packet->tech_upkeep_style);
7546 if (differ) {
7547 different++;
7548 BV_SET(fields, 114);
7549 }
7550
7551 differ = (old->techloss_forgiveness != real_packet->techloss_forgiveness);
7552 if (differ) {
7553 different++;
7554 BV_SET(fields, 115);
7555 }
7556
7557 differ = (old->free_tech_method != real_packet->free_tech_method);
7558 if (differ) {
7559 different++;
7560 BV_SET(fields, 116);
7561 }
7562
7563 differ = (old->gameloss_style != real_packet->gameloss_style);
7564 if (differ) {
7565 different++;
7566 BV_SET(fields, 117);
7567 }
7568
7569 differ = (old->timeout != real_packet->timeout);
7570 if (differ) {
7571 different++;
7572 BV_SET(fields, 118);
7573 }
7574
7575 differ = (old->first_timeout != real_packet->first_timeout);
7576 if (differ) {
7577 different++;
7578 BV_SET(fields, 119);
7579 }
7580
7581 differ = (old->tired_attack != real_packet->tired_attack);
7582 if (differ) {
7583 different++;
7584 }
7585 /* folded into head */
7586 if (real_packet->tired_attack) {
7587 BV_SET(fields, 120);
7588 }
7589
7590 differ = (old->trademindist != real_packet->trademindist);
7591 if (differ) {
7592 different++;
7593 BV_SET(fields, 121);
7594 }
7595
7596 differ = (old->trade_revenue_style != real_packet->trade_revenue_style);
7597 if (differ) {
7598 different++;
7599 BV_SET(fields, 122);
7600 }
7601
7602 differ = (old->trading_city != real_packet->trading_city);
7603 if (differ) {
7604 different++;
7605 }
7606 /* folded into head */
7607 if (real_packet->trading_city) {
7608 BV_SET(fields, 123);
7609 }
7610
7611 differ = (old->trading_gold != real_packet->trading_gold);
7612 if (differ) {
7613 different++;
7614 }
7615 /* folded into head */
7616 if (real_packet->trading_gold) {
7617 BV_SET(fields, 124);
7618 }
7619
7620 differ = (old->trading_tech != real_packet->trading_tech);
7621 if (differ) {
7622 different++;
7623 }
7624 /* folded into head */
7625 if (real_packet->trading_tech) {
7626 BV_SET(fields, 125);
7627 }
7628
7629 differ = (old->turn != real_packet->turn);
7630 if (differ) {
7631 different++;
7632 BV_SET(fields, 126);
7633 }
7634
7635 differ = (old->warminglevel != real_packet->warminglevel);
7636 if (differ) {
7637 different++;
7638 BV_SET(fields, 127);
7639 }
7640
7641 differ = (old->year != real_packet->year);
7642 if (differ) {
7643 different++;
7644 BV_SET(fields, 128);
7645 }
7646
7647 differ = (old->year_0_hack != real_packet->year_0_hack);
7648 if (differ) {
7649 different++;
7650 }
7651 /* folded into head */
7652 if (real_packet->year_0_hack) {
7653 BV_SET(fields, 129);
7654 }
7655
7656 differ = (old->top_cities_count != real_packet->top_cities_count);
7657 if (differ) {
7658 different++;
7659 BV_SET(fields, 130);
7660 }
7661
7662 differ = (old->fragment_count != real_packet->fragment_count);
7663 if (differ) {
7664 different++;
7665 BV_SET(fields, 131);
7666 }
7667
7668 differ = (old->civil_war_enabled != real_packet->civil_war_enabled);
7669 if (differ) {
7670 different++;
7671 }
7672 /* folded into head */
7673 if (real_packet->civil_war_enabled) {
7674 BV_SET(fields, 132);
7675 }
7676
7677 differ = (old->civil_war_bonus_celebrating != real_packet->civil_war_bonus_celebrating);
7678 if (differ) {
7679 different++;
7680 BV_SET(fields, 133);
7681 }
7682
7683 differ = (old->civil_war_bonus_unhappy != real_packet->civil_war_bonus_unhappy);
7684 if (differ) {
7685 different++;
7686 BV_SET(fields, 134);
7687 }
7688
7689 differ = (old->granularity != real_packet->granularity);
7690 if (differ) {
7691 different++;
7692 BV_SET(fields, 135);
7693 }
7694
7695 differ = (old->small_wonder_visibility != real_packet->small_wonder_visibility);
7696 if (differ) {
7697 different++;
7698 BV_SET(fields, 136);
7699 }
7700
7701 if (different == 0) {
7702 log_packet_detailed(" no change -> discard");
7703 SEND_PACKET_DISCARD();
7704 }
7705#endif /* FREECIV_DELTA_PROTOCOL */
7706
7707#ifdef FREECIV_JSON_CONNECTION
7708 struct plocation field_addr;
7709 {
7710 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
7711 field_addr = *field_addr_tmp;
7712 FC_FREE(field_addr_tmp);
7713 }
7714#endif /* FREECIV_JSON_CONNECTION */
7715
7716#ifdef FREECIV_DELTA_PROTOCOL
7717#ifdef FREECIV_JSON_CONNECTION
7718 field_addr.name = "fields";
7719#endif /* FREECIV_JSON_CONNECTION */
7720 e = 0;
7721 e |= DIO_BV_PUT(&dout, &field_addr, fields);
7722 if (e) {
7723 log_packet_detailed("fields bitvector error detected");
7724 }
7725
7726 if (BV_ISSET(fields, 0)) {
7727 log_packet_detailed(" field 'add_to_size_limit' has changed");
7728
7729#ifdef FREECIV_JSON_CONNECTION
7730 field_addr.name = "add_to_size_limit";
7731#endif /* FREECIV_JSON_CONNECTION */
7732 e = 0;
7733
7734 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->add_to_size_limit);
7735
7736 if (e) {
7737 log_packet_detailed("'add_to_size_limit' field error detected");
7738 }
7739 }
7740
7741 if (BV_ISSET(fields, 1)) {
7742 log_packet_detailed(" field 'aifill' has changed");
7743
7744#ifdef FREECIV_JSON_CONNECTION
7745 field_addr.name = "aifill";
7746#endif /* FREECIV_JSON_CONNECTION */
7747 e = 0;
7748
7749 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->aifill);
7750
7751 if (e) {
7752 log_packet_detailed("'aifill' field error detected");
7753 }
7754 }
7755
7756 if (BV_ISSET(fields, 2)) {
7757 log_packet_detailed(" field 'persistent_ready' has changed");
7758
7759#ifdef FREECIV_JSON_CONNECTION
7760 field_addr.name = "persistent_ready";
7761#endif /* FREECIV_JSON_CONNECTION */
7762 e = 0;
7763
7764 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->persistent_ready);
7765
7766 if (e) {
7767 log_packet_detailed("'persistent_ready' field error detected");
7768 }
7769 }
7770
7771 if (BV_ISSET(fields, 3)) {
7772 log_packet_detailed(" field 'airlifting_style' has changed");
7773
7774#ifdef FREECIV_JSON_CONNECTION
7775 field_addr.name = "airlifting_style";
7776#endif /* FREECIV_JSON_CONNECTION */
7777 e = 0;
7778
7779 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->airlifting_style);
7780
7781 if (e) {
7782 log_packet_detailed("'airlifting_style' field error detected");
7783 }
7784 }
7785
7786 /* field 4 is folded into the header */
7787
7788 /* field 5 is folded into the header */
7789
7790 if (BV_ISSET(fields, 6)) {
7791 log_packet_detailed(" field 'angrycitizen' has changed");
7792
7793#ifdef FREECIV_JSON_CONNECTION
7794 field_addr.name = "angrycitizen";
7795#endif /* FREECIV_JSON_CONNECTION */
7796 e = 0;
7797
7798 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->angrycitizen);
7799
7800 if (e) {
7801 log_packet_detailed("'angrycitizen' field error detected");
7802 }
7803 }
7804
7805 if (BV_ISSET(fields, 7)) {
7806 log_packet_detailed(" field 'base_pollution' has changed");
7807
7808#ifdef FREECIV_JSON_CONNECTION
7809 field_addr.name = "base_pollution";
7810#endif /* FREECIV_JSON_CONNECTION */
7811 e = 0;
7812
7813 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->base_pollution);
7814
7815 if (e) {
7816 log_packet_detailed("'base_pollution' field error detected");
7817 }
7818 }
7819
7820 if (BV_ISSET(fields, 8)) {
7821 log_packet_detailed(" field 'base_tech_cost' has changed");
7822
7823#ifdef FREECIV_JSON_CONNECTION
7824 field_addr.name = "base_tech_cost";
7825#endif /* FREECIV_JSON_CONNECTION */
7826 e = 0;
7827
7828 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->base_tech_cost);
7829
7830 if (e) {
7831 log_packet_detailed("'base_tech_cost' field error detected");
7832 }
7833 }
7834
7835 if (BV_ISSET(fields, 9)) {
7836 log_packet_detailed(" field 'min_tech_cost' has changed");
7837
7838#ifdef FREECIV_JSON_CONNECTION
7839 field_addr.name = "min_tech_cost";
7840#endif /* FREECIV_JSON_CONNECTION */
7841 e = 0;
7842
7843 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->min_tech_cost);
7844
7845 if (e) {
7846 log_packet_detailed("'min_tech_cost' field error detected");
7847 }
7848 }
7849
7850 if (BV_ISSET(fields, 10)) {
7851 log_packet_detailed(" field 'tech_leak_pct' has changed");
7852
7853#ifdef FREECIV_JSON_CONNECTION
7854 field_addr.name = "tech_leak_pct";
7855#endif /* FREECIV_JSON_CONNECTION */
7856 e = 0;
7857
7858 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_leak_pct);
7859
7860 if (e) {
7861 log_packet_detailed("'tech_leak_pct' field error detected");
7862 }
7863 }
7864
7865 if (BV_ISSET(fields, 11)) {
7866 log_packet_detailed(" field 'border_city_radius_sq' has changed");
7867
7868#ifdef FREECIV_JSON_CONNECTION
7869 field_addr.name = "border_city_radius_sq";
7870#endif /* FREECIV_JSON_CONNECTION */
7871 e = 0;
7872
7873 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->border_city_radius_sq);
7874
7875 if (e) {
7876 log_packet_detailed("'border_city_radius_sq' field error detected");
7877 }
7878 }
7879
7880 if (BV_ISSET(fields, 12)) {
7881 log_packet_detailed(" field 'border_size_effect' has changed");
7882
7883#ifdef FREECIV_JSON_CONNECTION
7884 field_addr.name = "border_size_effect";
7885#endif /* FREECIV_JSON_CONNECTION */
7886 e = 0;
7887
7888 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->border_size_effect);
7889
7890 if (e) {
7891 log_packet_detailed("'border_size_effect' field error detected");
7892 }
7893 }
7894
7895 if (BV_ISSET(fields, 13)) {
7896 log_packet_detailed(" field 'border_city_permanent_radius_sq' has changed");
7897
7898#ifdef FREECIV_JSON_CONNECTION
7899 field_addr.name = "border_city_permanent_radius_sq";
7900#endif /* FREECIV_JSON_CONNECTION */
7901 e = 0;
7902
7903 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->border_city_permanent_radius_sq);
7904
7905 if (e) {
7906 log_packet_detailed("'border_city_permanent_radius_sq' field error detected");
7907 }
7908 }
7909
7910 if (BV_ISSET(fields, 14)) {
7911 log_packet_detailed(" field 'borders' has changed");
7912
7913#ifdef FREECIV_JSON_CONNECTION
7914 field_addr.name = "borders";
7915#endif /* FREECIV_JSON_CONNECTION */
7916 e = 0;
7917
7918 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->borders);
7919
7920 if (e) {
7921 log_packet_detailed("'borders' field error detected");
7922 }
7923 }
7924
7925 if (BV_ISSET(fields, 15)) {
7926 log_packet_detailed(" field 'base_bribe_cost' has changed");
7927
7928#ifdef FREECIV_JSON_CONNECTION
7929 field_addr.name = "base_bribe_cost";
7930#endif /* FREECIV_JSON_CONNECTION */
7931 e = 0;
7932
7933 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->base_bribe_cost);
7934
7935 if (e) {
7936 log_packet_detailed("'base_bribe_cost' field error detected");
7937 }
7938 }
7939
7940 if (BV_ISSET(fields, 16)) {
7941 log_packet_detailed(" field 'caravan_bonus_style' has changed");
7942
7943#ifdef FREECIV_JSON_CONNECTION
7944 field_addr.name = "caravan_bonus_style";
7945#endif /* FREECIV_JSON_CONNECTION */
7946 e = 0;
7947
7948 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->caravan_bonus_style);
7949
7950 if (e) {
7951 log_packet_detailed("'caravan_bonus_style' field error detected");
7952 }
7953 }
7954
7955 if (BV_ISSET(fields, 17)) {
7956 log_packet_detailed(" field 'culture_vic_points' has changed");
7957
7958#ifdef FREECIV_JSON_CONNECTION
7959 field_addr.name = "culture_vic_points";
7960#endif /* FREECIV_JSON_CONNECTION */
7961 e = 0;
7962
7963 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->culture_vic_points);
7964
7965 if (e) {
7966 log_packet_detailed("'culture_vic_points' field error detected");
7967 }
7968 }
7969
7970 if (BV_ISSET(fields, 18)) {
7971 log_packet_detailed(" field 'culture_vic_lead' has changed");
7972
7973#ifdef FREECIV_JSON_CONNECTION
7974 field_addr.name = "culture_vic_lead";
7975#endif /* FREECIV_JSON_CONNECTION */
7976 e = 0;
7977
7978 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->culture_vic_lead);
7979
7980 if (e) {
7981 log_packet_detailed("'culture_vic_lead' field error detected");
7982 }
7983 }
7984
7985 if (BV_ISSET(fields, 19)) {
7986 log_packet_detailed(" field 'culture_migration_pml' has changed");
7987
7988#ifdef FREECIV_JSON_CONNECTION
7989 field_addr.name = "culture_migration_pml";
7990#endif /* FREECIV_JSON_CONNECTION */
7991 e = 0;
7992
7993 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->culture_migration_pml);
7994
7995 if (e) {
7996 log_packet_detailed("'culture_migration_pml' field error detected");
7997 }
7998 }
7999
8000 if (BV_ISSET(fields, 20)) {
8001 log_packet_detailed(" field 'history_interest_pml' has changed");
8002
8003#ifdef FREECIV_JSON_CONNECTION
8004 field_addr.name = "history_interest_pml";
8005#endif /* FREECIV_JSON_CONNECTION */
8006 e = 0;
8007
8008 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->history_interest_pml);
8009
8010 if (e) {
8011 log_packet_detailed("'history_interest_pml' field error detected");
8012 }
8013 }
8014
8015 if (BV_ISSET(fields, 21)) {
8016 log_packet_detailed(" field 'world_peace_turns' has changed");
8017
8018#ifdef FREECIV_JSON_CONNECTION
8019 field_addr.name = "world_peace_turns";
8020#endif /* FREECIV_JSON_CONNECTION */
8021 e = 0;
8022
8023 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->world_peace_turns);
8024
8025 if (e) {
8026 log_packet_detailed("'world_peace_turns' field error detected");
8027 }
8028 }
8029
8030 if (BV_ISSET(fields, 22)) {
8031 log_packet_detailed(" field 'celebratesize' has changed");
8032
8033#ifdef FREECIV_JSON_CONNECTION
8034 field_addr.name = "celebratesize";
8035#endif /* FREECIV_JSON_CONNECTION */
8036 e = 0;
8037
8038 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->celebratesize);
8039
8040 if (e) {
8041 log_packet_detailed("'celebratesize' field error detected");
8042 }
8043 }
8044
8045 /* field 23 is folded into the header */
8046
8047 if (BV_ISSET(fields, 24)) {
8048 log_packet_detailed(" field 'pop_report_zeroes' has changed");
8049
8050#ifdef FREECIV_JSON_CONNECTION
8051 field_addr.name = "pop_report_zeroes";
8052#endif /* FREECIV_JSON_CONNECTION */
8053 e = 0;
8054
8055 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->pop_report_zeroes);
8056
8057 if (e) {
8058 log_packet_detailed("'pop_report_zeroes' field error detected");
8059 }
8060 }
8061
8062 /* field 25 is folded into the header */
8063
8064 /* field 26 is folded into the header */
8065
8066 if (BV_ISSET(fields, 27)) {
8067 log_packet_detailed(" field 'citizen_convert_speed' has changed");
8068
8069#ifdef FREECIV_JSON_CONNECTION
8070 field_addr.name = "citizen_convert_speed";
8071#endif /* FREECIV_JSON_CONNECTION */
8072 e = 0;
8073
8074 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->citizen_convert_speed);
8075
8076 if (e) {
8077 log_packet_detailed("'citizen_convert_speed' field error detected");
8078 }
8079 }
8080
8081 if (BV_ISSET(fields, 28)) {
8082 log_packet_detailed(" field 'conquest_convert_pct' has changed");
8083
8084#ifdef FREECIV_JSON_CONNECTION
8085 field_addr.name = "conquest_convert_pct";
8086#endif /* FREECIV_JSON_CONNECTION */
8087 e = 0;
8088
8089 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->conquest_convert_pct);
8090
8091 if (e) {
8092 log_packet_detailed("'conquest_convert_pct' field error detected");
8093 }
8094 }
8095
8096 if (BV_ISSET(fields, 29)) {
8097 log_packet_detailed(" field 'citizen_partisans_pct' has changed");
8098
8099#ifdef FREECIV_JSON_CONNECTION
8100 field_addr.name = "citizen_partisans_pct";
8101#endif /* FREECIV_JSON_CONNECTION */
8102 e = 0;
8103
8104 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->citizen_partisans_pct);
8105
8106 if (e) {
8107 log_packet_detailed("'citizen_partisans_pct' field error detected");
8108 }
8109 }
8110
8111 if (BV_ISSET(fields, 30)) {
8112 log_packet_detailed(" field 'citymindist' has changed");
8113
8114#ifdef FREECIV_JSON_CONNECTION
8115 field_addr.name = "citymindist";
8116#endif /* FREECIV_JSON_CONNECTION */
8117 e = 0;
8118
8119 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->citymindist);
8120
8121 if (e) {
8122 log_packet_detailed("'citymindist' field error detected");
8123 }
8124 }
8125
8126 if (BV_ISSET(fields, 31)) {
8127 log_packet_detailed(" field 'cooling' has changed");
8128
8129#ifdef FREECIV_JSON_CONNECTION
8130 field_addr.name = "cooling";
8131#endif /* FREECIV_JSON_CONNECTION */
8132 e = 0;
8133
8134 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->cooling);
8135
8136 if (e) {
8137 log_packet_detailed("'cooling' field error detected");
8138 }
8139 }
8140
8141 if (BV_ISSET(fields, 32)) {
8142 log_packet_detailed(" field 'coolinglevel' has changed");
8143
8144#ifdef FREECIV_JSON_CONNECTION
8145 field_addr.name = "coolinglevel";
8146#endif /* FREECIV_JSON_CONNECTION */
8147 e = 0;
8148
8149 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->coolinglevel);
8150
8151 if (e) {
8152 log_packet_detailed("'coolinglevel' field error detected");
8153 }
8154 }
8155
8156 if (BV_ISSET(fields, 33)) {
8157 log_packet_detailed(" field 'diplchance_initial_odds' has changed");
8158
8159#ifdef FREECIV_JSON_CONNECTION
8160 field_addr.name = "diplchance_initial_odds";
8161#endif /* FREECIV_JSON_CONNECTION */
8162 e = 0;
8163
8164 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->diplchance_initial_odds);
8165
8166 if (e) {
8167 log_packet_detailed("'diplchance_initial_odds' field error detected");
8168 }
8169 }
8170
8171 if (BV_ISSET(fields, 34)) {
8172 log_packet_detailed(" field 'diplomacy' has changed");
8173
8174#ifdef FREECIV_JSON_CONNECTION
8175 field_addr.name = "diplomacy";
8176#endif /* FREECIV_JSON_CONNECTION */
8177 e = 0;
8178
8179 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->diplomacy);
8180
8181 if (e) {
8182 log_packet_detailed("'diplomacy' field error detected");
8183 }
8184 }
8185
8186 /* field 35 is folded into the header */
8187
8188 if (BV_ISSET(fields, 36)) {
8189 log_packet_detailed(" field 'food_cost' has changed");
8190
8191#ifdef FREECIV_JSON_CONNECTION
8192 field_addr.name = "food_cost";
8193#endif /* FREECIV_JSON_CONNECTION */
8194 e = 0;
8195
8196 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->food_cost);
8197
8198 if (e) {
8199 log_packet_detailed("'food_cost' field error detected");
8200 }
8201 }
8202
8203 if (BV_ISSET(fields, 37)) {
8204 log_packet_detailed(" field 'foodbox' has changed");
8205
8206#ifdef FREECIV_JSON_CONNECTION
8207 field_addr.name = "foodbox";
8208#endif /* FREECIV_JSON_CONNECTION */
8209 e = 0;
8210
8211 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->foodbox);
8212
8213 if (e) {
8214 log_packet_detailed("'foodbox' field error detected");
8215 }
8216 }
8217
8218 if (BV_ISSET(fields, 38)) {
8219 log_packet_detailed(" field 'forced_gold' has changed");
8220
8221#ifdef FREECIV_JSON_CONNECTION
8222 field_addr.name = "forced_gold";
8223#endif /* FREECIV_JSON_CONNECTION */
8224 e = 0;
8225
8226 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->forced_gold);
8227
8228 if (e) {
8229 log_packet_detailed("'forced_gold' field error detected");
8230 }
8231 }
8232
8233 if (BV_ISSET(fields, 39)) {
8234 log_packet_detailed(" field 'forced_luxury' has changed");
8235
8236#ifdef FREECIV_JSON_CONNECTION
8237 field_addr.name = "forced_luxury";
8238#endif /* FREECIV_JSON_CONNECTION */
8239 e = 0;
8240
8241 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->forced_luxury);
8242
8243 if (e) {
8244 log_packet_detailed("'forced_luxury' field error detected");
8245 }
8246 }
8247
8248 if (BV_ISSET(fields, 40)) {
8249 log_packet_detailed(" field 'forced_science' has changed");
8250
8251#ifdef FREECIV_JSON_CONNECTION
8252 field_addr.name = "forced_science";
8253#endif /* FREECIV_JSON_CONNECTION */
8254 e = 0;
8255
8256 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->forced_science);
8257
8258 if (e) {
8259 log_packet_detailed("'forced_science' field error detected");
8260 }
8261 }
8262
8263 if (BV_ISSET(fields, 41)) {
8264 log_packet_detailed(" field 'fulltradesize' has changed");
8265
8266#ifdef FREECIV_JSON_CONNECTION
8267 field_addr.name = "fulltradesize";
8268#endif /* FREECIV_JSON_CONNECTION */
8269 e = 0;
8270
8271 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fulltradesize);
8272
8273 if (e) {
8274 log_packet_detailed("'fulltradesize' field error detected");
8275 }
8276 }
8277
8278 if (BV_ISSET(fields, 42)) {
8279 log_packet_detailed(" field 'trade_world_rel_pct' has changed");
8280
8281#ifdef FREECIV_JSON_CONNECTION
8282 field_addr.name = "trade_world_rel_pct";
8283#endif /* FREECIV_JSON_CONNECTION */
8284 e = 0;
8285
8286 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->trade_world_rel_pct);
8287
8288 if (e) {
8289 log_packet_detailed("'trade_world_rel_pct' field error detected");
8290 }
8291 }
8292
8293 if (BV_ISSET(fields, 43)) {
8294 log_packet_detailed(" field 'min_trade_route_val' has changed");
8295
8296#ifdef FREECIV_JSON_CONNECTION
8297 field_addr.name = "min_trade_route_val";
8298#endif /* FREECIV_JSON_CONNECTION */
8299 e = 0;
8300
8301 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->min_trade_route_val);
8302
8303 if (e) {
8304 log_packet_detailed("'min_trade_route_val' field error detected");
8305 }
8306 }
8307
8308 /* field 44 is folded into the header */
8309
8310 if (BV_ISSET(fields, 45)) {
8311 log_packet_detailed(" field 'goods_selection' has changed");
8312
8313#ifdef FREECIV_JSON_CONNECTION
8314 field_addr.name = "goods_selection";
8315#endif /* FREECIV_JSON_CONNECTION */
8316 e = 0;
8317
8318 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->goods_selection);
8319
8320 if (e) {
8321 log_packet_detailed("'goods_selection' field error detected");
8322 }
8323 }
8324
8325 if (BV_ISSET(fields, 46)) {
8326 log_packet_detailed(" field 'global_advance_count' has changed");
8327
8328#ifdef FREECIV_JSON_CONNECTION
8329 field_addr.name = "global_advance_count";
8330#endif /* FREECIV_JSON_CONNECTION */
8331 e = 0;
8332
8333 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->global_advance_count);
8334
8335 if (e) {
8336 log_packet_detailed("'global_advance_count' field error detected");
8337 }
8338 }
8339
8340 if (BV_ISSET(fields, 47)) {
8341 log_packet_detailed(" field 'global_advances' has changed");
8342
8343#ifdef FREECIV_JSON_CONNECTION
8344 field_addr.name = "global_advances";
8345#endif /* FREECIV_JSON_CONNECTION */
8346 e = 0;
8347
8348 {
8349 int i;
8350
8351 FC_STATIC_ASSERT(A_LAST <= MAX_UINT16, packet_array_too_long_global_advances);
8352
8353#ifdef FREECIV_JSON_CONNECTION
8354 size_t count_i = 0;
8355
8356 /* Create the array. */
8357 e |= DIO_PUT(farray, &dout, &field_addr, 0);
8358
8359 /* Enter array. */
8360 field_addr.sub_location = plocation_elem_new(0);
8361#endif /* FREECIV_JSON_CONNECTION */
8362
8363 for (i = 0; i < A_LAST; i++) {
8364 differ = (old->global_advances[i] != real_packet->global_advances[i]);
8365
8366 if (!differ) {
8367 continue;
8368 }
8369
8370#ifdef FREECIV_JSON_CONNECTION
8371 /* Append next diff array element. */
8372 field_addr.sub_location->number = -1;
8373
8374 /* Create the diff array element. */
8375 e |= DIO_PUT(object, &dout, &field_addr);
8376
8377 /* Enter diff array element (start at the index address). */
8378 field_addr.sub_location->number = count_i++;
8379 field_addr.sub_location->sub_location = plocation_field_new("index");
8380#endif /* FREECIV_JSON_CONNECTION */
8381
8382 /* Write the index */
8383#if A_LAST <= MAX_UINT8
8384 e |= DIO_PUT(uint8, &dout, &field_addr, i);
8385#else
8386 e |= DIO_PUT(uint16, &dout, &field_addr, i);
8387#endif
8388
8389#ifdef FREECIV_JSON_CONNECTION
8390 /* Content address. */
8391 field_addr.sub_location->sub_location->name = "data";
8392#endif /* FREECIV_JSON_CONNECTION */
8393
8394 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->global_advances[i]);
8395
8396#ifdef FREECIV_JSON_CONNECTION
8397 /* Exit diff array element. */
8398 FC_FREE(field_addr.sub_location->sub_location);
8399#endif /* FREECIV_JSON_CONNECTION */
8400 }
8401
8402#ifdef FREECIV_JSON_CONNECTION
8403 /* Append diff array element. */
8404 field_addr.sub_location->number = -1;
8405
8406 /* Create the terminating diff array element. */
8407 e |= DIO_PUT(object, &dout, &field_addr);
8408
8409 /* Enter diff array element (start at the index address). */
8410 field_addr.sub_location->number = count_i;
8411 field_addr.sub_location->sub_location = plocation_field_new("index");
8412#endif /* FREECIV_JSON_CONNECTION */
8413
8414 /* Write the sentinel value */
8415#if A_LAST <= MAX_UINT8
8416 e |= DIO_PUT(uint8, &dout, &field_addr, A_LAST);
8417#else
8418 e |= DIO_PUT(uint16, &dout, &field_addr, A_LAST);
8419#endif
8420
8421#ifdef FREECIV_JSON_CONNECTION
8422 /* Exit diff array element. */
8423 FC_FREE(field_addr.sub_location->sub_location);
8424 /* Exit array. */
8425 FC_FREE(field_addr.sub_location);
8426#endif /* FREECIV_JSON_CONNECTION */
8427 }
8428
8429 if (e) {
8430 log_packet_detailed("'global_advances' field error detected");
8431 }
8432 }
8433
8434 /* field 48 is folded into the header */
8435
8436 if (BV_ISSET(fields, 49)) {
8437 log_packet_detailed(" field 'globalwarming' has changed");
8438
8439#ifdef FREECIV_JSON_CONNECTION
8440 field_addr.name = "globalwarming";
8441#endif /* FREECIV_JSON_CONNECTION */
8442 e = 0;
8443
8444 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->globalwarming);
8445
8446 if (e) {
8447 log_packet_detailed("'globalwarming' field error detected");
8448 }
8449 }
8450
8451 if (BV_ISSET(fields, 50)) {
8452 log_packet_detailed(" field 'gold' has changed");
8453
8454#ifdef FREECIV_JSON_CONNECTION
8455 field_addr.name = "gold";
8456#endif /* FREECIV_JSON_CONNECTION */
8457 e = 0;
8458
8459 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->gold);
8460
8461 if (e) {
8462 log_packet_detailed("'gold' field error detected");
8463 }
8464 }
8465
8466 if (BV_ISSET(fields, 51)) {
8467 log_packet_detailed(" field 'gold_upkeep_style' has changed");
8468
8469#ifdef FREECIV_JSON_CONNECTION
8470 field_addr.name = "gold_upkeep_style";
8471#endif /* FREECIV_JSON_CONNECTION */
8472 e = 0;
8473
8474 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gold_upkeep_style);
8475
8476 if (e) {
8477 log_packet_detailed("'gold_upkeep_style' field error detected");
8478 }
8479 }
8480
8481 /* field 52 is folded into the header */
8482
8483 if (BV_ISSET(fields, 53)) {
8484 log_packet_detailed(" field 'infrapoints' has changed");
8485
8486#ifdef FREECIV_JSON_CONNECTION
8487 field_addr.name = "infrapoints";
8488#endif /* FREECIV_JSON_CONNECTION */
8489 e = 0;
8490
8491 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->infrapoints);
8492
8493 if (e) {
8494 log_packet_detailed("'infrapoints' field error detected");
8495 }
8496 }
8497
8498 if (BV_ISSET(fields, 54)) {
8499 log_packet_detailed(" field 'revolentype' has changed");
8500
8501#ifdef FREECIV_JSON_CONNECTION
8502 field_addr.name = "revolentype";
8503#endif /* FREECIV_JSON_CONNECTION */
8504 e = 0;
8505
8506 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->revolentype);
8507
8508 if (e) {
8509 log_packet_detailed("'revolentype' field error detected");
8510 }
8511 }
8512
8513 if (BV_ISSET(fields, 55)) {
8514 log_packet_detailed(" field 'default_government_id' has changed");
8515
8516#ifdef FREECIV_JSON_CONNECTION
8517 field_addr.name = "default_government_id";
8518#endif /* FREECIV_JSON_CONNECTION */
8519 e = 0;
8520
8521 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->default_government_id);
8522
8523 if (e) {
8524 log_packet_detailed("'default_government_id' field error detected");
8525 }
8526 }
8527
8528 if (BV_ISSET(fields, 56)) {
8529 log_packet_detailed(" field 'government_during_revolution_id' has changed");
8530
8531#ifdef FREECIV_JSON_CONNECTION
8532 field_addr.name = "government_during_revolution_id";
8533#endif /* FREECIV_JSON_CONNECTION */
8534 e = 0;
8535
8536 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government_during_revolution_id);
8537
8538 if (e) {
8539 log_packet_detailed("'government_during_revolution_id' field error detected");
8540 }
8541 }
8542
8543 if (BV_ISSET(fields, 57)) {
8544 log_packet_detailed(" field 'granary_food_inc' has changed");
8545
8546#ifdef FREECIV_JSON_CONNECTION
8547 field_addr.name = "granary_food_inc";
8548#endif /* FREECIV_JSON_CONNECTION */
8549 e = 0;
8550
8551 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granary_food_inc);
8552
8553 if (e) {
8554 log_packet_detailed("'granary_food_inc' field error detected");
8555 }
8556 }
8557
8558 if (BV_ISSET(fields, 58)) {
8559 log_packet_detailed(" field 'granary_food_ini' has changed");
8560
8561#ifdef FREECIV_JSON_CONNECTION
8562 field_addr.name = "granary_food_ini";
8563#endif /* FREECIV_JSON_CONNECTION */
8564 e = 0;
8565
8566 {
8567 int i;
8568
8569#ifdef FREECIV_JSON_CONNECTION
8570 /* Create the array. */
8571 e |= DIO_PUT(farray, &dout, &field_addr, MAX_GRANARY_INIS);
8572
8573 /* Enter array. */
8574 field_addr.sub_location = plocation_elem_new(0);
8575#endif /* FREECIV_JSON_CONNECTION */
8576
8577 for (i = 0; i < MAX_GRANARY_INIS; i++) {
8578#ifdef FREECIV_JSON_CONNECTION
8579 /* Next array element. */
8580 field_addr.sub_location->number = i;
8581#endif /* FREECIV_JSON_CONNECTION */
8582
8583 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granary_food_ini[i]);
8584 }
8585
8586#ifdef FREECIV_JSON_CONNECTION
8587 /* Exit array. */
8588 FC_FREE(field_addr.sub_location);
8589#endif /* FREECIV_JSON_CONNECTION */
8590 }
8591
8592 if (e) {
8593 log_packet_detailed("'granary_food_ini' field error detected");
8594 }
8595 }
8596
8597 if (BV_ISSET(fields, 59)) {
8598 log_packet_detailed(" field 'granary_num_inis' has changed");
8599
8600#ifdef FREECIV_JSON_CONNECTION
8601 field_addr.name = "granary_num_inis";
8602#endif /* FREECIV_JSON_CONNECTION */
8603 e = 0;
8604
8605 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->granary_num_inis);
8606
8607 if (e) {
8608 log_packet_detailed("'granary_num_inis' field error detected");
8609 }
8610 }
8611
8612 if (BV_ISSET(fields, 60)) {
8613 log_packet_detailed(" field 'great_wonder_owners' has changed");
8614
8615#ifdef FREECIV_JSON_CONNECTION
8616 field_addr.name = "great_wonder_owners";
8617#endif /* FREECIV_JSON_CONNECTION */
8618 e = 0;
8619
8620 {
8621 int i;
8622
8623 FC_STATIC_ASSERT(B_LAST <= MAX_UINT16, packet_array_too_long_great_wonder_owners);
8624
8625#ifdef FREECIV_JSON_CONNECTION
8626 size_t count_i = 0;
8627
8628 /* Create the array. */
8629 e |= DIO_PUT(farray, &dout, &field_addr, 0);
8630
8631 /* Enter array. */
8632 field_addr.sub_location = plocation_elem_new(0);
8633#endif /* FREECIV_JSON_CONNECTION */
8634
8635 for (i = 0; i < B_LAST; i++) {
8636 differ = (old->great_wonder_owners[i] != real_packet->great_wonder_owners[i]);
8637
8638 if (!differ) {
8639 continue;
8640 }
8641
8642#ifdef FREECIV_JSON_CONNECTION
8643 /* Append next diff array element. */
8644 field_addr.sub_location->number = -1;
8645
8646 /* Create the diff array element. */
8647 e |= DIO_PUT(object, &dout, &field_addr);
8648
8649 /* Enter diff array element (start at the index address). */
8650 field_addr.sub_location->number = count_i++;
8651 field_addr.sub_location->sub_location = plocation_field_new("index");
8652#endif /* FREECIV_JSON_CONNECTION */
8653
8654 /* Write the index */
8655#if B_LAST <= MAX_UINT8
8656 e |= DIO_PUT(uint8, &dout, &field_addr, i);
8657#else
8658 e |= DIO_PUT(uint16, &dout, &field_addr, i);
8659#endif
8660
8661#ifdef FREECIV_JSON_CONNECTION
8662 /* Content address. */
8663 field_addr.sub_location->sub_location->name = "data";
8664#endif /* FREECIV_JSON_CONNECTION */
8665
8666 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->great_wonder_owners[i]);
8667
8668#ifdef FREECIV_JSON_CONNECTION
8669 /* Exit diff array element. */
8670 FC_FREE(field_addr.sub_location->sub_location);
8671#endif /* FREECIV_JSON_CONNECTION */
8672 }
8673
8674#ifdef FREECIV_JSON_CONNECTION
8675 /* Append diff array element. */
8676 field_addr.sub_location->number = -1;
8677
8678 /* Create the terminating diff array element. */
8679 e |= DIO_PUT(object, &dout, &field_addr);
8680
8681 /* Enter diff array element (start at the index address). */
8682 field_addr.sub_location->number = count_i;
8683 field_addr.sub_location->sub_location = plocation_field_new("index");
8684#endif /* FREECIV_JSON_CONNECTION */
8685
8686 /* Write the sentinel value */
8687#if B_LAST <= MAX_UINT8
8688 e |= DIO_PUT(uint8, &dout, &field_addr, B_LAST);
8689#else
8690 e |= DIO_PUT(uint16, &dout, &field_addr, B_LAST);
8691#endif
8692
8693#ifdef FREECIV_JSON_CONNECTION
8694 /* Exit diff array element. */
8695 FC_FREE(field_addr.sub_location->sub_location);
8696 /* Exit array. */
8697 FC_FREE(field_addr.sub_location);
8698#endif /* FREECIV_JSON_CONNECTION */
8699 }
8700
8701 if (e) {
8702 log_packet_detailed("'great_wonder_owners' field error detected");
8703 }
8704 }
8705
8706 if (BV_ISSET(fields, 61)) {
8707 log_packet_detailed(" field 'happy_cost' has changed");
8708
8709#ifdef FREECIV_JSON_CONNECTION
8710 field_addr.name = "happy_cost";
8711#endif /* FREECIV_JSON_CONNECTION */
8712 e = 0;
8713
8714 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->happy_cost);
8715
8716 if (e) {
8717 log_packet_detailed("'happy_cost' field error detected");
8718 }
8719 }
8720
8721 if (BV_ISSET(fields, 62)) {
8722 log_packet_detailed(" field 'happyborders' has changed");
8723
8724#ifdef FREECIV_JSON_CONNECTION
8725 field_addr.name = "happyborders";
8726#endif /* FREECIV_JSON_CONNECTION */
8727 e = 0;
8728
8729 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->happyborders);
8730
8731 if (e) {
8732 log_packet_detailed("'happyborders' field error detected");
8733 }
8734 }
8735
8736 if (BV_ISSET(fields, 63)) {
8737 log_packet_detailed(" field 'heating' has changed");
8738
8739#ifdef FREECIV_JSON_CONNECTION
8740 field_addr.name = "heating";
8741#endif /* FREECIV_JSON_CONNECTION */
8742 e = 0;
8743
8744 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->heating);
8745
8746 if (e) {
8747 log_packet_detailed("'heating' field error detected");
8748 }
8749 }
8750
8751 if (BV_ISSET(fields, 64)) {
8752 log_packet_detailed(" field 'illness_base_factor' has changed");
8753
8754#ifdef FREECIV_JSON_CONNECTION
8755 field_addr.name = "illness_base_factor";
8756#endif /* FREECIV_JSON_CONNECTION */
8757 e = 0;
8758
8759 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_base_factor);
8760
8761 if (e) {
8762 log_packet_detailed("'illness_base_factor' field error detected");
8763 }
8764 }
8765
8766 if (BV_ISSET(fields, 65)) {
8767 log_packet_detailed(" field 'illness_min_size' has changed");
8768
8769#ifdef FREECIV_JSON_CONNECTION
8770 field_addr.name = "illness_min_size";
8771#endif /* FREECIV_JSON_CONNECTION */
8772 e = 0;
8773
8774 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->illness_min_size);
8775
8776 if (e) {
8777 log_packet_detailed("'illness_min_size' field error detected");
8778 }
8779 }
8780
8781 /* field 66 is folded into the header */
8782
8783 if (BV_ISSET(fields, 67)) {
8784 log_packet_detailed(" field 'illness_pollution_factor' has changed");
8785
8786#ifdef FREECIV_JSON_CONNECTION
8787 field_addr.name = "illness_pollution_factor";
8788#endif /* FREECIV_JSON_CONNECTION */
8789 e = 0;
8790
8791 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_pollution_factor);
8792
8793 if (e) {
8794 log_packet_detailed("'illness_pollution_factor' field error detected");
8795 }
8796 }
8797
8798 if (BV_ISSET(fields, 68)) {
8799 log_packet_detailed(" field 'illness_trade_infection' has changed");
8800
8801#ifdef FREECIV_JSON_CONNECTION
8802 field_addr.name = "illness_trade_infection";
8803#endif /* FREECIV_JSON_CONNECTION */
8804 e = 0;
8805
8806 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_trade_infection);
8807
8808 if (e) {
8809 log_packet_detailed("'illness_trade_infection' field error detected");
8810 }
8811 }
8812
8813 if (BV_ISSET(fields, 69)) {
8814 log_packet_detailed(" field 'init_city_radius_sq' has changed");
8815
8816#ifdef FREECIV_JSON_CONNECTION
8817 field_addr.name = "init_city_radius_sq";
8818#endif /* FREECIV_JSON_CONNECTION */
8819 e = 0;
8820
8821 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_city_radius_sq);
8822
8823 if (e) {
8824 log_packet_detailed("'init_city_radius_sq' field error detected");
8825 }
8826 }
8827
8828 /* field 70 is folded into the header */
8829
8830 /* field 71 is folded into the header */
8831
8832 /* field 72 is folded into the header */
8833
8834 /* field 73 is folded into the header */
8835
8836 /* field 74 is folded into the header */
8837
8838 /* field 75 is folded into the header */
8839
8840 /* field 76 is folded into the header */
8841
8842 /* field 77 is folded into the header */
8843
8844 if (BV_ISSET(fields, 78)) {
8845 log_packet_detailed(" field 'low_firepower_badwallattacker' has changed");
8846
8847#ifdef FREECIV_JSON_CONNECTION
8848 field_addr.name = "low_firepower_badwallattacker";
8849#endif /* FREECIV_JSON_CONNECTION */
8850 e = 0;
8851
8852 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_badwallattacker);
8853
8854 if (e) {
8855 log_packet_detailed("'low_firepower_badwallattacker' field error detected");
8856 }
8857 }
8858
8859 if (BV_ISSET(fields, 79)) {
8860 log_packet_detailed(" field 'low_firepower_pearl_harbour' has changed");
8861
8862#ifdef FREECIV_JSON_CONNECTION
8863 field_addr.name = "low_firepower_pearl_harbour";
8864#endif /* FREECIV_JSON_CONNECTION */
8865 e = 0;
8866
8867 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_pearl_harbour);
8868
8869 if (e) {
8870 log_packet_detailed("'low_firepower_pearl_harbour' field error detected");
8871 }
8872 }
8873
8874 if (BV_ISSET(fields, 80)) {
8875 log_packet_detailed(" field 'low_firepower_combat_bonus' has changed");
8876
8877#ifdef FREECIV_JSON_CONNECTION
8878 field_addr.name = "low_firepower_combat_bonus";
8879#endif /* FREECIV_JSON_CONNECTION */
8880 e = 0;
8881
8882 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_combat_bonus);
8883
8884 if (e) {
8885 log_packet_detailed("'low_firepower_combat_bonus' field error detected");
8886 }
8887 }
8888
8889 if (BV_ISSET(fields, 81)) {
8890 log_packet_detailed(" field 'low_firepower_nonnat_bombard' has changed");
8891
8892#ifdef FREECIV_JSON_CONNECTION
8893 field_addr.name = "low_firepower_nonnat_bombard";
8894#endif /* FREECIV_JSON_CONNECTION */
8895 e = 0;
8896
8897 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_nonnat_bombard);
8898
8899 if (e) {
8900 log_packet_detailed("'low_firepower_nonnat_bombard' field error detected");
8901 }
8902 }
8903
8904 if (BV_ISSET(fields, 82)) {
8905 log_packet_detailed(" field 'nuke_pop_loss_pct' has changed");
8906
8907#ifdef FREECIV_JSON_CONNECTION
8908 field_addr.name = "nuke_pop_loss_pct";
8909#endif /* FREECIV_JSON_CONNECTION */
8910 e = 0;
8911
8912 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nuke_pop_loss_pct);
8913
8914 if (e) {
8915 log_packet_detailed("'nuke_pop_loss_pct' field error detected");
8916 }
8917 }
8918
8919 if (BV_ISSET(fields, 83)) {
8920 log_packet_detailed(" field 'nuke_defender_survival_chance_pct' has changed");
8921
8922#ifdef FREECIV_JSON_CONNECTION
8923 field_addr.name = "nuke_defender_survival_chance_pct";
8924#endif /* FREECIV_JSON_CONNECTION */
8925 e = 0;
8926
8927 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nuke_defender_survival_chance_pct);
8928
8929 if (e) {
8930 log_packet_detailed("'nuke_defender_survival_chance_pct' field error detected");
8931 }
8932 }
8933
8934 if (BV_ISSET(fields, 84)) {
8935 log_packet_detailed(" field 'min_city_center_output' has changed");
8936
8937#ifdef FREECIV_JSON_CONNECTION
8938 field_addr.name = "min_city_center_output";
8939#endif /* FREECIV_JSON_CONNECTION */
8940 e = 0;
8941
8942 {
8943 int i;
8944
8945#ifdef FREECIV_JSON_CONNECTION
8946 /* Create the array. */
8947 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
8948
8949 /* Enter array. */
8950 field_addr.sub_location = plocation_elem_new(0);
8951#endif /* FREECIV_JSON_CONNECTION */
8952
8953 for (i = 0; i < O_LAST; i++) {
8954#ifdef FREECIV_JSON_CONNECTION
8955 /* Next array element. */
8956 field_addr.sub_location->number = i;
8957#endif /* FREECIV_JSON_CONNECTION */
8958
8959 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->min_city_center_output[i]);
8960 }
8961
8962#ifdef FREECIV_JSON_CONNECTION
8963 /* Exit array. */
8964 FC_FREE(field_addr.sub_location);
8965#endif /* FREECIV_JSON_CONNECTION */
8966 }
8967
8968 if (e) {
8969 log_packet_detailed("'min_city_center_output' field error detected");
8970 }
8971 }
8972
8973 /* field 85 is folded into the header */
8974
8975 /* field 86 is folded into the header */
8976
8977 /* field 87 is folded into the header */
8978
8979 if (BV_ISSET(fields, 88)) {
8980 log_packet_detailed(" field 'notradesize' has changed");
8981
8982#ifdef FREECIV_JSON_CONNECTION
8983 field_addr.name = "notradesize";
8984#endif /* FREECIV_JSON_CONNECTION */
8985 e = 0;
8986
8987 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->notradesize);
8988
8989 if (e) {
8990 log_packet_detailed("'notradesize' field error detected");
8991 }
8992 }
8993
8994 /* field 89 is folded into the header */
8995
8996 if (BV_ISSET(fields, 90)) {
8997 log_packet_detailed(" field 'nuclearwinter' has changed");
8998
8999#ifdef FREECIV_JSON_CONNECTION
9000 field_addr.name = "nuclearwinter";
9001#endif /* FREECIV_JSON_CONNECTION */
9002 e = 0;
9003
9004 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->nuclearwinter);
9005
9006 if (e) {
9007 log_packet_detailed("'nuclearwinter' field error detected");
9008 }
9009 }
9010
9011 if (BV_ISSET(fields, 91)) {
9012 log_packet_detailed(" field 'phase' has changed");
9013
9014#ifdef FREECIV_JSON_CONNECTION
9015 field_addr.name = "phase";
9016#endif /* FREECIV_JSON_CONNECTION */
9017 e = 0;
9018
9019 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
9020
9021 if (e) {
9022 log_packet_detailed("'phase' field error detected");
9023 }
9024 }
9025
9026 if (BV_ISSET(fields, 92)) {
9027 log_packet_detailed(" field 'phase_mode' has changed");
9028
9029#ifdef FREECIV_JSON_CONNECTION
9030 field_addr.name = "phase_mode";
9031#endif /* FREECIV_JSON_CONNECTION */
9032 e = 0;
9033
9034 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->phase_mode);
9035
9036 if (e) {
9037 log_packet_detailed("'phase_mode' field error detected");
9038 }
9039 }
9040
9041 /* field 93 is folded into the header */
9042
9043 /* field 94 is folded into the header */
9044
9045 /* field 95 is folded into the header */
9046
9047 /* field 96 is folded into the header */
9048
9049 /* field 97 is folded into the header */
9050
9051 /* field 98 is folded into the header */
9052
9053 /* field 99 is folded into the header */
9054
9055 /* field 100 is folded into the header */
9056
9057 if (BV_ISSET(fields, 101)) {
9058 log_packet_detailed(" field 'rapturedelay' has changed");
9059
9060#ifdef FREECIV_JSON_CONNECTION
9061 field_addr.name = "rapturedelay";
9062#endif /* FREECIV_JSON_CONNECTION */
9063 e = 0;
9064
9065 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->rapturedelay);
9066
9067 if (e) {
9068 log_packet_detailed("'rapturedelay' field error detected");
9069 }
9070 }
9071
9072 if (BV_ISSET(fields, 102)) {
9073 log_packet_detailed(" field 'disasters' has changed");
9074
9075#ifdef FREECIV_JSON_CONNECTION
9076 field_addr.name = "disasters";
9077#endif /* FREECIV_JSON_CONNECTION */
9078 e = 0;
9079
9080 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->disasters);
9081
9082 if (e) {
9083 log_packet_detailed("'disasters' field error detected");
9084 }
9085 }
9086
9087 /* field 103 is folded into the header */
9088
9089 /* field 104 is folded into the header */
9090
9091 if (BV_ISSET(fields, 105)) {
9092 log_packet_detailed(" field 'sciencebox' has changed");
9093
9094#ifdef FREECIV_JSON_CONNECTION
9095 field_addr.name = "sciencebox";
9096#endif /* FREECIV_JSON_CONNECTION */
9097 e = 0;
9098
9099 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->sciencebox);
9100
9101 if (e) {
9102 log_packet_detailed("'sciencebox' field error detected");
9103 }
9104 }
9105
9106 if (BV_ISSET(fields, 106)) {
9107 log_packet_detailed(" field 'shieldbox' has changed");
9108
9109#ifdef FREECIV_JSON_CONNECTION
9110 field_addr.name = "shieldbox";
9111#endif /* FREECIV_JSON_CONNECTION */
9112 e = 0;
9113
9114 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->shieldbox);
9115
9116 if (e) {
9117 log_packet_detailed("'shieldbox' field error detected");
9118 }
9119 }
9120
9121 if (BV_ISSET(fields, 107)) {
9122 log_packet_detailed(" field 'skill_level' has changed");
9123
9124#ifdef FREECIV_JSON_CONNECTION
9125 field_addr.name = "skill_level";
9126#endif /* FREECIV_JSON_CONNECTION */
9127 e = 0;
9128
9129 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->skill_level);
9130
9131 if (e) {
9132 log_packet_detailed("'skill_level' field error detected");
9133 }
9134 }
9135
9136 if (BV_ISSET(fields, 108)) {
9137 log_packet_detailed(" field 'victory_conditions' has changed");
9138
9139#ifdef FREECIV_JSON_CONNECTION
9140 field_addr.name = "victory_conditions";
9141#endif /* FREECIV_JSON_CONNECTION */
9142 e = 0;
9143
9144 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->victory_conditions);
9145
9146 if (e) {
9147 log_packet_detailed("'victory_conditions' field error detected");
9148 }
9149 }
9150
9151 /* field 109 is folded into the header */
9152
9153 if (BV_ISSET(fields, 110)) {
9154 log_packet_detailed(" field 'tech' has changed");
9155
9156#ifdef FREECIV_JSON_CONNECTION
9157 field_addr.name = "tech";
9158#endif /* FREECIV_JSON_CONNECTION */
9159 e = 0;
9160
9161 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->tech);
9162
9163 if (e) {
9164 log_packet_detailed("'tech' field error detected");
9165 }
9166 }
9167
9168 if (BV_ISSET(fields, 111)) {
9169 log_packet_detailed(" field 'tech_cost_style' has changed");
9170
9171#ifdef FREECIV_JSON_CONNECTION
9172 field_addr.name = "tech_cost_style";
9173#endif /* FREECIV_JSON_CONNECTION */
9174 e = 0;
9175
9176 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_cost_style);
9177
9178 if (e) {
9179 log_packet_detailed("'tech_cost_style' field error detected");
9180 }
9181 }
9182
9183 if (BV_ISSET(fields, 112)) {
9184 log_packet_detailed(" field 'tech_leakage' has changed");
9185
9186#ifdef FREECIV_JSON_CONNECTION
9187 field_addr.name = "tech_leakage";
9188#endif /* FREECIV_JSON_CONNECTION */
9189 e = 0;
9190
9191 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_leakage);
9192
9193 if (e) {
9194 log_packet_detailed("'tech_leakage' field error detected");
9195 }
9196 }
9197
9198 if (BV_ISSET(fields, 113)) {
9199 log_packet_detailed(" field 'tech_upkeep_divider' has changed");
9200
9201#ifdef FREECIV_JSON_CONNECTION
9202 field_addr.name = "tech_upkeep_divider";
9203#endif /* FREECIV_JSON_CONNECTION */
9204 e = 0;
9205
9206 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech_upkeep_divider);
9207
9208 if (e) {
9209 log_packet_detailed("'tech_upkeep_divider' field error detected");
9210 }
9211 }
9212
9213 if (BV_ISSET(fields, 114)) {
9214 log_packet_detailed(" field 'tech_upkeep_style' has changed");
9215
9216#ifdef FREECIV_JSON_CONNECTION
9217 field_addr.name = "tech_upkeep_style";
9218#endif /* FREECIV_JSON_CONNECTION */
9219 e = 0;
9220
9221 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_upkeep_style);
9222
9223 if (e) {
9224 log_packet_detailed("'tech_upkeep_style' field error detected");
9225 }
9226 }
9227
9228 if (BV_ISSET(fields, 115)) {
9229 log_packet_detailed(" field 'techloss_forgiveness' has changed");
9230
9231#ifdef FREECIV_JSON_CONNECTION
9232 field_addr.name = "techloss_forgiveness";
9233#endif /* FREECIV_JSON_CONNECTION */
9234 e = 0;
9235
9236 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->techloss_forgiveness);
9237
9238 if (e) {
9239 log_packet_detailed("'techloss_forgiveness' field error detected");
9240 }
9241 }
9242
9243 if (BV_ISSET(fields, 116)) {
9244 log_packet_detailed(" field 'free_tech_method' has changed");
9245
9246#ifdef FREECIV_JSON_CONNECTION
9247 field_addr.name = "free_tech_method";
9248#endif /* FREECIV_JSON_CONNECTION */
9249 e = 0;
9250
9251 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->free_tech_method);
9252
9253 if (e) {
9254 log_packet_detailed("'free_tech_method' field error detected");
9255 }
9256 }
9257
9258 if (BV_ISSET(fields, 117)) {
9259 log_packet_detailed(" field 'gameloss_style' has changed");
9260
9261#ifdef FREECIV_JSON_CONNECTION
9262 field_addr.name = "gameloss_style";
9263#endif /* FREECIV_JSON_CONNECTION */
9264 e = 0;
9265
9266 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gameloss_style);
9267
9268 if (e) {
9269 log_packet_detailed("'gameloss_style' field error detected");
9270 }
9271 }
9272
9273 if (BV_ISSET(fields, 118)) {
9274 log_packet_detailed(" field 'timeout' has changed");
9275
9276#ifdef FREECIV_JSON_CONNECTION
9277 field_addr.name = "timeout";
9278#endif /* FREECIV_JSON_CONNECTION */
9279 e = 0;
9280
9281 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->timeout);
9282
9283 if (e) {
9284 log_packet_detailed("'timeout' field error detected");
9285 }
9286 }
9287
9288 if (BV_ISSET(fields, 119)) {
9289 log_packet_detailed(" field 'first_timeout' has changed");
9290
9291#ifdef FREECIV_JSON_CONNECTION
9292 field_addr.name = "first_timeout";
9293#endif /* FREECIV_JSON_CONNECTION */
9294 e = 0;
9295
9296 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->first_timeout);
9297
9298 if (e) {
9299 log_packet_detailed("'first_timeout' field error detected");
9300 }
9301 }
9302
9303 /* field 120 is folded into the header */
9304
9305 if (BV_ISSET(fields, 121)) {
9306 log_packet_detailed(" field 'trademindist' has changed");
9307
9308#ifdef FREECIV_JSON_CONNECTION
9309 field_addr.name = "trademindist";
9310#endif /* FREECIV_JSON_CONNECTION */
9311 e = 0;
9312
9313 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->trademindist);
9314
9315 if (e) {
9316 log_packet_detailed("'trademindist' field error detected");
9317 }
9318 }
9319
9320 if (BV_ISSET(fields, 122)) {
9321 log_packet_detailed(" field 'trade_revenue_style' has changed");
9322
9323#ifdef FREECIV_JSON_CONNECTION
9324 field_addr.name = "trade_revenue_style";
9325#endif /* FREECIV_JSON_CONNECTION */
9326 e = 0;
9327
9328 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->trade_revenue_style);
9329
9330 if (e) {
9331 log_packet_detailed("'trade_revenue_style' field error detected");
9332 }
9333 }
9334
9335 /* field 123 is folded into the header */
9336
9337 /* field 124 is folded into the header */
9338
9339 /* field 125 is folded into the header */
9340
9341 if (BV_ISSET(fields, 126)) {
9342 log_packet_detailed(" field 'turn' has changed");
9343
9344#ifdef FREECIV_JSON_CONNECTION
9345 field_addr.name = "turn";
9346#endif /* FREECIV_JSON_CONNECTION */
9347 e = 0;
9348
9349 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
9350
9351 if (e) {
9352 log_packet_detailed("'turn' field error detected");
9353 }
9354 }
9355
9356 if (BV_ISSET(fields, 127)) {
9357 log_packet_detailed(" field 'warminglevel' has changed");
9358
9359#ifdef FREECIV_JSON_CONNECTION
9360 field_addr.name = "warminglevel";
9361#endif /* FREECIV_JSON_CONNECTION */
9362 e = 0;
9363
9364 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->warminglevel);
9365
9366 if (e) {
9367 log_packet_detailed("'warminglevel' field error detected");
9368 }
9369 }
9370
9371 if (BV_ISSET(fields, 128)) {
9372 log_packet_detailed(" field 'year' has changed");
9373
9374#ifdef FREECIV_JSON_CONNECTION
9375 field_addr.name = "year";
9376#endif /* FREECIV_JSON_CONNECTION */
9377 e = 0;
9378
9379 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->year);
9380
9381 if (e) {
9382 log_packet_detailed("'year' field error detected");
9383 }
9384 }
9385
9386 /* field 129 is folded into the header */
9387
9388 if (BV_ISSET(fields, 130)) {
9389 log_packet_detailed(" field 'top_cities_count' has changed");
9390
9391#ifdef FREECIV_JSON_CONNECTION
9392 field_addr.name = "top_cities_count";
9393#endif /* FREECIV_JSON_CONNECTION */
9394 e = 0;
9395
9396 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->top_cities_count);
9397
9398 if (e) {
9399 log_packet_detailed("'top_cities_count' field error detected");
9400 }
9401 }
9402
9403 if (BV_ISSET(fields, 131)) {
9404 log_packet_detailed(" field 'fragment_count' has changed");
9405
9406#ifdef FREECIV_JSON_CONNECTION
9407 field_addr.name = "fragment_count";
9408#endif /* FREECIV_JSON_CONNECTION */
9409 e = 0;
9410
9411 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->fragment_count);
9412
9413 if (e) {
9414 log_packet_detailed("'fragment_count' field error detected");
9415 }
9416 }
9417
9418 /* field 132 is folded into the header */
9419
9420 if (BV_ISSET(fields, 133)) {
9421 log_packet_detailed(" field 'civil_war_bonus_celebrating' has changed");
9422
9423#ifdef FREECIV_JSON_CONNECTION
9424 field_addr.name = "civil_war_bonus_celebrating";
9425#endif /* FREECIV_JSON_CONNECTION */
9426 e = 0;
9427
9428 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->civil_war_bonus_celebrating);
9429
9430 if (e) {
9431 log_packet_detailed("'civil_war_bonus_celebrating' field error detected");
9432 }
9433 }
9434
9435 if (BV_ISSET(fields, 134)) {
9436 log_packet_detailed(" field 'civil_war_bonus_unhappy' has changed");
9437
9438#ifdef FREECIV_JSON_CONNECTION
9439 field_addr.name = "civil_war_bonus_unhappy";
9440#endif /* FREECIV_JSON_CONNECTION */
9441 e = 0;
9442
9443 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->civil_war_bonus_unhappy);
9444
9445 if (e) {
9446 log_packet_detailed("'civil_war_bonus_unhappy' field error detected");
9447 }
9448 }
9449
9450 if (BV_ISSET(fields, 135)) {
9451 log_packet_detailed(" field 'granularity' has changed");
9452
9453#ifdef FREECIV_JSON_CONNECTION
9454 field_addr.name = "granularity";
9455#endif /* FREECIV_JSON_CONNECTION */
9456 e = 0;
9457
9458 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granularity);
9459
9460 if (e) {
9461 log_packet_detailed("'granularity' field error detected");
9462 }
9463 }
9464
9465 if (BV_ISSET(fields, 136)) {
9466 log_packet_detailed(" field 'small_wonder_visibility' has changed");
9467
9468#ifdef FREECIV_JSON_CONNECTION
9469 field_addr.name = "small_wonder_visibility";
9470#endif /* FREECIV_JSON_CONNECTION */
9471 e = 0;
9472
9473 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->small_wonder_visibility);
9474
9475 if (e) {
9476 log_packet_detailed("'small_wonder_visibility' field error detected");
9477 }
9478 }
9479
9480 *old = *real_packet;
9481
9482#else /* FREECIV_DELTA_PROTOCOL */
9483#ifdef FREECIV_JSON_CONNECTION
9484 field_addr.name = "add_to_size_limit";
9485#endif /* FREECIV_JSON_CONNECTION */
9486 e = 0;
9487
9488 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->add_to_size_limit);
9489
9490 if (e) {
9491 log_packet_detailed("'add_to_size_limit' field error detected");
9492 }
9493
9494#ifdef FREECIV_JSON_CONNECTION
9495 field_addr.name = "aifill";
9496#endif /* FREECIV_JSON_CONNECTION */
9497 e = 0;
9498
9499 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->aifill);
9500
9501 if (e) {
9502 log_packet_detailed("'aifill' field error detected");
9503 }
9504
9505#ifdef FREECIV_JSON_CONNECTION
9506 field_addr.name = "persistent_ready";
9507#endif /* FREECIV_JSON_CONNECTION */
9508 e = 0;
9509
9510 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->persistent_ready);
9511
9512 if (e) {
9513 log_packet_detailed("'persistent_ready' field error detected");
9514 }
9515
9516#ifdef FREECIV_JSON_CONNECTION
9517 field_addr.name = "airlifting_style";
9518#endif /* FREECIV_JSON_CONNECTION */
9519 e = 0;
9520
9521 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->airlifting_style);
9522
9523 if (e) {
9524 log_packet_detailed("'airlifting_style' field error detected");
9525 }
9526
9527#ifdef FREECIV_JSON_CONNECTION
9528 field_addr.name = "airlift_from_always_enabled";
9529#endif /* FREECIV_JSON_CONNECTION */
9530 e = 0;
9531
9532 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->airlift_from_always_enabled);
9533
9534 if (e) {
9535 log_packet_detailed("'airlift_from_always_enabled' field error detected");
9536 }
9537
9538#ifdef FREECIV_JSON_CONNECTION
9539 field_addr.name = "airlift_to_always_enabled";
9540#endif /* FREECIV_JSON_CONNECTION */
9541 e = 0;
9542
9543 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->airlift_to_always_enabled);
9544
9545 if (e) {
9546 log_packet_detailed("'airlift_to_always_enabled' field error detected");
9547 }
9548
9549#ifdef FREECIV_JSON_CONNECTION
9550 field_addr.name = "angrycitizen";
9551#endif /* FREECIV_JSON_CONNECTION */
9552 e = 0;
9553
9554 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->angrycitizen);
9555
9556 if (e) {
9557 log_packet_detailed("'angrycitizen' field error detected");
9558 }
9559
9560#ifdef FREECIV_JSON_CONNECTION
9561 field_addr.name = "base_pollution";
9562#endif /* FREECIV_JSON_CONNECTION */
9563 e = 0;
9564
9565 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->base_pollution);
9566
9567 if (e) {
9568 log_packet_detailed("'base_pollution' field error detected");
9569 }
9570
9571#ifdef FREECIV_JSON_CONNECTION
9572 field_addr.name = "base_tech_cost";
9573#endif /* FREECIV_JSON_CONNECTION */
9574 e = 0;
9575
9576 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->base_tech_cost);
9577
9578 if (e) {
9579 log_packet_detailed("'base_tech_cost' field error detected");
9580 }
9581
9582#ifdef FREECIV_JSON_CONNECTION
9583 field_addr.name = "min_tech_cost";
9584#endif /* FREECIV_JSON_CONNECTION */
9585 e = 0;
9586
9587 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->min_tech_cost);
9588
9589 if (e) {
9590 log_packet_detailed("'min_tech_cost' field error detected");
9591 }
9592
9593#ifdef FREECIV_JSON_CONNECTION
9594 field_addr.name = "tech_leak_pct";
9595#endif /* FREECIV_JSON_CONNECTION */
9596 e = 0;
9597
9598 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_leak_pct);
9599
9600 if (e) {
9601 log_packet_detailed("'tech_leak_pct' field error detected");
9602 }
9603
9604#ifdef FREECIV_JSON_CONNECTION
9605 field_addr.name = "border_city_radius_sq";
9606#endif /* FREECIV_JSON_CONNECTION */
9607 e = 0;
9608
9609 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->border_city_radius_sq);
9610
9611 if (e) {
9612 log_packet_detailed("'border_city_radius_sq' field error detected");
9613 }
9614
9615#ifdef FREECIV_JSON_CONNECTION
9616 field_addr.name = "border_size_effect";
9617#endif /* FREECIV_JSON_CONNECTION */
9618 e = 0;
9619
9620 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->border_size_effect);
9621
9622 if (e) {
9623 log_packet_detailed("'border_size_effect' field error detected");
9624 }
9625
9626#ifdef FREECIV_JSON_CONNECTION
9627 field_addr.name = "border_city_permanent_radius_sq";
9628#endif /* FREECIV_JSON_CONNECTION */
9629 e = 0;
9630
9631 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->border_city_permanent_radius_sq);
9632
9633 if (e) {
9634 log_packet_detailed("'border_city_permanent_radius_sq' field error detected");
9635 }
9636
9637#ifdef FREECIV_JSON_CONNECTION
9638 field_addr.name = "borders";
9639#endif /* FREECIV_JSON_CONNECTION */
9640 e = 0;
9641
9642 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->borders);
9643
9644 if (e) {
9645 log_packet_detailed("'borders' field error detected");
9646 }
9647
9648#ifdef FREECIV_JSON_CONNECTION
9649 field_addr.name = "base_bribe_cost";
9650#endif /* FREECIV_JSON_CONNECTION */
9651 e = 0;
9652
9653 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->base_bribe_cost);
9654
9655 if (e) {
9656 log_packet_detailed("'base_bribe_cost' field error detected");
9657 }
9658
9659#ifdef FREECIV_JSON_CONNECTION
9660 field_addr.name = "caravan_bonus_style";
9661#endif /* FREECIV_JSON_CONNECTION */
9662 e = 0;
9663
9664 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->caravan_bonus_style);
9665
9666 if (e) {
9667 log_packet_detailed("'caravan_bonus_style' field error detected");
9668 }
9669
9670#ifdef FREECIV_JSON_CONNECTION
9671 field_addr.name = "culture_vic_points";
9672#endif /* FREECIV_JSON_CONNECTION */
9673 e = 0;
9674
9675 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->culture_vic_points);
9676
9677 if (e) {
9678 log_packet_detailed("'culture_vic_points' field error detected");
9679 }
9680
9681#ifdef FREECIV_JSON_CONNECTION
9682 field_addr.name = "culture_vic_lead";
9683#endif /* FREECIV_JSON_CONNECTION */
9684 e = 0;
9685
9686 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->culture_vic_lead);
9687
9688 if (e) {
9689 log_packet_detailed("'culture_vic_lead' field error detected");
9690 }
9691
9692#ifdef FREECIV_JSON_CONNECTION
9693 field_addr.name = "culture_migration_pml";
9694#endif /* FREECIV_JSON_CONNECTION */
9695 e = 0;
9696
9697 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->culture_migration_pml);
9698
9699 if (e) {
9700 log_packet_detailed("'culture_migration_pml' field error detected");
9701 }
9702
9703#ifdef FREECIV_JSON_CONNECTION
9704 field_addr.name = "history_interest_pml";
9705#endif /* FREECIV_JSON_CONNECTION */
9706 e = 0;
9707
9708 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->history_interest_pml);
9709
9710 if (e) {
9711 log_packet_detailed("'history_interest_pml' field error detected");
9712 }
9713
9714#ifdef FREECIV_JSON_CONNECTION
9715 field_addr.name = "world_peace_turns";
9716#endif /* FREECIV_JSON_CONNECTION */
9717 e = 0;
9718
9719 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->world_peace_turns);
9720
9721 if (e) {
9722 log_packet_detailed("'world_peace_turns' field error detected");
9723 }
9724
9725#ifdef FREECIV_JSON_CONNECTION
9726 field_addr.name = "celebratesize";
9727#endif /* FREECIV_JSON_CONNECTION */
9728 e = 0;
9729
9730 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->celebratesize);
9731
9732 if (e) {
9733 log_packet_detailed("'celebratesize' field error detected");
9734 }
9735
9736#ifdef FREECIV_JSON_CONNECTION
9737 field_addr.name = "changable_tax";
9738#endif /* FREECIV_JSON_CONNECTION */
9739 e = 0;
9740
9741 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->changable_tax);
9742
9743 if (e) {
9744 log_packet_detailed("'changable_tax' field error detected");
9745 }
9746
9747#ifdef FREECIV_JSON_CONNECTION
9748 field_addr.name = "pop_report_zeroes";
9749#endif /* FREECIV_JSON_CONNECTION */
9750 e = 0;
9751
9752 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->pop_report_zeroes);
9753
9754 if (e) {
9755 log_packet_detailed("'pop_report_zeroes' field error detected");
9756 }
9757
9758#ifdef FREECIV_JSON_CONNECTION
9759 field_addr.name = "citizen_nationality";
9760#endif /* FREECIV_JSON_CONNECTION */
9761 e = 0;
9762
9763 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->citizen_nationality);
9764
9765 if (e) {
9766 log_packet_detailed("'citizen_nationality' field error detected");
9767 }
9768
9769#ifdef FREECIV_JSON_CONNECTION
9770 field_addr.name = "unit_builders_nationality";
9771#endif /* FREECIV_JSON_CONNECTION */
9772 e = 0;
9773
9774 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->unit_builders_nationality);
9775
9776 if (e) {
9777 log_packet_detailed("'unit_builders_nationality' field error detected");
9778 }
9779
9780#ifdef FREECIV_JSON_CONNECTION
9781 field_addr.name = "citizen_convert_speed";
9782#endif /* FREECIV_JSON_CONNECTION */
9783 e = 0;
9784
9785 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->citizen_convert_speed);
9786
9787 if (e) {
9788 log_packet_detailed("'citizen_convert_speed' field error detected");
9789 }
9790
9791#ifdef FREECIV_JSON_CONNECTION
9792 field_addr.name = "conquest_convert_pct";
9793#endif /* FREECIV_JSON_CONNECTION */
9794 e = 0;
9795
9796 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->conquest_convert_pct);
9797
9798 if (e) {
9799 log_packet_detailed("'conquest_convert_pct' field error detected");
9800 }
9801
9802#ifdef FREECIV_JSON_CONNECTION
9803 field_addr.name = "citizen_partisans_pct";
9804#endif /* FREECIV_JSON_CONNECTION */
9805 e = 0;
9806
9807 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->citizen_partisans_pct);
9808
9809 if (e) {
9810 log_packet_detailed("'citizen_partisans_pct' field error detected");
9811 }
9812
9813#ifdef FREECIV_JSON_CONNECTION
9814 field_addr.name = "citymindist";
9815#endif /* FREECIV_JSON_CONNECTION */
9816 e = 0;
9817
9818 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->citymindist);
9819
9820 if (e) {
9821 log_packet_detailed("'citymindist' field error detected");
9822 }
9823
9824#ifdef FREECIV_JSON_CONNECTION
9825 field_addr.name = "cooling";
9826#endif /* FREECIV_JSON_CONNECTION */
9827 e = 0;
9828
9829 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->cooling);
9830
9831 if (e) {
9832 log_packet_detailed("'cooling' field error detected");
9833 }
9834
9835#ifdef FREECIV_JSON_CONNECTION
9836 field_addr.name = "coolinglevel";
9837#endif /* FREECIV_JSON_CONNECTION */
9838 e = 0;
9839
9840 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->coolinglevel);
9841
9842 if (e) {
9843 log_packet_detailed("'coolinglevel' field error detected");
9844 }
9845
9846#ifdef FREECIV_JSON_CONNECTION
9847 field_addr.name = "diplchance_initial_odds";
9848#endif /* FREECIV_JSON_CONNECTION */
9849 e = 0;
9850
9851 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->diplchance_initial_odds);
9852
9853 if (e) {
9854 log_packet_detailed("'diplchance_initial_odds' field error detected");
9855 }
9856
9857#ifdef FREECIV_JSON_CONNECTION
9858 field_addr.name = "diplomacy";
9859#endif /* FREECIV_JSON_CONNECTION */
9860 e = 0;
9861
9862 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->diplomacy);
9863
9864 if (e) {
9865 log_packet_detailed("'diplomacy' field error detected");
9866 }
9867
9868#ifdef FREECIV_JSON_CONNECTION
9869 field_addr.name = "fogofwar";
9870#endif /* FREECIV_JSON_CONNECTION */
9871 e = 0;
9872
9873 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->fogofwar);
9874
9875 if (e) {
9876 log_packet_detailed("'fogofwar' field error detected");
9877 }
9878
9879#ifdef FREECIV_JSON_CONNECTION
9880 field_addr.name = "food_cost";
9881#endif /* FREECIV_JSON_CONNECTION */
9882 e = 0;
9883
9884 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->food_cost);
9885
9886 if (e) {
9887 log_packet_detailed("'food_cost' field error detected");
9888 }
9889
9890#ifdef FREECIV_JSON_CONNECTION
9891 field_addr.name = "foodbox";
9892#endif /* FREECIV_JSON_CONNECTION */
9893 e = 0;
9894
9895 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->foodbox);
9896
9897 if (e) {
9898 log_packet_detailed("'foodbox' field error detected");
9899 }
9900
9901#ifdef FREECIV_JSON_CONNECTION
9902 field_addr.name = "forced_gold";
9903#endif /* FREECIV_JSON_CONNECTION */
9904 e = 0;
9905
9906 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->forced_gold);
9907
9908 if (e) {
9909 log_packet_detailed("'forced_gold' field error detected");
9910 }
9911
9912#ifdef FREECIV_JSON_CONNECTION
9913 field_addr.name = "forced_luxury";
9914#endif /* FREECIV_JSON_CONNECTION */
9915 e = 0;
9916
9917 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->forced_luxury);
9918
9919 if (e) {
9920 log_packet_detailed("'forced_luxury' field error detected");
9921 }
9922
9923#ifdef FREECIV_JSON_CONNECTION
9924 field_addr.name = "forced_science";
9925#endif /* FREECIV_JSON_CONNECTION */
9926 e = 0;
9927
9928 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->forced_science);
9929
9930 if (e) {
9931 log_packet_detailed("'forced_science' field error detected");
9932 }
9933
9934#ifdef FREECIV_JSON_CONNECTION
9935 field_addr.name = "fulltradesize";
9936#endif /* FREECIV_JSON_CONNECTION */
9937 e = 0;
9938
9939 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fulltradesize);
9940
9941 if (e) {
9942 log_packet_detailed("'fulltradesize' field error detected");
9943 }
9944
9945#ifdef FREECIV_JSON_CONNECTION
9946 field_addr.name = "trade_world_rel_pct";
9947#endif /* FREECIV_JSON_CONNECTION */
9948 e = 0;
9949
9950 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->trade_world_rel_pct);
9951
9952 if (e) {
9953 log_packet_detailed("'trade_world_rel_pct' field error detected");
9954 }
9955
9956#ifdef FREECIV_JSON_CONNECTION
9957 field_addr.name = "min_trade_route_val";
9958#endif /* FREECIV_JSON_CONNECTION */
9959 e = 0;
9960
9961 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->min_trade_route_val);
9962
9963 if (e) {
9964 log_packet_detailed("'min_trade_route_val' field error detected");
9965 }
9966
9967#ifdef FREECIV_JSON_CONNECTION
9968 field_addr.name = "reveal_trade_partner";
9969#endif /* FREECIV_JSON_CONNECTION */
9970 e = 0;
9971
9972 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->reveal_trade_partner);
9973
9974 if (e) {
9975 log_packet_detailed("'reveal_trade_partner' field error detected");
9976 }
9977
9978#ifdef FREECIV_JSON_CONNECTION
9979 field_addr.name = "goods_selection";
9980#endif /* FREECIV_JSON_CONNECTION */
9981 e = 0;
9982
9983 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->goods_selection);
9984
9985 if (e) {
9986 log_packet_detailed("'goods_selection' field error detected");
9987 }
9988
9989#ifdef FREECIV_JSON_CONNECTION
9990 field_addr.name = "global_advance_count";
9991#endif /* FREECIV_JSON_CONNECTION */
9992 e = 0;
9993
9994 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->global_advance_count);
9995
9996 if (e) {
9997 log_packet_detailed("'global_advance_count' field error detected");
9998 }
9999
10000#ifdef FREECIV_JSON_CONNECTION
10001 field_addr.name = "global_advances";
10002#endif /* FREECIV_JSON_CONNECTION */
10003 e = 0;
10004
10005 {
10006 int i;
10007
10008#ifdef FREECIV_JSON_CONNECTION
10009 /* Create the array. */
10010 e |= DIO_PUT(farray, &dout, &field_addr, A_LAST);
10011
10012 /* Enter array. */
10013 field_addr.sub_location = plocation_elem_new(0);
10014#endif /* FREECIV_JSON_CONNECTION */
10015
10016 for (i = 0; i < A_LAST; i++) {
10017#ifdef FREECIV_JSON_CONNECTION
10018 /* Next array element. */
10019 field_addr.sub_location->number = i;
10020#endif /* FREECIV_JSON_CONNECTION */
10021
10022 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->global_advances[i]);
10023 }
10024
10025#ifdef FREECIV_JSON_CONNECTION
10026 /* Exit array. */
10027 FC_FREE(field_addr.sub_location);
10028#endif /* FREECIV_JSON_CONNECTION */
10029 }
10030
10031 if (e) {
10032 log_packet_detailed("'global_advances' field error detected");
10033 }
10034
10035#ifdef FREECIV_JSON_CONNECTION
10036 field_addr.name = "global_warming";
10037#endif /* FREECIV_JSON_CONNECTION */
10038 e = 0;
10039
10040 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->global_warming);
10041
10042 if (e) {
10043 log_packet_detailed("'global_warming' field error detected");
10044 }
10045
10046#ifdef FREECIV_JSON_CONNECTION
10047 field_addr.name = "globalwarming";
10048#endif /* FREECIV_JSON_CONNECTION */
10049 e = 0;
10050
10051 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->globalwarming);
10052
10053 if (e) {
10054 log_packet_detailed("'globalwarming' field error detected");
10055 }
10056
10057#ifdef FREECIV_JSON_CONNECTION
10058 field_addr.name = "gold";
10059#endif /* FREECIV_JSON_CONNECTION */
10060 e = 0;
10061
10062 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->gold);
10063
10064 if (e) {
10065 log_packet_detailed("'gold' field error detected");
10066 }
10067
10068#ifdef FREECIV_JSON_CONNECTION
10069 field_addr.name = "gold_upkeep_style";
10070#endif /* FREECIV_JSON_CONNECTION */
10071 e = 0;
10072
10073 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gold_upkeep_style);
10074
10075 if (e) {
10076 log_packet_detailed("'gold_upkeep_style' field error detected");
10077 }
10078
10079#ifdef FREECIV_JSON_CONNECTION
10080 field_addr.name = "homeless_gold_upkeep";
10081#endif /* FREECIV_JSON_CONNECTION */
10082 e = 0;
10083
10084 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->homeless_gold_upkeep);
10085
10086 if (e) {
10087 log_packet_detailed("'homeless_gold_upkeep' field error detected");
10088 }
10089
10090#ifdef FREECIV_JSON_CONNECTION
10091 field_addr.name = "infrapoints";
10092#endif /* FREECIV_JSON_CONNECTION */
10093 e = 0;
10094
10095 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->infrapoints);
10096
10097 if (e) {
10098 log_packet_detailed("'infrapoints' field error detected");
10099 }
10100
10101#ifdef FREECIV_JSON_CONNECTION
10102 field_addr.name = "revolentype";
10103#endif /* FREECIV_JSON_CONNECTION */
10104 e = 0;
10105
10106 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->revolentype);
10107
10108 if (e) {
10109 log_packet_detailed("'revolentype' field error detected");
10110 }
10111
10112#ifdef FREECIV_JSON_CONNECTION
10113 field_addr.name = "default_government_id";
10114#endif /* FREECIV_JSON_CONNECTION */
10115 e = 0;
10116
10117 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->default_government_id);
10118
10119 if (e) {
10120 log_packet_detailed("'default_government_id' field error detected");
10121 }
10122
10123#ifdef FREECIV_JSON_CONNECTION
10124 field_addr.name = "government_during_revolution_id";
10125#endif /* FREECIV_JSON_CONNECTION */
10126 e = 0;
10127
10128 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government_during_revolution_id);
10129
10130 if (e) {
10131 log_packet_detailed("'government_during_revolution_id' field error detected");
10132 }
10133
10134#ifdef FREECIV_JSON_CONNECTION
10135 field_addr.name = "granary_food_inc";
10136#endif /* FREECIV_JSON_CONNECTION */
10137 e = 0;
10138
10139 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granary_food_inc);
10140
10141 if (e) {
10142 log_packet_detailed("'granary_food_inc' field error detected");
10143 }
10144
10145#ifdef FREECIV_JSON_CONNECTION
10146 field_addr.name = "granary_food_ini";
10147#endif /* FREECIV_JSON_CONNECTION */
10148 e = 0;
10149
10150 {
10151 int i;
10152
10153#ifdef FREECIV_JSON_CONNECTION
10154 /* Create the array. */
10155 e |= DIO_PUT(farray, &dout, &field_addr, MAX_GRANARY_INIS);
10156
10157 /* Enter array. */
10158 field_addr.sub_location = plocation_elem_new(0);
10159#endif /* FREECIV_JSON_CONNECTION */
10160
10161 for (i = 0; i < MAX_GRANARY_INIS; i++) {
10162#ifdef FREECIV_JSON_CONNECTION
10163 /* Next array element. */
10164 field_addr.sub_location->number = i;
10165#endif /* FREECIV_JSON_CONNECTION */
10166
10167 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granary_food_ini[i]);
10168 }
10169
10170#ifdef FREECIV_JSON_CONNECTION
10171 /* Exit array. */
10172 FC_FREE(field_addr.sub_location);
10173#endif /* FREECIV_JSON_CONNECTION */
10174 }
10175
10176 if (e) {
10177 log_packet_detailed("'granary_food_ini' field error detected");
10178 }
10179
10180#ifdef FREECIV_JSON_CONNECTION
10181 field_addr.name = "granary_num_inis";
10182#endif /* FREECIV_JSON_CONNECTION */
10183 e = 0;
10184
10185 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->granary_num_inis);
10186
10187 if (e) {
10188 log_packet_detailed("'granary_num_inis' field error detected");
10189 }
10190
10191#ifdef FREECIV_JSON_CONNECTION
10192 field_addr.name = "great_wonder_owners";
10193#endif /* FREECIV_JSON_CONNECTION */
10194 e = 0;
10195
10196 {
10197 int i;
10198
10199#ifdef FREECIV_JSON_CONNECTION
10200 /* Create the array. */
10201 e |= DIO_PUT(farray, &dout, &field_addr, B_LAST);
10202
10203 /* Enter array. */
10204 field_addr.sub_location = plocation_elem_new(0);
10205#endif /* FREECIV_JSON_CONNECTION */
10206
10207 for (i = 0; i < B_LAST; i++) {
10208#ifdef FREECIV_JSON_CONNECTION
10209 /* Next array element. */
10210 field_addr.sub_location->number = i;
10211#endif /* FREECIV_JSON_CONNECTION */
10212
10213 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->great_wonder_owners[i]);
10214 }
10215
10216#ifdef FREECIV_JSON_CONNECTION
10217 /* Exit array. */
10218 FC_FREE(field_addr.sub_location);
10219#endif /* FREECIV_JSON_CONNECTION */
10220 }
10221
10222 if (e) {
10223 log_packet_detailed("'great_wonder_owners' field error detected");
10224 }
10225
10226#ifdef FREECIV_JSON_CONNECTION
10227 field_addr.name = "happy_cost";
10228#endif /* FREECIV_JSON_CONNECTION */
10229 e = 0;
10230
10231 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->happy_cost);
10232
10233 if (e) {
10234 log_packet_detailed("'happy_cost' field error detected");
10235 }
10236
10237#ifdef FREECIV_JSON_CONNECTION
10238 field_addr.name = "happyborders";
10239#endif /* FREECIV_JSON_CONNECTION */
10240 e = 0;
10241
10242 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->happyborders);
10243
10244 if (e) {
10245 log_packet_detailed("'happyborders' field error detected");
10246 }
10247
10248#ifdef FREECIV_JSON_CONNECTION
10249 field_addr.name = "heating";
10250#endif /* FREECIV_JSON_CONNECTION */
10251 e = 0;
10252
10253 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->heating);
10254
10255 if (e) {
10256 log_packet_detailed("'heating' field error detected");
10257 }
10258
10259#ifdef FREECIV_JSON_CONNECTION
10260 field_addr.name = "illness_base_factor";
10261#endif /* FREECIV_JSON_CONNECTION */
10262 e = 0;
10263
10264 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_base_factor);
10265
10266 if (e) {
10267 log_packet_detailed("'illness_base_factor' field error detected");
10268 }
10269
10270#ifdef FREECIV_JSON_CONNECTION
10271 field_addr.name = "illness_min_size";
10272#endif /* FREECIV_JSON_CONNECTION */
10273 e = 0;
10274
10275 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->illness_min_size);
10276
10277 if (e) {
10278 log_packet_detailed("'illness_min_size' field error detected");
10279 }
10280
10281#ifdef FREECIV_JSON_CONNECTION
10282 field_addr.name = "illness_on";
10283#endif /* FREECIV_JSON_CONNECTION */
10284 e = 0;
10285
10286 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->illness_on);
10287
10288 if (e) {
10289 log_packet_detailed("'illness_on' field error detected");
10290 }
10291
10292#ifdef FREECIV_JSON_CONNECTION
10293 field_addr.name = "illness_pollution_factor";
10294#endif /* FREECIV_JSON_CONNECTION */
10295 e = 0;
10296
10297 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_pollution_factor);
10298
10299 if (e) {
10300 log_packet_detailed("'illness_pollution_factor' field error detected");
10301 }
10302
10303#ifdef FREECIV_JSON_CONNECTION
10304 field_addr.name = "illness_trade_infection";
10305#endif /* FREECIV_JSON_CONNECTION */
10306 e = 0;
10307
10308 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_trade_infection);
10309
10310 if (e) {
10311 log_packet_detailed("'illness_trade_infection' field error detected");
10312 }
10313
10314#ifdef FREECIV_JSON_CONNECTION
10315 field_addr.name = "init_city_radius_sq";
10316#endif /* FREECIV_JSON_CONNECTION */
10317 e = 0;
10318
10319 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_city_radius_sq);
10320
10321 if (e) {
10322 log_packet_detailed("'init_city_radius_sq' field error detected");
10323 }
10324
10325#ifdef FREECIV_JSON_CONNECTION
10326 field_addr.name = "is_edit_mode";
10327#endif /* FREECIV_JSON_CONNECTION */
10328 e = 0;
10329
10330 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_edit_mode);
10331
10332 if (e) {
10333 log_packet_detailed("'is_edit_mode' field error detected");
10334 }
10335
10336#ifdef FREECIV_JSON_CONNECTION
10337 field_addr.name = "is_new_game";
10338#endif /* FREECIV_JSON_CONNECTION */
10339 e = 0;
10340
10341 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_new_game);
10342
10343 if (e) {
10344 log_packet_detailed("'is_new_game' field error detected");
10345 }
10346
10347#ifdef FREECIV_JSON_CONNECTION
10348 field_addr.name = "killcitizen";
10349#endif /* FREECIV_JSON_CONNECTION */
10350 e = 0;
10351
10352 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->killcitizen);
10353
10354 if (e) {
10355 log_packet_detailed("'killcitizen' field error detected");
10356 }
10357
10358#ifdef FREECIV_JSON_CONNECTION
10359 field_addr.name = "killstack";
10360#endif /* FREECIV_JSON_CONNECTION */
10361 e = 0;
10362
10363 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->killstack);
10364
10365 if (e) {
10366 log_packet_detailed("'killstack' field error detected");
10367 }
10368
10369#ifdef FREECIV_JSON_CONNECTION
10370 field_addr.name = "only_killing_makes_veteran";
10371#endif /* FREECIV_JSON_CONNECTION */
10372 e = 0;
10373
10374 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->only_killing_makes_veteran);
10375
10376 if (e) {
10377 log_packet_detailed("'only_killing_makes_veteran' field error detected");
10378 }
10379
10380#ifdef FREECIV_JSON_CONNECTION
10381 field_addr.name = "only_real_fight_makes_veteran";
10382#endif /* FREECIV_JSON_CONNECTION */
10383 e = 0;
10384
10385 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->only_real_fight_makes_veteran);
10386
10387 if (e) {
10388 log_packet_detailed("'only_real_fight_makes_veteran' field error detected");
10389 }
10390
10391#ifdef FREECIV_JSON_CONNECTION
10392 field_addr.name = "combat_odds_scaled_veterancy";
10393#endif /* FREECIV_JSON_CONNECTION */
10394 e = 0;
10395
10396 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->combat_odds_scaled_veterancy);
10397
10398 if (e) {
10399 log_packet_detailed("'combat_odds_scaled_veterancy' field error detected");
10400 }
10401
10402#ifdef FREECIV_JSON_CONNECTION
10403 field_addr.name = "damage_reduces_bombard_rate";
10404#endif /* FREECIV_JSON_CONNECTION */
10405 e = 0;
10406
10407 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->damage_reduces_bombard_rate);
10408
10409 if (e) {
10410 log_packet_detailed("'damage_reduces_bombard_rate' field error detected");
10411 }
10412
10413#ifdef FREECIV_JSON_CONNECTION
10414 field_addr.name = "low_firepower_badwallattacker";
10415#endif /* FREECIV_JSON_CONNECTION */
10416 e = 0;
10417
10418 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_badwallattacker);
10419
10420 if (e) {
10421 log_packet_detailed("'low_firepower_badwallattacker' field error detected");
10422 }
10423
10424#ifdef FREECIV_JSON_CONNECTION
10425 field_addr.name = "low_firepower_pearl_harbour";
10426#endif /* FREECIV_JSON_CONNECTION */
10427 e = 0;
10428
10429 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_pearl_harbour);
10430
10431 if (e) {
10432 log_packet_detailed("'low_firepower_pearl_harbour' field error detected");
10433 }
10434
10435#ifdef FREECIV_JSON_CONNECTION
10436 field_addr.name = "low_firepower_combat_bonus";
10437#endif /* FREECIV_JSON_CONNECTION */
10438 e = 0;
10439
10440 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_combat_bonus);
10441
10442 if (e) {
10443 log_packet_detailed("'low_firepower_combat_bonus' field error detected");
10444 }
10445
10446#ifdef FREECIV_JSON_CONNECTION
10447 field_addr.name = "low_firepower_nonnat_bombard";
10448#endif /* FREECIV_JSON_CONNECTION */
10449 e = 0;
10450
10451 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->low_firepower_nonnat_bombard);
10452
10453 if (e) {
10454 log_packet_detailed("'low_firepower_nonnat_bombard' field error detected");
10455 }
10456
10457#ifdef FREECIV_JSON_CONNECTION
10458 field_addr.name = "nuke_pop_loss_pct";
10459#endif /* FREECIV_JSON_CONNECTION */
10460 e = 0;
10461
10462 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nuke_pop_loss_pct);
10463
10464 if (e) {
10465 log_packet_detailed("'nuke_pop_loss_pct' field error detected");
10466 }
10467
10468#ifdef FREECIV_JSON_CONNECTION
10469 field_addr.name = "nuke_defender_survival_chance_pct";
10470#endif /* FREECIV_JSON_CONNECTION */
10471 e = 0;
10472
10473 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nuke_defender_survival_chance_pct);
10474
10475 if (e) {
10476 log_packet_detailed("'nuke_defender_survival_chance_pct' field error detected");
10477 }
10478
10479#ifdef FREECIV_JSON_CONNECTION
10480 field_addr.name = "min_city_center_output";
10481#endif /* FREECIV_JSON_CONNECTION */
10482 e = 0;
10483
10484 {
10485 int i;
10486
10487#ifdef FREECIV_JSON_CONNECTION
10488 /* Create the array. */
10489 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
10490
10491 /* Enter array. */
10492 field_addr.sub_location = plocation_elem_new(0);
10493#endif /* FREECIV_JSON_CONNECTION */
10494
10495 for (i = 0; i < O_LAST; i++) {
10496#ifdef FREECIV_JSON_CONNECTION
10497 /* Next array element. */
10498 field_addr.sub_location->number = i;
10499#endif /* FREECIV_JSON_CONNECTION */
10500
10501 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->min_city_center_output[i]);
10502 }
10503
10504#ifdef FREECIV_JSON_CONNECTION
10505 /* Exit array. */
10506 FC_FREE(field_addr.sub_location);
10507#endif /* FREECIV_JSON_CONNECTION */
10508 }
10509
10510 if (e) {
10511 log_packet_detailed("'min_city_center_output' field error detected");
10512 }
10513
10514#ifdef FREECIV_JSON_CONNECTION
10515 field_addr.name = "muuk_food_wipe";
10516#endif /* FREECIV_JSON_CONNECTION */
10517 e = 0;
10518
10519 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->muuk_food_wipe);
10520
10521 if (e) {
10522 log_packet_detailed("'muuk_food_wipe' field error detected");
10523 }
10524
10525#ifdef FREECIV_JSON_CONNECTION
10526 field_addr.name = "muuk_gold_wipe";
10527#endif /* FREECIV_JSON_CONNECTION */
10528 e = 0;
10529
10530 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->muuk_gold_wipe);
10531
10532 if (e) {
10533 log_packet_detailed("'muuk_gold_wipe' field error detected");
10534 }
10535
10536#ifdef FREECIV_JSON_CONNECTION
10537 field_addr.name = "muuk_shield_wipe";
10538#endif /* FREECIV_JSON_CONNECTION */
10539 e = 0;
10540
10541 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->muuk_shield_wipe);
10542
10543 if (e) {
10544 log_packet_detailed("'muuk_shield_wipe' field error detected");
10545 }
10546
10547#ifdef FREECIV_JSON_CONNECTION
10548 field_addr.name = "notradesize";
10549#endif /* FREECIV_JSON_CONNECTION */
10550 e = 0;
10551
10552 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->notradesize);
10553
10554 if (e) {
10555 log_packet_detailed("'notradesize' field error detected");
10556 }
10557
10558#ifdef FREECIV_JSON_CONNECTION
10559 field_addr.name = "nuclear_winter";
10560#endif /* FREECIV_JSON_CONNECTION */
10561 e = 0;
10562
10563 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->nuclear_winter);
10564
10565 if (e) {
10566 log_packet_detailed("'nuclear_winter' field error detected");
10567 }
10568
10569#ifdef FREECIV_JSON_CONNECTION
10570 field_addr.name = "nuclearwinter";
10571#endif /* FREECIV_JSON_CONNECTION */
10572 e = 0;
10573
10574 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->nuclearwinter);
10575
10576 if (e) {
10577 log_packet_detailed("'nuclearwinter' field error detected");
10578 }
10579
10580#ifdef FREECIV_JSON_CONNECTION
10581 field_addr.name = "phase";
10582#endif /* FREECIV_JSON_CONNECTION */
10583 e = 0;
10584
10585 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
10586
10587 if (e) {
10588 log_packet_detailed("'phase' field error detected");
10589 }
10590
10591#ifdef FREECIV_JSON_CONNECTION
10592 field_addr.name = "phase_mode";
10593#endif /* FREECIV_JSON_CONNECTION */
10594 e = 0;
10595
10596 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->phase_mode);
10597
10598 if (e) {
10599 log_packet_detailed("'phase_mode' field error detected");
10600 }
10601
10602#ifdef FREECIV_JSON_CONNECTION
10603 field_addr.name = "pillage_select";
10604#endif /* FREECIV_JSON_CONNECTION */
10605 e = 0;
10606
10607 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->pillage_select);
10608
10609 if (e) {
10610 log_packet_detailed("'pillage_select' field error detected");
10611 }
10612
10613#ifdef FREECIV_JSON_CONNECTION
10614 field_addr.name = "steal_maps_reveals_all_cities";
10615#endif /* FREECIV_JSON_CONNECTION */
10616 e = 0;
10617
10618 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->steal_maps_reveals_all_cities);
10619
10620 if (e) {
10621 log_packet_detailed("'steal_maps_reveals_all_cities' field error detected");
10622 }
10623
10624#ifdef FREECIV_JSON_CONNECTION
10625 field_addr.name = "poison_empties_food_stock";
10626#endif /* FREECIV_JSON_CONNECTION */
10627 e = 0;
10628
10629 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->poison_empties_food_stock);
10630
10631 if (e) {
10632 log_packet_detailed("'poison_empties_food_stock' field error detected");
10633 }
10634
10635#ifdef FREECIV_JSON_CONNECTION
10636 field_addr.name = "tech_steal_allow_holes";
10637#endif /* FREECIV_JSON_CONNECTION */
10638 e = 0;
10639
10640 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->tech_steal_allow_holes);
10641
10642 if (e) {
10643 log_packet_detailed("'tech_steal_allow_holes' field error detected");
10644 }
10645
10646#ifdef FREECIV_JSON_CONNECTION
10647 field_addr.name = "tech_trade_allow_holes";
10648#endif /* FREECIV_JSON_CONNECTION */
10649 e = 0;
10650
10651 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->tech_trade_allow_holes);
10652
10653 if (e) {
10654 log_packet_detailed("'tech_trade_allow_holes' field error detected");
10655 }
10656
10657#ifdef FREECIV_JSON_CONNECTION
10658 field_addr.name = "tech_trade_loss_allow_holes";
10659#endif /* FREECIV_JSON_CONNECTION */
10660 e = 0;
10661
10662 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->tech_trade_loss_allow_holes);
10663
10664 if (e) {
10665 log_packet_detailed("'tech_trade_loss_allow_holes' field error detected");
10666 }
10667
10668#ifdef FREECIV_JSON_CONNECTION
10669 field_addr.name = "tech_parasite_allow_holes";
10670#endif /* FREECIV_JSON_CONNECTION */
10671 e = 0;
10672
10673 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->tech_parasite_allow_holes);
10674
10675 if (e) {
10676 log_packet_detailed("'tech_parasite_allow_holes' field error detected");
10677 }
10678
10679#ifdef FREECIV_JSON_CONNECTION
10680 field_addr.name = "tech_loss_allow_holes";
10681#endif /* FREECIV_JSON_CONNECTION */
10682 e = 0;
10683
10684 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->tech_loss_allow_holes);
10685
10686 if (e) {
10687 log_packet_detailed("'tech_loss_allow_holes' field error detected");
10688 }
10689
10690#ifdef FREECIV_JSON_CONNECTION
10691 field_addr.name = "rapturedelay";
10692#endif /* FREECIV_JSON_CONNECTION */
10693 e = 0;
10694
10695 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->rapturedelay);
10696
10697 if (e) {
10698 log_packet_detailed("'rapturedelay' field error detected");
10699 }
10700
10701#ifdef FREECIV_JSON_CONNECTION
10702 field_addr.name = "disasters";
10703#endif /* FREECIV_JSON_CONNECTION */
10704 e = 0;
10705
10706 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->disasters);
10707
10708 if (e) {
10709 log_packet_detailed("'disasters' field error detected");
10710 }
10711
10712#ifdef FREECIV_JSON_CONNECTION
10713 field_addr.name = "restrictinfra";
10714#endif /* FREECIV_JSON_CONNECTION */
10715 e = 0;
10716
10717 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->restrictinfra);
10718
10719 if (e) {
10720 log_packet_detailed("'restrictinfra' field error detected");
10721 }
10722
10723#ifdef FREECIV_JSON_CONNECTION
10724 field_addr.name = "unreachable_protects";
10725#endif /* FREECIV_JSON_CONNECTION */
10726 e = 0;
10727
10728 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->unreachable_protects);
10729
10730 if (e) {
10731 log_packet_detailed("'unreachable_protects' field error detected");
10732 }
10733
10734#ifdef FREECIV_JSON_CONNECTION
10735 field_addr.name = "sciencebox";
10736#endif /* FREECIV_JSON_CONNECTION */
10737 e = 0;
10738
10739 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->sciencebox);
10740
10741 if (e) {
10742 log_packet_detailed("'sciencebox' field error detected");
10743 }
10744
10745#ifdef FREECIV_JSON_CONNECTION
10746 field_addr.name = "shieldbox";
10747#endif /* FREECIV_JSON_CONNECTION */
10748 e = 0;
10749
10750 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->shieldbox);
10751
10752 if (e) {
10753 log_packet_detailed("'shieldbox' field error detected");
10754 }
10755
10756#ifdef FREECIV_JSON_CONNECTION
10757 field_addr.name = "skill_level";
10758#endif /* FREECIV_JSON_CONNECTION */
10759 e = 0;
10760
10761 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->skill_level);
10762
10763 if (e) {
10764 log_packet_detailed("'skill_level' field error detected");
10765 }
10766
10767#ifdef FREECIV_JSON_CONNECTION
10768 field_addr.name = "victory_conditions";
10769#endif /* FREECIV_JSON_CONNECTION */
10770 e = 0;
10771
10772 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->victory_conditions);
10773
10774 if (e) {
10775 log_packet_detailed("'victory_conditions' field error detected");
10776 }
10777
10778#ifdef FREECIV_JSON_CONNECTION
10779 field_addr.name = "team_pooled_research";
10780#endif /* FREECIV_JSON_CONNECTION */
10781 e = 0;
10782
10783 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->team_pooled_research);
10784
10785 if (e) {
10786 log_packet_detailed("'team_pooled_research' field error detected");
10787 }
10788
10789#ifdef FREECIV_JSON_CONNECTION
10790 field_addr.name = "tech";
10791#endif /* FREECIV_JSON_CONNECTION */
10792 e = 0;
10793
10794 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->tech);
10795
10796 if (e) {
10797 log_packet_detailed("'tech' field error detected");
10798 }
10799
10800#ifdef FREECIV_JSON_CONNECTION
10801 field_addr.name = "tech_cost_style";
10802#endif /* FREECIV_JSON_CONNECTION */
10803 e = 0;
10804
10805 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_cost_style);
10806
10807 if (e) {
10808 log_packet_detailed("'tech_cost_style' field error detected");
10809 }
10810
10811#ifdef FREECIV_JSON_CONNECTION
10812 field_addr.name = "tech_leakage";
10813#endif /* FREECIV_JSON_CONNECTION */
10814 e = 0;
10815
10816 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_leakage);
10817
10818 if (e) {
10819 log_packet_detailed("'tech_leakage' field error detected");
10820 }
10821
10822#ifdef FREECIV_JSON_CONNECTION
10823 field_addr.name = "tech_upkeep_divider";
10824#endif /* FREECIV_JSON_CONNECTION */
10825 e = 0;
10826
10827 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech_upkeep_divider);
10828
10829 if (e) {
10830 log_packet_detailed("'tech_upkeep_divider' field error detected");
10831 }
10832
10833#ifdef FREECIV_JSON_CONNECTION
10834 field_addr.name = "tech_upkeep_style";
10835#endif /* FREECIV_JSON_CONNECTION */
10836 e = 0;
10837
10838 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tech_upkeep_style);
10839
10840 if (e) {
10841 log_packet_detailed("'tech_upkeep_style' field error detected");
10842 }
10843
10844#ifdef FREECIV_JSON_CONNECTION
10845 field_addr.name = "techloss_forgiveness";
10846#endif /* FREECIV_JSON_CONNECTION */
10847 e = 0;
10848
10849 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->techloss_forgiveness);
10850
10851 if (e) {
10852 log_packet_detailed("'techloss_forgiveness' field error detected");
10853 }
10854
10855#ifdef FREECIV_JSON_CONNECTION
10856 field_addr.name = "free_tech_method";
10857#endif /* FREECIV_JSON_CONNECTION */
10858 e = 0;
10859
10860 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->free_tech_method);
10861
10862 if (e) {
10863 log_packet_detailed("'free_tech_method' field error detected");
10864 }
10865
10866#ifdef FREECIV_JSON_CONNECTION
10867 field_addr.name = "gameloss_style";
10868#endif /* FREECIV_JSON_CONNECTION */
10869 e = 0;
10870
10871 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gameloss_style);
10872
10873 if (e) {
10874 log_packet_detailed("'gameloss_style' field error detected");
10875 }
10876
10877#ifdef FREECIV_JSON_CONNECTION
10878 field_addr.name = "timeout";
10879#endif /* FREECIV_JSON_CONNECTION */
10880 e = 0;
10881
10882 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->timeout);
10883
10884 if (e) {
10885 log_packet_detailed("'timeout' field error detected");
10886 }
10887
10888#ifdef FREECIV_JSON_CONNECTION
10889 field_addr.name = "first_timeout";
10890#endif /* FREECIV_JSON_CONNECTION */
10891 e = 0;
10892
10893 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->first_timeout);
10894
10895 if (e) {
10896 log_packet_detailed("'first_timeout' field error detected");
10897 }
10898
10899#ifdef FREECIV_JSON_CONNECTION
10900 field_addr.name = "tired_attack";
10901#endif /* FREECIV_JSON_CONNECTION */
10902 e = 0;
10903
10904 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->tired_attack);
10905
10906 if (e) {
10907 log_packet_detailed("'tired_attack' field error detected");
10908 }
10909
10910#ifdef FREECIV_JSON_CONNECTION
10911 field_addr.name = "trademindist";
10912#endif /* FREECIV_JSON_CONNECTION */
10913 e = 0;
10914
10915 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->trademindist);
10916
10917 if (e) {
10918 log_packet_detailed("'trademindist' field error detected");
10919 }
10920
10921#ifdef FREECIV_JSON_CONNECTION
10922 field_addr.name = "trade_revenue_style";
10923#endif /* FREECIV_JSON_CONNECTION */
10924 e = 0;
10925
10926 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->trade_revenue_style);
10927
10928 if (e) {
10929 log_packet_detailed("'trade_revenue_style' field error detected");
10930 }
10931
10932#ifdef FREECIV_JSON_CONNECTION
10933 field_addr.name = "trading_city";
10934#endif /* FREECIV_JSON_CONNECTION */
10935 e = 0;
10936
10937 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->trading_city);
10938
10939 if (e) {
10940 log_packet_detailed("'trading_city' field error detected");
10941 }
10942
10943#ifdef FREECIV_JSON_CONNECTION
10944 field_addr.name = "trading_gold";
10945#endif /* FREECIV_JSON_CONNECTION */
10946 e = 0;
10947
10948 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->trading_gold);
10949
10950 if (e) {
10951 log_packet_detailed("'trading_gold' field error detected");
10952 }
10953
10954#ifdef FREECIV_JSON_CONNECTION
10955 field_addr.name = "trading_tech";
10956#endif /* FREECIV_JSON_CONNECTION */
10957 e = 0;
10958
10959 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->trading_tech);
10960
10961 if (e) {
10962 log_packet_detailed("'trading_tech' field error detected");
10963 }
10964
10965#ifdef FREECIV_JSON_CONNECTION
10966 field_addr.name = "turn";
10967#endif /* FREECIV_JSON_CONNECTION */
10968 e = 0;
10969
10970 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
10971
10972 if (e) {
10973 log_packet_detailed("'turn' field error detected");
10974 }
10975
10976#ifdef FREECIV_JSON_CONNECTION
10977 field_addr.name = "warminglevel";
10978#endif /* FREECIV_JSON_CONNECTION */
10979 e = 0;
10980
10981 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->warminglevel);
10982
10983 if (e) {
10984 log_packet_detailed("'warminglevel' field error detected");
10985 }
10986
10987#ifdef FREECIV_JSON_CONNECTION
10988 field_addr.name = "year";
10989#endif /* FREECIV_JSON_CONNECTION */
10990 e = 0;
10991
10992 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->year);
10993
10994 if (e) {
10995 log_packet_detailed("'year' field error detected");
10996 }
10997
10998#ifdef FREECIV_JSON_CONNECTION
10999 field_addr.name = "year_0_hack";
11000#endif /* FREECIV_JSON_CONNECTION */
11001 e = 0;
11002
11003 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->year_0_hack);
11004
11005 if (e) {
11006 log_packet_detailed("'year_0_hack' field error detected");
11007 }
11008
11009#ifdef FREECIV_JSON_CONNECTION
11010 field_addr.name = "top_cities_count";
11011#endif /* FREECIV_JSON_CONNECTION */
11012 e = 0;
11013
11014 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->top_cities_count);
11015
11016 if (e) {
11017 log_packet_detailed("'top_cities_count' field error detected");
11018 }
11019
11020#ifdef FREECIV_JSON_CONNECTION
11021 field_addr.name = "fragment_count";
11022#endif /* FREECIV_JSON_CONNECTION */
11023 e = 0;
11024
11025 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->fragment_count);
11026
11027 if (e) {
11028 log_packet_detailed("'fragment_count' field error detected");
11029 }
11030
11031#ifdef FREECIV_JSON_CONNECTION
11032 field_addr.name = "civil_war_enabled";
11033#endif /* FREECIV_JSON_CONNECTION */
11034 e = 0;
11035
11036 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->civil_war_enabled);
11037
11038 if (e) {
11039 log_packet_detailed("'civil_war_enabled' field error detected");
11040 }
11041
11042#ifdef FREECIV_JSON_CONNECTION
11043 field_addr.name = "civil_war_bonus_celebrating";
11044#endif /* FREECIV_JSON_CONNECTION */
11045 e = 0;
11046
11047 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->civil_war_bonus_celebrating);
11048
11049 if (e) {
11050 log_packet_detailed("'civil_war_bonus_celebrating' field error detected");
11051 }
11052
11053#ifdef FREECIV_JSON_CONNECTION
11054 field_addr.name = "civil_war_bonus_unhappy";
11055#endif /* FREECIV_JSON_CONNECTION */
11056 e = 0;
11057
11058 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->civil_war_bonus_unhappy);
11059
11060 if (e) {
11061 log_packet_detailed("'civil_war_bonus_unhappy' field error detected");
11062 }
11063
11064#ifdef FREECIV_JSON_CONNECTION
11065 field_addr.name = "granularity";
11066#endif /* FREECIV_JSON_CONNECTION */
11067 e = 0;
11068
11069 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granularity);
11070
11071 if (e) {
11072 log_packet_detailed("'granularity' field error detected");
11073 }
11074
11075#ifdef FREECIV_JSON_CONNECTION
11076 field_addr.name = "small_wonder_visibility";
11077#endif /* FREECIV_JSON_CONNECTION */
11078 e = 0;
11079
11080 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->small_wonder_visibility);
11081
11082 if (e) {
11083 log_packet_detailed("'small_wonder_visibility' field error detected");
11084 }
11085#endif /* FREECIV_DELTA_PROTOCOL */
11086
11087 SEND_PACKET_END(PACKET_GAME_INFO);
11088}
11089
11090 int send_packet_game_info(struct connection *pc, const struct packet_game_info *packet)
11091{
11092 if (!pc->used) {
11093 log_error("WARNING: trying to send data to the closed connection %s",
11094 conn_description(pc));
11095 return -1;
11096 }
11097 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_GAME_INFO].packet != nullptr, -1,
11098 "Handler for PACKET_GAME_INFO not installed");
11099 return pc->phs.handlers->send[PACKET_GAME_INFO].packet(pc, packet);
11100}
11101
11102 static inline void init_packet_calendar_info(struct packet_calendar_info *packet)
11103{
11104 memset(packet, 0, sizeof(*packet));
11105}
11106
11107#define free_packet_calendar_info(_packet) (void) 0
11108#define destroy_packet_calendar_info free
11109
11110#ifdef FREECIV_DELTA_PROTOCOL
11111#define hash_packet_calendar_info_100 hash_const
11112#define cmp_packet_calendar_info_100 cmp_const
11113 BV_DEFINE(packet_calendar_info_100_fields, 5);
11114#endif /* FREECIV_DELTA_PROTOCOL */
11115
11116 static struct packet_calendar_info *receive_packet_calendar_info_100(struct connection *pc)
11117{
11118#define FREE_PACKET_STRUCT(_packet) free_packet_calendar_info(_packet)
11119 RECEIVE_PACKET_START(packet_calendar_info, real_packet);
11120
11121#ifdef FREECIV_JSON_CONNECTION
11122 struct plocation field_addr;
11123 {
11124 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
11125 field_addr = *field_addr_tmp;
11126 FC_FREE(field_addr_tmp);
11127 }
11128#endif /* FREECIV_JSON_CONNECTION */
11129
11130 log_packet_detailed("packet_calendar_info_100: got info about ()");
11131
11132#ifdef FREECIV_DELTA_PROTOCOL
11133 packet_calendar_info_100_fields fields;
11134 struct packet_calendar_info *old;
11135 struct genhash **hash = pc->phs.received + PACKET_CALENDAR_INFO;
11136
11137 if (nullptr == *hash) {
11138 *hash = genhash_new_full(hash_packet_calendar_info_100, cmp_packet_calendar_info_100,
11139 nullptr, nullptr, nullptr, destroy_packet_calendar_info);
11140 }
11141
11142 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
11143 *real_packet = *old;
11144 } else {
11145 /* packet is already initialized empty */
11146 log_packet_detailed(" no old info");
11147 }
11148
11149#ifdef FREECIV_JSON_CONNECTION
11150 field_addr.name = "fields";
11151#endif /* FREECIV_JSON_CONNECTION */
11152 DIO_BV_GET(&din, &field_addr, fields);
11153
11154 if (BV_ISSET(fields, 0)) {
11155 log_packet_detailed(" got field 'positive_year_label'");
11156
11157#ifdef FREECIV_JSON_CONNECTION
11158 field_addr.name = "positive_year_label";
11159#endif /* FREECIV_JSON_CONNECTION */
11160
11161 if (!DIO_GET(string, &din, &field_addr, real_packet->positive_year_label, sizeof(real_packet->positive_year_label))) {
11162 RECEIVE_PACKET_FIELD_ERROR(positive_year_label);
11163 }
11164 }
11165
11166 if (BV_ISSET(fields, 1)) {
11167 log_packet_detailed(" got field 'negative_year_label'");
11168
11169#ifdef FREECIV_JSON_CONNECTION
11170 field_addr.name = "negative_year_label";
11171#endif /* FREECIV_JSON_CONNECTION */
11172
11173 if (!DIO_GET(string, &din, &field_addr, real_packet->negative_year_label, sizeof(real_packet->negative_year_label))) {
11174 RECEIVE_PACKET_FIELD_ERROR(negative_year_label);
11175 }
11176 }
11177
11178 if (BV_ISSET(fields, 2)) {
11179 log_packet_detailed(" got field 'calendar_fragments'");
11180
11181#ifdef FREECIV_JSON_CONNECTION
11182 field_addr.name = "calendar_fragments";
11183#endif /* FREECIV_JSON_CONNECTION */
11184
11185 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->calendar_fragments)) {
11186 RECEIVE_PACKET_FIELD_ERROR(calendar_fragments);
11187 }
11188 }
11189
11190 if (BV_ISSET(fields, 3)) {
11191 log_packet_detailed(" got field 'calendar_fragment_name'");
11192
11193#ifdef FREECIV_JSON_CONNECTION
11194 field_addr.name = "calendar_fragment_name";
11195#endif /* FREECIV_JSON_CONNECTION */
11196
11197 {
11198 int i;
11199
11200
11201#ifdef FREECIV_JSON_CONNECTION
11202 /* Enter array. */
11203 field_addr.sub_location = plocation_elem_new(0);
11204#endif /* FREECIV_JSON_CONNECTION */
11205
11206 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
11207#ifdef FREECIV_JSON_CONNECTION
11208 /* Next array element */
11209 field_addr.sub_location->number = i;
11210#endif /* FREECIV_JSON_CONNECTION */
11211
11212 if (!DIO_GET(string, &din, &field_addr, real_packet->calendar_fragment_name[i], sizeof(real_packet->calendar_fragment_name[i]))) {
11213 RECEIVE_PACKET_FIELD_ERROR(calendar_fragment_name);
11214 }
11215 }
11216
11217#ifdef FREECIV_JSON_CONNECTION
11218 /* Exit array. */
11219 FC_FREE(field_addr.sub_location);
11220#endif /* FREECIV_JSON_CONNECTION */
11221 }
11222 }
11223
11224 real_packet->calendar_skip_0 = BV_ISSET(fields, 4);
11225
11226 if (nullptr == old) {
11227 old = fc_malloc(sizeof(*old));
11228 init_packet_calendar_info(old);
11229 *old = *real_packet;
11230 genhash_insert(*hash, old, old);
11231 } else {
11232 *old = *real_packet;
11233 }
11234
11235#else /* FREECIV_DELTA_PROTOCOL */
11236#ifdef FREECIV_JSON_CONNECTION
11237 field_addr.name = "positive_year_label";
11238#endif /* FREECIV_JSON_CONNECTION */
11239
11240 if (!DIO_GET(string, &din, &field_addr, real_packet->positive_year_label, sizeof(real_packet->positive_year_label))) {
11241 RECEIVE_PACKET_FIELD_ERROR(positive_year_label);
11242 }
11243
11244#ifdef FREECIV_JSON_CONNECTION
11245 field_addr.name = "negative_year_label";
11246#endif /* FREECIV_JSON_CONNECTION */
11247
11248 if (!DIO_GET(string, &din, &field_addr, real_packet->negative_year_label, sizeof(real_packet->negative_year_label))) {
11249 RECEIVE_PACKET_FIELD_ERROR(negative_year_label);
11250 }
11251
11252#ifdef FREECIV_JSON_CONNECTION
11253 field_addr.name = "calendar_fragments";
11254#endif /* FREECIV_JSON_CONNECTION */
11255
11256 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->calendar_fragments)) {
11257 RECEIVE_PACKET_FIELD_ERROR(calendar_fragments);
11258 }
11259
11260#ifdef FREECIV_JSON_CONNECTION
11261 field_addr.name = "calendar_fragment_name";
11262#endif /* FREECIV_JSON_CONNECTION */
11263
11264 {
11265 int i;
11266
11267
11268#ifdef FREECIV_JSON_CONNECTION
11269 /* Enter array. */
11270 field_addr.sub_location = plocation_elem_new(0);
11271#endif /* FREECIV_JSON_CONNECTION */
11272
11273 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
11274#ifdef FREECIV_JSON_CONNECTION
11275 /* Next array element */
11276 field_addr.sub_location->number = i;
11277#endif /* FREECIV_JSON_CONNECTION */
11278
11279 if (!DIO_GET(string, &din, &field_addr, real_packet->calendar_fragment_name[i], sizeof(real_packet->calendar_fragment_name[i]))) {
11280 RECEIVE_PACKET_FIELD_ERROR(calendar_fragment_name);
11281 }
11282 }
11283
11284#ifdef FREECIV_JSON_CONNECTION
11285 /* Exit array. */
11286 FC_FREE(field_addr.sub_location);
11287#endif /* FREECIV_JSON_CONNECTION */
11288 }
11289
11290#ifdef FREECIV_JSON_CONNECTION
11291 field_addr.name = "calendar_skip_0";
11292#endif /* FREECIV_JSON_CONNECTION */
11293
11294 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->calendar_skip_0)) {
11295 RECEIVE_PACKET_FIELD_ERROR(calendar_skip_0);
11296 }
11297#endif /* FREECIV_DELTA_PROTOCOL */
11298
11299 RECEIVE_PACKET_END(real_packet);
11300#undef FREE_PACKET_STRUCT
11301}
11302
11303 static int send_packet_calendar_info_100(struct connection *pc, const struct packet_calendar_info *packet)
11304{
11305 const struct packet_calendar_info *real_packet = packet;
11306 int e;
11307 SEND_PACKET_START(PACKET_CALENDAR_INFO);
11308
11309 log_packet_detailed("packet_calendar_info_100: sending info about ()");
11310
11311#ifdef FREECIV_DELTA_PROTOCOL
11312 packet_calendar_info_100_fields fields;
11313 struct packet_calendar_info *old;
11314 bool differ;
11315 int different = 0;
11316 struct genhash **hash = pc->phs.sent + PACKET_CALENDAR_INFO;
11317
11318 if (nullptr == *hash) {
11319 *hash = genhash_new_full(hash_packet_calendar_info_100, cmp_packet_calendar_info_100,
11320 nullptr, nullptr, nullptr, destroy_packet_calendar_info);
11321 }
11322 BV_CLR_ALL(fields);
11323
11324 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
11325 old = fc_malloc(sizeof(*old));
11326 /* temporary bitcopy just to insert correctly */
11327 *old = *real_packet;
11328 genhash_insert(*hash, old, old);
11329 init_packet_calendar_info(old);
11330 different = 1; /* Force to send. */
11331 }
11332
11333 differ = (strcmp(old->positive_year_label, real_packet->positive_year_label) != 0);
11334 if (differ) {
11335 different++;
11336 BV_SET(fields, 0);
11337 }
11338
11339 differ = (strcmp(old->negative_year_label, real_packet->negative_year_label) != 0);
11340 if (differ) {
11341 different++;
11342 BV_SET(fields, 1);
11343 }
11344
11345 differ = (old->calendar_fragments != real_packet->calendar_fragments);
11346 if (differ) {
11347 different++;
11348 BV_SET(fields, 2);
11349 }
11350
11351 differ = FALSE;
11352 {
11353 int i;
11354
11355 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
11356 differ = (strcmp(old->calendar_fragment_name[i], real_packet->calendar_fragment_name[i]) != 0);
11357 if (differ) {
11358 break;
11359 }
11360 }
11361 }
11362 if (differ) {
11363 different++;
11364 BV_SET(fields, 3);
11365 }
11366
11367 differ = (old->calendar_skip_0 != real_packet->calendar_skip_0);
11368 if (differ) {
11369 different++;
11370 }
11371 /* folded into head */
11372 if (real_packet->calendar_skip_0) {
11373 BV_SET(fields, 4);
11374 }
11375
11376 if (different == 0) {
11377 log_packet_detailed(" no change -> discard");
11378 SEND_PACKET_DISCARD();
11379 }
11380#endif /* FREECIV_DELTA_PROTOCOL */
11381
11382#ifdef FREECIV_JSON_CONNECTION
11383 struct plocation field_addr;
11384 {
11385 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
11386 field_addr = *field_addr_tmp;
11387 FC_FREE(field_addr_tmp);
11388 }
11389#endif /* FREECIV_JSON_CONNECTION */
11390
11391#ifdef FREECIV_DELTA_PROTOCOL
11392#ifdef FREECIV_JSON_CONNECTION
11393 field_addr.name = "fields";
11394#endif /* FREECIV_JSON_CONNECTION */
11395 e = 0;
11396 e |= DIO_BV_PUT(&dout, &field_addr, fields);
11397 if (e) {
11398 log_packet_detailed("fields bitvector error detected");
11399 }
11400
11401 if (BV_ISSET(fields, 0)) {
11402 log_packet_detailed(" field 'positive_year_label' has changed");
11403
11404#ifdef FREECIV_JSON_CONNECTION
11405 field_addr.name = "positive_year_label";
11406#endif /* FREECIV_JSON_CONNECTION */
11407 e = 0;
11408
11409 e |= DIO_PUT(string, &dout, &field_addr, real_packet->positive_year_label);
11410
11411 if (e) {
11412 log_packet_detailed("'positive_year_label' field error detected");
11413 }
11414 }
11415
11416 if (BV_ISSET(fields, 1)) {
11417 log_packet_detailed(" field 'negative_year_label' has changed");
11418
11419#ifdef FREECIV_JSON_CONNECTION
11420 field_addr.name = "negative_year_label";
11421#endif /* FREECIV_JSON_CONNECTION */
11422 e = 0;
11423
11424 e |= DIO_PUT(string, &dout, &field_addr, real_packet->negative_year_label);
11425
11426 if (e) {
11427 log_packet_detailed("'negative_year_label' field error detected");
11428 }
11429 }
11430
11431 if (BV_ISSET(fields, 2)) {
11432 log_packet_detailed(" field 'calendar_fragments' has changed");
11433
11434#ifdef FREECIV_JSON_CONNECTION
11435 field_addr.name = "calendar_fragments";
11436#endif /* FREECIV_JSON_CONNECTION */
11437 e = 0;
11438
11439 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->calendar_fragments);
11440
11441 if (e) {
11442 log_packet_detailed("'calendar_fragments' field error detected");
11443 }
11444 }
11445
11446 if (BV_ISSET(fields, 3)) {
11447 log_packet_detailed(" field 'calendar_fragment_name' has changed");
11448
11449#ifdef FREECIV_JSON_CONNECTION
11450 field_addr.name = "calendar_fragment_name";
11451#endif /* FREECIV_JSON_CONNECTION */
11452 e = 0;
11453
11454 {
11455 int i;
11456
11457#ifdef FREECIV_JSON_CONNECTION
11458 /* Create the array. */
11459 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CALENDAR_FRAGMENTS);
11460
11461 /* Enter array. */
11462 field_addr.sub_location = plocation_elem_new(0);
11463#endif /* FREECIV_JSON_CONNECTION */
11464
11465 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
11466#ifdef FREECIV_JSON_CONNECTION
11467 /* Next array element. */
11468 field_addr.sub_location->number = i;
11469#endif /* FREECIV_JSON_CONNECTION */
11470
11471 e |= DIO_PUT(string, &dout, &field_addr, real_packet->calendar_fragment_name[i]);
11472 }
11473
11474#ifdef FREECIV_JSON_CONNECTION
11475 /* Exit array. */
11476 FC_FREE(field_addr.sub_location);
11477#endif /* FREECIV_JSON_CONNECTION */
11478 }
11479
11480 if (e) {
11481 log_packet_detailed("'calendar_fragment_name' field error detected");
11482 }
11483 }
11484
11485 /* field 4 is folded into the header */
11486
11487 *old = *real_packet;
11488
11489#else /* FREECIV_DELTA_PROTOCOL */
11490#ifdef FREECIV_JSON_CONNECTION
11491 field_addr.name = "positive_year_label";
11492#endif /* FREECIV_JSON_CONNECTION */
11493 e = 0;
11494
11495 e |= DIO_PUT(string, &dout, &field_addr, real_packet->positive_year_label);
11496
11497 if (e) {
11498 log_packet_detailed("'positive_year_label' field error detected");
11499 }
11500
11501#ifdef FREECIV_JSON_CONNECTION
11502 field_addr.name = "negative_year_label";
11503#endif /* FREECIV_JSON_CONNECTION */
11504 e = 0;
11505
11506 e |= DIO_PUT(string, &dout, &field_addr, real_packet->negative_year_label);
11507
11508 if (e) {
11509 log_packet_detailed("'negative_year_label' field error detected");
11510 }
11511
11512#ifdef FREECIV_JSON_CONNECTION
11513 field_addr.name = "calendar_fragments";
11514#endif /* FREECIV_JSON_CONNECTION */
11515 e = 0;
11516
11517 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->calendar_fragments);
11518
11519 if (e) {
11520 log_packet_detailed("'calendar_fragments' field error detected");
11521 }
11522
11523#ifdef FREECIV_JSON_CONNECTION
11524 field_addr.name = "calendar_fragment_name";
11525#endif /* FREECIV_JSON_CONNECTION */
11526 e = 0;
11527
11528 {
11529 int i;
11530
11531#ifdef FREECIV_JSON_CONNECTION
11532 /* Create the array. */
11533 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CALENDAR_FRAGMENTS);
11534
11535 /* Enter array. */
11536 field_addr.sub_location = plocation_elem_new(0);
11537#endif /* FREECIV_JSON_CONNECTION */
11538
11539 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
11540#ifdef FREECIV_JSON_CONNECTION
11541 /* Next array element. */
11542 field_addr.sub_location->number = i;
11543#endif /* FREECIV_JSON_CONNECTION */
11544
11545 e |= DIO_PUT(string, &dout, &field_addr, real_packet->calendar_fragment_name[i]);
11546 }
11547
11548#ifdef FREECIV_JSON_CONNECTION
11549 /* Exit array. */
11550 FC_FREE(field_addr.sub_location);
11551#endif /* FREECIV_JSON_CONNECTION */
11552 }
11553
11554 if (e) {
11555 log_packet_detailed("'calendar_fragment_name' field error detected");
11556 }
11557
11558#ifdef FREECIV_JSON_CONNECTION
11559 field_addr.name = "calendar_skip_0";
11560#endif /* FREECIV_JSON_CONNECTION */
11561 e = 0;
11562
11563 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->calendar_skip_0);
11564
11565 if (e) {
11566 log_packet_detailed("'calendar_skip_0' field error detected");
11567 }
11568#endif /* FREECIV_DELTA_PROTOCOL */
11569
11570 SEND_PACKET_END(PACKET_CALENDAR_INFO);
11571}
11572
11573 int send_packet_calendar_info(struct connection *pc, const struct packet_calendar_info *packet)
11574{
11575 if (!pc->used) {
11576 log_error("WARNING: trying to send data to the closed connection %s",
11577 conn_description(pc));
11578 return -1;
11579 }
11580 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CALENDAR_INFO].packet != nullptr, -1,
11581 "Handler for PACKET_CALENDAR_INFO not installed");
11582 return pc->phs.handlers->send[PACKET_CALENDAR_INFO].packet(pc, packet);
11583}
11584
11585 static inline void init_packet_timeout_info(struct packet_timeout_info *packet)
11586{
11587 memset(packet, 0, sizeof(*packet));
11588}
11589
11590#define free_packet_timeout_info(_packet) (void) 0
11591#define destroy_packet_timeout_info free
11592
11593#ifdef FREECIV_DELTA_PROTOCOL
11594#define hash_packet_timeout_info_100 hash_const
11595#define cmp_packet_timeout_info_100 cmp_const
11596 BV_DEFINE(packet_timeout_info_100_fields, 2);
11597#endif /* FREECIV_DELTA_PROTOCOL */
11598
11599 static struct packet_timeout_info *receive_packet_timeout_info_100(struct connection *pc)
11600{
11601#define FREE_PACKET_STRUCT(_packet) free_packet_timeout_info(_packet)
11602 RECEIVE_PACKET_START(packet_timeout_info, real_packet);
11603
11604#ifdef FREECIV_JSON_CONNECTION
11605 struct plocation field_addr;
11606 {
11607 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
11608 field_addr = *field_addr_tmp;
11609 FC_FREE(field_addr_tmp);
11610 }
11611#endif /* FREECIV_JSON_CONNECTION */
11612
11613 log_packet_detailed("packet_timeout_info_100: got info about ()");
11614
11615#ifdef FREECIV_DELTA_PROTOCOL
11616 packet_timeout_info_100_fields fields;
11617 struct packet_timeout_info *old;
11618 struct genhash **hash = pc->phs.received + PACKET_TIMEOUT_INFO;
11619
11620 if (nullptr == *hash) {
11621 *hash = genhash_new_full(hash_packet_timeout_info_100, cmp_packet_timeout_info_100,
11622 nullptr, nullptr, nullptr, destroy_packet_timeout_info);
11623 }
11624
11625 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
11626 *real_packet = *old;
11627 } else {
11628 /* packet is already initialized empty */
11629 log_packet_detailed(" no old info");
11630 }
11631
11632#ifdef FREECIV_JSON_CONNECTION
11633 field_addr.name = "fields";
11634#endif /* FREECIV_JSON_CONNECTION */
11635 DIO_BV_GET(&din, &field_addr, fields);
11636
11637 if (BV_ISSET(fields, 0)) {
11638 log_packet_detailed(" got field 'seconds_to_phasedone'");
11639
11640#ifdef FREECIV_JSON_CONNECTION
11641 field_addr.name = "seconds_to_phasedone";
11642#endif /* FREECIV_JSON_CONNECTION */
11643
11644 if (!DIO_GET(sfloat, &din, &field_addr, &real_packet->seconds_to_phasedone, 100)) {
11645 RECEIVE_PACKET_FIELD_ERROR(seconds_to_phasedone);
11646 }
11647 }
11648
11649 if (BV_ISSET(fields, 1)) {
11650 log_packet_detailed(" got field 'last_turn_change_time'");
11651
11652#ifdef FREECIV_JSON_CONNECTION
11653 field_addr.name = "last_turn_change_time";
11654#endif /* FREECIV_JSON_CONNECTION */
11655
11656 if (!DIO_GET(sfloat, &din, &field_addr, &real_packet->last_turn_change_time, 100)) {
11657 RECEIVE_PACKET_FIELD_ERROR(last_turn_change_time);
11658 }
11659 }
11660
11661 if (nullptr == old) {
11662 old = fc_malloc(sizeof(*old));
11663 init_packet_timeout_info(old);
11664 *old = *real_packet;
11665 genhash_insert(*hash, old, old);
11666 } else {
11667 *old = *real_packet;
11668 }
11669
11670#else /* FREECIV_DELTA_PROTOCOL */
11671#ifdef FREECIV_JSON_CONNECTION
11672 field_addr.name = "seconds_to_phasedone";
11673#endif /* FREECIV_JSON_CONNECTION */
11674
11675 if (!DIO_GET(sfloat, &din, &field_addr, &real_packet->seconds_to_phasedone, 100)) {
11676 RECEIVE_PACKET_FIELD_ERROR(seconds_to_phasedone);
11677 }
11678
11679#ifdef FREECIV_JSON_CONNECTION
11680 field_addr.name = "last_turn_change_time";
11681#endif /* FREECIV_JSON_CONNECTION */
11682
11683 if (!DIO_GET(sfloat, &din, &field_addr, &real_packet->last_turn_change_time, 100)) {
11684 RECEIVE_PACKET_FIELD_ERROR(last_turn_change_time);
11685 }
11686#endif /* FREECIV_DELTA_PROTOCOL */
11687
11688 RECEIVE_PACKET_END(real_packet);
11689#undef FREE_PACKET_STRUCT
11690}
11691
11692 static int send_packet_timeout_info_100(struct connection *pc, const struct packet_timeout_info *packet)
11693{
11694 const struct packet_timeout_info *real_packet = packet;
11695 int e;
11696 SEND_PACKET_START(PACKET_TIMEOUT_INFO);
11697
11698 log_packet_detailed("packet_timeout_info_100: sending info about ()");
11699
11700#ifdef FREECIV_DELTA_PROTOCOL
11701 packet_timeout_info_100_fields fields;
11702 struct packet_timeout_info *old;
11703 bool differ;
11704 struct genhash **hash = pc->phs.sent + PACKET_TIMEOUT_INFO;
11705
11706 if (nullptr == *hash) {
11707 *hash = genhash_new_full(hash_packet_timeout_info_100, cmp_packet_timeout_info_100,
11708 nullptr, nullptr, nullptr, destroy_packet_timeout_info);
11709 }
11710 BV_CLR_ALL(fields);
11711
11712 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
11713 old = fc_malloc(sizeof(*old));
11714 /* temporary bitcopy just to insert correctly */
11715 *old = *real_packet;
11716 genhash_insert(*hash, old, old);
11717 init_packet_timeout_info(old);
11718 }
11719
11720 differ = ((int) (old->seconds_to_phasedone * 100) != (int) (real_packet->seconds_to_phasedone * 100));
11721 if (differ) {
11722 BV_SET(fields, 0);
11723 }
11724
11725 differ = ((int) (old->last_turn_change_time * 100) != (int) (real_packet->last_turn_change_time * 100));
11726 if (differ) {
11727 BV_SET(fields, 1);
11728 }
11729#endif /* FREECIV_DELTA_PROTOCOL */
11730
11731#ifdef FREECIV_JSON_CONNECTION
11732 struct plocation field_addr;
11733 {
11734 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
11735 field_addr = *field_addr_tmp;
11736 FC_FREE(field_addr_tmp);
11737 }
11738#endif /* FREECIV_JSON_CONNECTION */
11739
11740#ifdef FREECIV_DELTA_PROTOCOL
11741#ifdef FREECIV_JSON_CONNECTION
11742 field_addr.name = "fields";
11743#endif /* FREECIV_JSON_CONNECTION */
11744 e = 0;
11745 e |= DIO_BV_PUT(&dout, &field_addr, fields);
11746 if (e) {
11747 log_packet_detailed("fields bitvector error detected");
11748 }
11749
11750 if (BV_ISSET(fields, 0)) {
11751 log_packet_detailed(" field 'seconds_to_phasedone' has changed");
11752
11753#ifdef FREECIV_JSON_CONNECTION
11754 field_addr.name = "seconds_to_phasedone";
11755#endif /* FREECIV_JSON_CONNECTION */
11756 e = 0;
11757
11758 e |= DIO_PUT(sfloat, &dout, &field_addr, real_packet->seconds_to_phasedone, 100);
11759
11760 if (e) {
11761 log_packet_detailed("'seconds_to_phasedone' field error detected");
11762 }
11763 }
11764
11765 if (BV_ISSET(fields, 1)) {
11766 log_packet_detailed(" field 'last_turn_change_time' has changed");
11767
11768#ifdef FREECIV_JSON_CONNECTION
11769 field_addr.name = "last_turn_change_time";
11770#endif /* FREECIV_JSON_CONNECTION */
11771 e = 0;
11772
11773 e |= DIO_PUT(sfloat, &dout, &field_addr, real_packet->last_turn_change_time, 100);
11774
11775 if (e) {
11776 log_packet_detailed("'last_turn_change_time' field error detected");
11777 }
11778 }
11779
11780 *old = *real_packet;
11781
11782#else /* FREECIV_DELTA_PROTOCOL */
11783#ifdef FREECIV_JSON_CONNECTION
11784 field_addr.name = "seconds_to_phasedone";
11785#endif /* FREECIV_JSON_CONNECTION */
11786 e = 0;
11787
11788 e |= DIO_PUT(sfloat, &dout, &field_addr, real_packet->seconds_to_phasedone, 100);
11789
11790 if (e) {
11791 log_packet_detailed("'seconds_to_phasedone' field error detected");
11792 }
11793
11794#ifdef FREECIV_JSON_CONNECTION
11795 field_addr.name = "last_turn_change_time";
11796#endif /* FREECIV_JSON_CONNECTION */
11797 e = 0;
11798
11799 e |= DIO_PUT(sfloat, &dout, &field_addr, real_packet->last_turn_change_time, 100);
11800
11801 if (e) {
11802 log_packet_detailed("'last_turn_change_time' field error detected");
11803 }
11804#endif /* FREECIV_DELTA_PROTOCOL */
11805
11806 SEND_PACKET_END(PACKET_TIMEOUT_INFO);
11807}
11808
11809 int send_packet_timeout_info(struct connection *pc, const struct packet_timeout_info *packet)
11810{
11811 if (!pc->used) {
11812 log_error("WARNING: trying to send data to the closed connection %s",
11813 conn_description(pc));
11814 return -1;
11815 }
11816 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_TIMEOUT_INFO].packet != nullptr, -1,
11817 "Handler for PACKET_TIMEOUT_INFO not installed");
11818 return pc->phs.handlers->send[PACKET_TIMEOUT_INFO].packet(pc, packet);
11819}
11820
11821 static inline void init_packet_map_info(struct packet_map_info *packet)
11822{
11823 memset(packet, 0, sizeof(*packet));
11824}
11825
11826#define free_packet_map_info(_packet) (void) 0
11827#define destroy_packet_map_info free
11828
11829#ifdef FREECIV_DELTA_PROTOCOL
11830#define hash_packet_map_info_100 hash_const
11831#define cmp_packet_map_info_100 cmp_const
11832 BV_DEFINE(packet_map_info_100_fields, 7);
11833#endif /* FREECIV_DELTA_PROTOCOL */
11834
11835 static struct packet_map_info *receive_packet_map_info_100(struct connection *pc)
11836{
11837#define FREE_PACKET_STRUCT(_packet) free_packet_map_info(_packet)
11838 RECEIVE_PACKET_START(packet_map_info, real_packet);
11839
11840#ifdef FREECIV_JSON_CONNECTION
11841 struct plocation field_addr;
11842 {
11843 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
11844 field_addr = *field_addr_tmp;
11845 FC_FREE(field_addr_tmp);
11846 }
11847#endif /* FREECIV_JSON_CONNECTION */
11848
11849 log_packet_detailed("packet_map_info_100: got info about ()");
11850
11851#ifdef FREECIV_DELTA_PROTOCOL
11852 packet_map_info_100_fields fields;
11853 struct packet_map_info *old;
11854 struct genhash **hash = pc->phs.received + PACKET_MAP_INFO;
11855
11856 if (nullptr == *hash) {
11857 *hash = genhash_new_full(hash_packet_map_info_100, cmp_packet_map_info_100,
11858 nullptr, nullptr, nullptr, destroy_packet_map_info);
11859 }
11860
11861 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
11862 *real_packet = *old;
11863 } else {
11864 /* packet is already initialized empty */
11865 log_packet_detailed(" no old info");
11866 }
11867
11868#ifdef FREECIV_JSON_CONNECTION
11869 field_addr.name = "fields";
11870#endif /* FREECIV_JSON_CONNECTION */
11871 DIO_BV_GET(&din, &field_addr, fields);
11872
11873 if (BV_ISSET(fields, 0)) {
11874 log_packet_detailed(" got field 'xsize'");
11875
11876#ifdef FREECIV_JSON_CONNECTION
11877 field_addr.name = "xsize";
11878#endif /* FREECIV_JSON_CONNECTION */
11879
11880 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->xsize)) {
11881 RECEIVE_PACKET_FIELD_ERROR(xsize);
11882 }
11883 }
11884
11885 if (BV_ISSET(fields, 1)) {
11886 log_packet_detailed(" got field 'ysize'");
11887
11888#ifdef FREECIV_JSON_CONNECTION
11889 field_addr.name = "ysize";
11890#endif /* FREECIV_JSON_CONNECTION */
11891
11892 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->ysize)) {
11893 RECEIVE_PACKET_FIELD_ERROR(ysize);
11894 }
11895 }
11896
11897 if (BV_ISSET(fields, 2)) {
11898 log_packet_detailed(" got field 'topology_id'");
11899
11900#ifdef FREECIV_JSON_CONNECTION
11901 field_addr.name = "topology_id";
11902#endif /* FREECIV_JSON_CONNECTION */
11903
11904 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->topology_id)) {
11905 RECEIVE_PACKET_FIELD_ERROR(topology_id);
11906 }
11907 }
11908
11909 if (BV_ISSET(fields, 3)) {
11910 log_packet_detailed(" got field 'wrap_id'");
11911
11912#ifdef FREECIV_JSON_CONNECTION
11913 field_addr.name = "wrap_id";
11914#endif /* FREECIV_JSON_CONNECTION */
11915
11916 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->wrap_id)) {
11917 RECEIVE_PACKET_FIELD_ERROR(wrap_id);
11918 }
11919 }
11920
11921 if (BV_ISSET(fields, 4)) {
11922 log_packet_detailed(" got field 'north_latitude'");
11923
11924#ifdef FREECIV_JSON_CONNECTION
11925 field_addr.name = "north_latitude";
11926#endif /* FREECIV_JSON_CONNECTION */
11927
11928 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->north_latitude)) {
11929 RECEIVE_PACKET_FIELD_ERROR(north_latitude);
11930 }
11931 }
11932
11933 if (BV_ISSET(fields, 5)) {
11934 log_packet_detailed(" got field 'south_latitude'");
11935
11936#ifdef FREECIV_JSON_CONNECTION
11937 field_addr.name = "south_latitude";
11938#endif /* FREECIV_JSON_CONNECTION */
11939
11940 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->south_latitude)) {
11941 RECEIVE_PACKET_FIELD_ERROR(south_latitude);
11942 }
11943 }
11944
11945 real_packet->altitude_info = BV_ISSET(fields, 6);
11946
11947 if (nullptr == old) {
11948 old = fc_malloc(sizeof(*old));
11949 init_packet_map_info(old);
11950 *old = *real_packet;
11951 genhash_insert(*hash, old, old);
11952 } else {
11953 *old = *real_packet;
11954 }
11955
11956#else /* FREECIV_DELTA_PROTOCOL */
11957#ifdef FREECIV_JSON_CONNECTION
11958 field_addr.name = "xsize";
11959#endif /* FREECIV_JSON_CONNECTION */
11960
11961 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->xsize)) {
11962 RECEIVE_PACKET_FIELD_ERROR(xsize);
11963 }
11964
11965#ifdef FREECIV_JSON_CONNECTION
11966 field_addr.name = "ysize";
11967#endif /* FREECIV_JSON_CONNECTION */
11968
11969 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->ysize)) {
11970 RECEIVE_PACKET_FIELD_ERROR(ysize);
11971 }
11972
11973#ifdef FREECIV_JSON_CONNECTION
11974 field_addr.name = "topology_id";
11975#endif /* FREECIV_JSON_CONNECTION */
11976
11977 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->topology_id)) {
11978 RECEIVE_PACKET_FIELD_ERROR(topology_id);
11979 }
11980
11981#ifdef FREECIV_JSON_CONNECTION
11982 field_addr.name = "wrap_id";
11983#endif /* FREECIV_JSON_CONNECTION */
11984
11985 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->wrap_id)) {
11986 RECEIVE_PACKET_FIELD_ERROR(wrap_id);
11987 }
11988
11989#ifdef FREECIV_JSON_CONNECTION
11990 field_addr.name = "north_latitude";
11991#endif /* FREECIV_JSON_CONNECTION */
11992
11993 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->north_latitude)) {
11994 RECEIVE_PACKET_FIELD_ERROR(north_latitude);
11995 }
11996
11997#ifdef FREECIV_JSON_CONNECTION
11998 field_addr.name = "south_latitude";
11999#endif /* FREECIV_JSON_CONNECTION */
12000
12001 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->south_latitude)) {
12002 RECEIVE_PACKET_FIELD_ERROR(south_latitude);
12003 }
12004
12005#ifdef FREECIV_JSON_CONNECTION
12006 field_addr.name = "altitude_info";
12007#endif /* FREECIV_JSON_CONNECTION */
12008
12009 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->altitude_info)) {
12010 RECEIVE_PACKET_FIELD_ERROR(altitude_info);
12011 }
12012#endif /* FREECIV_DELTA_PROTOCOL */
12013
12014 RECEIVE_PACKET_END(real_packet);
12015#undef FREE_PACKET_STRUCT
12016}
12017
12018 static int send_packet_map_info_100(struct connection *pc, const struct packet_map_info *packet)
12019{
12020 const struct packet_map_info *real_packet = packet;
12021 int e;
12022 SEND_PACKET_START(PACKET_MAP_INFO);
12023
12024 log_packet_detailed("packet_map_info_100: sending info about ()");
12025
12026#ifdef FREECIV_DELTA_PROTOCOL
12027 packet_map_info_100_fields fields;
12028 struct packet_map_info *old;
12029 bool differ;
12030 struct genhash **hash = pc->phs.sent + PACKET_MAP_INFO;
12031
12032 if (nullptr == *hash) {
12033 *hash = genhash_new_full(hash_packet_map_info_100, cmp_packet_map_info_100,
12034 nullptr, nullptr, nullptr, destroy_packet_map_info);
12035 }
12036 BV_CLR_ALL(fields);
12037
12038 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12039 old = fc_malloc(sizeof(*old));
12040 /* temporary bitcopy just to insert correctly */
12041 *old = *real_packet;
12042 genhash_insert(*hash, old, old);
12043 init_packet_map_info(old);
12044 }
12045
12046 differ = (old->xsize != real_packet->xsize);
12047 if (differ) {
12048 BV_SET(fields, 0);
12049 }
12050
12051 differ = (old->ysize != real_packet->ysize);
12052 if (differ) {
12053 BV_SET(fields, 1);
12054 }
12055
12056 differ = (old->topology_id != real_packet->topology_id);
12057 if (differ) {
12058 BV_SET(fields, 2);
12059 }
12060
12061 differ = (old->wrap_id != real_packet->wrap_id);
12062 if (differ) {
12063 BV_SET(fields, 3);
12064 }
12065
12066 differ = (old->north_latitude != real_packet->north_latitude);
12067 if (differ) {
12068 BV_SET(fields, 4);
12069 }
12070
12071 differ = (old->south_latitude != real_packet->south_latitude);
12072 if (differ) {
12073 BV_SET(fields, 5);
12074 }
12075
12076 /* folded into head */
12077 if (real_packet->altitude_info) {
12078 BV_SET(fields, 6);
12079 }
12080#endif /* FREECIV_DELTA_PROTOCOL */
12081
12082#ifdef FREECIV_JSON_CONNECTION
12083 struct plocation field_addr;
12084 {
12085 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12086 field_addr = *field_addr_tmp;
12087 FC_FREE(field_addr_tmp);
12088 }
12089#endif /* FREECIV_JSON_CONNECTION */
12090
12091#ifdef FREECIV_DELTA_PROTOCOL
12092#ifdef FREECIV_JSON_CONNECTION
12093 field_addr.name = "fields";
12094#endif /* FREECIV_JSON_CONNECTION */
12095 e = 0;
12096 e |= DIO_BV_PUT(&dout, &field_addr, fields);
12097 if (e) {
12098 log_packet_detailed("fields bitvector error detected");
12099 }
12100
12101 if (BV_ISSET(fields, 0)) {
12102 log_packet_detailed(" field 'xsize' has changed");
12103
12104#ifdef FREECIV_JSON_CONNECTION
12105 field_addr.name = "xsize";
12106#endif /* FREECIV_JSON_CONNECTION */
12107 e = 0;
12108
12109 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->xsize);
12110
12111 if (e) {
12112 log_packet_detailed("'xsize' field error detected");
12113 }
12114 }
12115
12116 if (BV_ISSET(fields, 1)) {
12117 log_packet_detailed(" field 'ysize' has changed");
12118
12119#ifdef FREECIV_JSON_CONNECTION
12120 field_addr.name = "ysize";
12121#endif /* FREECIV_JSON_CONNECTION */
12122 e = 0;
12123
12124 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->ysize);
12125
12126 if (e) {
12127 log_packet_detailed("'ysize' field error detected");
12128 }
12129 }
12130
12131 if (BV_ISSET(fields, 2)) {
12132 log_packet_detailed(" field 'topology_id' has changed");
12133
12134#ifdef FREECIV_JSON_CONNECTION
12135 field_addr.name = "topology_id";
12136#endif /* FREECIV_JSON_CONNECTION */
12137 e = 0;
12138
12139 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->topology_id);
12140
12141 if (e) {
12142 log_packet_detailed("'topology_id' field error detected");
12143 }
12144 }
12145
12146 if (BV_ISSET(fields, 3)) {
12147 log_packet_detailed(" field 'wrap_id' has changed");
12148
12149#ifdef FREECIV_JSON_CONNECTION
12150 field_addr.name = "wrap_id";
12151#endif /* FREECIV_JSON_CONNECTION */
12152 e = 0;
12153
12154 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->wrap_id);
12155
12156 if (e) {
12157 log_packet_detailed("'wrap_id' field error detected");
12158 }
12159 }
12160
12161 if (BV_ISSET(fields, 4)) {
12162 log_packet_detailed(" field 'north_latitude' has changed");
12163
12164#ifdef FREECIV_JSON_CONNECTION
12165 field_addr.name = "north_latitude";
12166#endif /* FREECIV_JSON_CONNECTION */
12167 e = 0;
12168
12169 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->north_latitude);
12170
12171 if (e) {
12172 log_packet_detailed("'north_latitude' field error detected");
12173 }
12174 }
12175
12176 if (BV_ISSET(fields, 5)) {
12177 log_packet_detailed(" field 'south_latitude' has changed");
12178
12179#ifdef FREECIV_JSON_CONNECTION
12180 field_addr.name = "south_latitude";
12181#endif /* FREECIV_JSON_CONNECTION */
12182 e = 0;
12183
12184 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->south_latitude);
12185
12186 if (e) {
12187 log_packet_detailed("'south_latitude' field error detected");
12188 }
12189 }
12190
12191 /* field 6 is folded into the header */
12192
12193 *old = *real_packet;
12194
12195#else /* FREECIV_DELTA_PROTOCOL */
12196#ifdef FREECIV_JSON_CONNECTION
12197 field_addr.name = "xsize";
12198#endif /* FREECIV_JSON_CONNECTION */
12199 e = 0;
12200
12201 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->xsize);
12202
12203 if (e) {
12204 log_packet_detailed("'xsize' field error detected");
12205 }
12206
12207#ifdef FREECIV_JSON_CONNECTION
12208 field_addr.name = "ysize";
12209#endif /* FREECIV_JSON_CONNECTION */
12210 e = 0;
12211
12212 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->ysize);
12213
12214 if (e) {
12215 log_packet_detailed("'ysize' field error detected");
12216 }
12217
12218#ifdef FREECIV_JSON_CONNECTION
12219 field_addr.name = "topology_id";
12220#endif /* FREECIV_JSON_CONNECTION */
12221 e = 0;
12222
12223 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->topology_id);
12224
12225 if (e) {
12226 log_packet_detailed("'topology_id' field error detected");
12227 }
12228
12229#ifdef FREECIV_JSON_CONNECTION
12230 field_addr.name = "wrap_id";
12231#endif /* FREECIV_JSON_CONNECTION */
12232 e = 0;
12233
12234 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->wrap_id);
12235
12236 if (e) {
12237 log_packet_detailed("'wrap_id' field error detected");
12238 }
12239
12240#ifdef FREECIV_JSON_CONNECTION
12241 field_addr.name = "north_latitude";
12242#endif /* FREECIV_JSON_CONNECTION */
12243 e = 0;
12244
12245 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->north_latitude);
12246
12247 if (e) {
12248 log_packet_detailed("'north_latitude' field error detected");
12249 }
12250
12251#ifdef FREECIV_JSON_CONNECTION
12252 field_addr.name = "south_latitude";
12253#endif /* FREECIV_JSON_CONNECTION */
12254 e = 0;
12255
12256 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->south_latitude);
12257
12258 if (e) {
12259 log_packet_detailed("'south_latitude' field error detected");
12260 }
12261
12262#ifdef FREECIV_JSON_CONNECTION
12263 field_addr.name = "altitude_info";
12264#endif /* FREECIV_JSON_CONNECTION */
12265 e = 0;
12266
12267 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->altitude_info);
12268
12269 if (e) {
12270 log_packet_detailed("'altitude_info' field error detected");
12271 }
12272#endif /* FREECIV_DELTA_PROTOCOL */
12273
12274 SEND_PACKET_END(PACKET_MAP_INFO);
12275}
12276
12277 int send_packet_map_info(struct connection *pc, const struct packet_map_info *packet)
12278{
12279 if (!pc->used) {
12280 log_error("WARNING: trying to send data to the closed connection %s",
12281 conn_description(pc));
12282 return -1;
12283 }
12284 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_MAP_INFO].packet != nullptr, -1,
12285 "Handler for PACKET_MAP_INFO not installed");
12286 return pc->phs.handlers->send[PACKET_MAP_INFO].packet(pc, packet);
12287}
12288
12289 void lsend_packet_map_info(struct conn_list *dest, const struct packet_map_info *packet)
12290{
12291 conn_list_iterate(dest, pconn) {
12292 send_packet_map_info(pconn, packet);
12293 } conn_list_iterate_end;
12294}
12295
12296 static inline void init_packet_nuke_tile_info(struct packet_nuke_tile_info *packet)
12297{
12298 memset(packet, 0, sizeof(*packet));
12299}
12300
12301#define free_packet_nuke_tile_info(_packet) (void) 0
12302#define destroy_packet_nuke_tile_info free
12303
12304#ifdef FREECIV_DELTA_PROTOCOL
12305#define hash_packet_nuke_tile_info_100 hash_const
12306#define cmp_packet_nuke_tile_info_100 cmp_const
12307 BV_DEFINE(packet_nuke_tile_info_100_fields, 1);
12308#endif /* FREECIV_DELTA_PROTOCOL */
12309
12310 static struct packet_nuke_tile_info *receive_packet_nuke_tile_info_100(struct connection *pc)
12311{
12312#define FREE_PACKET_STRUCT(_packet) free_packet_nuke_tile_info(_packet)
12313 RECEIVE_PACKET_START(packet_nuke_tile_info, real_packet);
12314
12315#ifdef FREECIV_JSON_CONNECTION
12316 struct plocation field_addr;
12317 {
12318 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12319 field_addr = *field_addr_tmp;
12320 FC_FREE(field_addr_tmp);
12321 }
12322#endif /* FREECIV_JSON_CONNECTION */
12323
12324 log_packet_detailed("packet_nuke_tile_info_100: got info about ()");
12325
12326#ifdef FREECIV_DELTA_PROTOCOL
12327 packet_nuke_tile_info_100_fields fields;
12328 struct packet_nuke_tile_info *old;
12329 struct genhash **hash = pc->phs.received + PACKET_NUKE_TILE_INFO;
12330
12331 if (nullptr == *hash) {
12332 *hash = genhash_new_full(hash_packet_nuke_tile_info_100, cmp_packet_nuke_tile_info_100,
12333 nullptr, nullptr, nullptr, destroy_packet_nuke_tile_info);
12334 }
12335
12336 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12337 *real_packet = *old;
12338 } else {
12339 /* packet is already initialized empty */
12340 log_packet_detailed(" no old info");
12341 }
12342
12343#ifdef FREECIV_JSON_CONNECTION
12344 field_addr.name = "fields";
12345#endif /* FREECIV_JSON_CONNECTION */
12346 DIO_BV_GET(&din, &field_addr, fields);
12347
12348 if (BV_ISSET(fields, 0)) {
12349 log_packet_detailed(" got field 'tile'");
12350
12351#ifdef FREECIV_JSON_CONNECTION
12352 field_addr.name = "tile";
12353#endif /* FREECIV_JSON_CONNECTION */
12354
12355 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
12356 RECEIVE_PACKET_FIELD_ERROR(tile);
12357 }
12358 }
12359
12360 if (nullptr == old) {
12361 old = fc_malloc(sizeof(*old));
12362 init_packet_nuke_tile_info(old);
12363 *old = *real_packet;
12364 genhash_insert(*hash, old, old);
12365 } else {
12366 *old = *real_packet;
12367 }
12368
12369#else /* FREECIV_DELTA_PROTOCOL */
12370#ifdef FREECIV_JSON_CONNECTION
12371 field_addr.name = "tile";
12372#endif /* FREECIV_JSON_CONNECTION */
12373
12374 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
12375 RECEIVE_PACKET_FIELD_ERROR(tile);
12376 }
12377#endif /* FREECIV_DELTA_PROTOCOL */
12378
12379 RECEIVE_PACKET_END(real_packet);
12380#undef FREE_PACKET_STRUCT
12381}
12382
12383 static int send_packet_nuke_tile_info_100(struct connection *pc, const struct packet_nuke_tile_info *packet)
12384{
12385 const struct packet_nuke_tile_info *real_packet = packet;
12386 int e;
12387 SEND_PACKET_START(PACKET_NUKE_TILE_INFO);
12388
12389 log_packet_detailed("packet_nuke_tile_info_100: sending info about ()");
12390
12391#ifdef FREECIV_DELTA_PROTOCOL
12392 packet_nuke_tile_info_100_fields fields;
12393 struct packet_nuke_tile_info *old;
12394 bool differ;
12395 struct genhash **hash = pc->phs.sent + PACKET_NUKE_TILE_INFO;
12396
12397 if (nullptr == *hash) {
12398 *hash = genhash_new_full(hash_packet_nuke_tile_info_100, cmp_packet_nuke_tile_info_100,
12399 nullptr, nullptr, nullptr, destroy_packet_nuke_tile_info);
12400 }
12401 BV_CLR_ALL(fields);
12402
12403 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12404 old = fc_malloc(sizeof(*old));
12405 /* temporary bitcopy just to insert correctly */
12406 *old = *real_packet;
12407 genhash_insert(*hash, old, old);
12408 init_packet_nuke_tile_info(old);
12409 }
12410
12411 differ = (old->tile != real_packet->tile);
12412 if (differ) {
12413 BV_SET(fields, 0);
12414 }
12415#endif /* FREECIV_DELTA_PROTOCOL */
12416
12417#ifdef FREECIV_JSON_CONNECTION
12418 struct plocation field_addr;
12419 {
12420 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12421 field_addr = *field_addr_tmp;
12422 FC_FREE(field_addr_tmp);
12423 }
12424#endif /* FREECIV_JSON_CONNECTION */
12425
12426#ifdef FREECIV_DELTA_PROTOCOL
12427#ifdef FREECIV_JSON_CONNECTION
12428 field_addr.name = "fields";
12429#endif /* FREECIV_JSON_CONNECTION */
12430 e = 0;
12431 e |= DIO_BV_PUT(&dout, &field_addr, fields);
12432 if (e) {
12433 log_packet_detailed("fields bitvector error detected");
12434 }
12435
12436 if (BV_ISSET(fields, 0)) {
12437 log_packet_detailed(" field 'tile' has changed");
12438
12439#ifdef FREECIV_JSON_CONNECTION
12440 field_addr.name = "tile";
12441#endif /* FREECIV_JSON_CONNECTION */
12442 e = 0;
12443
12444 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
12445
12446 if (e) {
12447 log_packet_detailed("'tile' field error detected");
12448 }
12449 }
12450
12451 *old = *real_packet;
12452
12453#else /* FREECIV_DELTA_PROTOCOL */
12454#ifdef FREECIV_JSON_CONNECTION
12455 field_addr.name = "tile";
12456#endif /* FREECIV_JSON_CONNECTION */
12457 e = 0;
12458
12459 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
12460
12461 if (e) {
12462 log_packet_detailed("'tile' field error detected");
12463 }
12464#endif /* FREECIV_DELTA_PROTOCOL */
12465
12466 SEND_PACKET_END(PACKET_NUKE_TILE_INFO);
12467}
12468
12469 int send_packet_nuke_tile_info(struct connection *pc, const struct packet_nuke_tile_info *packet)
12470{
12471 if (!pc->used) {
12472 log_error("WARNING: trying to send data to the closed connection %s",
12473 conn_description(pc));
12474 return -1;
12475 }
12476 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NUKE_TILE_INFO].packet != nullptr, -1,
12477 "Handler for PACKET_NUKE_TILE_INFO not installed");
12478 return pc->phs.handlers->send[PACKET_NUKE_TILE_INFO].packet(pc, packet);
12479}
12480
12481 void lsend_packet_nuke_tile_info(struct conn_list *dest, const struct packet_nuke_tile_info *packet)
12482{
12483 conn_list_iterate(dest, pconn) {
12484 send_packet_nuke_tile_info(pconn, packet);
12485 } conn_list_iterate_end;
12486}
12487
12488 int dsend_packet_nuke_tile_info(struct connection *pc, int tile)
12489{
12490 struct packet_nuke_tile_info packet, *real_packet = &packet;
12491
12492 real_packet->tile = tile;
12493
12494 return send_packet_nuke_tile_info(pc, real_packet);
12495}
12496
12497 void dlsend_packet_nuke_tile_info(struct conn_list *dest, int tile)
12498{
12499 struct packet_nuke_tile_info packet, *real_packet = &packet;
12500
12501 real_packet->tile = tile;
12502
12503 lsend_packet_nuke_tile_info(dest, real_packet);
12504}
12505
12506 static inline void init_packet_team_name_info(struct packet_team_name_info *packet)
12507{
12508 memset(packet, 0, sizeof(*packet));
12509}
12510
12511#define free_packet_team_name_info(_packet) (void) 0
12512#define destroy_packet_team_name_info free
12513
12514#ifdef FREECIV_DELTA_PROTOCOL
12515static genhash_val_t hash_packet_team_name_info_100(const void *vkey)
12516{
12517 const struct packet_team_name_info *key = (const struct packet_team_name_info *) vkey;
12518 genhash_val_t result = 0;
12519
12520 result += key->team_id;
12521
12522 result &= 0xFFFFFFFF;
12523 return result;
12524}
12525
12526static bool cmp_packet_team_name_info_100(const void *vkey1, const void *vkey2)
12527{
12528 const struct packet_team_name_info *old = (const struct packet_team_name_info *) vkey1;
12529 const struct packet_team_name_info *real_packet = (const struct packet_team_name_info *) vkey2;
12530 bool differ;
12531
12532 differ = (old->team_id != real_packet->team_id);
12533
12534 return !differ;
12535}
12536 BV_DEFINE(packet_team_name_info_100_fields, 1);
12537#endif /* FREECIV_DELTA_PROTOCOL */
12538
12539 static struct packet_team_name_info *receive_packet_team_name_info_100(struct connection *pc)
12540{
12541#define FREE_PACKET_STRUCT(_packet) free_packet_team_name_info(_packet)
12542 RECEIVE_PACKET_START(packet_team_name_info, real_packet);
12543
12544#ifdef FREECIV_JSON_CONNECTION
12545 struct plocation field_addr;
12546 {
12547 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12548 field_addr = *field_addr_tmp;
12549 FC_FREE(field_addr_tmp);
12550 }
12551#endif /* FREECIV_JSON_CONNECTION */
12552
12553#ifdef FREECIV_JSON_CONNECTION
12554 field_addr.name = "team_id";
12555#endif /* FREECIV_JSON_CONNECTION */
12556
12557 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->team_id)) {
12558 RECEIVE_PACKET_FIELD_ERROR(team_id);
12559 }
12560
12561 log_packet_detailed("packet_team_name_info_100: got info about (%d)",
12562 real_packet->team_id);
12563
12564#ifdef FREECIV_DELTA_PROTOCOL
12565 packet_team_name_info_100_fields fields;
12566 struct packet_team_name_info *old;
12567 struct genhash **hash = pc->phs.received + PACKET_TEAM_NAME_INFO;
12568
12569 if (nullptr == *hash) {
12570 *hash = genhash_new_full(hash_packet_team_name_info_100, cmp_packet_team_name_info_100,
12571 nullptr, nullptr, nullptr, destroy_packet_team_name_info);
12572 }
12573
12574 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12575 *real_packet = *old;
12576 } else {
12577 /* packet is already initialized empty */
12578 log_packet_detailed(" no old info");
12579 }
12580
12581#ifdef FREECIV_JSON_CONNECTION
12582 field_addr.name = "fields";
12583#endif /* FREECIV_JSON_CONNECTION */
12584 DIO_BV_GET(&din, &field_addr, fields);
12585
12586 if (BV_ISSET(fields, 0)) {
12587 log_packet_detailed(" got field 'team_name'");
12588
12589#ifdef FREECIV_JSON_CONNECTION
12590 field_addr.name = "team_name";
12591#endif /* FREECIV_JSON_CONNECTION */
12592
12593 if (!DIO_GET(string, &din, &field_addr, real_packet->team_name, sizeof(real_packet->team_name))) {
12594 RECEIVE_PACKET_FIELD_ERROR(team_name);
12595 }
12596 }
12597
12598 if (nullptr == old) {
12599 old = fc_malloc(sizeof(*old));
12600 init_packet_team_name_info(old);
12601 *old = *real_packet;
12602 genhash_insert(*hash, old, old);
12603 } else {
12604 *old = *real_packet;
12605 }
12606
12607#else /* FREECIV_DELTA_PROTOCOL */
12608#ifdef FREECIV_JSON_CONNECTION
12609 field_addr.name = "team_name";
12610#endif /* FREECIV_JSON_CONNECTION */
12611
12612 if (!DIO_GET(string, &din, &field_addr, real_packet->team_name, sizeof(real_packet->team_name))) {
12613 RECEIVE_PACKET_FIELD_ERROR(team_name);
12614 }
12615#endif /* FREECIV_DELTA_PROTOCOL */
12616
12617 RECEIVE_PACKET_END(real_packet);
12618#undef FREE_PACKET_STRUCT
12619}
12620
12621 static int send_packet_team_name_info_100(struct connection *pc, const struct packet_team_name_info *packet)
12622{
12623 const struct packet_team_name_info *real_packet = packet;
12624 int e;
12625 SEND_PACKET_START(PACKET_TEAM_NAME_INFO);
12626
12627 log_packet_detailed("packet_team_name_info_100: sending info about (%d)",
12628 real_packet->team_id);
12629
12630#ifdef FREECIV_DELTA_PROTOCOL
12631 packet_team_name_info_100_fields fields;
12632 struct packet_team_name_info *old;
12633 bool differ;
12634 struct genhash **hash = pc->phs.sent + PACKET_TEAM_NAME_INFO;
12635
12636 if (nullptr == *hash) {
12637 *hash = genhash_new_full(hash_packet_team_name_info_100, cmp_packet_team_name_info_100,
12638 nullptr, nullptr, nullptr, destroy_packet_team_name_info);
12639 }
12640 BV_CLR_ALL(fields);
12641
12642 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12643 old = fc_malloc(sizeof(*old));
12644 /* temporary bitcopy just to insert correctly */
12645 *old = *real_packet;
12646 genhash_insert(*hash, old, old);
12647 init_packet_team_name_info(old);
12648 }
12649
12650 differ = (strcmp(old->team_name, real_packet->team_name) != 0);
12651 if (differ) {
12652 BV_SET(fields, 0);
12653 }
12654#endif /* FREECIV_DELTA_PROTOCOL */
12655
12656#ifdef FREECIV_JSON_CONNECTION
12657 struct plocation field_addr;
12658 {
12659 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12660 field_addr = *field_addr_tmp;
12661 FC_FREE(field_addr_tmp);
12662 }
12663#endif /* FREECIV_JSON_CONNECTION */
12664
12665#ifdef FREECIV_JSON_CONNECTION
12666 field_addr.name = "team_id";
12667#endif /* FREECIV_JSON_CONNECTION */
12668 e = 0;
12669
12670 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->team_id);
12671
12672 if (e) {
12673 log_packet_detailed("'team_id' field error detected");
12674 }
12675
12676#ifdef FREECIV_DELTA_PROTOCOL
12677#ifdef FREECIV_JSON_CONNECTION
12678 field_addr.name = "fields";
12679#endif /* FREECIV_JSON_CONNECTION */
12680 e = 0;
12681 e |= DIO_BV_PUT(&dout, &field_addr, fields);
12682 if (e) {
12683 log_packet_detailed("fields bitvector error detected");
12684 }
12685
12686 if (BV_ISSET(fields, 0)) {
12687 log_packet_detailed(" field 'team_name' has changed");
12688
12689#ifdef FREECIV_JSON_CONNECTION
12690 field_addr.name = "team_name";
12691#endif /* FREECIV_JSON_CONNECTION */
12692 e = 0;
12693
12694 e |= DIO_PUT(string, &dout, &field_addr, real_packet->team_name);
12695
12696 if (e) {
12697 log_packet_detailed("'team_name' field error detected");
12698 }
12699 }
12700
12701 *old = *real_packet;
12702
12703#else /* FREECIV_DELTA_PROTOCOL */
12704#ifdef FREECIV_JSON_CONNECTION
12705 field_addr.name = "team_name";
12706#endif /* FREECIV_JSON_CONNECTION */
12707 e = 0;
12708
12709 e |= DIO_PUT(string, &dout, &field_addr, real_packet->team_name);
12710
12711 if (e) {
12712 log_packet_detailed("'team_name' field error detected");
12713 }
12714#endif /* FREECIV_DELTA_PROTOCOL */
12715
12716 SEND_PACKET_END(PACKET_TEAM_NAME_INFO);
12717}
12718
12719 int send_packet_team_name_info(struct connection *pc, const struct packet_team_name_info *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_TEAM_NAME_INFO].packet != nullptr, -1,
12727 "Handler for PACKET_TEAM_NAME_INFO not installed");
12728 return pc->phs.handlers->send[PACKET_TEAM_NAME_INFO].packet(pc, packet);
12729}
12730
12731 void lsend_packet_team_name_info(struct conn_list *dest, const struct packet_team_name_info *packet)
12732{
12733 conn_list_iterate(dest, pconn) {
12734 send_packet_team_name_info(pconn, packet);
12735 } conn_list_iterate_end;
12736}
12737
12738 static inline void init_packet_achievement_info(struct packet_achievement_info *packet)
12739{
12740 memset(packet, 0, sizeof(*packet));
12741}
12742
12743#define free_packet_achievement_info(_packet) (void) 0
12744#define destroy_packet_achievement_info free
12745
12746#ifdef FREECIV_DELTA_PROTOCOL
12747#define hash_packet_achievement_info_100 hash_const
12748#define cmp_packet_achievement_info_100 cmp_const
12749 BV_DEFINE(packet_achievement_info_100_fields, 3);
12750#endif /* FREECIV_DELTA_PROTOCOL */
12751
12752 static struct packet_achievement_info *receive_packet_achievement_info_100(struct connection *pc)
12753{
12754#define FREE_PACKET_STRUCT(_packet) free_packet_achievement_info(_packet)
12755 RECEIVE_PACKET_START(packet_achievement_info, real_packet);
12756
12757#ifdef FREECIV_JSON_CONNECTION
12758 struct plocation field_addr;
12759 {
12760 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12761 field_addr = *field_addr_tmp;
12762 FC_FREE(field_addr_tmp);
12763 }
12764#endif /* FREECIV_JSON_CONNECTION */
12765
12766 log_packet_detailed("packet_achievement_info_100: got info about ()");
12767
12768#ifdef FREECIV_DELTA_PROTOCOL
12769 packet_achievement_info_100_fields fields;
12770 struct packet_achievement_info *old;
12771 struct genhash **hash = pc->phs.received + PACKET_ACHIEVEMENT_INFO;
12772
12773 if (nullptr == *hash) {
12774 *hash = genhash_new_full(hash_packet_achievement_info_100, cmp_packet_achievement_info_100,
12775 nullptr, nullptr, nullptr, destroy_packet_achievement_info);
12776 }
12777
12778 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
12779 *real_packet = *old;
12780 } else {
12781 /* packet is already initialized empty */
12782 log_packet_detailed(" no old info");
12783 }
12784
12785#ifdef FREECIV_JSON_CONNECTION
12786 field_addr.name = "fields";
12787#endif /* FREECIV_JSON_CONNECTION */
12788 DIO_BV_GET(&din, &field_addr, fields);
12789
12790 if (BV_ISSET(fields, 0)) {
12791 log_packet_detailed(" got field 'id'");
12792
12793#ifdef FREECIV_JSON_CONNECTION
12794 field_addr.name = "id";
12795#endif /* FREECIV_JSON_CONNECTION */
12796
12797 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
12798 RECEIVE_PACKET_FIELD_ERROR(id);
12799 }
12800 }
12801
12802 real_packet->gained = BV_ISSET(fields, 1);
12803
12804 real_packet->first = BV_ISSET(fields, 2);
12805
12806 if (nullptr == old) {
12807 old = fc_malloc(sizeof(*old));
12808 init_packet_achievement_info(old);
12809 *old = *real_packet;
12810 genhash_insert(*hash, old, old);
12811 } else {
12812 *old = *real_packet;
12813 }
12814
12815#else /* FREECIV_DELTA_PROTOCOL */
12816#ifdef FREECIV_JSON_CONNECTION
12817 field_addr.name = "id";
12818#endif /* FREECIV_JSON_CONNECTION */
12819
12820 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
12821 RECEIVE_PACKET_FIELD_ERROR(id);
12822 }
12823
12824#ifdef FREECIV_JSON_CONNECTION
12825 field_addr.name = "gained";
12826#endif /* FREECIV_JSON_CONNECTION */
12827
12828 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->gained)) {
12829 RECEIVE_PACKET_FIELD_ERROR(gained);
12830 }
12831
12832#ifdef FREECIV_JSON_CONNECTION
12833 field_addr.name = "first";
12834#endif /* FREECIV_JSON_CONNECTION */
12835
12836 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->first)) {
12837 RECEIVE_PACKET_FIELD_ERROR(first);
12838 }
12839#endif /* FREECIV_DELTA_PROTOCOL */
12840
12841 RECEIVE_PACKET_END(real_packet);
12842#undef FREE_PACKET_STRUCT
12843}
12844
12845 static int send_packet_achievement_info_100(struct connection *pc, const struct packet_achievement_info *packet)
12846{
12847 const struct packet_achievement_info *real_packet = packet;
12848 int e;
12849 SEND_PACKET_START(PACKET_ACHIEVEMENT_INFO);
12850
12851 log_packet_detailed("packet_achievement_info_100: sending info about ()");
12852
12853#ifdef FREECIV_DELTA_PROTOCOL
12854 packet_achievement_info_100_fields fields;
12855 struct packet_achievement_info *old;
12856 bool differ;
12857 struct genhash **hash = pc->phs.sent + PACKET_ACHIEVEMENT_INFO;
12858
12859 if (nullptr == *hash) {
12860 *hash = genhash_new_full(hash_packet_achievement_info_100, cmp_packet_achievement_info_100,
12861 nullptr, nullptr, nullptr, destroy_packet_achievement_info);
12862 }
12863 BV_CLR_ALL(fields);
12864
12865 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
12866 old = fc_malloc(sizeof(*old));
12867 /* temporary bitcopy just to insert correctly */
12868 *old = *real_packet;
12869 genhash_insert(*hash, old, old);
12870 init_packet_achievement_info(old);
12871 }
12872
12873 differ = (old->id != real_packet->id);
12874 if (differ) {
12875 BV_SET(fields, 0);
12876 }
12877
12878 /* folded into head */
12879 if (real_packet->gained) {
12880 BV_SET(fields, 1);
12881 }
12882
12883 /* folded into head */
12884 if (real_packet->first) {
12885 BV_SET(fields, 2);
12886 }
12887#endif /* FREECIV_DELTA_PROTOCOL */
12888
12889#ifdef FREECIV_JSON_CONNECTION
12890 struct plocation field_addr;
12891 {
12892 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
12893 field_addr = *field_addr_tmp;
12894 FC_FREE(field_addr_tmp);
12895 }
12896#endif /* FREECIV_JSON_CONNECTION */
12897
12898#ifdef FREECIV_DELTA_PROTOCOL
12899#ifdef FREECIV_JSON_CONNECTION
12900 field_addr.name = "fields";
12901#endif /* FREECIV_JSON_CONNECTION */
12902 e = 0;
12903 e |= DIO_BV_PUT(&dout, &field_addr, fields);
12904 if (e) {
12905 log_packet_detailed("fields bitvector error detected");
12906 }
12907
12908 if (BV_ISSET(fields, 0)) {
12909 log_packet_detailed(" field 'id' has changed");
12910
12911#ifdef FREECIV_JSON_CONNECTION
12912 field_addr.name = "id";
12913#endif /* FREECIV_JSON_CONNECTION */
12914 e = 0;
12915
12916 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
12917
12918 if (e) {
12919 log_packet_detailed("'id' field error detected");
12920 }
12921 }
12922
12923 /* field 1 is folded into the header */
12924
12925 /* field 2 is folded into the header */
12926
12927 *old = *real_packet;
12928
12929#else /* FREECIV_DELTA_PROTOCOL */
12930#ifdef FREECIV_JSON_CONNECTION
12931 field_addr.name = "id";
12932#endif /* FREECIV_JSON_CONNECTION */
12933 e = 0;
12934
12935 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
12936
12937 if (e) {
12938 log_packet_detailed("'id' field error detected");
12939 }
12940
12941#ifdef FREECIV_JSON_CONNECTION
12942 field_addr.name = "gained";
12943#endif /* FREECIV_JSON_CONNECTION */
12944 e = 0;
12945
12946 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->gained);
12947
12948 if (e) {
12949 log_packet_detailed("'gained' field error detected");
12950 }
12951
12952#ifdef FREECIV_JSON_CONNECTION
12953 field_addr.name = "first";
12954#endif /* FREECIV_JSON_CONNECTION */
12955 e = 0;
12956
12957 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->first);
12958
12959 if (e) {
12960 log_packet_detailed("'first' field error detected");
12961 }
12962#endif /* FREECIV_DELTA_PROTOCOL */
12963
12964 SEND_PACKET_END(PACKET_ACHIEVEMENT_INFO);
12965}
12966
12967 int send_packet_achievement_info(struct connection *pc, const struct packet_achievement_info *packet)
12968{
12969 if (!pc->used) {
12970 log_error("WARNING: trying to send data to the closed connection %s",
12971 conn_description(pc));
12972 return -1;
12973 }
12974 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_ACHIEVEMENT_INFO].packet != nullptr, -1,
12975 "Handler for PACKET_ACHIEVEMENT_INFO not installed");
12976 return pc->phs.handlers->send[PACKET_ACHIEVEMENT_INFO].packet(pc, packet);
12977}
12978
12979 void lsend_packet_achievement_info(struct conn_list *dest, const struct packet_achievement_info *packet)
12980{
12981 conn_list_iterate(dest, pconn) {
12982 send_packet_achievement_info(pconn, packet);
12983 } conn_list_iterate_end;
12984}
12985
12986 static inline void init_packet_chat_msg(struct packet_chat_msg *packet)
12987{
12988 memset(packet, 0, sizeof(*packet));
12989}
12990
12991#define free_packet_chat_msg(_packet) (void) 0
12992#define destroy_packet_chat_msg free
12993
12994#ifdef FREECIV_DELTA_PROTOCOL
12995#define hash_packet_chat_msg_100 hash_const
12996#define cmp_packet_chat_msg_100 cmp_const
12997 BV_DEFINE(packet_chat_msg_100_fields, 6);
12998#endif /* FREECIV_DELTA_PROTOCOL */
12999
13000 static struct packet_chat_msg *receive_packet_chat_msg_100(struct connection *pc)
13001{
13002#define FREE_PACKET_STRUCT(_packet) free_packet_chat_msg(_packet)
13003 RECEIVE_PACKET_START(packet_chat_msg, real_packet);
13004
13005#ifdef FREECIV_JSON_CONNECTION
13006 struct plocation field_addr;
13007 {
13008 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
13009 field_addr = *field_addr_tmp;
13010 FC_FREE(field_addr_tmp);
13011 }
13012#endif /* FREECIV_JSON_CONNECTION */
13013
13014 log_packet_detailed("packet_chat_msg_100: got info about ()");
13015
13016#ifdef FREECIV_DELTA_PROTOCOL
13017 packet_chat_msg_100_fields fields;
13018 struct packet_chat_msg *old;
13019 struct genhash **hash = pc->phs.received + PACKET_CHAT_MSG;
13020
13021 if (nullptr == *hash) {
13022 *hash = genhash_new_full(hash_packet_chat_msg_100, cmp_packet_chat_msg_100,
13023 nullptr, nullptr, nullptr, destroy_packet_chat_msg);
13024 }
13025
13026 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13027 *real_packet = *old;
13028 } else {
13029 /* packet is already initialized empty */
13030 log_packet_detailed(" no old info");
13031 }
13032
13033#ifdef FREECIV_JSON_CONNECTION
13034 field_addr.name = "fields";
13035#endif /* FREECIV_JSON_CONNECTION */
13036 DIO_BV_GET(&din, &field_addr, fields);
13037
13038 if (BV_ISSET(fields, 0)) {
13039 log_packet_detailed(" got field 'message'");
13040
13041#ifdef FREECIV_JSON_CONNECTION
13042 field_addr.name = "message";
13043#endif /* FREECIV_JSON_CONNECTION */
13044
13045 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
13046 RECEIVE_PACKET_FIELD_ERROR(message);
13047 }
13048 }
13049
13050 if (BV_ISSET(fields, 1)) {
13051 log_packet_detailed(" got field 'tile'");
13052
13053#ifdef FREECIV_JSON_CONNECTION
13054 field_addr.name = "tile";
13055#endif /* FREECIV_JSON_CONNECTION */
13056
13057 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
13058 RECEIVE_PACKET_FIELD_ERROR(tile);
13059 }
13060 }
13061
13062 if (BV_ISSET(fields, 2)) {
13063 log_packet_detailed(" got field 'event'");
13064
13065#ifdef FREECIV_JSON_CONNECTION
13066 field_addr.name = "event";
13067#endif /* FREECIV_JSON_CONNECTION */
13068
13069 {
13070 int readin;
13071
13072 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
13073 RECEIVE_PACKET_FIELD_ERROR(event);
13074 }
13075 real_packet->event = readin;
13076 }
13077 }
13078
13079 if (BV_ISSET(fields, 3)) {
13080 log_packet_detailed(" got field 'turn'");
13081
13082#ifdef FREECIV_JSON_CONNECTION
13083 field_addr.name = "turn";
13084#endif /* FREECIV_JSON_CONNECTION */
13085
13086 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
13087 RECEIVE_PACKET_FIELD_ERROR(turn);
13088 }
13089 }
13090
13091 if (BV_ISSET(fields, 4)) {
13092 log_packet_detailed(" got field 'phase'");
13093
13094#ifdef FREECIV_JSON_CONNECTION
13095 field_addr.name = "phase";
13096#endif /* FREECIV_JSON_CONNECTION */
13097
13098 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
13099 RECEIVE_PACKET_FIELD_ERROR(phase);
13100 }
13101 }
13102
13103 if (BV_ISSET(fields, 5)) {
13104 log_packet_detailed(" got field 'conn_id'");
13105
13106#ifdef FREECIV_JSON_CONNECTION
13107 field_addr.name = "conn_id";
13108#endif /* FREECIV_JSON_CONNECTION */
13109
13110 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id)) {
13111 RECEIVE_PACKET_FIELD_ERROR(conn_id);
13112 }
13113 }
13114
13115 if (nullptr == old) {
13116 old = fc_malloc(sizeof(*old));
13117 init_packet_chat_msg(old);
13118 *old = *real_packet;
13119 genhash_insert(*hash, old, old);
13120 } else {
13121 *old = *real_packet;
13122 }
13123
13124#else /* FREECIV_DELTA_PROTOCOL */
13125#ifdef FREECIV_JSON_CONNECTION
13126 field_addr.name = "message";
13127#endif /* FREECIV_JSON_CONNECTION */
13128
13129 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
13130 RECEIVE_PACKET_FIELD_ERROR(message);
13131 }
13132
13133#ifdef FREECIV_JSON_CONNECTION
13134 field_addr.name = "tile";
13135#endif /* FREECIV_JSON_CONNECTION */
13136
13137 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
13138 RECEIVE_PACKET_FIELD_ERROR(tile);
13139 }
13140
13141#ifdef FREECIV_JSON_CONNECTION
13142 field_addr.name = "event";
13143#endif /* FREECIV_JSON_CONNECTION */
13144
13145 {
13146 int readin;
13147
13148 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
13149 RECEIVE_PACKET_FIELD_ERROR(event);
13150 }
13151 real_packet->event = readin;
13152 }
13153
13154#ifdef FREECIV_JSON_CONNECTION
13155 field_addr.name = "turn";
13156#endif /* FREECIV_JSON_CONNECTION */
13157
13158 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
13159 RECEIVE_PACKET_FIELD_ERROR(turn);
13160 }
13161
13162#ifdef FREECIV_JSON_CONNECTION
13163 field_addr.name = "phase";
13164#endif /* FREECIV_JSON_CONNECTION */
13165
13166 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
13167 RECEIVE_PACKET_FIELD_ERROR(phase);
13168 }
13169
13170#ifdef FREECIV_JSON_CONNECTION
13171 field_addr.name = "conn_id";
13172#endif /* FREECIV_JSON_CONNECTION */
13173
13174 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id)) {
13175 RECEIVE_PACKET_FIELD_ERROR(conn_id);
13176 }
13177#endif /* FREECIV_DELTA_PROTOCOL */
13178
13179 RECEIVE_PACKET_END(real_packet);
13180#undef FREE_PACKET_STRUCT
13181}
13182
13183 static int send_packet_chat_msg_100(struct connection *pc, const struct packet_chat_msg *packet)
13184{
13185 const struct packet_chat_msg *real_packet = packet;
13186 int e;
13187 SEND_PACKET_START(PACKET_CHAT_MSG);
13188
13189 log_packet_detailed("packet_chat_msg_100: sending info about ()");
13190
13191#ifdef FREECIV_DELTA_PROTOCOL
13192 packet_chat_msg_100_fields fields;
13193 struct packet_chat_msg *old;
13194 bool differ;
13195 struct genhash **hash = pc->phs.sent + PACKET_CHAT_MSG;
13196
13197 if (nullptr == *hash) {
13198 *hash = genhash_new_full(hash_packet_chat_msg_100, cmp_packet_chat_msg_100,
13199 nullptr, nullptr, nullptr, destroy_packet_chat_msg);
13200 }
13201 BV_CLR_ALL(fields);
13202
13203 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13204 old = fc_malloc(sizeof(*old));
13205 /* temporary bitcopy just to insert correctly */
13206 *old = *real_packet;
13207 genhash_insert(*hash, old, old);
13208 init_packet_chat_msg(old);
13209 }
13210
13211 differ = (strcmp(old->message, real_packet->message) != 0);
13212 if (differ) {
13213 BV_SET(fields, 0);
13214 }
13215
13216 differ = (old->tile != real_packet->tile);
13217 if (differ) {
13218 BV_SET(fields, 1);
13219 }
13220
13221 differ = (old->event != real_packet->event);
13222 if (differ) {
13223 BV_SET(fields, 2);
13224 }
13225
13226 differ = (old->turn != real_packet->turn);
13227 if (differ) {
13228 BV_SET(fields, 3);
13229 }
13230
13231 differ = (old->phase != real_packet->phase);
13232 if (differ) {
13233 BV_SET(fields, 4);
13234 }
13235
13236 differ = (old->conn_id != real_packet->conn_id);
13237 if (differ) {
13238 BV_SET(fields, 5);
13239 }
13240#endif /* FREECIV_DELTA_PROTOCOL */
13241
13242#ifdef FREECIV_JSON_CONNECTION
13243 struct plocation field_addr;
13244 {
13245 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
13246 field_addr = *field_addr_tmp;
13247 FC_FREE(field_addr_tmp);
13248 }
13249#endif /* FREECIV_JSON_CONNECTION */
13250
13251#ifdef FREECIV_DELTA_PROTOCOL
13252#ifdef FREECIV_JSON_CONNECTION
13253 field_addr.name = "fields";
13254#endif /* FREECIV_JSON_CONNECTION */
13255 e = 0;
13256 e |= DIO_BV_PUT(&dout, &field_addr, fields);
13257 if (e) {
13258 log_packet_detailed("fields bitvector error detected");
13259 }
13260
13261 if (BV_ISSET(fields, 0)) {
13262 log_packet_detailed(" field 'message' has changed");
13263
13264#ifdef FREECIV_JSON_CONNECTION
13265 field_addr.name = "message";
13266#endif /* FREECIV_JSON_CONNECTION */
13267 e = 0;
13268
13269 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
13270
13271 if (e) {
13272 log_packet_detailed("'message' field error detected");
13273 }
13274 }
13275
13276 if (BV_ISSET(fields, 1)) {
13277 log_packet_detailed(" field 'tile' has changed");
13278
13279#ifdef FREECIV_JSON_CONNECTION
13280 field_addr.name = "tile";
13281#endif /* FREECIV_JSON_CONNECTION */
13282 e = 0;
13283
13284 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
13285
13286 if (e) {
13287 log_packet_detailed("'tile' field error detected");
13288 }
13289 }
13290
13291 if (BV_ISSET(fields, 2)) {
13292 log_packet_detailed(" field 'event' has changed");
13293
13294#ifdef FREECIV_JSON_CONNECTION
13295 field_addr.name = "event";
13296#endif /* FREECIV_JSON_CONNECTION */
13297 e = 0;
13298
13299 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->event);
13300
13301 if (e) {
13302 log_packet_detailed("'event' field error detected");
13303 }
13304 }
13305
13306 if (BV_ISSET(fields, 3)) {
13307 log_packet_detailed(" field 'turn' has changed");
13308
13309#ifdef FREECIV_JSON_CONNECTION
13310 field_addr.name = "turn";
13311#endif /* FREECIV_JSON_CONNECTION */
13312 e = 0;
13313
13314 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
13315
13316 if (e) {
13317 log_packet_detailed("'turn' field error detected");
13318 }
13319 }
13320
13321 if (BV_ISSET(fields, 4)) {
13322 log_packet_detailed(" field 'phase' has changed");
13323
13324#ifdef FREECIV_JSON_CONNECTION
13325 field_addr.name = "phase";
13326#endif /* FREECIV_JSON_CONNECTION */
13327 e = 0;
13328
13329 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
13330
13331 if (e) {
13332 log_packet_detailed("'phase' field error detected");
13333 }
13334 }
13335
13336 if (BV_ISSET(fields, 5)) {
13337 log_packet_detailed(" field 'conn_id' has changed");
13338
13339#ifdef FREECIV_JSON_CONNECTION
13340 field_addr.name = "conn_id";
13341#endif /* FREECIV_JSON_CONNECTION */
13342 e = 0;
13343
13344 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id);
13345
13346 if (e) {
13347 log_packet_detailed("'conn_id' field error detected");
13348 }
13349 }
13350
13351 *old = *real_packet;
13352
13353#else /* FREECIV_DELTA_PROTOCOL */
13354#ifdef FREECIV_JSON_CONNECTION
13355 field_addr.name = "message";
13356#endif /* FREECIV_JSON_CONNECTION */
13357 e = 0;
13358
13359 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
13360
13361 if (e) {
13362 log_packet_detailed("'message' field error detected");
13363 }
13364
13365#ifdef FREECIV_JSON_CONNECTION
13366 field_addr.name = "tile";
13367#endif /* FREECIV_JSON_CONNECTION */
13368 e = 0;
13369
13370 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
13371
13372 if (e) {
13373 log_packet_detailed("'tile' field error detected");
13374 }
13375
13376#ifdef FREECIV_JSON_CONNECTION
13377 field_addr.name = "event";
13378#endif /* FREECIV_JSON_CONNECTION */
13379 e = 0;
13380
13381 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->event);
13382
13383 if (e) {
13384 log_packet_detailed("'event' field error detected");
13385 }
13386
13387#ifdef FREECIV_JSON_CONNECTION
13388 field_addr.name = "turn";
13389#endif /* FREECIV_JSON_CONNECTION */
13390 e = 0;
13391
13392 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
13393
13394 if (e) {
13395 log_packet_detailed("'turn' field error detected");
13396 }
13397
13398#ifdef FREECIV_JSON_CONNECTION
13399 field_addr.name = "phase";
13400#endif /* FREECIV_JSON_CONNECTION */
13401 e = 0;
13402
13403 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
13404
13405 if (e) {
13406 log_packet_detailed("'phase' field error detected");
13407 }
13408
13409#ifdef FREECIV_JSON_CONNECTION
13410 field_addr.name = "conn_id";
13411#endif /* FREECIV_JSON_CONNECTION */
13412 e = 0;
13413
13414 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id);
13415
13416 if (e) {
13417 log_packet_detailed("'conn_id' field error detected");
13418 }
13419#endif /* FREECIV_DELTA_PROTOCOL */
13420
13421 SEND_PACKET_END(PACKET_CHAT_MSG);
13422}
13423
13424 int send_packet_chat_msg(struct connection *pc, const struct packet_chat_msg *packet)
13425{
13426 if (!pc->used) {
13427 log_error("WARNING: trying to send data to the closed connection %s",
13428 conn_description(pc));
13429 return -1;
13430 }
13431 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CHAT_MSG].packet != nullptr, -1,
13432 "Handler for PACKET_CHAT_MSG not installed");
13433 return pc->phs.handlers->send[PACKET_CHAT_MSG].packet(pc, packet);
13434}
13435
13436 void lsend_packet_chat_msg(struct conn_list *dest, const struct packet_chat_msg *packet)
13437{
13438 conn_list_iterate(dest, pconn) {
13439 send_packet_chat_msg(pconn, packet);
13440 } conn_list_iterate_end;
13441}
13442
13443 static inline void init_packet_early_chat_msg(struct packet_early_chat_msg *packet)
13444{
13445 memset(packet, 0, sizeof(*packet));
13446}
13447
13448#define free_packet_early_chat_msg(_packet) (void) 0
13449#define destroy_packet_early_chat_msg free
13450
13451#ifdef FREECIV_DELTA_PROTOCOL
13452#define hash_packet_early_chat_msg_100 hash_const
13453#define cmp_packet_early_chat_msg_100 cmp_const
13454 BV_DEFINE(packet_early_chat_msg_100_fields, 6);
13455#endif /* FREECIV_DELTA_PROTOCOL */
13456
13457 static struct packet_early_chat_msg *receive_packet_early_chat_msg_100(struct connection *pc)
13458{
13459#define FREE_PACKET_STRUCT(_packet) free_packet_early_chat_msg(_packet)
13460 RECEIVE_PACKET_START(packet_early_chat_msg, real_packet);
13461
13462#ifdef FREECIV_JSON_CONNECTION
13463 struct plocation field_addr;
13464 {
13465 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
13466 field_addr = *field_addr_tmp;
13467 FC_FREE(field_addr_tmp);
13468 }
13469#endif /* FREECIV_JSON_CONNECTION */
13470
13471 log_packet_detailed("packet_early_chat_msg_100: got info about ()");
13472
13473#ifdef FREECIV_DELTA_PROTOCOL
13474 packet_early_chat_msg_100_fields fields;
13475 struct packet_early_chat_msg *old;
13476 struct genhash **hash = pc->phs.received + PACKET_EARLY_CHAT_MSG;
13477
13478 if (nullptr == *hash) {
13479 *hash = genhash_new_full(hash_packet_early_chat_msg_100, cmp_packet_early_chat_msg_100,
13480 nullptr, nullptr, nullptr, destroy_packet_early_chat_msg);
13481 }
13482
13483 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13484 *real_packet = *old;
13485 } else {
13486 /* packet is already initialized empty */
13487 log_packet_detailed(" no old info");
13488 }
13489
13490#ifdef FREECIV_JSON_CONNECTION
13491 field_addr.name = "fields";
13492#endif /* FREECIV_JSON_CONNECTION */
13493 DIO_BV_GET(&din, &field_addr, fields);
13494
13495 if (BV_ISSET(fields, 0)) {
13496 log_packet_detailed(" got field 'message'");
13497
13498#ifdef FREECIV_JSON_CONNECTION
13499 field_addr.name = "message";
13500#endif /* FREECIV_JSON_CONNECTION */
13501
13502 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
13503 RECEIVE_PACKET_FIELD_ERROR(message);
13504 }
13505 }
13506
13507 if (BV_ISSET(fields, 1)) {
13508 log_packet_detailed(" got field 'tile'");
13509
13510#ifdef FREECIV_JSON_CONNECTION
13511 field_addr.name = "tile";
13512#endif /* FREECIV_JSON_CONNECTION */
13513
13514 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
13515 RECEIVE_PACKET_FIELD_ERROR(tile);
13516 }
13517 }
13518
13519 if (BV_ISSET(fields, 2)) {
13520 log_packet_detailed(" got field 'event'");
13521
13522#ifdef FREECIV_JSON_CONNECTION
13523 field_addr.name = "event";
13524#endif /* FREECIV_JSON_CONNECTION */
13525
13526 {
13527 int readin;
13528
13529 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
13530 RECEIVE_PACKET_FIELD_ERROR(event);
13531 }
13532 real_packet->event = readin;
13533 }
13534 }
13535
13536 if (BV_ISSET(fields, 3)) {
13537 log_packet_detailed(" got field 'turn'");
13538
13539#ifdef FREECIV_JSON_CONNECTION
13540 field_addr.name = "turn";
13541#endif /* FREECIV_JSON_CONNECTION */
13542
13543 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
13544 RECEIVE_PACKET_FIELD_ERROR(turn);
13545 }
13546 }
13547
13548 if (BV_ISSET(fields, 4)) {
13549 log_packet_detailed(" got field 'phase'");
13550
13551#ifdef FREECIV_JSON_CONNECTION
13552 field_addr.name = "phase";
13553#endif /* FREECIV_JSON_CONNECTION */
13554
13555 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
13556 RECEIVE_PACKET_FIELD_ERROR(phase);
13557 }
13558 }
13559
13560 if (BV_ISSET(fields, 5)) {
13561 log_packet_detailed(" got field 'conn_id'");
13562
13563#ifdef FREECIV_JSON_CONNECTION
13564 field_addr.name = "conn_id";
13565#endif /* FREECIV_JSON_CONNECTION */
13566
13567 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id)) {
13568 RECEIVE_PACKET_FIELD_ERROR(conn_id);
13569 }
13570 }
13571
13572 if (nullptr == old) {
13573 old = fc_malloc(sizeof(*old));
13574 init_packet_early_chat_msg(old);
13575 *old = *real_packet;
13576 genhash_insert(*hash, old, old);
13577 } else {
13578 *old = *real_packet;
13579 }
13580
13581#else /* FREECIV_DELTA_PROTOCOL */
13582#ifdef FREECIV_JSON_CONNECTION
13583 field_addr.name = "message";
13584#endif /* FREECIV_JSON_CONNECTION */
13585
13586 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
13587 RECEIVE_PACKET_FIELD_ERROR(message);
13588 }
13589
13590#ifdef FREECIV_JSON_CONNECTION
13591 field_addr.name = "tile";
13592#endif /* FREECIV_JSON_CONNECTION */
13593
13594 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
13595 RECEIVE_PACKET_FIELD_ERROR(tile);
13596 }
13597
13598#ifdef FREECIV_JSON_CONNECTION
13599 field_addr.name = "event";
13600#endif /* FREECIV_JSON_CONNECTION */
13601
13602 {
13603 int readin;
13604
13605 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
13606 RECEIVE_PACKET_FIELD_ERROR(event);
13607 }
13608 real_packet->event = readin;
13609 }
13610
13611#ifdef FREECIV_JSON_CONNECTION
13612 field_addr.name = "turn";
13613#endif /* FREECIV_JSON_CONNECTION */
13614
13615 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
13616 RECEIVE_PACKET_FIELD_ERROR(turn);
13617 }
13618
13619#ifdef FREECIV_JSON_CONNECTION
13620 field_addr.name = "phase";
13621#endif /* FREECIV_JSON_CONNECTION */
13622
13623 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
13624 RECEIVE_PACKET_FIELD_ERROR(phase);
13625 }
13626
13627#ifdef FREECIV_JSON_CONNECTION
13628 field_addr.name = "conn_id";
13629#endif /* FREECIV_JSON_CONNECTION */
13630
13631 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id)) {
13632 RECEIVE_PACKET_FIELD_ERROR(conn_id);
13633 }
13634#endif /* FREECIV_DELTA_PROTOCOL */
13635
13636 RECEIVE_PACKET_END(real_packet);
13637#undef FREE_PACKET_STRUCT
13638}
13639
13640 static int send_packet_early_chat_msg_100(struct connection *pc, const struct packet_early_chat_msg *packet)
13641{
13642 const struct packet_early_chat_msg *real_packet = packet;
13643 int e;
13644 SEND_PACKET_START(PACKET_EARLY_CHAT_MSG);
13645
13646 log_packet_detailed("packet_early_chat_msg_100: sending info about ()");
13647
13648#ifdef FREECIV_DELTA_PROTOCOL
13649 packet_early_chat_msg_100_fields fields;
13650 struct packet_early_chat_msg *old;
13651 bool differ;
13652 struct genhash **hash = pc->phs.sent + PACKET_EARLY_CHAT_MSG;
13653
13654 if (nullptr == *hash) {
13655 *hash = genhash_new_full(hash_packet_early_chat_msg_100, cmp_packet_early_chat_msg_100,
13656 nullptr, nullptr, nullptr, destroy_packet_early_chat_msg);
13657 }
13658 BV_CLR_ALL(fields);
13659
13660 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
13661 old = fc_malloc(sizeof(*old));
13662 /* temporary bitcopy just to insert correctly */
13663 *old = *real_packet;
13664 genhash_insert(*hash, old, old);
13665 init_packet_early_chat_msg(old);
13666 }
13667
13668 differ = (strcmp(old->message, real_packet->message) != 0);
13669 if (differ) {
13670 BV_SET(fields, 0);
13671 }
13672
13673 differ = (old->tile != real_packet->tile);
13674 if (differ) {
13675 BV_SET(fields, 1);
13676 }
13677
13678 differ = (old->event != real_packet->event);
13679 if (differ) {
13680 BV_SET(fields, 2);
13681 }
13682
13683 differ = (old->turn != real_packet->turn);
13684 if (differ) {
13685 BV_SET(fields, 3);
13686 }
13687
13688 differ = (old->phase != real_packet->phase);
13689 if (differ) {
13690 BV_SET(fields, 4);
13691 }
13692
13693 differ = (old->conn_id != real_packet->conn_id);
13694 if (differ) {
13695 BV_SET(fields, 5);
13696 }
13697#endif /* FREECIV_DELTA_PROTOCOL */
13698
13699#ifdef FREECIV_JSON_CONNECTION
13700 struct plocation field_addr;
13701 {
13702 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
13703 field_addr = *field_addr_tmp;
13704 FC_FREE(field_addr_tmp);
13705 }
13706#endif /* FREECIV_JSON_CONNECTION */
13707
13708#ifdef FREECIV_DELTA_PROTOCOL
13709#ifdef FREECIV_JSON_CONNECTION
13710 field_addr.name = "fields";
13711#endif /* FREECIV_JSON_CONNECTION */
13712 e = 0;
13713 e |= DIO_BV_PUT(&dout, &field_addr, fields);
13714 if (e) {
13715 log_packet_detailed("fields bitvector error detected");
13716 }
13717
13718 if (BV_ISSET(fields, 0)) {
13719 log_packet_detailed(" field 'message' has changed");
13720
13721#ifdef FREECIV_JSON_CONNECTION
13722 field_addr.name = "message";
13723#endif /* FREECIV_JSON_CONNECTION */
13724 e = 0;
13725
13726 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
13727
13728 if (e) {
13729 log_packet_detailed("'message' field error detected");
13730 }
13731 }
13732
13733 if (BV_ISSET(fields, 1)) {
13734 log_packet_detailed(" field 'tile' has changed");
13735
13736#ifdef FREECIV_JSON_CONNECTION
13737 field_addr.name = "tile";
13738#endif /* FREECIV_JSON_CONNECTION */
13739 e = 0;
13740
13741 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
13742
13743 if (e) {
13744 log_packet_detailed("'tile' field error detected");
13745 }
13746 }
13747
13748 if (BV_ISSET(fields, 2)) {
13749 log_packet_detailed(" field 'event' has changed");
13750
13751#ifdef FREECIV_JSON_CONNECTION
13752 field_addr.name = "event";
13753#endif /* FREECIV_JSON_CONNECTION */
13754 e = 0;
13755
13756 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->event);
13757
13758 if (e) {
13759 log_packet_detailed("'event' field error detected");
13760 }
13761 }
13762
13763 if (BV_ISSET(fields, 3)) {
13764 log_packet_detailed(" field 'turn' has changed");
13765
13766#ifdef FREECIV_JSON_CONNECTION
13767 field_addr.name = "turn";
13768#endif /* FREECIV_JSON_CONNECTION */
13769 e = 0;
13770
13771 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
13772
13773 if (e) {
13774 log_packet_detailed("'turn' field error detected");
13775 }
13776 }
13777
13778 if (BV_ISSET(fields, 4)) {
13779 log_packet_detailed(" field 'phase' has changed");
13780
13781#ifdef FREECIV_JSON_CONNECTION
13782 field_addr.name = "phase";
13783#endif /* FREECIV_JSON_CONNECTION */
13784 e = 0;
13785
13786 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
13787
13788 if (e) {
13789 log_packet_detailed("'phase' field error detected");
13790 }
13791 }
13792
13793 if (BV_ISSET(fields, 5)) {
13794 log_packet_detailed(" field 'conn_id' has changed");
13795
13796#ifdef FREECIV_JSON_CONNECTION
13797 field_addr.name = "conn_id";
13798#endif /* FREECIV_JSON_CONNECTION */
13799 e = 0;
13800
13801 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id);
13802
13803 if (e) {
13804 log_packet_detailed("'conn_id' field error detected");
13805 }
13806 }
13807
13808 *old = *real_packet;
13809
13810#else /* FREECIV_DELTA_PROTOCOL */
13811#ifdef FREECIV_JSON_CONNECTION
13812 field_addr.name = "message";
13813#endif /* FREECIV_JSON_CONNECTION */
13814 e = 0;
13815
13816 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
13817
13818 if (e) {
13819 log_packet_detailed("'message' field error detected");
13820 }
13821
13822#ifdef FREECIV_JSON_CONNECTION
13823 field_addr.name = "tile";
13824#endif /* FREECIV_JSON_CONNECTION */
13825 e = 0;
13826
13827 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
13828
13829 if (e) {
13830 log_packet_detailed("'tile' field error detected");
13831 }
13832
13833#ifdef FREECIV_JSON_CONNECTION
13834 field_addr.name = "event";
13835#endif /* FREECIV_JSON_CONNECTION */
13836 e = 0;
13837
13838 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->event);
13839
13840 if (e) {
13841 log_packet_detailed("'event' field error detected");
13842 }
13843
13844#ifdef FREECIV_JSON_CONNECTION
13845 field_addr.name = "turn";
13846#endif /* FREECIV_JSON_CONNECTION */
13847 e = 0;
13848
13849 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
13850
13851 if (e) {
13852 log_packet_detailed("'turn' field error detected");
13853 }
13854
13855#ifdef FREECIV_JSON_CONNECTION
13856 field_addr.name = "phase";
13857#endif /* FREECIV_JSON_CONNECTION */
13858 e = 0;
13859
13860 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
13861
13862 if (e) {
13863 log_packet_detailed("'phase' field error detected");
13864 }
13865
13866#ifdef FREECIV_JSON_CONNECTION
13867 field_addr.name = "conn_id";
13868#endif /* FREECIV_JSON_CONNECTION */
13869 e = 0;
13870
13871 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id);
13872
13873 if (e) {
13874 log_packet_detailed("'conn_id' field error detected");
13875 }
13876#endif /* FREECIV_DELTA_PROTOCOL */
13877
13878 SEND_PACKET_END(PACKET_EARLY_CHAT_MSG);
13879}
13880
13881 int send_packet_early_chat_msg(struct connection *pc, const struct packet_early_chat_msg *packet)
13882{
13883 if (!pc->used) {
13884 log_error("WARNING: trying to send data to the closed connection %s",
13885 conn_description(pc));
13886 return -1;
13887 }
13888 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EARLY_CHAT_MSG].packet != nullptr, -1,
13889 "Handler for PACKET_EARLY_CHAT_MSG not installed");
13890 return pc->phs.handlers->send[PACKET_EARLY_CHAT_MSG].packet(pc, packet);
13891}
13892
13893 void lsend_packet_early_chat_msg(struct conn_list *dest, const struct packet_early_chat_msg *packet)
13894{
13895 conn_list_iterate(dest, pconn) {
13896 send_packet_early_chat_msg(pconn, packet);
13897 } conn_list_iterate_end;
13898}
13899
13900 static inline void init_packet_chat_msg_req(struct packet_chat_msg_req *packet)
13901{
13902 memset(packet, 0, sizeof(*packet));
13903}
13904
13905#define free_packet_chat_msg_req(_packet) (void) 0
13906#define destroy_packet_chat_msg_req free
13907
13908#ifdef FREECIV_DELTA_PROTOCOL
13909#define hash_packet_chat_msg_req_100 hash_const
13910#define cmp_packet_chat_msg_req_100 cmp_const
13911 BV_DEFINE(packet_chat_msg_req_100_fields, 1);
13912#endif /* FREECIV_DELTA_PROTOCOL */
13913
13914 static struct packet_chat_msg_req *receive_packet_chat_msg_req_100(struct connection *pc)
13915{
13916#define FREE_PACKET_STRUCT(_packet) free_packet_chat_msg_req(_packet)
13917 RECEIVE_PACKET_START(packet_chat_msg_req, real_packet);
13918
13919#ifdef FREECIV_JSON_CONNECTION
13920 struct plocation field_addr;
13921 {
13922 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
13923 field_addr = *field_addr_tmp;
13924 FC_FREE(field_addr_tmp);
13925 }
13926#endif /* FREECIV_JSON_CONNECTION */
13927
13928 log_packet_detailed("packet_chat_msg_req_100: got info about ()");
13929
13930#ifdef FREECIV_DELTA_PROTOCOL
13931 packet_chat_msg_req_100_fields fields;
13932 struct packet_chat_msg_req *old;
13933 struct genhash **hash = pc->phs.received + PACKET_CHAT_MSG_REQ;
13934
13935 if (nullptr == *hash) {
13936 *hash = genhash_new_full(hash_packet_chat_msg_req_100, cmp_packet_chat_msg_req_100,
13937 nullptr, nullptr, nullptr, destroy_packet_chat_msg_req);
13938 }
13939
13940 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
13941 *real_packet = *old;
13942 } else {
13943 /* packet is already initialized empty */
13944 log_packet_detailed(" no old info");
13945 }
13946
13947#ifdef FREECIV_JSON_CONNECTION
13948 field_addr.name = "fields";
13949#endif /* FREECIV_JSON_CONNECTION */
13950 DIO_BV_GET(&din, &field_addr, fields);
13951
13952 if (BV_ISSET(fields, 0)) {
13953 log_packet_detailed(" got field 'message'");
13954
13955#ifdef FREECIV_JSON_CONNECTION
13956 field_addr.name = "message";
13957#endif /* FREECIV_JSON_CONNECTION */
13958
13959 if (!DIO_GET(estring, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
13960 RECEIVE_PACKET_FIELD_ERROR(message);
13961 }
13962 }
13963
13964 if (nullptr == old) {
13965 old = fc_malloc(sizeof(*old));
13966 init_packet_chat_msg_req(old);
13967 *old = *real_packet;
13968 genhash_insert(*hash, old, old);
13969 } else {
13970 *old = *real_packet;
13971 }
13972
13973#else /* FREECIV_DELTA_PROTOCOL */
13974#ifdef FREECIV_JSON_CONNECTION
13975 field_addr.name = "message";
13976#endif /* FREECIV_JSON_CONNECTION */
13977
13978 if (!DIO_GET(estring, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
13979 RECEIVE_PACKET_FIELD_ERROR(message);
13980 }
13981#endif /* FREECIV_DELTA_PROTOCOL */
13982
13983 RECEIVE_PACKET_END(real_packet);
13984#undef FREE_PACKET_STRUCT
13985}
13986
13987 static int send_packet_chat_msg_req_100(struct connection *pc, const struct packet_chat_msg_req *packet)
13988{
13989 const struct packet_chat_msg_req *real_packet = packet;
13990 int e;
13991 SEND_PACKET_START(PACKET_CHAT_MSG_REQ);
13992
13993 log_packet_detailed("packet_chat_msg_req_100: sending info about ()");
13994
13995#ifdef FREECIV_DELTA_PROTOCOL
13996 packet_chat_msg_req_100_fields fields;
13997 struct packet_chat_msg_req *old;
13998 bool differ;
13999 struct genhash **hash = pc->phs.sent + PACKET_CHAT_MSG_REQ;
14000
14001 if (nullptr == *hash) {
14002 *hash = genhash_new_full(hash_packet_chat_msg_req_100, cmp_packet_chat_msg_req_100,
14003 nullptr, nullptr, nullptr, destroy_packet_chat_msg_req);
14004 }
14005 BV_CLR_ALL(fields);
14006
14007 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14008 old = fc_malloc(sizeof(*old));
14009 /* temporary bitcopy just to insert correctly */
14010 *old = *real_packet;
14011 genhash_insert(*hash, old, old);
14012 init_packet_chat_msg_req(old);
14013 }
14014
14015 differ = (strcmp(old->message, real_packet->message) != 0);
14016 if (differ) {
14017 BV_SET(fields, 0);
14018 }
14019#endif /* FREECIV_DELTA_PROTOCOL */
14020
14021#ifdef FREECIV_JSON_CONNECTION
14022 struct plocation field_addr;
14023 {
14024 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14025 field_addr = *field_addr_tmp;
14026 FC_FREE(field_addr_tmp);
14027 }
14028#endif /* FREECIV_JSON_CONNECTION */
14029
14030#ifdef FREECIV_DELTA_PROTOCOL
14031#ifdef FREECIV_JSON_CONNECTION
14032 field_addr.name = "fields";
14033#endif /* FREECIV_JSON_CONNECTION */
14034 e = 0;
14035 e |= DIO_BV_PUT(&dout, &field_addr, fields);
14036 if (e) {
14037 log_packet_detailed("fields bitvector error detected");
14038 }
14039
14040 if (BV_ISSET(fields, 0)) {
14041 log_packet_detailed(" field 'message' has changed");
14042
14043#ifdef FREECIV_JSON_CONNECTION
14044 field_addr.name = "message";
14045#endif /* FREECIV_JSON_CONNECTION */
14046 e = 0;
14047
14048 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->message);
14049
14050 if (e) {
14051 log_packet_detailed("'message' field error detected");
14052 }
14053 }
14054
14055 *old = *real_packet;
14056
14057#else /* FREECIV_DELTA_PROTOCOL */
14058#ifdef FREECIV_JSON_CONNECTION
14059 field_addr.name = "message";
14060#endif /* FREECIV_JSON_CONNECTION */
14061 e = 0;
14062
14063 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->message);
14064
14065 if (e) {
14066 log_packet_detailed("'message' field error detected");
14067 }
14068#endif /* FREECIV_DELTA_PROTOCOL */
14069
14070 SEND_PACKET_END(PACKET_CHAT_MSG_REQ);
14071}
14072
14073 int send_packet_chat_msg_req(struct connection *pc, const struct packet_chat_msg_req *packet)
14074{
14075 if (!pc->used) {
14076 log_error("WARNING: trying to send data to the closed connection %s",
14077 conn_description(pc));
14078 return -1;
14079 }
14080 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CHAT_MSG_REQ].packet != nullptr, -1,
14081 "Handler for PACKET_CHAT_MSG_REQ not installed");
14082 return pc->phs.handlers->send[PACKET_CHAT_MSG_REQ].packet(pc, packet);
14083}
14084
14085 int dsend_packet_chat_msg_req(struct connection *pc, const char *message)
14086{
14087 struct packet_chat_msg_req packet, *real_packet = &packet;
14088
14089 sz_strlcpy(real_packet->message, message);
14090
14091 return send_packet_chat_msg_req(pc, real_packet);
14092}
14093
14094 static inline void init_packet_connect_msg(struct packet_connect_msg *packet)
14095{
14096 memset(packet, 0, sizeof(*packet));
14097}
14098
14099#define free_packet_connect_msg(_packet) (void) 0
14100#define destroy_packet_connect_msg free
14101
14102#ifdef FREECIV_DELTA_PROTOCOL
14103#define hash_packet_connect_msg_100 hash_const
14104#define cmp_packet_connect_msg_100 cmp_const
14105 BV_DEFINE(packet_connect_msg_100_fields, 1);
14106#endif /* FREECIV_DELTA_PROTOCOL */
14107
14108 static struct packet_connect_msg *receive_packet_connect_msg_100(struct connection *pc)
14109{
14110#define FREE_PACKET_STRUCT(_packet) free_packet_connect_msg(_packet)
14111 RECEIVE_PACKET_START(packet_connect_msg, real_packet);
14112
14113#ifdef FREECIV_JSON_CONNECTION
14114 struct plocation field_addr;
14115 {
14116 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14117 field_addr = *field_addr_tmp;
14118 FC_FREE(field_addr_tmp);
14119 }
14120#endif /* FREECIV_JSON_CONNECTION */
14121
14122 log_packet_detailed("packet_connect_msg_100: got info about ()");
14123
14124#ifdef FREECIV_DELTA_PROTOCOL
14125 packet_connect_msg_100_fields fields;
14126 struct packet_connect_msg *old;
14127 struct genhash **hash = pc->phs.received + PACKET_CONNECT_MSG;
14128
14129 if (nullptr == *hash) {
14130 *hash = genhash_new_full(hash_packet_connect_msg_100, cmp_packet_connect_msg_100,
14131 nullptr, nullptr, nullptr, destroy_packet_connect_msg);
14132 }
14133
14134 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
14135 *real_packet = *old;
14136 } else {
14137 /* packet is already initialized empty */
14138 log_packet_detailed(" no old info");
14139 }
14140
14141#ifdef FREECIV_JSON_CONNECTION
14142 field_addr.name = "fields";
14143#endif /* FREECIV_JSON_CONNECTION */
14144 DIO_BV_GET(&din, &field_addr, fields);
14145
14146 if (BV_ISSET(fields, 0)) {
14147 log_packet_detailed(" got field 'message'");
14148
14149#ifdef FREECIV_JSON_CONNECTION
14150 field_addr.name = "message";
14151#endif /* FREECIV_JSON_CONNECTION */
14152
14153 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
14154 RECEIVE_PACKET_FIELD_ERROR(message);
14155 }
14156 }
14157
14158 if (nullptr == old) {
14159 old = fc_malloc(sizeof(*old));
14160 init_packet_connect_msg(old);
14161 *old = *real_packet;
14162 genhash_insert(*hash, old, old);
14163 } else {
14164 *old = *real_packet;
14165 }
14166
14167#else /* FREECIV_DELTA_PROTOCOL */
14168#ifdef FREECIV_JSON_CONNECTION
14169 field_addr.name = "message";
14170#endif /* FREECIV_JSON_CONNECTION */
14171
14172 if (!DIO_GET(string, &din, &field_addr, real_packet->message, sizeof(real_packet->message))) {
14173 RECEIVE_PACKET_FIELD_ERROR(message);
14174 }
14175#endif /* FREECIV_DELTA_PROTOCOL */
14176
14177 RECEIVE_PACKET_END(real_packet);
14178#undef FREE_PACKET_STRUCT
14179}
14180
14181 static int send_packet_connect_msg_100(struct connection *pc, const struct packet_connect_msg *packet)
14182{
14183 const struct packet_connect_msg *real_packet = packet;
14184 int e;
14185 SEND_PACKET_START(PACKET_CONNECT_MSG);
14186
14187 log_packet_detailed("packet_connect_msg_100: sending info about ()");
14188
14189#ifdef FREECIV_DELTA_PROTOCOL
14190 packet_connect_msg_100_fields fields;
14191 struct packet_connect_msg *old;
14192 bool differ;
14193 struct genhash **hash = pc->phs.sent + PACKET_CONNECT_MSG;
14194
14195 if (nullptr == *hash) {
14196 *hash = genhash_new_full(hash_packet_connect_msg_100, cmp_packet_connect_msg_100,
14197 nullptr, nullptr, nullptr, destroy_packet_connect_msg);
14198 }
14199 BV_CLR_ALL(fields);
14200
14201 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14202 old = fc_malloc(sizeof(*old));
14203 /* temporary bitcopy just to insert correctly */
14204 *old = *real_packet;
14205 genhash_insert(*hash, old, old);
14206 init_packet_connect_msg(old);
14207 }
14208
14209 differ = (strcmp(old->message, real_packet->message) != 0);
14210 if (differ) {
14211 BV_SET(fields, 0);
14212 }
14213#endif /* FREECIV_DELTA_PROTOCOL */
14214
14215#ifdef FREECIV_JSON_CONNECTION
14216 struct plocation field_addr;
14217 {
14218 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14219 field_addr = *field_addr_tmp;
14220 FC_FREE(field_addr_tmp);
14221 }
14222#endif /* FREECIV_JSON_CONNECTION */
14223
14224#ifdef FREECIV_DELTA_PROTOCOL
14225#ifdef FREECIV_JSON_CONNECTION
14226 field_addr.name = "fields";
14227#endif /* FREECIV_JSON_CONNECTION */
14228 e = 0;
14229 e |= DIO_BV_PUT(&dout, &field_addr, fields);
14230 if (e) {
14231 log_packet_detailed("fields bitvector error detected");
14232 }
14233
14234 if (BV_ISSET(fields, 0)) {
14235 log_packet_detailed(" field 'message' has changed");
14236
14237#ifdef FREECIV_JSON_CONNECTION
14238 field_addr.name = "message";
14239#endif /* FREECIV_JSON_CONNECTION */
14240 e = 0;
14241
14242 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
14243
14244 if (e) {
14245 log_packet_detailed("'message' field error detected");
14246 }
14247 }
14248
14249 *old = *real_packet;
14250
14251#else /* FREECIV_DELTA_PROTOCOL */
14252#ifdef FREECIV_JSON_CONNECTION
14253 field_addr.name = "message";
14254#endif /* FREECIV_JSON_CONNECTION */
14255 e = 0;
14256
14257 e |= DIO_PUT(string, &dout, &field_addr, real_packet->message);
14258
14259 if (e) {
14260 log_packet_detailed("'message' field error detected");
14261 }
14262#endif /* FREECIV_DELTA_PROTOCOL */
14263
14264 SEND_PACKET_END(PACKET_CONNECT_MSG);
14265}
14266
14267 int send_packet_connect_msg(struct connection *pc, const struct packet_connect_msg *packet)
14268{
14269 if (!pc->used) {
14270 log_error("WARNING: trying to send data to the closed connection %s",
14271 conn_description(pc));
14272 return -1;
14273 }
14274 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONNECT_MSG].packet != nullptr, -1,
14275 "Handler for PACKET_CONNECT_MSG not installed");
14276 return pc->phs.handlers->send[PACKET_CONNECT_MSG].packet(pc, packet);
14277}
14278
14279 int dsend_packet_connect_msg(struct connection *pc, const char *message)
14280{
14281 struct packet_connect_msg packet, *real_packet = &packet;
14282
14283 sz_strlcpy(real_packet->message, message);
14284
14285 return send_packet_connect_msg(pc, real_packet);
14286}
14287
14288 static inline void init_packet_server_info(struct packet_server_info *packet)
14289{
14290 memset(packet, 0, sizeof(*packet));
14291}
14292
14293#define free_packet_server_info(_packet) (void) 0
14294#define destroy_packet_server_info free
14295
14296#ifdef FREECIV_DELTA_PROTOCOL
14297#define hash_packet_server_info_100 hash_const
14298#define cmp_packet_server_info_100 cmp_const
14299 BV_DEFINE(packet_server_info_100_fields, 5);
14300#endif /* FREECIV_DELTA_PROTOCOL */
14301
14302 static struct packet_server_info *receive_packet_server_info_100(struct connection *pc)
14303{
14304#define FREE_PACKET_STRUCT(_packet) free_packet_server_info(_packet)
14305 RECEIVE_PACKET_START(packet_server_info, real_packet);
14306
14307#ifdef FREECIV_JSON_CONNECTION
14308 struct plocation field_addr;
14309 {
14310 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14311 field_addr = *field_addr_tmp;
14312 FC_FREE(field_addr_tmp);
14313 }
14314#endif /* FREECIV_JSON_CONNECTION */
14315
14316 log_packet_detailed("packet_server_info_100: got info about ()");
14317
14318#ifdef FREECIV_DELTA_PROTOCOL
14319 packet_server_info_100_fields fields;
14320 struct packet_server_info *old;
14321 struct genhash **hash = pc->phs.received + PACKET_SERVER_INFO;
14322
14323 if (nullptr == *hash) {
14324 *hash = genhash_new_full(hash_packet_server_info_100, cmp_packet_server_info_100,
14325 nullptr, nullptr, nullptr, destroy_packet_server_info);
14326 }
14327
14328 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
14329 *real_packet = *old;
14330 } else {
14331 /* packet is already initialized empty */
14332 log_packet_detailed(" no old info");
14333 }
14334
14335#ifdef FREECIV_JSON_CONNECTION
14336 field_addr.name = "fields";
14337#endif /* FREECIV_JSON_CONNECTION */
14338 DIO_BV_GET(&din, &field_addr, fields);
14339
14340 if (BV_ISSET(fields, 0)) {
14341 log_packet_detailed(" got field 'version_label'");
14342
14343#ifdef FREECIV_JSON_CONNECTION
14344 field_addr.name = "version_label";
14345#endif /* FREECIV_JSON_CONNECTION */
14346
14347 if (!DIO_GET(string, &din, &field_addr, real_packet->version_label, sizeof(real_packet->version_label))) {
14348 RECEIVE_PACKET_FIELD_ERROR(version_label);
14349 }
14350 }
14351
14352 if (BV_ISSET(fields, 1)) {
14353 log_packet_detailed(" got field 'major_version'");
14354
14355#ifdef FREECIV_JSON_CONNECTION
14356 field_addr.name = "major_version";
14357#endif /* FREECIV_JSON_CONNECTION */
14358
14359 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->major_version)) {
14360 RECEIVE_PACKET_FIELD_ERROR(major_version);
14361 }
14362 }
14363
14364 if (BV_ISSET(fields, 2)) {
14365 log_packet_detailed(" got field 'minor_version'");
14366
14367#ifdef FREECIV_JSON_CONNECTION
14368 field_addr.name = "minor_version";
14369#endif /* FREECIV_JSON_CONNECTION */
14370
14371 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->minor_version)) {
14372 RECEIVE_PACKET_FIELD_ERROR(minor_version);
14373 }
14374 }
14375
14376 if (BV_ISSET(fields, 3)) {
14377 log_packet_detailed(" got field 'patch_version'");
14378
14379#ifdef FREECIV_JSON_CONNECTION
14380 field_addr.name = "patch_version";
14381#endif /* FREECIV_JSON_CONNECTION */
14382
14383 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->patch_version)) {
14384 RECEIVE_PACKET_FIELD_ERROR(patch_version);
14385 }
14386 }
14387
14388 if (BV_ISSET(fields, 4)) {
14389 log_packet_detailed(" got field 'emerg_version'");
14390
14391#ifdef FREECIV_JSON_CONNECTION
14392 field_addr.name = "emerg_version";
14393#endif /* FREECIV_JSON_CONNECTION */
14394
14395 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->emerg_version)) {
14396 RECEIVE_PACKET_FIELD_ERROR(emerg_version);
14397 }
14398 }
14399
14400 if (nullptr == old) {
14401 old = fc_malloc(sizeof(*old));
14402 init_packet_server_info(old);
14403 *old = *real_packet;
14404 genhash_insert(*hash, old, old);
14405 } else {
14406 *old = *real_packet;
14407 }
14408
14409#else /* FREECIV_DELTA_PROTOCOL */
14410#ifdef FREECIV_JSON_CONNECTION
14411 field_addr.name = "version_label";
14412#endif /* FREECIV_JSON_CONNECTION */
14413
14414 if (!DIO_GET(string, &din, &field_addr, real_packet->version_label, sizeof(real_packet->version_label))) {
14415 RECEIVE_PACKET_FIELD_ERROR(version_label);
14416 }
14417
14418#ifdef FREECIV_JSON_CONNECTION
14419 field_addr.name = "major_version";
14420#endif /* FREECIV_JSON_CONNECTION */
14421
14422 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->major_version)) {
14423 RECEIVE_PACKET_FIELD_ERROR(major_version);
14424 }
14425
14426#ifdef FREECIV_JSON_CONNECTION
14427 field_addr.name = "minor_version";
14428#endif /* FREECIV_JSON_CONNECTION */
14429
14430 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->minor_version)) {
14431 RECEIVE_PACKET_FIELD_ERROR(minor_version);
14432 }
14433
14434#ifdef FREECIV_JSON_CONNECTION
14435 field_addr.name = "patch_version";
14436#endif /* FREECIV_JSON_CONNECTION */
14437
14438 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->patch_version)) {
14439 RECEIVE_PACKET_FIELD_ERROR(patch_version);
14440 }
14441
14442#ifdef FREECIV_JSON_CONNECTION
14443 field_addr.name = "emerg_version";
14444#endif /* FREECIV_JSON_CONNECTION */
14445
14446 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->emerg_version)) {
14447 RECEIVE_PACKET_FIELD_ERROR(emerg_version);
14448 }
14449#endif /* FREECIV_DELTA_PROTOCOL */
14450
14451 RECEIVE_PACKET_END(real_packet);
14452#undef FREE_PACKET_STRUCT
14453}
14454
14455 static int send_packet_server_info_100(struct connection *pc, const struct packet_server_info *packet)
14456{
14457 const struct packet_server_info *real_packet = packet;
14458 int e;
14459 SEND_PACKET_START(PACKET_SERVER_INFO);
14460
14461 log_packet_detailed("packet_server_info_100: sending info about ()");
14462
14463#ifdef FREECIV_DELTA_PROTOCOL
14464 packet_server_info_100_fields fields;
14465 struct packet_server_info *old;
14466 bool differ;
14467 struct genhash **hash = pc->phs.sent + PACKET_SERVER_INFO;
14468
14469 if (nullptr == *hash) {
14470 *hash = genhash_new_full(hash_packet_server_info_100, cmp_packet_server_info_100,
14471 nullptr, nullptr, nullptr, destroy_packet_server_info);
14472 }
14473 BV_CLR_ALL(fields);
14474
14475 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14476 old = fc_malloc(sizeof(*old));
14477 /* temporary bitcopy just to insert correctly */
14478 *old = *real_packet;
14479 genhash_insert(*hash, old, old);
14480 init_packet_server_info(old);
14481 }
14482
14483 differ = (strcmp(old->version_label, real_packet->version_label) != 0);
14484 if (differ) {
14485 BV_SET(fields, 0);
14486 }
14487
14488 differ = (old->major_version != real_packet->major_version);
14489 if (differ) {
14490 BV_SET(fields, 1);
14491 }
14492
14493 differ = (old->minor_version != real_packet->minor_version);
14494 if (differ) {
14495 BV_SET(fields, 2);
14496 }
14497
14498 differ = (old->patch_version != real_packet->patch_version);
14499 if (differ) {
14500 BV_SET(fields, 3);
14501 }
14502
14503 differ = (old->emerg_version != real_packet->emerg_version);
14504 if (differ) {
14505 BV_SET(fields, 4);
14506 }
14507#endif /* FREECIV_DELTA_PROTOCOL */
14508
14509#ifdef FREECIV_JSON_CONNECTION
14510 struct plocation field_addr;
14511 {
14512 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14513 field_addr = *field_addr_tmp;
14514 FC_FREE(field_addr_tmp);
14515 }
14516#endif /* FREECIV_JSON_CONNECTION */
14517
14518#ifdef FREECIV_DELTA_PROTOCOL
14519#ifdef FREECIV_JSON_CONNECTION
14520 field_addr.name = "fields";
14521#endif /* FREECIV_JSON_CONNECTION */
14522 e = 0;
14523 e |= DIO_BV_PUT(&dout, &field_addr, fields);
14524 if (e) {
14525 log_packet_detailed("fields bitvector error detected");
14526 }
14527
14528 if (BV_ISSET(fields, 0)) {
14529 log_packet_detailed(" field 'version_label' has changed");
14530
14531#ifdef FREECIV_JSON_CONNECTION
14532 field_addr.name = "version_label";
14533#endif /* FREECIV_JSON_CONNECTION */
14534 e = 0;
14535
14536 e |= DIO_PUT(string, &dout, &field_addr, real_packet->version_label);
14537
14538 if (e) {
14539 log_packet_detailed("'version_label' field error detected");
14540 }
14541 }
14542
14543 if (BV_ISSET(fields, 1)) {
14544 log_packet_detailed(" field 'major_version' has changed");
14545
14546#ifdef FREECIV_JSON_CONNECTION
14547 field_addr.name = "major_version";
14548#endif /* FREECIV_JSON_CONNECTION */
14549 e = 0;
14550
14551 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->major_version);
14552
14553 if (e) {
14554 log_packet_detailed("'major_version' field error detected");
14555 }
14556 }
14557
14558 if (BV_ISSET(fields, 2)) {
14559 log_packet_detailed(" field 'minor_version' has changed");
14560
14561#ifdef FREECIV_JSON_CONNECTION
14562 field_addr.name = "minor_version";
14563#endif /* FREECIV_JSON_CONNECTION */
14564 e = 0;
14565
14566 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->minor_version);
14567
14568 if (e) {
14569 log_packet_detailed("'minor_version' field error detected");
14570 }
14571 }
14572
14573 if (BV_ISSET(fields, 3)) {
14574 log_packet_detailed(" field 'patch_version' has changed");
14575
14576#ifdef FREECIV_JSON_CONNECTION
14577 field_addr.name = "patch_version";
14578#endif /* FREECIV_JSON_CONNECTION */
14579 e = 0;
14580
14581 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->patch_version);
14582
14583 if (e) {
14584 log_packet_detailed("'patch_version' field error detected");
14585 }
14586 }
14587
14588 if (BV_ISSET(fields, 4)) {
14589 log_packet_detailed(" field 'emerg_version' has changed");
14590
14591#ifdef FREECIV_JSON_CONNECTION
14592 field_addr.name = "emerg_version";
14593#endif /* FREECIV_JSON_CONNECTION */
14594 e = 0;
14595
14596 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->emerg_version);
14597
14598 if (e) {
14599 log_packet_detailed("'emerg_version' field error detected");
14600 }
14601 }
14602
14603 *old = *real_packet;
14604
14605#else /* FREECIV_DELTA_PROTOCOL */
14606#ifdef FREECIV_JSON_CONNECTION
14607 field_addr.name = "version_label";
14608#endif /* FREECIV_JSON_CONNECTION */
14609 e = 0;
14610
14611 e |= DIO_PUT(string, &dout, &field_addr, real_packet->version_label);
14612
14613 if (e) {
14614 log_packet_detailed("'version_label' field error detected");
14615 }
14616
14617#ifdef FREECIV_JSON_CONNECTION
14618 field_addr.name = "major_version";
14619#endif /* FREECIV_JSON_CONNECTION */
14620 e = 0;
14621
14622 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->major_version);
14623
14624 if (e) {
14625 log_packet_detailed("'major_version' field error detected");
14626 }
14627
14628#ifdef FREECIV_JSON_CONNECTION
14629 field_addr.name = "minor_version";
14630#endif /* FREECIV_JSON_CONNECTION */
14631 e = 0;
14632
14633 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->minor_version);
14634
14635 if (e) {
14636 log_packet_detailed("'minor_version' field error detected");
14637 }
14638
14639#ifdef FREECIV_JSON_CONNECTION
14640 field_addr.name = "patch_version";
14641#endif /* FREECIV_JSON_CONNECTION */
14642 e = 0;
14643
14644 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->patch_version);
14645
14646 if (e) {
14647 log_packet_detailed("'patch_version' field error detected");
14648 }
14649
14650#ifdef FREECIV_JSON_CONNECTION
14651 field_addr.name = "emerg_version";
14652#endif /* FREECIV_JSON_CONNECTION */
14653 e = 0;
14654
14655 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->emerg_version);
14656
14657 if (e) {
14658 log_packet_detailed("'emerg_version' field error detected");
14659 }
14660#endif /* FREECIV_DELTA_PROTOCOL */
14661
14662 SEND_PACKET_END(PACKET_SERVER_INFO);
14663}
14664
14665 int send_packet_server_info(struct connection *pc, const struct packet_server_info *packet)
14666{
14667 if (!pc->used) {
14668 log_error("WARNING: trying to send data to the closed connection %s",
14669 conn_description(pc));
14670 return -1;
14671 }
14672 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_INFO].packet != nullptr, -1,
14673 "Handler for PACKET_SERVER_INFO not installed");
14674 return pc->phs.handlers->send[PACKET_SERVER_INFO].packet(pc, packet);
14675}
14676
14677 int dsend_packet_server_info(struct connection *pc, const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
14678{
14679 struct packet_server_info packet, *real_packet = &packet;
14680
14681 sz_strlcpy(real_packet->version_label, version_label);
14682 real_packet->major_version = major_version;
14683 real_packet->minor_version = minor_version;
14684 real_packet->patch_version = patch_version;
14685 real_packet->emerg_version = emerg_version;
14686
14687 return send_packet_server_info(pc, real_packet);
14688}
14689
14690 static inline void init_packet_city_remove(struct packet_city_remove *packet)
14691{
14692 memset(packet, 0, sizeof(*packet));
14693}
14694
14695#define free_packet_city_remove(_packet) (void) 0
14696#define destroy_packet_city_remove free
14697
14698#ifdef FREECIV_DELTA_PROTOCOL
14699#define hash_packet_city_remove_100 hash_const
14700#define cmp_packet_city_remove_100 cmp_const
14701 BV_DEFINE(packet_city_remove_100_fields, 1);
14702#endif /* FREECIV_DELTA_PROTOCOL */
14703
14704 static struct packet_city_remove *receive_packet_city_remove_100(struct connection *pc)
14705{
14706#define FREE_PACKET_STRUCT(_packet) free_packet_city_remove(_packet)
14707 RECEIVE_PACKET_START(packet_city_remove, real_packet);
14708
14709#ifdef FREECIV_JSON_CONNECTION
14710 struct plocation field_addr;
14711 {
14712 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14713 field_addr = *field_addr_tmp;
14714 FC_FREE(field_addr_tmp);
14715 }
14716#endif /* FREECIV_JSON_CONNECTION */
14717
14718 log_packet_detailed("packet_city_remove_100: got info about ()");
14719
14720#ifdef FREECIV_DELTA_PROTOCOL
14721 packet_city_remove_100_fields fields;
14722 struct packet_city_remove *old;
14723 struct genhash **hash = pc->phs.received + PACKET_CITY_REMOVE;
14724
14725 if (nullptr == *hash) {
14726 *hash = genhash_new_full(hash_packet_city_remove_100, cmp_packet_city_remove_100,
14727 nullptr, nullptr, nullptr, destroy_packet_city_remove);
14728 }
14729
14730 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
14731 *real_packet = *old;
14732 } else {
14733 /* packet is already initialized empty */
14734 log_packet_detailed(" no old info");
14735 }
14736
14737#ifdef FREECIV_JSON_CONNECTION
14738 field_addr.name = "fields";
14739#endif /* FREECIV_JSON_CONNECTION */
14740 DIO_BV_GET(&din, &field_addr, fields);
14741
14742 if (BV_ISSET(fields, 0)) {
14743 log_packet_detailed(" got field 'city_id'");
14744
14745#ifdef FREECIV_JSON_CONNECTION
14746 field_addr.name = "city_id";
14747#endif /* FREECIV_JSON_CONNECTION */
14748
14749 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
14750 RECEIVE_PACKET_FIELD_ERROR(city_id);
14751 }
14752 }
14753
14754 if (nullptr == old) {
14755 old = fc_malloc(sizeof(*old));
14756 init_packet_city_remove(old);
14757 *old = *real_packet;
14758 genhash_insert(*hash, old, old);
14759 } else {
14760 *old = *real_packet;
14761 }
14762
14763 hash = pc->phs.received + PACKET_CITY_INFO;
14764 if (nullptr != *hash) {
14765 genhash_remove(*hash, real_packet);
14766 }
14767
14768 hash = pc->phs.received + PACKET_WEB_CITY_INFO_ADDITION;
14769 if (nullptr != *hash) {
14770 genhash_remove(*hash, real_packet);
14771 }
14772
14773 hash = pc->phs.received + PACKET_CITY_NATIONALITIES;
14774 if (nullptr != *hash) {
14775 genhash_remove(*hash, real_packet);
14776 }
14777
14778 hash = pc->phs.received + PACKET_CITY_RALLY_POINT;
14779 if (nullptr != *hash) {
14780 genhash_remove(*hash, real_packet);
14781 }
14782
14783 hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
14784 if (nullptr != *hash) {
14785 genhash_remove(*hash, real_packet);
14786 }
14787
14788#else /* FREECIV_DELTA_PROTOCOL */
14789#ifdef FREECIV_JSON_CONNECTION
14790 field_addr.name = "city_id";
14791#endif /* FREECIV_JSON_CONNECTION */
14792
14793 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
14794 RECEIVE_PACKET_FIELD_ERROR(city_id);
14795 }
14796#endif /* FREECIV_DELTA_PROTOCOL */
14797
14798 RECEIVE_PACKET_END(real_packet);
14799#undef FREE_PACKET_STRUCT
14800}
14801
14802 static int send_packet_city_remove_100(struct connection *pc, const struct packet_city_remove *packet)
14803{
14804 const struct packet_city_remove *real_packet = packet;
14805 int e;
14806 SEND_PACKET_START(PACKET_CITY_REMOVE);
14807
14808 log_packet_detailed("packet_city_remove_100: sending info about ()");
14809
14810#ifdef FREECIV_DELTA_PROTOCOL
14811 packet_city_remove_100_fields fields;
14812 struct packet_city_remove *old;
14813 bool differ;
14814 struct genhash **hash = pc->phs.sent + PACKET_CITY_REMOVE;
14815
14816 if (nullptr == *hash) {
14817 *hash = genhash_new_full(hash_packet_city_remove_100, cmp_packet_city_remove_100,
14818 nullptr, nullptr, nullptr, destroy_packet_city_remove);
14819 }
14820 BV_CLR_ALL(fields);
14821
14822 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
14823 old = fc_malloc(sizeof(*old));
14824 /* temporary bitcopy just to insert correctly */
14825 *old = *real_packet;
14826 genhash_insert(*hash, old, old);
14827 init_packet_city_remove(old);
14828 }
14829
14830 differ = (old->city_id != real_packet->city_id);
14831 if (differ) {
14832 BV_SET(fields, 0);
14833 }
14834#endif /* FREECIV_DELTA_PROTOCOL */
14835
14836#ifdef FREECIV_JSON_CONNECTION
14837 struct plocation field_addr;
14838 {
14839 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14840 field_addr = *field_addr_tmp;
14841 FC_FREE(field_addr_tmp);
14842 }
14843#endif /* FREECIV_JSON_CONNECTION */
14844
14845#ifdef FREECIV_DELTA_PROTOCOL
14846#ifdef FREECIV_JSON_CONNECTION
14847 field_addr.name = "fields";
14848#endif /* FREECIV_JSON_CONNECTION */
14849 e = 0;
14850 e |= DIO_BV_PUT(&dout, &field_addr, fields);
14851 if (e) {
14852 log_packet_detailed("fields bitvector error detected");
14853 }
14854
14855 if (BV_ISSET(fields, 0)) {
14856 log_packet_detailed(" field 'city_id' has changed");
14857
14858#ifdef FREECIV_JSON_CONNECTION
14859 field_addr.name = "city_id";
14860#endif /* FREECIV_JSON_CONNECTION */
14861 e = 0;
14862
14863 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
14864
14865 if (e) {
14866 log_packet_detailed("'city_id' field error detected");
14867 }
14868 }
14869
14870 *old = *real_packet;
14871
14872 hash = pc->phs.sent + PACKET_CITY_INFO;
14873 if (nullptr != *hash) {
14874 genhash_remove(*hash, real_packet);
14875 }
14876
14877 hash = pc->phs.sent + PACKET_WEB_CITY_INFO_ADDITION;
14878 if (nullptr != *hash) {
14879 genhash_remove(*hash, real_packet);
14880 }
14881
14882 hash = pc->phs.sent + PACKET_CITY_NATIONALITIES;
14883 if (nullptr != *hash) {
14884 genhash_remove(*hash, real_packet);
14885 }
14886
14887 hash = pc->phs.sent + PACKET_CITY_RALLY_POINT;
14888 if (nullptr != *hash) {
14889 genhash_remove(*hash, real_packet);
14890 }
14891
14892 hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
14893 if (nullptr != *hash) {
14894 genhash_remove(*hash, real_packet);
14895 }
14896
14897#else /* FREECIV_DELTA_PROTOCOL */
14898#ifdef FREECIV_JSON_CONNECTION
14899 field_addr.name = "city_id";
14900#endif /* FREECIV_JSON_CONNECTION */
14901 e = 0;
14902
14903 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
14904
14905 if (e) {
14906 log_packet_detailed("'city_id' field error detected");
14907 }
14908#endif /* FREECIV_DELTA_PROTOCOL */
14909
14910 SEND_PACKET_END(PACKET_CITY_REMOVE);
14911}
14912
14913 int send_packet_city_remove(struct connection *pc, const struct packet_city_remove *packet)
14914{
14915 if (!pc->used) {
14916 log_error("WARNING: trying to send data to the closed connection %s",
14917 conn_description(pc));
14918 return -1;
14919 }
14920 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_REMOVE].packet != nullptr, -1,
14921 "Handler for PACKET_CITY_REMOVE not installed");
14922 return pc->phs.handlers->send[PACKET_CITY_REMOVE].packet(pc, packet);
14923}
14924
14925 void lsend_packet_city_remove(struct conn_list *dest, const struct packet_city_remove *packet)
14926{
14927 conn_list_iterate(dest, pconn) {
14928 send_packet_city_remove(pconn, packet);
14929 } conn_list_iterate_end;
14930}
14931
14932 int dsend_packet_city_remove(struct connection *pc, int city_id)
14933{
14934 struct packet_city_remove packet, *real_packet = &packet;
14935
14936 real_packet->city_id = city_id;
14937
14938 return send_packet_city_remove(pc, real_packet);
14939}
14940
14941 void dlsend_packet_city_remove(struct conn_list *dest, int city_id)
14942{
14943 struct packet_city_remove packet, *real_packet = &packet;
14944
14945 real_packet->city_id = city_id;
14946
14947 lsend_packet_city_remove(dest, real_packet);
14948}
14949
14950 static inline void init_packet_city_info(struct packet_city_info *packet)
14951{
14952 memset(packet, 0, sizeof(*packet));
14953}
14954
14955#define free_packet_city_info(_packet) (void) 0
14956#define destroy_packet_city_info free
14957
14958#ifdef FREECIV_DELTA_PROTOCOL
14959static genhash_val_t hash_packet_city_info_100(const void *vkey)
14960{
14961 const struct packet_city_info *key = (const struct packet_city_info *) vkey;
14962 genhash_val_t result = 0;
14963
14964 result += key->id;
14965
14966 result &= 0xFFFFFFFF;
14967 return result;
14968}
14969
14970static bool cmp_packet_city_info_100(const void *vkey1, const void *vkey2)
14971{
14972 const struct packet_city_info *old = (const struct packet_city_info *) vkey1;
14973 const struct packet_city_info *real_packet = (const struct packet_city_info *) vkey2;
14974 bool differ;
14975
14976 differ = (old->id != real_packet->id);
14977
14978 return !differ;
14979}
14980 BV_DEFINE(packet_city_info_100_fields, 50);
14981#endif /* FREECIV_DELTA_PROTOCOL */
14982
14983 static struct packet_city_info *receive_packet_city_info_100(struct connection *pc)
14984{
14985#define FREE_PACKET_STRUCT(_packet) free_packet_city_info(_packet)
14986 RECEIVE_PACKET_START(packet_city_info, real_packet);
14987
14988#ifdef FREECIV_JSON_CONNECTION
14989 struct plocation field_addr;
14990 {
14991 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
14992 field_addr = *field_addr_tmp;
14993 FC_FREE(field_addr_tmp);
14994 }
14995#endif /* FREECIV_JSON_CONNECTION */
14996
14997#ifdef FREECIV_JSON_CONNECTION
14998 field_addr.name = "id";
14999#endif /* FREECIV_JSON_CONNECTION */
15000
15001 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
15002 RECEIVE_PACKET_FIELD_ERROR(id);
15003 }
15004
15005 log_packet_detailed("packet_city_info_100: got info about (%d)",
15006 real_packet->id);
15007
15008#ifdef FREECIV_DELTA_PROTOCOL
15009 packet_city_info_100_fields fields;
15010 struct packet_city_info *old;
15011 struct genhash **hash = pc->phs.received + PACKET_CITY_INFO;
15012
15013 if (nullptr == *hash) {
15014 *hash = genhash_new_full(hash_packet_city_info_100, cmp_packet_city_info_100,
15015 nullptr, nullptr, nullptr, destroy_packet_city_info);
15016 }
15017
15018 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
15019 *real_packet = *old;
15020 } else {
15021 /* packet is already initialized empty */
15022 log_packet_detailed(" no old info");
15023 }
15024
15025#ifdef FREECIV_JSON_CONNECTION
15026 field_addr.name = "fields";
15027#endif /* FREECIV_JSON_CONNECTION */
15028 DIO_BV_GET(&din, &field_addr, fields);
15029
15030 if (BV_ISSET(fields, 0)) {
15031 log_packet_detailed(" got field 'tile'");
15032
15033#ifdef FREECIV_JSON_CONNECTION
15034 field_addr.name = "tile";
15035#endif /* FREECIV_JSON_CONNECTION */
15036
15037 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
15038 RECEIVE_PACKET_FIELD_ERROR(tile);
15039 }
15040 }
15041
15042 if (BV_ISSET(fields, 1)) {
15043 log_packet_detailed(" got field 'owner'");
15044
15045#ifdef FREECIV_JSON_CONNECTION
15046 field_addr.name = "owner";
15047#endif /* FREECIV_JSON_CONNECTION */
15048
15049 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
15050 RECEIVE_PACKET_FIELD_ERROR(owner);
15051 }
15052 }
15053
15054 if (BV_ISSET(fields, 2)) {
15055 log_packet_detailed(" got field 'original'");
15056
15057#ifdef FREECIV_JSON_CONNECTION
15058 field_addr.name = "original";
15059#endif /* FREECIV_JSON_CONNECTION */
15060
15061 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->original)) {
15062 RECEIVE_PACKET_FIELD_ERROR(original);
15063 }
15064 }
15065
15066 if (BV_ISSET(fields, 3)) {
15067 log_packet_detailed(" got field 'size'");
15068
15069#ifdef FREECIV_JSON_CONNECTION
15070 field_addr.name = "size";
15071#endif /* FREECIV_JSON_CONNECTION */
15072
15073 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
15074 RECEIVE_PACKET_FIELD_ERROR(size);
15075 }
15076 }
15077
15078 if (BV_ISSET(fields, 4)) {
15079 log_packet_detailed(" got field 'city_radius_sq'");
15080
15081#ifdef FREECIV_JSON_CONNECTION
15082 field_addr.name = "city_radius_sq";
15083#endif /* FREECIV_JSON_CONNECTION */
15084
15085 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->city_radius_sq)) {
15086 RECEIVE_PACKET_FIELD_ERROR(city_radius_sq);
15087 }
15088 }
15089
15090 if (BV_ISSET(fields, 5)) {
15091 log_packet_detailed(" got field 'style'");
15092
15093#ifdef FREECIV_JSON_CONNECTION
15094 field_addr.name = "style";
15095#endif /* FREECIV_JSON_CONNECTION */
15096
15097 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
15098 RECEIVE_PACKET_FIELD_ERROR(style);
15099 }
15100 }
15101
15102 if (BV_ISSET(fields, 6)) {
15103 log_packet_detailed(" got field 'capital'");
15104
15105#ifdef FREECIV_JSON_CONNECTION
15106 field_addr.name = "capital";
15107#endif /* FREECIV_JSON_CONNECTION */
15108
15109 {
15110 int readin;
15111
15112 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
15113 RECEIVE_PACKET_FIELD_ERROR(capital);
15114 }
15115 real_packet->capital = readin;
15116 }
15117 }
15118
15119 if (BV_ISSET(fields, 7)) {
15120 log_packet_detailed(" got field 'ppl_happy'");
15121
15122#ifdef FREECIV_JSON_CONNECTION
15123 field_addr.name = "ppl_happy";
15124#endif /* FREECIV_JSON_CONNECTION */
15125
15126 {
15127 int i;
15128
15129
15130#ifdef FREECIV_JSON_CONNECTION
15131 /* Enter array. */
15132 field_addr.sub_location = plocation_elem_new(0);
15133#endif /* FREECIV_JSON_CONNECTION */
15134
15135 for (i = 0; i < FEELING_LAST; i++) {
15136#ifdef FREECIV_JSON_CONNECTION
15137 /* Next array element */
15138 field_addr.sub_location->number = i;
15139#endif /* FREECIV_JSON_CONNECTION */
15140
15141 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_happy[i])) {
15142 RECEIVE_PACKET_FIELD_ERROR(ppl_happy);
15143 }
15144 }
15145
15146#ifdef FREECIV_JSON_CONNECTION
15147 /* Exit array. */
15148 FC_FREE(field_addr.sub_location);
15149#endif /* FREECIV_JSON_CONNECTION */
15150 }
15151 }
15152
15153 if (BV_ISSET(fields, 8)) {
15154 log_packet_detailed(" got field 'ppl_content'");
15155
15156#ifdef FREECIV_JSON_CONNECTION
15157 field_addr.name = "ppl_content";
15158#endif /* FREECIV_JSON_CONNECTION */
15159
15160 {
15161 int i;
15162
15163
15164#ifdef FREECIV_JSON_CONNECTION
15165 /* Enter array. */
15166 field_addr.sub_location = plocation_elem_new(0);
15167#endif /* FREECIV_JSON_CONNECTION */
15168
15169 for (i = 0; i < FEELING_LAST; i++) {
15170#ifdef FREECIV_JSON_CONNECTION
15171 /* Next array element */
15172 field_addr.sub_location->number = i;
15173#endif /* FREECIV_JSON_CONNECTION */
15174
15175 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_content[i])) {
15176 RECEIVE_PACKET_FIELD_ERROR(ppl_content);
15177 }
15178 }
15179
15180#ifdef FREECIV_JSON_CONNECTION
15181 /* Exit array. */
15182 FC_FREE(field_addr.sub_location);
15183#endif /* FREECIV_JSON_CONNECTION */
15184 }
15185 }
15186
15187 if (BV_ISSET(fields, 9)) {
15188 log_packet_detailed(" got field 'ppl_unhappy'");
15189
15190#ifdef FREECIV_JSON_CONNECTION
15191 field_addr.name = "ppl_unhappy";
15192#endif /* FREECIV_JSON_CONNECTION */
15193
15194 {
15195 int i;
15196
15197
15198#ifdef FREECIV_JSON_CONNECTION
15199 /* Enter array. */
15200 field_addr.sub_location = plocation_elem_new(0);
15201#endif /* FREECIV_JSON_CONNECTION */
15202
15203 for (i = 0; i < FEELING_LAST; i++) {
15204#ifdef FREECIV_JSON_CONNECTION
15205 /* Next array element */
15206 field_addr.sub_location->number = i;
15207#endif /* FREECIV_JSON_CONNECTION */
15208
15209 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_unhappy[i])) {
15210 RECEIVE_PACKET_FIELD_ERROR(ppl_unhappy);
15211 }
15212 }
15213
15214#ifdef FREECIV_JSON_CONNECTION
15215 /* Exit array. */
15216 FC_FREE(field_addr.sub_location);
15217#endif /* FREECIV_JSON_CONNECTION */
15218 }
15219 }
15220
15221 if (BV_ISSET(fields, 10)) {
15222 log_packet_detailed(" got field 'ppl_angry'");
15223
15224#ifdef FREECIV_JSON_CONNECTION
15225 field_addr.name = "ppl_angry";
15226#endif /* FREECIV_JSON_CONNECTION */
15227
15228 {
15229 int i;
15230
15231
15232#ifdef FREECIV_JSON_CONNECTION
15233 /* Enter array. */
15234 field_addr.sub_location = plocation_elem_new(0);
15235#endif /* FREECIV_JSON_CONNECTION */
15236
15237 for (i = 0; i < FEELING_LAST; i++) {
15238#ifdef FREECIV_JSON_CONNECTION
15239 /* Next array element */
15240 field_addr.sub_location->number = i;
15241#endif /* FREECIV_JSON_CONNECTION */
15242
15243 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_angry[i])) {
15244 RECEIVE_PACKET_FIELD_ERROR(ppl_angry);
15245 }
15246 }
15247
15248#ifdef FREECIV_JSON_CONNECTION
15249 /* Exit array. */
15250 FC_FREE(field_addr.sub_location);
15251#endif /* FREECIV_JSON_CONNECTION */
15252 }
15253 }
15254
15255 if (BV_ISSET(fields, 11)) {
15256 log_packet_detailed(" got field 'specialists_size'");
15257
15258#ifdef FREECIV_JSON_CONNECTION
15259 field_addr.name = "specialists_size";
15260#endif /* FREECIV_JSON_CONNECTION */
15261
15262 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists_size)) {
15263 RECEIVE_PACKET_FIELD_ERROR(specialists_size);
15264 }
15265 }
15266
15267 if (BV_ISSET(fields, 12)) {
15268 log_packet_detailed(" got field 'specialists'");
15269
15270#ifdef FREECIV_JSON_CONNECTION
15271 field_addr.name = "specialists";
15272#endif /* FREECIV_JSON_CONNECTION */
15273
15274 {
15275 int i;
15276
15277 if (real_packet->specialists_size > SP_MAX) {
15278 RECEIVE_PACKET_FIELD_ERROR(specialists, ": array truncated");
15279 }
15280
15281#ifdef FREECIV_JSON_CONNECTION
15282 /* Enter array. */
15283 field_addr.sub_location = plocation_elem_new(0);
15284#endif /* FREECIV_JSON_CONNECTION */
15285
15286 for (i = 0; i < real_packet->specialists_size; i++) {
15287#ifdef FREECIV_JSON_CONNECTION
15288 /* Next array element */
15289 field_addr.sub_location->number = i;
15290#endif /* FREECIV_JSON_CONNECTION */
15291
15292 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists[i])) {
15293 RECEIVE_PACKET_FIELD_ERROR(specialists);
15294 }
15295 }
15296
15297#ifdef FREECIV_JSON_CONNECTION
15298 /* Exit array. */
15299 FC_FREE(field_addr.sub_location);
15300#endif /* FREECIV_JSON_CONNECTION */
15301 }
15302 }
15303
15304 if (BV_ISSET(fields, 13)) {
15305 log_packet_detailed(" got field 'history'");
15306
15307#ifdef FREECIV_JSON_CONNECTION
15308 field_addr.name = "history";
15309#endif /* FREECIV_JSON_CONNECTION */
15310
15311 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->history)) {
15312 RECEIVE_PACKET_FIELD_ERROR(history);
15313 }
15314 }
15315
15316 if (BV_ISSET(fields, 14)) {
15317 log_packet_detailed(" got field 'culture'");
15318
15319#ifdef FREECIV_JSON_CONNECTION
15320 field_addr.name = "culture";
15321#endif /* FREECIV_JSON_CONNECTION */
15322
15323 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->culture)) {
15324 RECEIVE_PACKET_FIELD_ERROR(culture);
15325 }
15326 }
15327
15328 if (BV_ISSET(fields, 15)) {
15329 log_packet_detailed(" got field 'buy_cost'");
15330
15331#ifdef FREECIV_JSON_CONNECTION
15332 field_addr.name = "buy_cost";
15333#endif /* FREECIV_JSON_CONNECTION */
15334
15335 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->buy_cost)) {
15336 RECEIVE_PACKET_FIELD_ERROR(buy_cost);
15337 }
15338 }
15339
15340 if (BV_ISSET(fields, 16)) {
15341 log_packet_detailed(" got field 'surplus'");
15342
15343#ifdef FREECIV_JSON_CONNECTION
15344 field_addr.name = "surplus";
15345#endif /* FREECIV_JSON_CONNECTION */
15346
15347 {
15348 int i;
15349
15350
15351#ifdef FREECIV_JSON_CONNECTION
15352 /* Enter array. */
15353 field_addr.sub_location = plocation_elem_new(0);
15354#endif /* FREECIV_JSON_CONNECTION */
15355
15356 for (i = 0; i < O_LAST; i++) {
15357#ifdef FREECIV_JSON_CONNECTION
15358 /* Next array element */
15359 field_addr.sub_location->number = i;
15360#endif /* FREECIV_JSON_CONNECTION */
15361
15362 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->surplus[i])) {
15363 RECEIVE_PACKET_FIELD_ERROR(surplus);
15364 }
15365 }
15366
15367#ifdef FREECIV_JSON_CONNECTION
15368 /* Exit array. */
15369 FC_FREE(field_addr.sub_location);
15370#endif /* FREECIV_JSON_CONNECTION */
15371 }
15372 }
15373
15374 if (BV_ISSET(fields, 17)) {
15375 log_packet_detailed(" got field 'waste'");
15376
15377#ifdef FREECIV_JSON_CONNECTION
15378 field_addr.name = "waste";
15379#endif /* FREECIV_JSON_CONNECTION */
15380
15381 {
15382 int i;
15383
15384
15385#ifdef FREECIV_JSON_CONNECTION
15386 /* Enter array. */
15387 field_addr.sub_location = plocation_elem_new(0);
15388#endif /* FREECIV_JSON_CONNECTION */
15389
15390 for (i = 0; i < O_LAST; i++) {
15391#ifdef FREECIV_JSON_CONNECTION
15392 /* Next array element */
15393 field_addr.sub_location->number = i;
15394#endif /* FREECIV_JSON_CONNECTION */
15395
15396 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->waste[i])) {
15397 RECEIVE_PACKET_FIELD_ERROR(waste);
15398 }
15399 }
15400
15401#ifdef FREECIV_JSON_CONNECTION
15402 /* Exit array. */
15403 FC_FREE(field_addr.sub_location);
15404#endif /* FREECIV_JSON_CONNECTION */
15405 }
15406 }
15407
15408 if (BV_ISSET(fields, 18)) {
15409 log_packet_detailed(" got field 'unhappy_penalty'");
15410
15411#ifdef FREECIV_JSON_CONNECTION
15412 field_addr.name = "unhappy_penalty";
15413#endif /* FREECIV_JSON_CONNECTION */
15414
15415 {
15416 int i;
15417
15418
15419#ifdef FREECIV_JSON_CONNECTION
15420 /* Enter array. */
15421 field_addr.sub_location = plocation_elem_new(0);
15422#endif /* FREECIV_JSON_CONNECTION */
15423
15424 for (i = 0; i < O_LAST; i++) {
15425#ifdef FREECIV_JSON_CONNECTION
15426 /* Next array element */
15427 field_addr.sub_location->number = i;
15428#endif /* FREECIV_JSON_CONNECTION */
15429
15430 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->unhappy_penalty[i])) {
15431 RECEIVE_PACKET_FIELD_ERROR(unhappy_penalty);
15432 }
15433 }
15434
15435#ifdef FREECIV_JSON_CONNECTION
15436 /* Exit array. */
15437 FC_FREE(field_addr.sub_location);
15438#endif /* FREECIV_JSON_CONNECTION */
15439 }
15440 }
15441
15442 if (BV_ISSET(fields, 19)) {
15443 log_packet_detailed(" got field 'prod'");
15444
15445#ifdef FREECIV_JSON_CONNECTION
15446 field_addr.name = "prod";
15447#endif /* FREECIV_JSON_CONNECTION */
15448
15449 {
15450 int i;
15451
15452
15453#ifdef FREECIV_JSON_CONNECTION
15454 /* Enter array. */
15455 field_addr.sub_location = plocation_elem_new(0);
15456#endif /* FREECIV_JSON_CONNECTION */
15457
15458 for (i = 0; i < O_LAST; i++) {
15459#ifdef FREECIV_JSON_CONNECTION
15460 /* Next array element */
15461 field_addr.sub_location->number = i;
15462#endif /* FREECIV_JSON_CONNECTION */
15463
15464 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->prod[i])) {
15465 RECEIVE_PACKET_FIELD_ERROR(prod);
15466 }
15467 }
15468
15469#ifdef FREECIV_JSON_CONNECTION
15470 /* Exit array. */
15471 FC_FREE(field_addr.sub_location);
15472#endif /* FREECIV_JSON_CONNECTION */
15473 }
15474 }
15475
15476 if (BV_ISSET(fields, 20)) {
15477 log_packet_detailed(" got field 'citizen_base'");
15478
15479#ifdef FREECIV_JSON_CONNECTION
15480 field_addr.name = "citizen_base";
15481#endif /* FREECIV_JSON_CONNECTION */
15482
15483 {
15484 int i;
15485
15486
15487#ifdef FREECIV_JSON_CONNECTION
15488 /* Enter array. */
15489 field_addr.sub_location = plocation_elem_new(0);
15490#endif /* FREECIV_JSON_CONNECTION */
15491
15492 for (i = 0; i < O_LAST; i++) {
15493#ifdef FREECIV_JSON_CONNECTION
15494 /* Next array element */
15495 field_addr.sub_location->number = i;
15496#endif /* FREECIV_JSON_CONNECTION */
15497
15498 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->citizen_base[i])) {
15499 RECEIVE_PACKET_FIELD_ERROR(citizen_base);
15500 }
15501 }
15502
15503#ifdef FREECIV_JSON_CONNECTION
15504 /* Exit array. */
15505 FC_FREE(field_addr.sub_location);
15506#endif /* FREECIV_JSON_CONNECTION */
15507 }
15508 }
15509
15510 if (BV_ISSET(fields, 21)) {
15511 log_packet_detailed(" got field 'usage'");
15512
15513#ifdef FREECIV_JSON_CONNECTION
15514 field_addr.name = "usage";
15515#endif /* FREECIV_JSON_CONNECTION */
15516
15517 {
15518 int i;
15519
15520
15521#ifdef FREECIV_JSON_CONNECTION
15522 /* Enter array. */
15523 field_addr.sub_location = plocation_elem_new(0);
15524#endif /* FREECIV_JSON_CONNECTION */
15525
15526 for (i = 0; i < O_LAST; i++) {
15527#ifdef FREECIV_JSON_CONNECTION
15528 /* Next array element */
15529 field_addr.sub_location->number = i;
15530#endif /* FREECIV_JSON_CONNECTION */
15531
15532 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->usage[i])) {
15533 RECEIVE_PACKET_FIELD_ERROR(usage);
15534 }
15535 }
15536
15537#ifdef FREECIV_JSON_CONNECTION
15538 /* Exit array. */
15539 FC_FREE(field_addr.sub_location);
15540#endif /* FREECIV_JSON_CONNECTION */
15541 }
15542 }
15543
15544 if (BV_ISSET(fields, 22)) {
15545 log_packet_detailed(" got field 'food_stock'");
15546
15547#ifdef FREECIV_JSON_CONNECTION
15548 field_addr.name = "food_stock";
15549#endif /* FREECIV_JSON_CONNECTION */
15550
15551 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->food_stock)) {
15552 RECEIVE_PACKET_FIELD_ERROR(food_stock);
15553 }
15554 }
15555
15556 if (BV_ISSET(fields, 23)) {
15557 log_packet_detailed(" got field 'shield_stock'");
15558
15559#ifdef FREECIV_JSON_CONNECTION
15560 field_addr.name = "shield_stock";
15561#endif /* FREECIV_JSON_CONNECTION */
15562
15563 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->shield_stock)) {
15564 RECEIVE_PACKET_FIELD_ERROR(shield_stock);
15565 }
15566 }
15567
15568 if (BV_ISSET(fields, 24)) {
15569 log_packet_detailed(" got field 'trade_route_count'");
15570
15571#ifdef FREECIV_JSON_CONNECTION
15572 field_addr.name = "trade_route_count";
15573#endif /* FREECIV_JSON_CONNECTION */
15574
15575 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->trade_route_count)) {
15576 RECEIVE_PACKET_FIELD_ERROR(trade_route_count);
15577 }
15578 }
15579
15580 if (BV_ISSET(fields, 25)) {
15581 log_packet_detailed(" got field 'pollution'");
15582
15583#ifdef FREECIV_JSON_CONNECTION
15584 field_addr.name = "pollution";
15585#endif /* FREECIV_JSON_CONNECTION */
15586
15587 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->pollution)) {
15588 RECEIVE_PACKET_FIELD_ERROR(pollution);
15589 }
15590 }
15591
15592 if (BV_ISSET(fields, 26)) {
15593 log_packet_detailed(" got field 'illness_trade'");
15594
15595#ifdef FREECIV_JSON_CONNECTION
15596 field_addr.name = "illness_trade";
15597#endif /* FREECIV_JSON_CONNECTION */
15598
15599 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_trade)) {
15600 RECEIVE_PACKET_FIELD_ERROR(illness_trade);
15601 }
15602 }
15603
15604 if (BV_ISSET(fields, 27)) {
15605 log_packet_detailed(" got field 'production_kind'");
15606
15607#ifdef FREECIV_JSON_CONNECTION
15608 field_addr.name = "production_kind";
15609#endif /* FREECIV_JSON_CONNECTION */
15610
15611 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_kind)) {
15612 RECEIVE_PACKET_FIELD_ERROR(production_kind);
15613 }
15614 }
15615
15616 if (BV_ISSET(fields, 28)) {
15617 log_packet_detailed(" got field 'production_value'");
15618
15619#ifdef FREECIV_JSON_CONNECTION
15620 field_addr.name = "production_value";
15621#endif /* FREECIV_JSON_CONNECTION */
15622
15623 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_value)) {
15624 RECEIVE_PACKET_FIELD_ERROR(production_value);
15625 }
15626 }
15627
15628 if (BV_ISSET(fields, 29)) {
15629 log_packet_detailed(" got field 'turn_founded'");
15630
15631#ifdef FREECIV_JSON_CONNECTION
15632 field_addr.name = "turn_founded";
15633#endif /* FREECIV_JSON_CONNECTION */
15634
15635 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_founded)) {
15636 RECEIVE_PACKET_FIELD_ERROR(turn_founded);
15637 }
15638 }
15639
15640 if (BV_ISSET(fields, 30)) {
15641 log_packet_detailed(" got field 'turn_last_built'");
15642
15643#ifdef FREECIV_JSON_CONNECTION
15644 field_addr.name = "turn_last_built";
15645#endif /* FREECIV_JSON_CONNECTION */
15646
15647 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_last_built)) {
15648 RECEIVE_PACKET_FIELD_ERROR(turn_last_built);
15649 }
15650 }
15651
15652 if (BV_ISSET(fields, 31)) {
15653 log_packet_detailed(" got field 'changed_from_kind'");
15654
15655#ifdef FREECIV_JSON_CONNECTION
15656 field_addr.name = "changed_from_kind";
15657#endif /* FREECIV_JSON_CONNECTION */
15658
15659 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->changed_from_kind)) {
15660 RECEIVE_PACKET_FIELD_ERROR(changed_from_kind);
15661 }
15662 }
15663
15664 if (BV_ISSET(fields, 32)) {
15665 log_packet_detailed(" got field 'changed_from_value'");
15666
15667#ifdef FREECIV_JSON_CONNECTION
15668 field_addr.name = "changed_from_value";
15669#endif /* FREECIV_JSON_CONNECTION */
15670
15671 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->changed_from_value)) {
15672 RECEIVE_PACKET_FIELD_ERROR(changed_from_value);
15673 }
15674 }
15675
15676 if (BV_ISSET(fields, 33)) {
15677 log_packet_detailed(" got field 'before_change_shields'");
15678
15679#ifdef FREECIV_JSON_CONNECTION
15680 field_addr.name = "before_change_shields";
15681#endif /* FREECIV_JSON_CONNECTION */
15682
15683 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->before_change_shields)) {
15684 RECEIVE_PACKET_FIELD_ERROR(before_change_shields);
15685 }
15686 }
15687
15688 if (BV_ISSET(fields, 34)) {
15689 log_packet_detailed(" got field 'disbanded_shields'");
15690
15691#ifdef FREECIV_JSON_CONNECTION
15692 field_addr.name = "disbanded_shields";
15693#endif /* FREECIV_JSON_CONNECTION */
15694
15695 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->disbanded_shields)) {
15696 RECEIVE_PACKET_FIELD_ERROR(disbanded_shields);
15697 }
15698 }
15699
15700 if (BV_ISSET(fields, 35)) {
15701 log_packet_detailed(" got field 'caravan_shields'");
15702
15703#ifdef FREECIV_JSON_CONNECTION
15704 field_addr.name = "caravan_shields";
15705#endif /* FREECIV_JSON_CONNECTION */
15706
15707 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->caravan_shields)) {
15708 RECEIVE_PACKET_FIELD_ERROR(caravan_shields);
15709 }
15710 }
15711
15712 if (BV_ISSET(fields, 36)) {
15713 log_packet_detailed(" got field 'last_turns_shield_surplus'");
15714
15715#ifdef FREECIV_JSON_CONNECTION
15716 field_addr.name = "last_turns_shield_surplus";
15717#endif /* FREECIV_JSON_CONNECTION */
15718
15719 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->last_turns_shield_surplus)) {
15720 RECEIVE_PACKET_FIELD_ERROR(last_turns_shield_surplus);
15721 }
15722 }
15723
15724 if (BV_ISSET(fields, 37)) {
15725 log_packet_detailed(" got field 'airlift'");
15726
15727#ifdef FREECIV_JSON_CONNECTION
15728 field_addr.name = "airlift";
15729#endif /* FREECIV_JSON_CONNECTION */
15730
15731 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->airlift)) {
15732 RECEIVE_PACKET_FIELD_ERROR(airlift);
15733 }
15734 }
15735
15736 real_packet->did_buy = BV_ISSET(fields, 38);
15737
15738 real_packet->did_sell = BV_ISSET(fields, 39);
15739
15740 real_packet->was_happy = BV_ISSET(fields, 40);
15741
15742 real_packet->had_famine = BV_ISSET(fields, 41);
15743
15744 real_packet->diplomat_investigate = BV_ISSET(fields, 42);
15745
15746 if (BV_ISSET(fields, 43)) {
15747 log_packet_detailed(" got field 'walls'");
15748
15749#ifdef FREECIV_JSON_CONNECTION
15750 field_addr.name = "walls";
15751#endif /* FREECIV_JSON_CONNECTION */
15752
15753 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->walls)) {
15754 RECEIVE_PACKET_FIELD_ERROR(walls);
15755 }
15756 }
15757
15758 if (BV_ISSET(fields, 44)) {
15759 log_packet_detailed(" got field 'city_image'");
15760
15761#ifdef FREECIV_JSON_CONNECTION
15762 field_addr.name = "city_image";
15763#endif /* FREECIV_JSON_CONNECTION */
15764
15765 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->city_image)) {
15766 RECEIVE_PACKET_FIELD_ERROR(city_image);
15767 }
15768 }
15769
15770 if (BV_ISSET(fields, 45)) {
15771 log_packet_detailed(" got field 'steal'");
15772
15773#ifdef FREECIV_JSON_CONNECTION
15774 field_addr.name = "steal";
15775#endif /* FREECIV_JSON_CONNECTION */
15776
15777 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->steal)) {
15778 RECEIVE_PACKET_FIELD_ERROR(steal);
15779 }
15780 }
15781
15782 if (BV_ISSET(fields, 46)) {
15783 log_packet_detailed(" got field 'worklist'");
15784
15785#ifdef FREECIV_JSON_CONNECTION
15786 field_addr.name = "worklist";
15787#endif /* FREECIV_JSON_CONNECTION */
15788
15789 if (!DIO_GET(worklist, &din, &field_addr, &real_packet->worklist)) {
15790 RECEIVE_PACKET_FIELD_ERROR(worklist);
15791 }
15792 }
15793
15794 if (BV_ISSET(fields, 47)) {
15795 log_packet_detailed(" got field 'improvements'");
15796
15797#ifdef FREECIV_JSON_CONNECTION
15798 field_addr.name = "improvements";
15799#endif /* FREECIV_JSON_CONNECTION */
15800
15801 if (!DIO_BV_GET(&din, &field_addr, real_packet->improvements)) {
15802 RECEIVE_PACKET_FIELD_ERROR(improvements);
15803 }
15804 }
15805
15806 if (BV_ISSET(fields, 48)) {
15807 log_packet_detailed(" got field 'city_options'");
15808
15809#ifdef FREECIV_JSON_CONNECTION
15810 field_addr.name = "city_options";
15811#endif /* FREECIV_JSON_CONNECTION */
15812
15813 if (!DIO_BV_GET(&din, &field_addr, real_packet->city_options)) {
15814 RECEIVE_PACKET_FIELD_ERROR(city_options);
15815 }
15816 }
15817
15818 if (BV_ISSET(fields, 49)) {
15819 log_packet_detailed(" got field 'name'");
15820
15821#ifdef FREECIV_JSON_CONNECTION
15822 field_addr.name = "name";
15823#endif /* FREECIV_JSON_CONNECTION */
15824
15825 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
15826 RECEIVE_PACKET_FIELD_ERROR(name);
15827 }
15828 }
15829
15830 if (nullptr == old) {
15831 old = fc_malloc(sizeof(*old));
15832 init_packet_city_info(old);
15833 *old = *real_packet;
15834 genhash_insert(*hash, old, old);
15835 } else {
15836 *old = *real_packet;
15837 }
15838
15839 hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
15840 if (nullptr != *hash) {
15841 genhash_remove(*hash, real_packet);
15842 }
15843
15844#else /* FREECIV_DELTA_PROTOCOL */
15845#ifdef FREECIV_JSON_CONNECTION
15846 field_addr.name = "tile";
15847#endif /* FREECIV_JSON_CONNECTION */
15848
15849 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
15850 RECEIVE_PACKET_FIELD_ERROR(tile);
15851 }
15852
15853#ifdef FREECIV_JSON_CONNECTION
15854 field_addr.name = "owner";
15855#endif /* FREECIV_JSON_CONNECTION */
15856
15857 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
15858 RECEIVE_PACKET_FIELD_ERROR(owner);
15859 }
15860
15861#ifdef FREECIV_JSON_CONNECTION
15862 field_addr.name = "original";
15863#endif /* FREECIV_JSON_CONNECTION */
15864
15865 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->original)) {
15866 RECEIVE_PACKET_FIELD_ERROR(original);
15867 }
15868
15869#ifdef FREECIV_JSON_CONNECTION
15870 field_addr.name = "size";
15871#endif /* FREECIV_JSON_CONNECTION */
15872
15873 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
15874 RECEIVE_PACKET_FIELD_ERROR(size);
15875 }
15876
15877#ifdef FREECIV_JSON_CONNECTION
15878 field_addr.name = "city_radius_sq";
15879#endif /* FREECIV_JSON_CONNECTION */
15880
15881 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->city_radius_sq)) {
15882 RECEIVE_PACKET_FIELD_ERROR(city_radius_sq);
15883 }
15884
15885#ifdef FREECIV_JSON_CONNECTION
15886 field_addr.name = "style";
15887#endif /* FREECIV_JSON_CONNECTION */
15888
15889 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
15890 RECEIVE_PACKET_FIELD_ERROR(style);
15891 }
15892
15893#ifdef FREECIV_JSON_CONNECTION
15894 field_addr.name = "capital";
15895#endif /* FREECIV_JSON_CONNECTION */
15896
15897 {
15898 int readin;
15899
15900 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
15901 RECEIVE_PACKET_FIELD_ERROR(capital);
15902 }
15903 real_packet->capital = readin;
15904 }
15905
15906#ifdef FREECIV_JSON_CONNECTION
15907 field_addr.name = "ppl_happy";
15908#endif /* FREECIV_JSON_CONNECTION */
15909
15910 {
15911 int i;
15912
15913
15914#ifdef FREECIV_JSON_CONNECTION
15915 /* Enter array. */
15916 field_addr.sub_location = plocation_elem_new(0);
15917#endif /* FREECIV_JSON_CONNECTION */
15918
15919 for (i = 0; i < FEELING_LAST; i++) {
15920#ifdef FREECIV_JSON_CONNECTION
15921 /* Next array element */
15922 field_addr.sub_location->number = i;
15923#endif /* FREECIV_JSON_CONNECTION */
15924
15925 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_happy[i])) {
15926 RECEIVE_PACKET_FIELD_ERROR(ppl_happy);
15927 }
15928 }
15929
15930#ifdef FREECIV_JSON_CONNECTION
15931 /* Exit array. */
15932 FC_FREE(field_addr.sub_location);
15933#endif /* FREECIV_JSON_CONNECTION */
15934 }
15935
15936#ifdef FREECIV_JSON_CONNECTION
15937 field_addr.name = "ppl_content";
15938#endif /* FREECIV_JSON_CONNECTION */
15939
15940 {
15941 int i;
15942
15943
15944#ifdef FREECIV_JSON_CONNECTION
15945 /* Enter array. */
15946 field_addr.sub_location = plocation_elem_new(0);
15947#endif /* FREECIV_JSON_CONNECTION */
15948
15949 for (i = 0; i < FEELING_LAST; i++) {
15950#ifdef FREECIV_JSON_CONNECTION
15951 /* Next array element */
15952 field_addr.sub_location->number = i;
15953#endif /* FREECIV_JSON_CONNECTION */
15954
15955 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_content[i])) {
15956 RECEIVE_PACKET_FIELD_ERROR(ppl_content);
15957 }
15958 }
15959
15960#ifdef FREECIV_JSON_CONNECTION
15961 /* Exit array. */
15962 FC_FREE(field_addr.sub_location);
15963#endif /* FREECIV_JSON_CONNECTION */
15964 }
15965
15966#ifdef FREECIV_JSON_CONNECTION
15967 field_addr.name = "ppl_unhappy";
15968#endif /* FREECIV_JSON_CONNECTION */
15969
15970 {
15971 int i;
15972
15973
15974#ifdef FREECIV_JSON_CONNECTION
15975 /* Enter array. */
15976 field_addr.sub_location = plocation_elem_new(0);
15977#endif /* FREECIV_JSON_CONNECTION */
15978
15979 for (i = 0; i < FEELING_LAST; i++) {
15980#ifdef FREECIV_JSON_CONNECTION
15981 /* Next array element */
15982 field_addr.sub_location->number = i;
15983#endif /* FREECIV_JSON_CONNECTION */
15984
15985 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_unhappy[i])) {
15986 RECEIVE_PACKET_FIELD_ERROR(ppl_unhappy);
15987 }
15988 }
15989
15990#ifdef FREECIV_JSON_CONNECTION
15991 /* Exit array. */
15992 FC_FREE(field_addr.sub_location);
15993#endif /* FREECIV_JSON_CONNECTION */
15994 }
15995
15996#ifdef FREECIV_JSON_CONNECTION
15997 field_addr.name = "ppl_angry";
15998#endif /* FREECIV_JSON_CONNECTION */
15999
16000 {
16001 int i;
16002
16003
16004#ifdef FREECIV_JSON_CONNECTION
16005 /* Enter array. */
16006 field_addr.sub_location = plocation_elem_new(0);
16007#endif /* FREECIV_JSON_CONNECTION */
16008
16009 for (i = 0; i < FEELING_LAST; i++) {
16010#ifdef FREECIV_JSON_CONNECTION
16011 /* Next array element */
16012 field_addr.sub_location->number = i;
16013#endif /* FREECIV_JSON_CONNECTION */
16014
16015 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_angry[i])) {
16016 RECEIVE_PACKET_FIELD_ERROR(ppl_angry);
16017 }
16018 }
16019
16020#ifdef FREECIV_JSON_CONNECTION
16021 /* Exit array. */
16022 FC_FREE(field_addr.sub_location);
16023#endif /* FREECIV_JSON_CONNECTION */
16024 }
16025
16026#ifdef FREECIV_JSON_CONNECTION
16027 field_addr.name = "specialists_size";
16028#endif /* FREECIV_JSON_CONNECTION */
16029
16030 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists_size)) {
16031 RECEIVE_PACKET_FIELD_ERROR(specialists_size);
16032 }
16033
16034#ifdef FREECIV_JSON_CONNECTION
16035 field_addr.name = "specialists";
16036#endif /* FREECIV_JSON_CONNECTION */
16037
16038 {
16039 int i;
16040
16041 if (real_packet->specialists_size > SP_MAX) {
16042 RECEIVE_PACKET_FIELD_ERROR(specialists, ": array truncated");
16043 }
16044
16045#ifdef FREECIV_JSON_CONNECTION
16046 /* Enter array. */
16047 field_addr.sub_location = plocation_elem_new(0);
16048#endif /* FREECIV_JSON_CONNECTION */
16049
16050 for (i = 0; i < real_packet->specialists_size; i++) {
16051#ifdef FREECIV_JSON_CONNECTION
16052 /* Next array element */
16053 field_addr.sub_location->number = i;
16054#endif /* FREECIV_JSON_CONNECTION */
16055
16056 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists[i])) {
16057 RECEIVE_PACKET_FIELD_ERROR(specialists);
16058 }
16059 }
16060
16061#ifdef FREECIV_JSON_CONNECTION
16062 /* Exit array. */
16063 FC_FREE(field_addr.sub_location);
16064#endif /* FREECIV_JSON_CONNECTION */
16065 }
16066
16067#ifdef FREECIV_JSON_CONNECTION
16068 field_addr.name = "history";
16069#endif /* FREECIV_JSON_CONNECTION */
16070
16071 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->history)) {
16072 RECEIVE_PACKET_FIELD_ERROR(history);
16073 }
16074
16075#ifdef FREECIV_JSON_CONNECTION
16076 field_addr.name = "culture";
16077#endif /* FREECIV_JSON_CONNECTION */
16078
16079 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->culture)) {
16080 RECEIVE_PACKET_FIELD_ERROR(culture);
16081 }
16082
16083#ifdef FREECIV_JSON_CONNECTION
16084 field_addr.name = "buy_cost";
16085#endif /* FREECIV_JSON_CONNECTION */
16086
16087 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->buy_cost)) {
16088 RECEIVE_PACKET_FIELD_ERROR(buy_cost);
16089 }
16090
16091#ifdef FREECIV_JSON_CONNECTION
16092 field_addr.name = "surplus";
16093#endif /* FREECIV_JSON_CONNECTION */
16094
16095 {
16096 int i;
16097
16098
16099#ifdef FREECIV_JSON_CONNECTION
16100 /* Enter array. */
16101 field_addr.sub_location = plocation_elem_new(0);
16102#endif /* FREECIV_JSON_CONNECTION */
16103
16104 for (i = 0; i < O_LAST; i++) {
16105#ifdef FREECIV_JSON_CONNECTION
16106 /* Next array element */
16107 field_addr.sub_location->number = i;
16108#endif /* FREECIV_JSON_CONNECTION */
16109
16110 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->surplus[i])) {
16111 RECEIVE_PACKET_FIELD_ERROR(surplus);
16112 }
16113 }
16114
16115#ifdef FREECIV_JSON_CONNECTION
16116 /* Exit array. */
16117 FC_FREE(field_addr.sub_location);
16118#endif /* FREECIV_JSON_CONNECTION */
16119 }
16120
16121#ifdef FREECIV_JSON_CONNECTION
16122 field_addr.name = "waste";
16123#endif /* FREECIV_JSON_CONNECTION */
16124
16125 {
16126 int i;
16127
16128
16129#ifdef FREECIV_JSON_CONNECTION
16130 /* Enter array. */
16131 field_addr.sub_location = plocation_elem_new(0);
16132#endif /* FREECIV_JSON_CONNECTION */
16133
16134 for (i = 0; i < O_LAST; i++) {
16135#ifdef FREECIV_JSON_CONNECTION
16136 /* Next array element */
16137 field_addr.sub_location->number = i;
16138#endif /* FREECIV_JSON_CONNECTION */
16139
16140 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->waste[i])) {
16141 RECEIVE_PACKET_FIELD_ERROR(waste);
16142 }
16143 }
16144
16145#ifdef FREECIV_JSON_CONNECTION
16146 /* Exit array. */
16147 FC_FREE(field_addr.sub_location);
16148#endif /* FREECIV_JSON_CONNECTION */
16149 }
16150
16151#ifdef FREECIV_JSON_CONNECTION
16152 field_addr.name = "unhappy_penalty";
16153#endif /* FREECIV_JSON_CONNECTION */
16154
16155 {
16156 int i;
16157
16158
16159#ifdef FREECIV_JSON_CONNECTION
16160 /* Enter array. */
16161 field_addr.sub_location = plocation_elem_new(0);
16162#endif /* FREECIV_JSON_CONNECTION */
16163
16164 for (i = 0; i < O_LAST; i++) {
16165#ifdef FREECIV_JSON_CONNECTION
16166 /* Next array element */
16167 field_addr.sub_location->number = i;
16168#endif /* FREECIV_JSON_CONNECTION */
16169
16170 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->unhappy_penalty[i])) {
16171 RECEIVE_PACKET_FIELD_ERROR(unhappy_penalty);
16172 }
16173 }
16174
16175#ifdef FREECIV_JSON_CONNECTION
16176 /* Exit array. */
16177 FC_FREE(field_addr.sub_location);
16178#endif /* FREECIV_JSON_CONNECTION */
16179 }
16180
16181#ifdef FREECIV_JSON_CONNECTION
16182 field_addr.name = "prod";
16183#endif /* FREECIV_JSON_CONNECTION */
16184
16185 {
16186 int i;
16187
16188
16189#ifdef FREECIV_JSON_CONNECTION
16190 /* Enter array. */
16191 field_addr.sub_location = plocation_elem_new(0);
16192#endif /* FREECIV_JSON_CONNECTION */
16193
16194 for (i = 0; i < O_LAST; i++) {
16195#ifdef FREECIV_JSON_CONNECTION
16196 /* Next array element */
16197 field_addr.sub_location->number = i;
16198#endif /* FREECIV_JSON_CONNECTION */
16199
16200 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->prod[i])) {
16201 RECEIVE_PACKET_FIELD_ERROR(prod);
16202 }
16203 }
16204
16205#ifdef FREECIV_JSON_CONNECTION
16206 /* Exit array. */
16207 FC_FREE(field_addr.sub_location);
16208#endif /* FREECIV_JSON_CONNECTION */
16209 }
16210
16211#ifdef FREECIV_JSON_CONNECTION
16212 field_addr.name = "citizen_base";
16213#endif /* FREECIV_JSON_CONNECTION */
16214
16215 {
16216 int i;
16217
16218
16219#ifdef FREECIV_JSON_CONNECTION
16220 /* Enter array. */
16221 field_addr.sub_location = plocation_elem_new(0);
16222#endif /* FREECIV_JSON_CONNECTION */
16223
16224 for (i = 0; i < O_LAST; i++) {
16225#ifdef FREECIV_JSON_CONNECTION
16226 /* Next array element */
16227 field_addr.sub_location->number = i;
16228#endif /* FREECIV_JSON_CONNECTION */
16229
16230 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->citizen_base[i])) {
16231 RECEIVE_PACKET_FIELD_ERROR(citizen_base);
16232 }
16233 }
16234
16235#ifdef FREECIV_JSON_CONNECTION
16236 /* Exit array. */
16237 FC_FREE(field_addr.sub_location);
16238#endif /* FREECIV_JSON_CONNECTION */
16239 }
16240
16241#ifdef FREECIV_JSON_CONNECTION
16242 field_addr.name = "usage";
16243#endif /* FREECIV_JSON_CONNECTION */
16244
16245 {
16246 int i;
16247
16248
16249#ifdef FREECIV_JSON_CONNECTION
16250 /* Enter array. */
16251 field_addr.sub_location = plocation_elem_new(0);
16252#endif /* FREECIV_JSON_CONNECTION */
16253
16254 for (i = 0; i < O_LAST; i++) {
16255#ifdef FREECIV_JSON_CONNECTION
16256 /* Next array element */
16257 field_addr.sub_location->number = i;
16258#endif /* FREECIV_JSON_CONNECTION */
16259
16260 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->usage[i])) {
16261 RECEIVE_PACKET_FIELD_ERROR(usage);
16262 }
16263 }
16264
16265#ifdef FREECIV_JSON_CONNECTION
16266 /* Exit array. */
16267 FC_FREE(field_addr.sub_location);
16268#endif /* FREECIV_JSON_CONNECTION */
16269 }
16270
16271#ifdef FREECIV_JSON_CONNECTION
16272 field_addr.name = "food_stock";
16273#endif /* FREECIV_JSON_CONNECTION */
16274
16275 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->food_stock)) {
16276 RECEIVE_PACKET_FIELD_ERROR(food_stock);
16277 }
16278
16279#ifdef FREECIV_JSON_CONNECTION
16280 field_addr.name = "shield_stock";
16281#endif /* FREECIV_JSON_CONNECTION */
16282
16283 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->shield_stock)) {
16284 RECEIVE_PACKET_FIELD_ERROR(shield_stock);
16285 }
16286
16287#ifdef FREECIV_JSON_CONNECTION
16288 field_addr.name = "trade_route_count";
16289#endif /* FREECIV_JSON_CONNECTION */
16290
16291 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->trade_route_count)) {
16292 RECEIVE_PACKET_FIELD_ERROR(trade_route_count);
16293 }
16294
16295#ifdef FREECIV_JSON_CONNECTION
16296 field_addr.name = "pollution";
16297#endif /* FREECIV_JSON_CONNECTION */
16298
16299 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->pollution)) {
16300 RECEIVE_PACKET_FIELD_ERROR(pollution);
16301 }
16302
16303#ifdef FREECIV_JSON_CONNECTION
16304 field_addr.name = "illness_trade";
16305#endif /* FREECIV_JSON_CONNECTION */
16306
16307 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->illness_trade)) {
16308 RECEIVE_PACKET_FIELD_ERROR(illness_trade);
16309 }
16310
16311#ifdef FREECIV_JSON_CONNECTION
16312 field_addr.name = "production_kind";
16313#endif /* FREECIV_JSON_CONNECTION */
16314
16315 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_kind)) {
16316 RECEIVE_PACKET_FIELD_ERROR(production_kind);
16317 }
16318
16319#ifdef FREECIV_JSON_CONNECTION
16320 field_addr.name = "production_value";
16321#endif /* FREECIV_JSON_CONNECTION */
16322
16323 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_value)) {
16324 RECEIVE_PACKET_FIELD_ERROR(production_value);
16325 }
16326
16327#ifdef FREECIV_JSON_CONNECTION
16328 field_addr.name = "turn_founded";
16329#endif /* FREECIV_JSON_CONNECTION */
16330
16331 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_founded)) {
16332 RECEIVE_PACKET_FIELD_ERROR(turn_founded);
16333 }
16334
16335#ifdef FREECIV_JSON_CONNECTION
16336 field_addr.name = "turn_last_built";
16337#endif /* FREECIV_JSON_CONNECTION */
16338
16339 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_last_built)) {
16340 RECEIVE_PACKET_FIELD_ERROR(turn_last_built);
16341 }
16342
16343#ifdef FREECIV_JSON_CONNECTION
16344 field_addr.name = "changed_from_kind";
16345#endif /* FREECIV_JSON_CONNECTION */
16346
16347 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->changed_from_kind)) {
16348 RECEIVE_PACKET_FIELD_ERROR(changed_from_kind);
16349 }
16350
16351#ifdef FREECIV_JSON_CONNECTION
16352 field_addr.name = "changed_from_value";
16353#endif /* FREECIV_JSON_CONNECTION */
16354
16355 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->changed_from_value)) {
16356 RECEIVE_PACKET_FIELD_ERROR(changed_from_value);
16357 }
16358
16359#ifdef FREECIV_JSON_CONNECTION
16360 field_addr.name = "before_change_shields";
16361#endif /* FREECIV_JSON_CONNECTION */
16362
16363 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->before_change_shields)) {
16364 RECEIVE_PACKET_FIELD_ERROR(before_change_shields);
16365 }
16366
16367#ifdef FREECIV_JSON_CONNECTION
16368 field_addr.name = "disbanded_shields";
16369#endif /* FREECIV_JSON_CONNECTION */
16370
16371 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->disbanded_shields)) {
16372 RECEIVE_PACKET_FIELD_ERROR(disbanded_shields);
16373 }
16374
16375#ifdef FREECIV_JSON_CONNECTION
16376 field_addr.name = "caravan_shields";
16377#endif /* FREECIV_JSON_CONNECTION */
16378
16379 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->caravan_shields)) {
16380 RECEIVE_PACKET_FIELD_ERROR(caravan_shields);
16381 }
16382
16383#ifdef FREECIV_JSON_CONNECTION
16384 field_addr.name = "last_turns_shield_surplus";
16385#endif /* FREECIV_JSON_CONNECTION */
16386
16387 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->last_turns_shield_surplus)) {
16388 RECEIVE_PACKET_FIELD_ERROR(last_turns_shield_surplus);
16389 }
16390
16391#ifdef FREECIV_JSON_CONNECTION
16392 field_addr.name = "airlift";
16393#endif /* FREECIV_JSON_CONNECTION */
16394
16395 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->airlift)) {
16396 RECEIVE_PACKET_FIELD_ERROR(airlift);
16397 }
16398
16399#ifdef FREECIV_JSON_CONNECTION
16400 field_addr.name = "did_buy";
16401#endif /* FREECIV_JSON_CONNECTION */
16402
16403 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->did_buy)) {
16404 RECEIVE_PACKET_FIELD_ERROR(did_buy);
16405 }
16406
16407#ifdef FREECIV_JSON_CONNECTION
16408 field_addr.name = "did_sell";
16409#endif /* FREECIV_JSON_CONNECTION */
16410
16411 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->did_sell)) {
16412 RECEIVE_PACKET_FIELD_ERROR(did_sell);
16413 }
16414
16415#ifdef FREECIV_JSON_CONNECTION
16416 field_addr.name = "was_happy";
16417#endif /* FREECIV_JSON_CONNECTION */
16418
16419 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->was_happy)) {
16420 RECEIVE_PACKET_FIELD_ERROR(was_happy);
16421 }
16422
16423#ifdef FREECIV_JSON_CONNECTION
16424 field_addr.name = "had_famine";
16425#endif /* FREECIV_JSON_CONNECTION */
16426
16427 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->had_famine)) {
16428 RECEIVE_PACKET_FIELD_ERROR(had_famine);
16429 }
16430
16431#ifdef FREECIV_JSON_CONNECTION
16432 field_addr.name = "diplomat_investigate";
16433#endif /* FREECIV_JSON_CONNECTION */
16434
16435 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->diplomat_investigate)) {
16436 RECEIVE_PACKET_FIELD_ERROR(diplomat_investigate);
16437 }
16438
16439#ifdef FREECIV_JSON_CONNECTION
16440 field_addr.name = "walls";
16441#endif /* FREECIV_JSON_CONNECTION */
16442
16443 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->walls)) {
16444 RECEIVE_PACKET_FIELD_ERROR(walls);
16445 }
16446
16447#ifdef FREECIV_JSON_CONNECTION
16448 field_addr.name = "city_image";
16449#endif /* FREECIV_JSON_CONNECTION */
16450
16451 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->city_image)) {
16452 RECEIVE_PACKET_FIELD_ERROR(city_image);
16453 }
16454
16455#ifdef FREECIV_JSON_CONNECTION
16456 field_addr.name = "steal";
16457#endif /* FREECIV_JSON_CONNECTION */
16458
16459 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->steal)) {
16460 RECEIVE_PACKET_FIELD_ERROR(steal);
16461 }
16462
16463#ifdef FREECIV_JSON_CONNECTION
16464 field_addr.name = "worklist";
16465#endif /* FREECIV_JSON_CONNECTION */
16466
16467 if (!DIO_GET(worklist, &din, &field_addr, &real_packet->worklist)) {
16468 RECEIVE_PACKET_FIELD_ERROR(worklist);
16469 }
16470
16471#ifdef FREECIV_JSON_CONNECTION
16472 field_addr.name = "improvements";
16473#endif /* FREECIV_JSON_CONNECTION */
16474
16475 if (!DIO_BV_GET(&din, &field_addr, real_packet->improvements)) {
16476 RECEIVE_PACKET_FIELD_ERROR(improvements);
16477 }
16478
16479#ifdef FREECIV_JSON_CONNECTION
16480 field_addr.name = "city_options";
16481#endif /* FREECIV_JSON_CONNECTION */
16482
16483 if (!DIO_BV_GET(&din, &field_addr, real_packet->city_options)) {
16484 RECEIVE_PACKET_FIELD_ERROR(city_options);
16485 }
16486
16487#ifdef FREECIV_JSON_CONNECTION
16488 field_addr.name = "name";
16489#endif /* FREECIV_JSON_CONNECTION */
16490
16491 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
16492 RECEIVE_PACKET_FIELD_ERROR(name);
16493 }
16494#endif /* FREECIV_DELTA_PROTOCOL */
16495
16496 RECEIVE_PACKET_END(real_packet);
16497#undef FREE_PACKET_STRUCT
16498}
16499
16500 static int send_packet_city_info_100(struct connection *pc, const struct packet_city_info *packet, bool force_to_send)
16501{
16502 const struct packet_city_info *real_packet = packet;
16503 int e;
16504 SEND_PACKET_START(PACKET_CITY_INFO);
16505
16506 log_packet_detailed("packet_city_info_100: sending info about (%d)",
16507 real_packet->id);
16508
16509#ifdef FREECIV_DELTA_PROTOCOL
16510 packet_city_info_100_fields fields;
16511 struct packet_city_info *old;
16512 bool differ;
16513 int different = force_to_send;
16514 struct genhash **hash = pc->phs.sent + PACKET_CITY_INFO;
16515
16516 if (nullptr == *hash) {
16517 *hash = genhash_new_full(hash_packet_city_info_100, cmp_packet_city_info_100,
16518 nullptr, nullptr, nullptr, destroy_packet_city_info);
16519 }
16520 BV_CLR_ALL(fields);
16521
16522 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
16523 old = fc_malloc(sizeof(*old));
16524 /* temporary bitcopy just to insert correctly */
16525 *old = *real_packet;
16526 genhash_insert(*hash, old, old);
16527 init_packet_city_info(old);
16528 different = 1; /* Force to send. */
16529 }
16530
16531 differ = (old->tile != real_packet->tile);
16532 if (differ) {
16533 different++;
16534 BV_SET(fields, 0);
16535 }
16536
16537 differ = (old->owner != real_packet->owner);
16538 if (differ) {
16539 different++;
16540 BV_SET(fields, 1);
16541 }
16542
16543 differ = (old->original != real_packet->original);
16544 if (differ) {
16545 different++;
16546 BV_SET(fields, 2);
16547 }
16548
16549 differ = (old->size != real_packet->size);
16550 if (differ) {
16551 different++;
16552 BV_SET(fields, 3);
16553 }
16554
16555 differ = (old->city_radius_sq != real_packet->city_radius_sq);
16556 if (differ) {
16557 different++;
16558 BV_SET(fields, 4);
16559 }
16560
16561 differ = (old->style != real_packet->style);
16562 if (differ) {
16563 different++;
16564 BV_SET(fields, 5);
16565 }
16566
16567 differ = (old->capital != real_packet->capital);
16568 if (differ) {
16569 different++;
16570 BV_SET(fields, 6);
16571 }
16572
16573 differ = FALSE;
16574 {
16575 int i;
16576
16577 for (i = 0; i < FEELING_LAST; i++) {
16578 differ = (old->ppl_happy[i] != real_packet->ppl_happy[i]);
16579 if (differ) {
16580 break;
16581 }
16582 }
16583 }
16584 if (differ) {
16585 different++;
16586 BV_SET(fields, 7);
16587 }
16588
16589 differ = FALSE;
16590 {
16591 int i;
16592
16593 for (i = 0; i < FEELING_LAST; i++) {
16594 differ = (old->ppl_content[i] != real_packet->ppl_content[i]);
16595 if (differ) {
16596 break;
16597 }
16598 }
16599 }
16600 if (differ) {
16601 different++;
16602 BV_SET(fields, 8);
16603 }
16604
16605 differ = FALSE;
16606 {
16607 int i;
16608
16609 for (i = 0; i < FEELING_LAST; i++) {
16610 differ = (old->ppl_unhappy[i] != real_packet->ppl_unhappy[i]);
16611 if (differ) {
16612 break;
16613 }
16614 }
16615 }
16616 if (differ) {
16617 different++;
16618 BV_SET(fields, 9);
16619 }
16620
16621 differ = FALSE;
16622 {
16623 int i;
16624
16625 for (i = 0; i < FEELING_LAST; i++) {
16626 differ = (old->ppl_angry[i] != real_packet->ppl_angry[i]);
16627 if (differ) {
16628 break;
16629 }
16630 }
16631 }
16632 if (differ) {
16633 different++;
16634 BV_SET(fields, 10);
16635 }
16636
16637 differ = (old->specialists_size != real_packet->specialists_size);
16638 if (differ) {
16639 different++;
16640 BV_SET(fields, 11);
16641 }
16642
16643 differ = (old->specialists_size != real_packet->specialists_size);
16644 if (!differ) {
16645 int i;
16646
16647 for (i = 0; i < old->specialists_size; i++) {
16648 differ = (old->specialists[i] != real_packet->specialists[i]);
16649 if (differ) {
16650 break;
16651 }
16652 }
16653 }
16654 if (differ) {
16655 different++;
16656 BV_SET(fields, 12);
16657 }
16658
16659 differ = (old->history != real_packet->history);
16660 if (differ) {
16661 different++;
16662 BV_SET(fields, 13);
16663 }
16664
16665 differ = (old->culture != real_packet->culture);
16666 if (differ) {
16667 different++;
16668 BV_SET(fields, 14);
16669 }
16670
16671 differ = (old->buy_cost != real_packet->buy_cost);
16672 if (differ) {
16673 different++;
16674 BV_SET(fields, 15);
16675 }
16676
16677 differ = FALSE;
16678 {
16679 int i;
16680
16681 for (i = 0; i < O_LAST; i++) {
16682 differ = (old->surplus[i] != real_packet->surplus[i]);
16683 if (differ) {
16684 break;
16685 }
16686 }
16687 }
16688 if (differ) {
16689 different++;
16690 BV_SET(fields, 16);
16691 }
16692
16693 differ = FALSE;
16694 {
16695 int i;
16696
16697 for (i = 0; i < O_LAST; i++) {
16698 differ = (old->waste[i] != real_packet->waste[i]);
16699 if (differ) {
16700 break;
16701 }
16702 }
16703 }
16704 if (differ) {
16705 different++;
16706 BV_SET(fields, 17);
16707 }
16708
16709 differ = FALSE;
16710 {
16711 int i;
16712
16713 for (i = 0; i < O_LAST; i++) {
16714 differ = (old->unhappy_penalty[i] != real_packet->unhappy_penalty[i]);
16715 if (differ) {
16716 break;
16717 }
16718 }
16719 }
16720 if (differ) {
16721 different++;
16722 BV_SET(fields, 18);
16723 }
16724
16725 differ = FALSE;
16726 {
16727 int i;
16728
16729 for (i = 0; i < O_LAST; i++) {
16730 differ = (old->prod[i] != real_packet->prod[i]);
16731 if (differ) {
16732 break;
16733 }
16734 }
16735 }
16736 if (differ) {
16737 different++;
16738 BV_SET(fields, 19);
16739 }
16740
16741 differ = FALSE;
16742 {
16743 int i;
16744
16745 for (i = 0; i < O_LAST; i++) {
16746 differ = (old->citizen_base[i] != real_packet->citizen_base[i]);
16747 if (differ) {
16748 break;
16749 }
16750 }
16751 }
16752 if (differ) {
16753 different++;
16754 BV_SET(fields, 20);
16755 }
16756
16757 differ = FALSE;
16758 {
16759 int i;
16760
16761 for (i = 0; i < O_LAST; i++) {
16762 differ = (old->usage[i] != real_packet->usage[i]);
16763 if (differ) {
16764 break;
16765 }
16766 }
16767 }
16768 if (differ) {
16769 different++;
16770 BV_SET(fields, 21);
16771 }
16772
16773 differ = (old->food_stock != real_packet->food_stock);
16774 if (differ) {
16775 different++;
16776 BV_SET(fields, 22);
16777 }
16778
16779 differ = (old->shield_stock != real_packet->shield_stock);
16780 if (differ) {
16781 different++;
16782 BV_SET(fields, 23);
16783 }
16784
16785 differ = (old->trade_route_count != real_packet->trade_route_count);
16786 if (differ) {
16787 different++;
16788 BV_SET(fields, 24);
16789 }
16790
16791 differ = (old->pollution != real_packet->pollution);
16792 if (differ) {
16793 different++;
16794 BV_SET(fields, 25);
16795 }
16796
16797 differ = (old->illness_trade != real_packet->illness_trade);
16798 if (differ) {
16799 different++;
16800 BV_SET(fields, 26);
16801 }
16802
16803 differ = (old->production_kind != real_packet->production_kind);
16804 if (differ) {
16805 different++;
16806 BV_SET(fields, 27);
16807 }
16808
16809 differ = (old->production_value != real_packet->production_value);
16810 if (differ) {
16811 different++;
16812 BV_SET(fields, 28);
16813 }
16814
16815 differ = (old->turn_founded != real_packet->turn_founded);
16816 if (differ) {
16817 different++;
16818 BV_SET(fields, 29);
16819 }
16820
16821 differ = (old->turn_last_built != real_packet->turn_last_built);
16822 if (differ) {
16823 different++;
16824 BV_SET(fields, 30);
16825 }
16826
16827 differ = (old->changed_from_kind != real_packet->changed_from_kind);
16828 if (differ) {
16829 different++;
16830 BV_SET(fields, 31);
16831 }
16832
16833 differ = (old->changed_from_value != real_packet->changed_from_value);
16834 if (differ) {
16835 different++;
16836 BV_SET(fields, 32);
16837 }
16838
16839 differ = (old->before_change_shields != real_packet->before_change_shields);
16840 if (differ) {
16841 different++;
16842 BV_SET(fields, 33);
16843 }
16844
16845 differ = (old->disbanded_shields != real_packet->disbanded_shields);
16846 if (differ) {
16847 different++;
16848 BV_SET(fields, 34);
16849 }
16850
16851 differ = (old->caravan_shields != real_packet->caravan_shields);
16852 if (differ) {
16853 different++;
16854 BV_SET(fields, 35);
16855 }
16856
16857 differ = (old->last_turns_shield_surplus != real_packet->last_turns_shield_surplus);
16858 if (differ) {
16859 different++;
16860 BV_SET(fields, 36);
16861 }
16862
16863 differ = (old->airlift != real_packet->airlift);
16864 if (differ) {
16865 different++;
16866 BV_SET(fields, 37);
16867 }
16868
16869 differ = (old->did_buy != real_packet->did_buy);
16870 if (differ) {
16871 different++;
16872 }
16873 /* folded into head */
16874 if (real_packet->did_buy) {
16875 BV_SET(fields, 38);
16876 }
16877
16878 differ = (old->did_sell != real_packet->did_sell);
16879 if (differ) {
16880 different++;
16881 }
16882 /* folded into head */
16883 if (real_packet->did_sell) {
16884 BV_SET(fields, 39);
16885 }
16886
16887 differ = (old->was_happy != real_packet->was_happy);
16888 if (differ) {
16889 different++;
16890 }
16891 /* folded into head */
16892 if (real_packet->was_happy) {
16893 BV_SET(fields, 40);
16894 }
16895
16896 differ = (old->had_famine != real_packet->had_famine);
16897 if (differ) {
16898 different++;
16899 }
16900 /* folded into head */
16901 if (real_packet->had_famine) {
16902 BV_SET(fields, 41);
16903 }
16904
16905 differ = (old->diplomat_investigate != real_packet->diplomat_investigate);
16906 if (differ) {
16907 different++;
16908 }
16909 /* folded into head */
16910 if (real_packet->diplomat_investigate) {
16911 BV_SET(fields, 42);
16912 }
16913
16914 differ = (old->walls != real_packet->walls);
16915 if (differ) {
16916 different++;
16917 BV_SET(fields, 43);
16918 }
16919
16920 differ = (old->city_image != real_packet->city_image);
16921 if (differ) {
16922 different++;
16923 BV_SET(fields, 44);
16924 }
16925
16926 differ = (old->steal != real_packet->steal);
16927 if (differ) {
16928 different++;
16929 BV_SET(fields, 45);
16930 }
16931
16932 differ = !are_worklists_equal(&old->worklist, &real_packet->worklist);
16933 if (differ) {
16934 different++;
16935 BV_SET(fields, 46);
16936 }
16937
16938 differ = !BV_ARE_EQUAL(old->improvements, real_packet->improvements);
16939 if (differ) {
16940 different++;
16941 BV_SET(fields, 47);
16942 }
16943
16944 differ = !BV_ARE_EQUAL(old->city_options, real_packet->city_options);
16945 if (differ) {
16946 different++;
16947 BV_SET(fields, 48);
16948 }
16949
16950 differ = (strcmp(old->name, real_packet->name) != 0);
16951 if (differ) {
16952 different++;
16953 BV_SET(fields, 49);
16954 }
16955
16956 if (different == 0) {
16957 log_packet_detailed(" no change -> discard");
16958 SEND_PACKET_DISCARD();
16959 }
16960#endif /* FREECIV_DELTA_PROTOCOL */
16961
16962#ifdef FREECIV_JSON_CONNECTION
16963 struct plocation field_addr;
16964 {
16965 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
16966 field_addr = *field_addr_tmp;
16967 FC_FREE(field_addr_tmp);
16968 }
16969#endif /* FREECIV_JSON_CONNECTION */
16970
16971#ifdef FREECIV_JSON_CONNECTION
16972 field_addr.name = "id";
16973#endif /* FREECIV_JSON_CONNECTION */
16974 e = 0;
16975
16976 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
16977
16978 if (e) {
16979 log_packet_detailed("'id' field error detected");
16980 }
16981
16982#ifdef FREECIV_DELTA_PROTOCOL
16983#ifdef FREECIV_JSON_CONNECTION
16984 field_addr.name = "fields";
16985#endif /* FREECIV_JSON_CONNECTION */
16986 e = 0;
16987 e |= DIO_BV_PUT(&dout, &field_addr, fields);
16988 if (e) {
16989 log_packet_detailed("fields bitvector error detected");
16990 }
16991
16992 if (BV_ISSET(fields, 0)) {
16993 log_packet_detailed(" field 'tile' has changed");
16994
16995#ifdef FREECIV_JSON_CONNECTION
16996 field_addr.name = "tile";
16997#endif /* FREECIV_JSON_CONNECTION */
16998 e = 0;
16999
17000 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
17001
17002 if (e) {
17003 log_packet_detailed("'tile' field error detected");
17004 }
17005 }
17006
17007 if (BV_ISSET(fields, 1)) {
17008 log_packet_detailed(" field 'owner' has changed");
17009
17010#ifdef FREECIV_JSON_CONNECTION
17011 field_addr.name = "owner";
17012#endif /* FREECIV_JSON_CONNECTION */
17013 e = 0;
17014
17015 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
17016
17017 if (e) {
17018 log_packet_detailed("'owner' field error detected");
17019 }
17020 }
17021
17022 if (BV_ISSET(fields, 2)) {
17023 log_packet_detailed(" field 'original' has changed");
17024
17025#ifdef FREECIV_JSON_CONNECTION
17026 field_addr.name = "original";
17027#endif /* FREECIV_JSON_CONNECTION */
17028 e = 0;
17029
17030 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->original);
17031
17032 if (e) {
17033 log_packet_detailed("'original' field error detected");
17034 }
17035 }
17036
17037 if (BV_ISSET(fields, 3)) {
17038 log_packet_detailed(" field 'size' has changed");
17039
17040#ifdef FREECIV_JSON_CONNECTION
17041 field_addr.name = "size";
17042#endif /* FREECIV_JSON_CONNECTION */
17043 e = 0;
17044
17045 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
17046
17047 if (e) {
17048 log_packet_detailed("'size' field error detected");
17049 }
17050 }
17051
17052 if (BV_ISSET(fields, 4)) {
17053 log_packet_detailed(" field 'city_radius_sq' has changed");
17054
17055#ifdef FREECIV_JSON_CONNECTION
17056 field_addr.name = "city_radius_sq";
17057#endif /* FREECIV_JSON_CONNECTION */
17058 e = 0;
17059
17060 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->city_radius_sq);
17061
17062 if (e) {
17063 log_packet_detailed("'city_radius_sq' field error detected");
17064 }
17065 }
17066
17067 if (BV_ISSET(fields, 5)) {
17068 log_packet_detailed(" field 'style' has changed");
17069
17070#ifdef FREECIV_JSON_CONNECTION
17071 field_addr.name = "style";
17072#endif /* FREECIV_JSON_CONNECTION */
17073 e = 0;
17074
17075 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
17076
17077 if (e) {
17078 log_packet_detailed("'style' field error detected");
17079 }
17080 }
17081
17082 if (BV_ISSET(fields, 6)) {
17083 log_packet_detailed(" field 'capital' has changed");
17084
17085#ifdef FREECIV_JSON_CONNECTION
17086 field_addr.name = "capital";
17087#endif /* FREECIV_JSON_CONNECTION */
17088 e = 0;
17089
17090 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->capital);
17091
17092 if (e) {
17093 log_packet_detailed("'capital' field error detected");
17094 }
17095 }
17096
17097 if (BV_ISSET(fields, 7)) {
17098 log_packet_detailed(" field 'ppl_happy' has changed");
17099
17100#ifdef FREECIV_JSON_CONNECTION
17101 field_addr.name = "ppl_happy";
17102#endif /* FREECIV_JSON_CONNECTION */
17103 e = 0;
17104
17105 {
17106 int i;
17107
17108#ifdef FREECIV_JSON_CONNECTION
17109 /* Create the array. */
17110 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
17111
17112 /* Enter array. */
17113 field_addr.sub_location = plocation_elem_new(0);
17114#endif /* FREECIV_JSON_CONNECTION */
17115
17116 for (i = 0; i < FEELING_LAST; i++) {
17117#ifdef FREECIV_JSON_CONNECTION
17118 /* Next array element. */
17119 field_addr.sub_location->number = i;
17120#endif /* FREECIV_JSON_CONNECTION */
17121
17122 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_happy[i]);
17123 }
17124
17125#ifdef FREECIV_JSON_CONNECTION
17126 /* Exit array. */
17127 FC_FREE(field_addr.sub_location);
17128#endif /* FREECIV_JSON_CONNECTION */
17129 }
17130
17131 if (e) {
17132 log_packet_detailed("'ppl_happy' field error detected");
17133 }
17134 }
17135
17136 if (BV_ISSET(fields, 8)) {
17137 log_packet_detailed(" field 'ppl_content' has changed");
17138
17139#ifdef FREECIV_JSON_CONNECTION
17140 field_addr.name = "ppl_content";
17141#endif /* FREECIV_JSON_CONNECTION */
17142 e = 0;
17143
17144 {
17145 int i;
17146
17147#ifdef FREECIV_JSON_CONNECTION
17148 /* Create the array. */
17149 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
17150
17151 /* Enter array. */
17152 field_addr.sub_location = plocation_elem_new(0);
17153#endif /* FREECIV_JSON_CONNECTION */
17154
17155 for (i = 0; i < FEELING_LAST; i++) {
17156#ifdef FREECIV_JSON_CONNECTION
17157 /* Next array element. */
17158 field_addr.sub_location->number = i;
17159#endif /* FREECIV_JSON_CONNECTION */
17160
17161 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_content[i]);
17162 }
17163
17164#ifdef FREECIV_JSON_CONNECTION
17165 /* Exit array. */
17166 FC_FREE(field_addr.sub_location);
17167#endif /* FREECIV_JSON_CONNECTION */
17168 }
17169
17170 if (e) {
17171 log_packet_detailed("'ppl_content' field error detected");
17172 }
17173 }
17174
17175 if (BV_ISSET(fields, 9)) {
17176 log_packet_detailed(" field 'ppl_unhappy' has changed");
17177
17178#ifdef FREECIV_JSON_CONNECTION
17179 field_addr.name = "ppl_unhappy";
17180#endif /* FREECIV_JSON_CONNECTION */
17181 e = 0;
17182
17183 {
17184 int i;
17185
17186#ifdef FREECIV_JSON_CONNECTION
17187 /* Create the array. */
17188 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
17189
17190 /* Enter array. */
17191 field_addr.sub_location = plocation_elem_new(0);
17192#endif /* FREECIV_JSON_CONNECTION */
17193
17194 for (i = 0; i < FEELING_LAST; i++) {
17195#ifdef FREECIV_JSON_CONNECTION
17196 /* Next array element. */
17197 field_addr.sub_location->number = i;
17198#endif /* FREECIV_JSON_CONNECTION */
17199
17200 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_unhappy[i]);
17201 }
17202
17203#ifdef FREECIV_JSON_CONNECTION
17204 /* Exit array. */
17205 FC_FREE(field_addr.sub_location);
17206#endif /* FREECIV_JSON_CONNECTION */
17207 }
17208
17209 if (e) {
17210 log_packet_detailed("'ppl_unhappy' field error detected");
17211 }
17212 }
17213
17214 if (BV_ISSET(fields, 10)) {
17215 log_packet_detailed(" field 'ppl_angry' has changed");
17216
17217#ifdef FREECIV_JSON_CONNECTION
17218 field_addr.name = "ppl_angry";
17219#endif /* FREECIV_JSON_CONNECTION */
17220 e = 0;
17221
17222 {
17223 int i;
17224
17225#ifdef FREECIV_JSON_CONNECTION
17226 /* Create the array. */
17227 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
17228
17229 /* Enter array. */
17230 field_addr.sub_location = plocation_elem_new(0);
17231#endif /* FREECIV_JSON_CONNECTION */
17232
17233 for (i = 0; i < FEELING_LAST; i++) {
17234#ifdef FREECIV_JSON_CONNECTION
17235 /* Next array element. */
17236 field_addr.sub_location->number = i;
17237#endif /* FREECIV_JSON_CONNECTION */
17238
17239 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_angry[i]);
17240 }
17241
17242#ifdef FREECIV_JSON_CONNECTION
17243 /* Exit array. */
17244 FC_FREE(field_addr.sub_location);
17245#endif /* FREECIV_JSON_CONNECTION */
17246 }
17247
17248 if (e) {
17249 log_packet_detailed("'ppl_angry' field error detected");
17250 }
17251 }
17252
17253 if (BV_ISSET(fields, 11)) {
17254 log_packet_detailed(" field 'specialists_size' has changed");
17255
17256#ifdef FREECIV_JSON_CONNECTION
17257 field_addr.name = "specialists_size";
17258#endif /* FREECIV_JSON_CONNECTION */
17259 e = 0;
17260
17261 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists_size);
17262
17263 if (e) {
17264 log_packet_detailed("'specialists_size' field error detected");
17265 }
17266 }
17267
17268 if (BV_ISSET(fields, 12)) {
17269 log_packet_detailed(" field 'specialists' has changed");
17270
17271#ifdef FREECIV_JSON_CONNECTION
17272 field_addr.name = "specialists";
17273#endif /* FREECIV_JSON_CONNECTION */
17274 e = 0;
17275
17276 {
17277 int i;
17278
17279#ifdef FREECIV_JSON_CONNECTION
17280 /* Create the array. */
17281 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->specialists_size);
17282
17283 /* Enter array. */
17284 field_addr.sub_location = plocation_elem_new(0);
17285#endif /* FREECIV_JSON_CONNECTION */
17286
17287 for (i = 0; i < real_packet->specialists_size; i++) {
17288#ifdef FREECIV_JSON_CONNECTION
17289 /* Next array element. */
17290 field_addr.sub_location->number = i;
17291#endif /* FREECIV_JSON_CONNECTION */
17292
17293 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists[i]);
17294 }
17295
17296#ifdef FREECIV_JSON_CONNECTION
17297 /* Exit array. */
17298 FC_FREE(field_addr.sub_location);
17299#endif /* FREECIV_JSON_CONNECTION */
17300 }
17301
17302 if (e) {
17303 log_packet_detailed("'specialists' field error detected");
17304 }
17305 }
17306
17307 if (BV_ISSET(fields, 13)) {
17308 log_packet_detailed(" field 'history' has changed");
17309
17310#ifdef FREECIV_JSON_CONNECTION
17311 field_addr.name = "history";
17312#endif /* FREECIV_JSON_CONNECTION */
17313 e = 0;
17314
17315 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->history);
17316
17317 if (e) {
17318 log_packet_detailed("'history' field error detected");
17319 }
17320 }
17321
17322 if (BV_ISSET(fields, 14)) {
17323 log_packet_detailed(" field 'culture' has changed");
17324
17325#ifdef FREECIV_JSON_CONNECTION
17326 field_addr.name = "culture";
17327#endif /* FREECIV_JSON_CONNECTION */
17328 e = 0;
17329
17330 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->culture);
17331
17332 if (e) {
17333 log_packet_detailed("'culture' field error detected");
17334 }
17335 }
17336
17337 if (BV_ISSET(fields, 15)) {
17338 log_packet_detailed(" field 'buy_cost' has changed");
17339
17340#ifdef FREECIV_JSON_CONNECTION
17341 field_addr.name = "buy_cost";
17342#endif /* FREECIV_JSON_CONNECTION */
17343 e = 0;
17344
17345 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->buy_cost);
17346
17347 if (e) {
17348 log_packet_detailed("'buy_cost' field error detected");
17349 }
17350 }
17351
17352 if (BV_ISSET(fields, 16)) {
17353 log_packet_detailed(" field 'surplus' has changed");
17354
17355#ifdef FREECIV_JSON_CONNECTION
17356 field_addr.name = "surplus";
17357#endif /* FREECIV_JSON_CONNECTION */
17358 e = 0;
17359
17360 {
17361 int i;
17362
17363#ifdef FREECIV_JSON_CONNECTION
17364 /* Create the array. */
17365 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
17366
17367 /* Enter array. */
17368 field_addr.sub_location = plocation_elem_new(0);
17369#endif /* FREECIV_JSON_CONNECTION */
17370
17371 for (i = 0; i < O_LAST; i++) {
17372#ifdef FREECIV_JSON_CONNECTION
17373 /* Next array element. */
17374 field_addr.sub_location->number = i;
17375#endif /* FREECIV_JSON_CONNECTION */
17376
17377 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->surplus[i]);
17378 }
17379
17380#ifdef FREECIV_JSON_CONNECTION
17381 /* Exit array. */
17382 FC_FREE(field_addr.sub_location);
17383#endif /* FREECIV_JSON_CONNECTION */
17384 }
17385
17386 if (e) {
17387 log_packet_detailed("'surplus' field error detected");
17388 }
17389 }
17390
17391 if (BV_ISSET(fields, 17)) {
17392 log_packet_detailed(" field 'waste' has changed");
17393
17394#ifdef FREECIV_JSON_CONNECTION
17395 field_addr.name = "waste";
17396#endif /* FREECIV_JSON_CONNECTION */
17397 e = 0;
17398
17399 {
17400 int i;
17401
17402#ifdef FREECIV_JSON_CONNECTION
17403 /* Create the array. */
17404 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
17405
17406 /* Enter array. */
17407 field_addr.sub_location = plocation_elem_new(0);
17408#endif /* FREECIV_JSON_CONNECTION */
17409
17410 for (i = 0; i < O_LAST; i++) {
17411#ifdef FREECIV_JSON_CONNECTION
17412 /* Next array element. */
17413 field_addr.sub_location->number = i;
17414#endif /* FREECIV_JSON_CONNECTION */
17415
17416 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->waste[i]);
17417 }
17418
17419#ifdef FREECIV_JSON_CONNECTION
17420 /* Exit array. */
17421 FC_FREE(field_addr.sub_location);
17422#endif /* FREECIV_JSON_CONNECTION */
17423 }
17424
17425 if (e) {
17426 log_packet_detailed("'waste' field error detected");
17427 }
17428 }
17429
17430 if (BV_ISSET(fields, 18)) {
17431 log_packet_detailed(" field 'unhappy_penalty' has changed");
17432
17433#ifdef FREECIV_JSON_CONNECTION
17434 field_addr.name = "unhappy_penalty";
17435#endif /* FREECIV_JSON_CONNECTION */
17436 e = 0;
17437
17438 {
17439 int i;
17440
17441#ifdef FREECIV_JSON_CONNECTION
17442 /* Create the array. */
17443 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
17444
17445 /* Enter array. */
17446 field_addr.sub_location = plocation_elem_new(0);
17447#endif /* FREECIV_JSON_CONNECTION */
17448
17449 for (i = 0; i < O_LAST; i++) {
17450#ifdef FREECIV_JSON_CONNECTION
17451 /* Next array element. */
17452 field_addr.sub_location->number = i;
17453#endif /* FREECIV_JSON_CONNECTION */
17454
17455 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->unhappy_penalty[i]);
17456 }
17457
17458#ifdef FREECIV_JSON_CONNECTION
17459 /* Exit array. */
17460 FC_FREE(field_addr.sub_location);
17461#endif /* FREECIV_JSON_CONNECTION */
17462 }
17463
17464 if (e) {
17465 log_packet_detailed("'unhappy_penalty' field error detected");
17466 }
17467 }
17468
17469 if (BV_ISSET(fields, 19)) {
17470 log_packet_detailed(" field 'prod' has changed");
17471
17472#ifdef FREECIV_JSON_CONNECTION
17473 field_addr.name = "prod";
17474#endif /* FREECIV_JSON_CONNECTION */
17475 e = 0;
17476
17477 {
17478 int i;
17479
17480#ifdef FREECIV_JSON_CONNECTION
17481 /* Create the array. */
17482 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
17483
17484 /* Enter array. */
17485 field_addr.sub_location = plocation_elem_new(0);
17486#endif /* FREECIV_JSON_CONNECTION */
17487
17488 for (i = 0; i < O_LAST; i++) {
17489#ifdef FREECIV_JSON_CONNECTION
17490 /* Next array element. */
17491 field_addr.sub_location->number = i;
17492#endif /* FREECIV_JSON_CONNECTION */
17493
17494 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->prod[i]);
17495 }
17496
17497#ifdef FREECIV_JSON_CONNECTION
17498 /* Exit array. */
17499 FC_FREE(field_addr.sub_location);
17500#endif /* FREECIV_JSON_CONNECTION */
17501 }
17502
17503 if (e) {
17504 log_packet_detailed("'prod' field error detected");
17505 }
17506 }
17507
17508 if (BV_ISSET(fields, 20)) {
17509 log_packet_detailed(" field 'citizen_base' has changed");
17510
17511#ifdef FREECIV_JSON_CONNECTION
17512 field_addr.name = "citizen_base";
17513#endif /* FREECIV_JSON_CONNECTION */
17514 e = 0;
17515
17516 {
17517 int i;
17518
17519#ifdef FREECIV_JSON_CONNECTION
17520 /* Create the array. */
17521 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
17522
17523 /* Enter array. */
17524 field_addr.sub_location = plocation_elem_new(0);
17525#endif /* FREECIV_JSON_CONNECTION */
17526
17527 for (i = 0; i < O_LAST; i++) {
17528#ifdef FREECIV_JSON_CONNECTION
17529 /* Next array element. */
17530 field_addr.sub_location->number = i;
17531#endif /* FREECIV_JSON_CONNECTION */
17532
17533 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->citizen_base[i]);
17534 }
17535
17536#ifdef FREECIV_JSON_CONNECTION
17537 /* Exit array. */
17538 FC_FREE(field_addr.sub_location);
17539#endif /* FREECIV_JSON_CONNECTION */
17540 }
17541
17542 if (e) {
17543 log_packet_detailed("'citizen_base' field error detected");
17544 }
17545 }
17546
17547 if (BV_ISSET(fields, 21)) {
17548 log_packet_detailed(" field 'usage' has changed");
17549
17550#ifdef FREECIV_JSON_CONNECTION
17551 field_addr.name = "usage";
17552#endif /* FREECIV_JSON_CONNECTION */
17553 e = 0;
17554
17555 {
17556 int i;
17557
17558#ifdef FREECIV_JSON_CONNECTION
17559 /* Create the array. */
17560 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
17561
17562 /* Enter array. */
17563 field_addr.sub_location = plocation_elem_new(0);
17564#endif /* FREECIV_JSON_CONNECTION */
17565
17566 for (i = 0; i < O_LAST; i++) {
17567#ifdef FREECIV_JSON_CONNECTION
17568 /* Next array element. */
17569 field_addr.sub_location->number = i;
17570#endif /* FREECIV_JSON_CONNECTION */
17571
17572 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->usage[i]);
17573 }
17574
17575#ifdef FREECIV_JSON_CONNECTION
17576 /* Exit array. */
17577 FC_FREE(field_addr.sub_location);
17578#endif /* FREECIV_JSON_CONNECTION */
17579 }
17580
17581 if (e) {
17582 log_packet_detailed("'usage' field error detected");
17583 }
17584 }
17585
17586 if (BV_ISSET(fields, 22)) {
17587 log_packet_detailed(" field 'food_stock' has changed");
17588
17589#ifdef FREECIV_JSON_CONNECTION
17590 field_addr.name = "food_stock";
17591#endif /* FREECIV_JSON_CONNECTION */
17592 e = 0;
17593
17594 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->food_stock);
17595
17596 if (e) {
17597 log_packet_detailed("'food_stock' field error detected");
17598 }
17599 }
17600
17601 if (BV_ISSET(fields, 23)) {
17602 log_packet_detailed(" field 'shield_stock' has changed");
17603
17604#ifdef FREECIV_JSON_CONNECTION
17605 field_addr.name = "shield_stock";
17606#endif /* FREECIV_JSON_CONNECTION */
17607 e = 0;
17608
17609 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->shield_stock);
17610
17611 if (e) {
17612 log_packet_detailed("'shield_stock' field error detected");
17613 }
17614 }
17615
17616 if (BV_ISSET(fields, 24)) {
17617 log_packet_detailed(" field 'trade_route_count' has changed");
17618
17619#ifdef FREECIV_JSON_CONNECTION
17620 field_addr.name = "trade_route_count";
17621#endif /* FREECIV_JSON_CONNECTION */
17622 e = 0;
17623
17624 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->trade_route_count);
17625
17626 if (e) {
17627 log_packet_detailed("'trade_route_count' field error detected");
17628 }
17629 }
17630
17631 if (BV_ISSET(fields, 25)) {
17632 log_packet_detailed(" field 'pollution' has changed");
17633
17634#ifdef FREECIV_JSON_CONNECTION
17635 field_addr.name = "pollution";
17636#endif /* FREECIV_JSON_CONNECTION */
17637 e = 0;
17638
17639 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->pollution);
17640
17641 if (e) {
17642 log_packet_detailed("'pollution' field error detected");
17643 }
17644 }
17645
17646 if (BV_ISSET(fields, 26)) {
17647 log_packet_detailed(" field 'illness_trade' has changed");
17648
17649#ifdef FREECIV_JSON_CONNECTION
17650 field_addr.name = "illness_trade";
17651#endif /* FREECIV_JSON_CONNECTION */
17652 e = 0;
17653
17654 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_trade);
17655
17656 if (e) {
17657 log_packet_detailed("'illness_trade' field error detected");
17658 }
17659 }
17660
17661 if (BV_ISSET(fields, 27)) {
17662 log_packet_detailed(" field 'production_kind' has changed");
17663
17664#ifdef FREECIV_JSON_CONNECTION
17665 field_addr.name = "production_kind";
17666#endif /* FREECIV_JSON_CONNECTION */
17667 e = 0;
17668
17669 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_kind);
17670
17671 if (e) {
17672 log_packet_detailed("'production_kind' field error detected");
17673 }
17674 }
17675
17676 if (BV_ISSET(fields, 28)) {
17677 log_packet_detailed(" field 'production_value' has changed");
17678
17679#ifdef FREECIV_JSON_CONNECTION
17680 field_addr.name = "production_value";
17681#endif /* FREECIV_JSON_CONNECTION */
17682 e = 0;
17683
17684 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_value);
17685
17686 if (e) {
17687 log_packet_detailed("'production_value' field error detected");
17688 }
17689 }
17690
17691 if (BV_ISSET(fields, 29)) {
17692 log_packet_detailed(" field 'turn_founded' has changed");
17693
17694#ifdef FREECIV_JSON_CONNECTION
17695 field_addr.name = "turn_founded";
17696#endif /* FREECIV_JSON_CONNECTION */
17697 e = 0;
17698
17699 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_founded);
17700
17701 if (e) {
17702 log_packet_detailed("'turn_founded' field error detected");
17703 }
17704 }
17705
17706 if (BV_ISSET(fields, 30)) {
17707 log_packet_detailed(" field 'turn_last_built' has changed");
17708
17709#ifdef FREECIV_JSON_CONNECTION
17710 field_addr.name = "turn_last_built";
17711#endif /* FREECIV_JSON_CONNECTION */
17712 e = 0;
17713
17714 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_last_built);
17715
17716 if (e) {
17717 log_packet_detailed("'turn_last_built' field error detected");
17718 }
17719 }
17720
17721 if (BV_ISSET(fields, 31)) {
17722 log_packet_detailed(" field 'changed_from_kind' has changed");
17723
17724#ifdef FREECIV_JSON_CONNECTION
17725 field_addr.name = "changed_from_kind";
17726#endif /* FREECIV_JSON_CONNECTION */
17727 e = 0;
17728
17729 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->changed_from_kind);
17730
17731 if (e) {
17732 log_packet_detailed("'changed_from_kind' field error detected");
17733 }
17734 }
17735
17736 if (BV_ISSET(fields, 32)) {
17737 log_packet_detailed(" field 'changed_from_value' has changed");
17738
17739#ifdef FREECIV_JSON_CONNECTION
17740 field_addr.name = "changed_from_value";
17741#endif /* FREECIV_JSON_CONNECTION */
17742 e = 0;
17743
17744 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->changed_from_value);
17745
17746 if (e) {
17747 log_packet_detailed("'changed_from_value' field error detected");
17748 }
17749 }
17750
17751 if (BV_ISSET(fields, 33)) {
17752 log_packet_detailed(" field 'before_change_shields' has changed");
17753
17754#ifdef FREECIV_JSON_CONNECTION
17755 field_addr.name = "before_change_shields";
17756#endif /* FREECIV_JSON_CONNECTION */
17757 e = 0;
17758
17759 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->before_change_shields);
17760
17761 if (e) {
17762 log_packet_detailed("'before_change_shields' field error detected");
17763 }
17764 }
17765
17766 if (BV_ISSET(fields, 34)) {
17767 log_packet_detailed(" field 'disbanded_shields' has changed");
17768
17769#ifdef FREECIV_JSON_CONNECTION
17770 field_addr.name = "disbanded_shields";
17771#endif /* FREECIV_JSON_CONNECTION */
17772 e = 0;
17773
17774 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->disbanded_shields);
17775
17776 if (e) {
17777 log_packet_detailed("'disbanded_shields' field error detected");
17778 }
17779 }
17780
17781 if (BV_ISSET(fields, 35)) {
17782 log_packet_detailed(" field 'caravan_shields' has changed");
17783
17784#ifdef FREECIV_JSON_CONNECTION
17785 field_addr.name = "caravan_shields";
17786#endif /* FREECIV_JSON_CONNECTION */
17787 e = 0;
17788
17789 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->caravan_shields);
17790
17791 if (e) {
17792 log_packet_detailed("'caravan_shields' field error detected");
17793 }
17794 }
17795
17796 if (BV_ISSET(fields, 36)) {
17797 log_packet_detailed(" field 'last_turns_shield_surplus' has changed");
17798
17799#ifdef FREECIV_JSON_CONNECTION
17800 field_addr.name = "last_turns_shield_surplus";
17801#endif /* FREECIV_JSON_CONNECTION */
17802 e = 0;
17803
17804 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->last_turns_shield_surplus);
17805
17806 if (e) {
17807 log_packet_detailed("'last_turns_shield_surplus' field error detected");
17808 }
17809 }
17810
17811 if (BV_ISSET(fields, 37)) {
17812 log_packet_detailed(" field 'airlift' has changed");
17813
17814#ifdef FREECIV_JSON_CONNECTION
17815 field_addr.name = "airlift";
17816#endif /* FREECIV_JSON_CONNECTION */
17817 e = 0;
17818
17819 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->airlift);
17820
17821 if (e) {
17822 log_packet_detailed("'airlift' field error detected");
17823 }
17824 }
17825
17826 /* field 38 is folded into the header */
17827
17828 /* field 39 is folded into the header */
17829
17830 /* field 40 is folded into the header */
17831
17832 /* field 41 is folded into the header */
17833
17834 /* field 42 is folded into the header */
17835
17836 if (BV_ISSET(fields, 43)) {
17837 log_packet_detailed(" field 'walls' has changed");
17838
17839#ifdef FREECIV_JSON_CONNECTION
17840 field_addr.name = "walls";
17841#endif /* FREECIV_JSON_CONNECTION */
17842 e = 0;
17843
17844 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->walls);
17845
17846 if (e) {
17847 log_packet_detailed("'walls' field error detected");
17848 }
17849 }
17850
17851 if (BV_ISSET(fields, 44)) {
17852 log_packet_detailed(" field 'city_image' has changed");
17853
17854#ifdef FREECIV_JSON_CONNECTION
17855 field_addr.name = "city_image";
17856#endif /* FREECIV_JSON_CONNECTION */
17857 e = 0;
17858
17859 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->city_image);
17860
17861 if (e) {
17862 log_packet_detailed("'city_image' field error detected");
17863 }
17864 }
17865
17866 if (BV_ISSET(fields, 45)) {
17867 log_packet_detailed(" field 'steal' has changed");
17868
17869#ifdef FREECIV_JSON_CONNECTION
17870 field_addr.name = "steal";
17871#endif /* FREECIV_JSON_CONNECTION */
17872 e = 0;
17873
17874 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->steal);
17875
17876 if (e) {
17877 log_packet_detailed("'steal' field error detected");
17878 }
17879 }
17880
17881 if (BV_ISSET(fields, 46)) {
17882 log_packet_detailed(" field 'worklist' has changed");
17883
17884#ifdef FREECIV_JSON_CONNECTION
17885 field_addr.name = "worklist";
17886#endif /* FREECIV_JSON_CONNECTION */
17887 e = 0;
17888
17889 e |= DIO_PUT(worklist, &dout, &field_addr, &real_packet->worklist);
17890
17891 if (e) {
17892 log_packet_detailed("'worklist' field error detected");
17893 }
17894 }
17895
17896 if (BV_ISSET(fields, 47)) {
17897 log_packet_detailed(" field 'improvements' has changed");
17898
17899#ifdef FREECIV_JSON_CONNECTION
17900 field_addr.name = "improvements";
17901#endif /* FREECIV_JSON_CONNECTION */
17902 e = 0;
17903
17904 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->improvements);
17905
17906 if (e) {
17907 log_packet_detailed("'improvements' field error detected");
17908 }
17909 }
17910
17911 if (BV_ISSET(fields, 48)) {
17912 log_packet_detailed(" field 'city_options' has changed");
17913
17914#ifdef FREECIV_JSON_CONNECTION
17915 field_addr.name = "city_options";
17916#endif /* FREECIV_JSON_CONNECTION */
17917 e = 0;
17918
17919 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->city_options);
17920
17921 if (e) {
17922 log_packet_detailed("'city_options' field error detected");
17923 }
17924 }
17925
17926 if (BV_ISSET(fields, 49)) {
17927 log_packet_detailed(" field 'name' has changed");
17928
17929#ifdef FREECIV_JSON_CONNECTION
17930 field_addr.name = "name";
17931#endif /* FREECIV_JSON_CONNECTION */
17932 e = 0;
17933
17934 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
17935
17936 if (e) {
17937 log_packet_detailed("'name' field error detected");
17938 }
17939 }
17940
17941 *old = *real_packet;
17942
17943 hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
17944 if (nullptr != *hash) {
17945 genhash_remove(*hash, real_packet);
17946 }
17947
17948#else /* FREECIV_DELTA_PROTOCOL */
17949#ifdef FREECIV_JSON_CONNECTION
17950 field_addr.name = "tile";
17951#endif /* FREECIV_JSON_CONNECTION */
17952 e = 0;
17953
17954 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
17955
17956 if (e) {
17957 log_packet_detailed("'tile' field error detected");
17958 }
17959
17960#ifdef FREECIV_JSON_CONNECTION
17961 field_addr.name = "owner";
17962#endif /* FREECIV_JSON_CONNECTION */
17963 e = 0;
17964
17965 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
17966
17967 if (e) {
17968 log_packet_detailed("'owner' field error detected");
17969 }
17970
17971#ifdef FREECIV_JSON_CONNECTION
17972 field_addr.name = "original";
17973#endif /* FREECIV_JSON_CONNECTION */
17974 e = 0;
17975
17976 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->original);
17977
17978 if (e) {
17979 log_packet_detailed("'original' field error detected");
17980 }
17981
17982#ifdef FREECIV_JSON_CONNECTION
17983 field_addr.name = "size";
17984#endif /* FREECIV_JSON_CONNECTION */
17985 e = 0;
17986
17987 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
17988
17989 if (e) {
17990 log_packet_detailed("'size' field error detected");
17991 }
17992
17993#ifdef FREECIV_JSON_CONNECTION
17994 field_addr.name = "city_radius_sq";
17995#endif /* FREECIV_JSON_CONNECTION */
17996 e = 0;
17997
17998 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->city_radius_sq);
17999
18000 if (e) {
18001 log_packet_detailed("'city_radius_sq' field error detected");
18002 }
18003
18004#ifdef FREECIV_JSON_CONNECTION
18005 field_addr.name = "style";
18006#endif /* FREECIV_JSON_CONNECTION */
18007 e = 0;
18008
18009 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
18010
18011 if (e) {
18012 log_packet_detailed("'style' field error detected");
18013 }
18014
18015#ifdef FREECIV_JSON_CONNECTION
18016 field_addr.name = "capital";
18017#endif /* FREECIV_JSON_CONNECTION */
18018 e = 0;
18019
18020 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->capital);
18021
18022 if (e) {
18023 log_packet_detailed("'capital' field error detected");
18024 }
18025
18026#ifdef FREECIV_JSON_CONNECTION
18027 field_addr.name = "ppl_happy";
18028#endif /* FREECIV_JSON_CONNECTION */
18029 e = 0;
18030
18031 {
18032 int i;
18033
18034#ifdef FREECIV_JSON_CONNECTION
18035 /* Create the array. */
18036 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
18037
18038 /* Enter array. */
18039 field_addr.sub_location = plocation_elem_new(0);
18040#endif /* FREECIV_JSON_CONNECTION */
18041
18042 for (i = 0; i < FEELING_LAST; i++) {
18043#ifdef FREECIV_JSON_CONNECTION
18044 /* Next array element. */
18045 field_addr.sub_location->number = i;
18046#endif /* FREECIV_JSON_CONNECTION */
18047
18048 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_happy[i]);
18049 }
18050
18051#ifdef FREECIV_JSON_CONNECTION
18052 /* Exit array. */
18053 FC_FREE(field_addr.sub_location);
18054#endif /* FREECIV_JSON_CONNECTION */
18055 }
18056
18057 if (e) {
18058 log_packet_detailed("'ppl_happy' field error detected");
18059 }
18060
18061#ifdef FREECIV_JSON_CONNECTION
18062 field_addr.name = "ppl_content";
18063#endif /* FREECIV_JSON_CONNECTION */
18064 e = 0;
18065
18066 {
18067 int i;
18068
18069#ifdef FREECIV_JSON_CONNECTION
18070 /* Create the array. */
18071 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
18072
18073 /* Enter array. */
18074 field_addr.sub_location = plocation_elem_new(0);
18075#endif /* FREECIV_JSON_CONNECTION */
18076
18077 for (i = 0; i < FEELING_LAST; i++) {
18078#ifdef FREECIV_JSON_CONNECTION
18079 /* Next array element. */
18080 field_addr.sub_location->number = i;
18081#endif /* FREECIV_JSON_CONNECTION */
18082
18083 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_content[i]);
18084 }
18085
18086#ifdef FREECIV_JSON_CONNECTION
18087 /* Exit array. */
18088 FC_FREE(field_addr.sub_location);
18089#endif /* FREECIV_JSON_CONNECTION */
18090 }
18091
18092 if (e) {
18093 log_packet_detailed("'ppl_content' field error detected");
18094 }
18095
18096#ifdef FREECIV_JSON_CONNECTION
18097 field_addr.name = "ppl_unhappy";
18098#endif /* FREECIV_JSON_CONNECTION */
18099 e = 0;
18100
18101 {
18102 int i;
18103
18104#ifdef FREECIV_JSON_CONNECTION
18105 /* Create the array. */
18106 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
18107
18108 /* Enter array. */
18109 field_addr.sub_location = plocation_elem_new(0);
18110#endif /* FREECIV_JSON_CONNECTION */
18111
18112 for (i = 0; i < FEELING_LAST; i++) {
18113#ifdef FREECIV_JSON_CONNECTION
18114 /* Next array element. */
18115 field_addr.sub_location->number = i;
18116#endif /* FREECIV_JSON_CONNECTION */
18117
18118 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_unhappy[i]);
18119 }
18120
18121#ifdef FREECIV_JSON_CONNECTION
18122 /* Exit array. */
18123 FC_FREE(field_addr.sub_location);
18124#endif /* FREECIV_JSON_CONNECTION */
18125 }
18126
18127 if (e) {
18128 log_packet_detailed("'ppl_unhappy' field error detected");
18129 }
18130
18131#ifdef FREECIV_JSON_CONNECTION
18132 field_addr.name = "ppl_angry";
18133#endif /* FREECIV_JSON_CONNECTION */
18134 e = 0;
18135
18136 {
18137 int i;
18138
18139#ifdef FREECIV_JSON_CONNECTION
18140 /* Create the array. */
18141 e |= DIO_PUT(farray, &dout, &field_addr, FEELING_LAST);
18142
18143 /* Enter array. */
18144 field_addr.sub_location = plocation_elem_new(0);
18145#endif /* FREECIV_JSON_CONNECTION */
18146
18147 for (i = 0; i < FEELING_LAST; i++) {
18148#ifdef FREECIV_JSON_CONNECTION
18149 /* Next array element. */
18150 field_addr.sub_location->number = i;
18151#endif /* FREECIV_JSON_CONNECTION */
18152
18153 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_angry[i]);
18154 }
18155
18156#ifdef FREECIV_JSON_CONNECTION
18157 /* Exit array. */
18158 FC_FREE(field_addr.sub_location);
18159#endif /* FREECIV_JSON_CONNECTION */
18160 }
18161
18162 if (e) {
18163 log_packet_detailed("'ppl_angry' field error detected");
18164 }
18165
18166#ifdef FREECIV_JSON_CONNECTION
18167 field_addr.name = "specialists_size";
18168#endif /* FREECIV_JSON_CONNECTION */
18169 e = 0;
18170
18171 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists_size);
18172
18173 if (e) {
18174 log_packet_detailed("'specialists_size' field error detected");
18175 }
18176
18177#ifdef FREECIV_JSON_CONNECTION
18178 field_addr.name = "specialists";
18179#endif /* FREECIV_JSON_CONNECTION */
18180 e = 0;
18181
18182 {
18183 int i;
18184
18185#ifdef FREECIV_JSON_CONNECTION
18186 /* Create the array. */
18187 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->specialists_size);
18188
18189 /* Enter array. */
18190 field_addr.sub_location = plocation_elem_new(0);
18191#endif /* FREECIV_JSON_CONNECTION */
18192
18193 for (i = 0; i < real_packet->specialists_size; i++) {
18194#ifdef FREECIV_JSON_CONNECTION
18195 /* Next array element. */
18196 field_addr.sub_location->number = i;
18197#endif /* FREECIV_JSON_CONNECTION */
18198
18199 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists[i]);
18200 }
18201
18202#ifdef FREECIV_JSON_CONNECTION
18203 /* Exit array. */
18204 FC_FREE(field_addr.sub_location);
18205#endif /* FREECIV_JSON_CONNECTION */
18206 }
18207
18208 if (e) {
18209 log_packet_detailed("'specialists' field error detected");
18210 }
18211
18212#ifdef FREECIV_JSON_CONNECTION
18213 field_addr.name = "history";
18214#endif /* FREECIV_JSON_CONNECTION */
18215 e = 0;
18216
18217 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->history);
18218
18219 if (e) {
18220 log_packet_detailed("'history' field error detected");
18221 }
18222
18223#ifdef FREECIV_JSON_CONNECTION
18224 field_addr.name = "culture";
18225#endif /* FREECIV_JSON_CONNECTION */
18226 e = 0;
18227
18228 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->culture);
18229
18230 if (e) {
18231 log_packet_detailed("'culture' field error detected");
18232 }
18233
18234#ifdef FREECIV_JSON_CONNECTION
18235 field_addr.name = "buy_cost";
18236#endif /* FREECIV_JSON_CONNECTION */
18237 e = 0;
18238
18239 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->buy_cost);
18240
18241 if (e) {
18242 log_packet_detailed("'buy_cost' field error detected");
18243 }
18244
18245#ifdef FREECIV_JSON_CONNECTION
18246 field_addr.name = "surplus";
18247#endif /* FREECIV_JSON_CONNECTION */
18248 e = 0;
18249
18250 {
18251 int i;
18252
18253#ifdef FREECIV_JSON_CONNECTION
18254 /* Create the array. */
18255 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
18256
18257 /* Enter array. */
18258 field_addr.sub_location = plocation_elem_new(0);
18259#endif /* FREECIV_JSON_CONNECTION */
18260
18261 for (i = 0; i < O_LAST; i++) {
18262#ifdef FREECIV_JSON_CONNECTION
18263 /* Next array element. */
18264 field_addr.sub_location->number = i;
18265#endif /* FREECIV_JSON_CONNECTION */
18266
18267 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->surplus[i]);
18268 }
18269
18270#ifdef FREECIV_JSON_CONNECTION
18271 /* Exit array. */
18272 FC_FREE(field_addr.sub_location);
18273#endif /* FREECIV_JSON_CONNECTION */
18274 }
18275
18276 if (e) {
18277 log_packet_detailed("'surplus' field error detected");
18278 }
18279
18280#ifdef FREECIV_JSON_CONNECTION
18281 field_addr.name = "waste";
18282#endif /* FREECIV_JSON_CONNECTION */
18283 e = 0;
18284
18285 {
18286 int i;
18287
18288#ifdef FREECIV_JSON_CONNECTION
18289 /* Create the array. */
18290 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
18291
18292 /* Enter array. */
18293 field_addr.sub_location = plocation_elem_new(0);
18294#endif /* FREECIV_JSON_CONNECTION */
18295
18296 for (i = 0; i < O_LAST; i++) {
18297#ifdef FREECIV_JSON_CONNECTION
18298 /* Next array element. */
18299 field_addr.sub_location->number = i;
18300#endif /* FREECIV_JSON_CONNECTION */
18301
18302 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->waste[i]);
18303 }
18304
18305#ifdef FREECIV_JSON_CONNECTION
18306 /* Exit array. */
18307 FC_FREE(field_addr.sub_location);
18308#endif /* FREECIV_JSON_CONNECTION */
18309 }
18310
18311 if (e) {
18312 log_packet_detailed("'waste' field error detected");
18313 }
18314
18315#ifdef FREECIV_JSON_CONNECTION
18316 field_addr.name = "unhappy_penalty";
18317#endif /* FREECIV_JSON_CONNECTION */
18318 e = 0;
18319
18320 {
18321 int i;
18322
18323#ifdef FREECIV_JSON_CONNECTION
18324 /* Create the array. */
18325 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
18326
18327 /* Enter array. */
18328 field_addr.sub_location = plocation_elem_new(0);
18329#endif /* FREECIV_JSON_CONNECTION */
18330
18331 for (i = 0; i < O_LAST; i++) {
18332#ifdef FREECIV_JSON_CONNECTION
18333 /* Next array element. */
18334 field_addr.sub_location->number = i;
18335#endif /* FREECIV_JSON_CONNECTION */
18336
18337 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->unhappy_penalty[i]);
18338 }
18339
18340#ifdef FREECIV_JSON_CONNECTION
18341 /* Exit array. */
18342 FC_FREE(field_addr.sub_location);
18343#endif /* FREECIV_JSON_CONNECTION */
18344 }
18345
18346 if (e) {
18347 log_packet_detailed("'unhappy_penalty' field error detected");
18348 }
18349
18350#ifdef FREECIV_JSON_CONNECTION
18351 field_addr.name = "prod";
18352#endif /* FREECIV_JSON_CONNECTION */
18353 e = 0;
18354
18355 {
18356 int i;
18357
18358#ifdef FREECIV_JSON_CONNECTION
18359 /* Create the array. */
18360 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
18361
18362 /* Enter array. */
18363 field_addr.sub_location = plocation_elem_new(0);
18364#endif /* FREECIV_JSON_CONNECTION */
18365
18366 for (i = 0; i < O_LAST; i++) {
18367#ifdef FREECIV_JSON_CONNECTION
18368 /* Next array element. */
18369 field_addr.sub_location->number = i;
18370#endif /* FREECIV_JSON_CONNECTION */
18371
18372 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->prod[i]);
18373 }
18374
18375#ifdef FREECIV_JSON_CONNECTION
18376 /* Exit array. */
18377 FC_FREE(field_addr.sub_location);
18378#endif /* FREECIV_JSON_CONNECTION */
18379 }
18380
18381 if (e) {
18382 log_packet_detailed("'prod' field error detected");
18383 }
18384
18385#ifdef FREECIV_JSON_CONNECTION
18386 field_addr.name = "citizen_base";
18387#endif /* FREECIV_JSON_CONNECTION */
18388 e = 0;
18389
18390 {
18391 int i;
18392
18393#ifdef FREECIV_JSON_CONNECTION
18394 /* Create the array. */
18395 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
18396
18397 /* Enter array. */
18398 field_addr.sub_location = plocation_elem_new(0);
18399#endif /* FREECIV_JSON_CONNECTION */
18400
18401 for (i = 0; i < O_LAST; i++) {
18402#ifdef FREECIV_JSON_CONNECTION
18403 /* Next array element. */
18404 field_addr.sub_location->number = i;
18405#endif /* FREECIV_JSON_CONNECTION */
18406
18407 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->citizen_base[i]);
18408 }
18409
18410#ifdef FREECIV_JSON_CONNECTION
18411 /* Exit array. */
18412 FC_FREE(field_addr.sub_location);
18413#endif /* FREECIV_JSON_CONNECTION */
18414 }
18415
18416 if (e) {
18417 log_packet_detailed("'citizen_base' field error detected");
18418 }
18419
18420#ifdef FREECIV_JSON_CONNECTION
18421 field_addr.name = "usage";
18422#endif /* FREECIV_JSON_CONNECTION */
18423 e = 0;
18424
18425 {
18426 int i;
18427
18428#ifdef FREECIV_JSON_CONNECTION
18429 /* Create the array. */
18430 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
18431
18432 /* Enter array. */
18433 field_addr.sub_location = plocation_elem_new(0);
18434#endif /* FREECIV_JSON_CONNECTION */
18435
18436 for (i = 0; i < O_LAST; i++) {
18437#ifdef FREECIV_JSON_CONNECTION
18438 /* Next array element. */
18439 field_addr.sub_location->number = i;
18440#endif /* FREECIV_JSON_CONNECTION */
18441
18442 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->usage[i]);
18443 }
18444
18445#ifdef FREECIV_JSON_CONNECTION
18446 /* Exit array. */
18447 FC_FREE(field_addr.sub_location);
18448#endif /* FREECIV_JSON_CONNECTION */
18449 }
18450
18451 if (e) {
18452 log_packet_detailed("'usage' field error detected");
18453 }
18454
18455#ifdef FREECIV_JSON_CONNECTION
18456 field_addr.name = "food_stock";
18457#endif /* FREECIV_JSON_CONNECTION */
18458 e = 0;
18459
18460 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->food_stock);
18461
18462 if (e) {
18463 log_packet_detailed("'food_stock' field error detected");
18464 }
18465
18466#ifdef FREECIV_JSON_CONNECTION
18467 field_addr.name = "shield_stock";
18468#endif /* FREECIV_JSON_CONNECTION */
18469 e = 0;
18470
18471 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->shield_stock);
18472
18473 if (e) {
18474 log_packet_detailed("'shield_stock' field error detected");
18475 }
18476
18477#ifdef FREECIV_JSON_CONNECTION
18478 field_addr.name = "trade_route_count";
18479#endif /* FREECIV_JSON_CONNECTION */
18480 e = 0;
18481
18482 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->trade_route_count);
18483
18484 if (e) {
18485 log_packet_detailed("'trade_route_count' field error detected");
18486 }
18487
18488#ifdef FREECIV_JSON_CONNECTION
18489 field_addr.name = "pollution";
18490#endif /* FREECIV_JSON_CONNECTION */
18491 e = 0;
18492
18493 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->pollution);
18494
18495 if (e) {
18496 log_packet_detailed("'pollution' field error detected");
18497 }
18498
18499#ifdef FREECIV_JSON_CONNECTION
18500 field_addr.name = "illness_trade";
18501#endif /* FREECIV_JSON_CONNECTION */
18502 e = 0;
18503
18504 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->illness_trade);
18505
18506 if (e) {
18507 log_packet_detailed("'illness_trade' field error detected");
18508 }
18509
18510#ifdef FREECIV_JSON_CONNECTION
18511 field_addr.name = "production_kind";
18512#endif /* FREECIV_JSON_CONNECTION */
18513 e = 0;
18514
18515 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_kind);
18516
18517 if (e) {
18518 log_packet_detailed("'production_kind' field error detected");
18519 }
18520
18521#ifdef FREECIV_JSON_CONNECTION
18522 field_addr.name = "production_value";
18523#endif /* FREECIV_JSON_CONNECTION */
18524 e = 0;
18525
18526 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_value);
18527
18528 if (e) {
18529 log_packet_detailed("'production_value' field error detected");
18530 }
18531
18532#ifdef FREECIV_JSON_CONNECTION
18533 field_addr.name = "turn_founded";
18534#endif /* FREECIV_JSON_CONNECTION */
18535 e = 0;
18536
18537 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_founded);
18538
18539 if (e) {
18540 log_packet_detailed("'turn_founded' field error detected");
18541 }
18542
18543#ifdef FREECIV_JSON_CONNECTION
18544 field_addr.name = "turn_last_built";
18545#endif /* FREECIV_JSON_CONNECTION */
18546 e = 0;
18547
18548 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_last_built);
18549
18550 if (e) {
18551 log_packet_detailed("'turn_last_built' field error detected");
18552 }
18553
18554#ifdef FREECIV_JSON_CONNECTION
18555 field_addr.name = "changed_from_kind";
18556#endif /* FREECIV_JSON_CONNECTION */
18557 e = 0;
18558
18559 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->changed_from_kind);
18560
18561 if (e) {
18562 log_packet_detailed("'changed_from_kind' field error detected");
18563 }
18564
18565#ifdef FREECIV_JSON_CONNECTION
18566 field_addr.name = "changed_from_value";
18567#endif /* FREECIV_JSON_CONNECTION */
18568 e = 0;
18569
18570 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->changed_from_value);
18571
18572 if (e) {
18573 log_packet_detailed("'changed_from_value' field error detected");
18574 }
18575
18576#ifdef FREECIV_JSON_CONNECTION
18577 field_addr.name = "before_change_shields";
18578#endif /* FREECIV_JSON_CONNECTION */
18579 e = 0;
18580
18581 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->before_change_shields);
18582
18583 if (e) {
18584 log_packet_detailed("'before_change_shields' field error detected");
18585 }
18586
18587#ifdef FREECIV_JSON_CONNECTION
18588 field_addr.name = "disbanded_shields";
18589#endif /* FREECIV_JSON_CONNECTION */
18590 e = 0;
18591
18592 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->disbanded_shields);
18593
18594 if (e) {
18595 log_packet_detailed("'disbanded_shields' field error detected");
18596 }
18597
18598#ifdef FREECIV_JSON_CONNECTION
18599 field_addr.name = "caravan_shields";
18600#endif /* FREECIV_JSON_CONNECTION */
18601 e = 0;
18602
18603 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->caravan_shields);
18604
18605 if (e) {
18606 log_packet_detailed("'caravan_shields' field error detected");
18607 }
18608
18609#ifdef FREECIV_JSON_CONNECTION
18610 field_addr.name = "last_turns_shield_surplus";
18611#endif /* FREECIV_JSON_CONNECTION */
18612 e = 0;
18613
18614 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->last_turns_shield_surplus);
18615
18616 if (e) {
18617 log_packet_detailed("'last_turns_shield_surplus' field error detected");
18618 }
18619
18620#ifdef FREECIV_JSON_CONNECTION
18621 field_addr.name = "airlift";
18622#endif /* FREECIV_JSON_CONNECTION */
18623 e = 0;
18624
18625 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->airlift);
18626
18627 if (e) {
18628 log_packet_detailed("'airlift' field error detected");
18629 }
18630
18631#ifdef FREECIV_JSON_CONNECTION
18632 field_addr.name = "did_buy";
18633#endif /* FREECIV_JSON_CONNECTION */
18634 e = 0;
18635
18636 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->did_buy);
18637
18638 if (e) {
18639 log_packet_detailed("'did_buy' field error detected");
18640 }
18641
18642#ifdef FREECIV_JSON_CONNECTION
18643 field_addr.name = "did_sell";
18644#endif /* FREECIV_JSON_CONNECTION */
18645 e = 0;
18646
18647 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->did_sell);
18648
18649 if (e) {
18650 log_packet_detailed("'did_sell' field error detected");
18651 }
18652
18653#ifdef FREECIV_JSON_CONNECTION
18654 field_addr.name = "was_happy";
18655#endif /* FREECIV_JSON_CONNECTION */
18656 e = 0;
18657
18658 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->was_happy);
18659
18660 if (e) {
18661 log_packet_detailed("'was_happy' field error detected");
18662 }
18663
18664#ifdef FREECIV_JSON_CONNECTION
18665 field_addr.name = "had_famine";
18666#endif /* FREECIV_JSON_CONNECTION */
18667 e = 0;
18668
18669 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->had_famine);
18670
18671 if (e) {
18672 log_packet_detailed("'had_famine' field error detected");
18673 }
18674
18675#ifdef FREECIV_JSON_CONNECTION
18676 field_addr.name = "diplomat_investigate";
18677#endif /* FREECIV_JSON_CONNECTION */
18678 e = 0;
18679
18680 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->diplomat_investigate);
18681
18682 if (e) {
18683 log_packet_detailed("'diplomat_investigate' field error detected");
18684 }
18685
18686#ifdef FREECIV_JSON_CONNECTION
18687 field_addr.name = "walls";
18688#endif /* FREECIV_JSON_CONNECTION */
18689 e = 0;
18690
18691 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->walls);
18692
18693 if (e) {
18694 log_packet_detailed("'walls' field error detected");
18695 }
18696
18697#ifdef FREECIV_JSON_CONNECTION
18698 field_addr.name = "city_image";
18699#endif /* FREECIV_JSON_CONNECTION */
18700 e = 0;
18701
18702 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->city_image);
18703
18704 if (e) {
18705 log_packet_detailed("'city_image' field error detected");
18706 }
18707
18708#ifdef FREECIV_JSON_CONNECTION
18709 field_addr.name = "steal";
18710#endif /* FREECIV_JSON_CONNECTION */
18711 e = 0;
18712
18713 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->steal);
18714
18715 if (e) {
18716 log_packet_detailed("'steal' field error detected");
18717 }
18718
18719#ifdef FREECIV_JSON_CONNECTION
18720 field_addr.name = "worklist";
18721#endif /* FREECIV_JSON_CONNECTION */
18722 e = 0;
18723
18724 e |= DIO_PUT(worklist, &dout, &field_addr, &real_packet->worklist);
18725
18726 if (e) {
18727 log_packet_detailed("'worklist' field error detected");
18728 }
18729
18730#ifdef FREECIV_JSON_CONNECTION
18731 field_addr.name = "improvements";
18732#endif /* FREECIV_JSON_CONNECTION */
18733 e = 0;
18734
18735 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->improvements);
18736
18737 if (e) {
18738 log_packet_detailed("'improvements' field error detected");
18739 }
18740
18741#ifdef FREECIV_JSON_CONNECTION
18742 field_addr.name = "city_options";
18743#endif /* FREECIV_JSON_CONNECTION */
18744 e = 0;
18745
18746 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->city_options);
18747
18748 if (e) {
18749 log_packet_detailed("'city_options' field error detected");
18750 }
18751
18752#ifdef FREECIV_JSON_CONNECTION
18753 field_addr.name = "name";
18754#endif /* FREECIV_JSON_CONNECTION */
18755 e = 0;
18756
18757 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
18758
18759 if (e) {
18760 log_packet_detailed("'name' field error detected");
18761 }
18762#endif /* FREECIV_DELTA_PROTOCOL */
18763
18764 SEND_PACKET_END(PACKET_CITY_INFO);
18765}
18766
18767 int send_packet_city_info(struct connection *pc, const struct packet_city_info *packet, bool force_to_send)
18768{
18769 if (!pc->used) {
18770 log_error("WARNING: trying to send data to the closed connection %s",
18771 conn_description(pc));
18772 return -1;
18773 }
18774 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_INFO].force_to_send != nullptr, -1,
18775 "Handler for PACKET_CITY_INFO not installed");
18776 return pc->phs.handlers->send[PACKET_CITY_INFO].force_to_send(pc, packet, force_to_send);
18777}
18778
18779 void lsend_packet_city_info(struct conn_list *dest, const struct packet_city_info *packet, bool force_to_send)
18780{
18781 conn_list_iterate(dest, pconn) {
18782 send_packet_city_info(pconn, packet, force_to_send);
18783 } conn_list_iterate_end;
18784}
18785
18786 static inline void init_packet_city_nationalities(struct packet_city_nationalities *packet)
18787{
18788 memset(packet, 0, sizeof(*packet));
18789}
18790
18791#define free_packet_city_nationalities(_packet) (void) 0
18792#define destroy_packet_city_nationalities free
18793
18794#ifdef FREECIV_DELTA_PROTOCOL
18795static genhash_val_t hash_packet_city_nationalities_100(const void *vkey)
18796{
18797 const struct packet_city_nationalities *key = (const struct packet_city_nationalities *) vkey;
18798 genhash_val_t result = 0;
18799
18800 result += key->id;
18801
18802 result &= 0xFFFFFFFF;
18803 return result;
18804}
18805
18806static bool cmp_packet_city_nationalities_100(const void *vkey1, const void *vkey2)
18807{
18808 const struct packet_city_nationalities *old = (const struct packet_city_nationalities *) vkey1;
18809 const struct packet_city_nationalities *real_packet = (const struct packet_city_nationalities *) vkey2;
18810 bool differ;
18811
18812 differ = (old->id != real_packet->id);
18813
18814 return !differ;
18815}
18816 BV_DEFINE(packet_city_nationalities_100_fields, 3);
18817#endif /* FREECIV_DELTA_PROTOCOL */
18818
18819 static struct packet_city_nationalities *receive_packet_city_nationalities_100(struct connection *pc)
18820{
18821#define FREE_PACKET_STRUCT(_packet) free_packet_city_nationalities(_packet)
18822 RECEIVE_PACKET_START(packet_city_nationalities, real_packet);
18823
18824#ifdef FREECIV_JSON_CONNECTION
18825 struct plocation field_addr;
18826 {
18827 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
18828 field_addr = *field_addr_tmp;
18829 FC_FREE(field_addr_tmp);
18830 }
18831#endif /* FREECIV_JSON_CONNECTION */
18832
18833#ifdef FREECIV_JSON_CONNECTION
18834 field_addr.name = "id";
18835#endif /* FREECIV_JSON_CONNECTION */
18836
18837 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
18838 RECEIVE_PACKET_FIELD_ERROR(id);
18839 }
18840
18841 log_packet_detailed("packet_city_nationalities_100: got info about (%d)",
18842 real_packet->id);
18843
18844#ifdef FREECIV_DELTA_PROTOCOL
18845 packet_city_nationalities_100_fields fields;
18846 struct packet_city_nationalities *old;
18847 struct genhash **hash = pc->phs.received + PACKET_CITY_NATIONALITIES;
18848
18849 if (nullptr == *hash) {
18850 *hash = genhash_new_full(hash_packet_city_nationalities_100, cmp_packet_city_nationalities_100,
18851 nullptr, nullptr, nullptr, destroy_packet_city_nationalities);
18852 }
18853
18854 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
18855 *real_packet = *old;
18856 } else {
18857 /* packet is already initialized empty */
18858 log_packet_detailed(" no old info");
18859 }
18860
18861#ifdef FREECIV_JSON_CONNECTION
18862 field_addr.name = "fields";
18863#endif /* FREECIV_JSON_CONNECTION */
18864 DIO_BV_GET(&din, &field_addr, fields);
18865
18866 if (BV_ISSET(fields, 0)) {
18867 log_packet_detailed(" got field 'nationalities_count'");
18868
18869#ifdef FREECIV_JSON_CONNECTION
18870 field_addr.name = "nationalities_count";
18871#endif /* FREECIV_JSON_CONNECTION */
18872
18873 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nationalities_count)) {
18874 RECEIVE_PACKET_FIELD_ERROR(nationalities_count);
18875 }
18876 }
18877
18878 if (BV_ISSET(fields, 1)) {
18879 log_packet_detailed(" got field 'nation_id'");
18880
18881#ifdef FREECIV_JSON_CONNECTION
18882 field_addr.name = "nation_id";
18883#endif /* FREECIV_JSON_CONNECTION */
18884
18885 {
18886 int i;
18887
18888 if (real_packet->nationalities_count > MAX_CITY_NATIONALITIES) {
18889 RECEIVE_PACKET_FIELD_ERROR(nation_id, ": array truncated");
18890 }
18891
18892#ifdef FREECIV_JSON_CONNECTION
18893 /* Enter array. */
18894 field_addr.sub_location = plocation_elem_new(0);
18895#endif /* FREECIV_JSON_CONNECTION */
18896
18897 for (i = 0; i < real_packet->nationalities_count; i++) {
18898#ifdef FREECIV_JSON_CONNECTION
18899 /* Next array element */
18900 field_addr.sub_location->number = i;
18901#endif /* FREECIV_JSON_CONNECTION */
18902
18903 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nation_id[i])) {
18904 RECEIVE_PACKET_FIELD_ERROR(nation_id);
18905 }
18906 }
18907
18908#ifdef FREECIV_JSON_CONNECTION
18909 /* Exit array. */
18910 FC_FREE(field_addr.sub_location);
18911#endif /* FREECIV_JSON_CONNECTION */
18912 }
18913 }
18914
18915 if (BV_ISSET(fields, 2)) {
18916 log_packet_detailed(" got field 'nation_citizens'");
18917
18918#ifdef FREECIV_JSON_CONNECTION
18919 field_addr.name = "nation_citizens";
18920#endif /* FREECIV_JSON_CONNECTION */
18921
18922 {
18923 int i;
18924
18925 if (real_packet->nationalities_count > MAX_CITY_NATIONALITIES) {
18926 RECEIVE_PACKET_FIELD_ERROR(nation_citizens, ": array truncated");
18927 }
18928
18929#ifdef FREECIV_JSON_CONNECTION
18930 /* Enter array. */
18931 field_addr.sub_location = plocation_elem_new(0);
18932#endif /* FREECIV_JSON_CONNECTION */
18933
18934 for (i = 0; i < real_packet->nationalities_count; i++) {
18935#ifdef FREECIV_JSON_CONNECTION
18936 /* Next array element */
18937 field_addr.sub_location->number = i;
18938#endif /* FREECIV_JSON_CONNECTION */
18939
18940 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nation_citizens[i])) {
18941 RECEIVE_PACKET_FIELD_ERROR(nation_citizens);
18942 }
18943 }
18944
18945#ifdef FREECIV_JSON_CONNECTION
18946 /* Exit array. */
18947 FC_FREE(field_addr.sub_location);
18948#endif /* FREECIV_JSON_CONNECTION */
18949 }
18950 }
18951
18952 if (nullptr == old) {
18953 old = fc_malloc(sizeof(*old));
18954 init_packet_city_nationalities(old);
18955 *old = *real_packet;
18956 genhash_insert(*hash, old, old);
18957 } else {
18958 *old = *real_packet;
18959 }
18960
18961#else /* FREECIV_DELTA_PROTOCOL */
18962#ifdef FREECIV_JSON_CONNECTION
18963 field_addr.name = "nationalities_count";
18964#endif /* FREECIV_JSON_CONNECTION */
18965
18966 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nationalities_count)) {
18967 RECEIVE_PACKET_FIELD_ERROR(nationalities_count);
18968 }
18969
18970#ifdef FREECIV_JSON_CONNECTION
18971 field_addr.name = "nation_id";
18972#endif /* FREECIV_JSON_CONNECTION */
18973
18974 {
18975 int i;
18976
18977 if (real_packet->nationalities_count > MAX_CITY_NATIONALITIES) {
18978 RECEIVE_PACKET_FIELD_ERROR(nation_id, ": array truncated");
18979 }
18980
18981#ifdef FREECIV_JSON_CONNECTION
18982 /* Enter array. */
18983 field_addr.sub_location = plocation_elem_new(0);
18984#endif /* FREECIV_JSON_CONNECTION */
18985
18986 for (i = 0; i < real_packet->nationalities_count; i++) {
18987#ifdef FREECIV_JSON_CONNECTION
18988 /* Next array element */
18989 field_addr.sub_location->number = i;
18990#endif /* FREECIV_JSON_CONNECTION */
18991
18992 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nation_id[i])) {
18993 RECEIVE_PACKET_FIELD_ERROR(nation_id);
18994 }
18995 }
18996
18997#ifdef FREECIV_JSON_CONNECTION
18998 /* Exit array. */
18999 FC_FREE(field_addr.sub_location);
19000#endif /* FREECIV_JSON_CONNECTION */
19001 }
19002
19003#ifdef FREECIV_JSON_CONNECTION
19004 field_addr.name = "nation_citizens";
19005#endif /* FREECIV_JSON_CONNECTION */
19006
19007 {
19008 int i;
19009
19010 if (real_packet->nationalities_count > MAX_CITY_NATIONALITIES) {
19011 RECEIVE_PACKET_FIELD_ERROR(nation_citizens, ": array truncated");
19012 }
19013
19014#ifdef FREECIV_JSON_CONNECTION
19015 /* Enter array. */
19016 field_addr.sub_location = plocation_elem_new(0);
19017#endif /* FREECIV_JSON_CONNECTION */
19018
19019 for (i = 0; i < real_packet->nationalities_count; i++) {
19020#ifdef FREECIV_JSON_CONNECTION
19021 /* Next array element */
19022 field_addr.sub_location->number = i;
19023#endif /* FREECIV_JSON_CONNECTION */
19024
19025 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nation_citizens[i])) {
19026 RECEIVE_PACKET_FIELD_ERROR(nation_citizens);
19027 }
19028 }
19029
19030#ifdef FREECIV_JSON_CONNECTION
19031 /* Exit array. */
19032 FC_FREE(field_addr.sub_location);
19033#endif /* FREECIV_JSON_CONNECTION */
19034 }
19035#endif /* FREECIV_DELTA_PROTOCOL */
19036
19037 RECEIVE_PACKET_END(real_packet);
19038#undef FREE_PACKET_STRUCT
19039}
19040
19041 static int send_packet_city_nationalities_100(struct connection *pc, const struct packet_city_nationalities *packet, bool force_to_send)
19042{
19043 const struct packet_city_nationalities *real_packet = packet;
19044 int e;
19045 SEND_PACKET_START(PACKET_CITY_NATIONALITIES);
19046
19047 log_packet_detailed("packet_city_nationalities_100: sending info about (%d)",
19048 real_packet->id);
19049
19050#ifdef FREECIV_DELTA_PROTOCOL
19051 packet_city_nationalities_100_fields fields;
19052 struct packet_city_nationalities *old;
19053 bool differ;
19054 int different = force_to_send;
19055 struct genhash **hash = pc->phs.sent + PACKET_CITY_NATIONALITIES;
19056
19057 if (nullptr == *hash) {
19058 *hash = genhash_new_full(hash_packet_city_nationalities_100, cmp_packet_city_nationalities_100,
19059 nullptr, nullptr, nullptr, destroy_packet_city_nationalities);
19060 }
19061 BV_CLR_ALL(fields);
19062
19063 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19064 old = fc_malloc(sizeof(*old));
19065 /* temporary bitcopy just to insert correctly */
19066 *old = *real_packet;
19067 genhash_insert(*hash, old, old);
19068 init_packet_city_nationalities(old);
19069 different = 1; /* Force to send. */
19070 }
19071
19072 differ = (old->nationalities_count != real_packet->nationalities_count);
19073 if (differ) {
19074 different++;
19075 BV_SET(fields, 0);
19076 }
19077
19078 differ = (old->nationalities_count != real_packet->nationalities_count);
19079 if (!differ) {
19080 int i;
19081
19082 for (i = 0; i < old->nationalities_count; i++) {
19083 differ = (old->nation_id[i] != real_packet->nation_id[i]);
19084 if (differ) {
19085 break;
19086 }
19087 }
19088 }
19089 if (differ) {
19090 different++;
19091 BV_SET(fields, 1);
19092 }
19093
19094 differ = (old->nationalities_count != real_packet->nationalities_count);
19095 if (!differ) {
19096 int i;
19097
19098 for (i = 0; i < old->nationalities_count; i++) {
19099 differ = (old->nation_citizens[i] != real_packet->nation_citizens[i]);
19100 if (differ) {
19101 break;
19102 }
19103 }
19104 }
19105 if (differ) {
19106 different++;
19107 BV_SET(fields, 2);
19108 }
19109
19110 if (different == 0) {
19111 log_packet_detailed(" no change -> discard");
19112 SEND_PACKET_DISCARD();
19113 }
19114#endif /* FREECIV_DELTA_PROTOCOL */
19115
19116#ifdef FREECIV_JSON_CONNECTION
19117 struct plocation field_addr;
19118 {
19119 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
19120 field_addr = *field_addr_tmp;
19121 FC_FREE(field_addr_tmp);
19122 }
19123#endif /* FREECIV_JSON_CONNECTION */
19124
19125#ifdef FREECIV_JSON_CONNECTION
19126 field_addr.name = "id";
19127#endif /* FREECIV_JSON_CONNECTION */
19128 e = 0;
19129
19130 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
19131
19132 if (e) {
19133 log_packet_detailed("'id' field error detected");
19134 }
19135
19136#ifdef FREECIV_DELTA_PROTOCOL
19137#ifdef FREECIV_JSON_CONNECTION
19138 field_addr.name = "fields";
19139#endif /* FREECIV_JSON_CONNECTION */
19140 e = 0;
19141 e |= DIO_BV_PUT(&dout, &field_addr, fields);
19142 if (e) {
19143 log_packet_detailed("fields bitvector error detected");
19144 }
19145
19146 if (BV_ISSET(fields, 0)) {
19147 log_packet_detailed(" field 'nationalities_count' has changed");
19148
19149#ifdef FREECIV_JSON_CONNECTION
19150 field_addr.name = "nationalities_count";
19151#endif /* FREECIV_JSON_CONNECTION */
19152 e = 0;
19153
19154 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nationalities_count);
19155
19156 if (e) {
19157 log_packet_detailed("'nationalities_count' field error detected");
19158 }
19159 }
19160
19161 if (BV_ISSET(fields, 1)) {
19162 log_packet_detailed(" field 'nation_id' has changed");
19163
19164#ifdef FREECIV_JSON_CONNECTION
19165 field_addr.name = "nation_id";
19166#endif /* FREECIV_JSON_CONNECTION */
19167 e = 0;
19168
19169 {
19170 int i;
19171
19172#ifdef FREECIV_JSON_CONNECTION
19173 /* Create the array. */
19174 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nationalities_count);
19175
19176 /* Enter array. */
19177 field_addr.sub_location = plocation_elem_new(0);
19178#endif /* FREECIV_JSON_CONNECTION */
19179
19180 for (i = 0; i < real_packet->nationalities_count; i++) {
19181#ifdef FREECIV_JSON_CONNECTION
19182 /* Next array element. */
19183 field_addr.sub_location->number = i;
19184#endif /* FREECIV_JSON_CONNECTION */
19185
19186 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation_id[i]);
19187 }
19188
19189#ifdef FREECIV_JSON_CONNECTION
19190 /* Exit array. */
19191 FC_FREE(field_addr.sub_location);
19192#endif /* FREECIV_JSON_CONNECTION */
19193 }
19194
19195 if (e) {
19196 log_packet_detailed("'nation_id' field error detected");
19197 }
19198 }
19199
19200 if (BV_ISSET(fields, 2)) {
19201 log_packet_detailed(" field 'nation_citizens' has changed");
19202
19203#ifdef FREECIV_JSON_CONNECTION
19204 field_addr.name = "nation_citizens";
19205#endif /* FREECIV_JSON_CONNECTION */
19206 e = 0;
19207
19208 {
19209 int i;
19210
19211#ifdef FREECIV_JSON_CONNECTION
19212 /* Create the array. */
19213 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nationalities_count);
19214
19215 /* Enter array. */
19216 field_addr.sub_location = plocation_elem_new(0);
19217#endif /* FREECIV_JSON_CONNECTION */
19218
19219 for (i = 0; i < real_packet->nationalities_count; i++) {
19220#ifdef FREECIV_JSON_CONNECTION
19221 /* Next array element. */
19222 field_addr.sub_location->number = i;
19223#endif /* FREECIV_JSON_CONNECTION */
19224
19225 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nation_citizens[i]);
19226 }
19227
19228#ifdef FREECIV_JSON_CONNECTION
19229 /* Exit array. */
19230 FC_FREE(field_addr.sub_location);
19231#endif /* FREECIV_JSON_CONNECTION */
19232 }
19233
19234 if (e) {
19235 log_packet_detailed("'nation_citizens' field error detected");
19236 }
19237 }
19238
19239 *old = *real_packet;
19240
19241#else /* FREECIV_DELTA_PROTOCOL */
19242#ifdef FREECIV_JSON_CONNECTION
19243 field_addr.name = "nationalities_count";
19244#endif /* FREECIV_JSON_CONNECTION */
19245 e = 0;
19246
19247 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nationalities_count);
19248
19249 if (e) {
19250 log_packet_detailed("'nationalities_count' field error detected");
19251 }
19252
19253#ifdef FREECIV_JSON_CONNECTION
19254 field_addr.name = "nation_id";
19255#endif /* FREECIV_JSON_CONNECTION */
19256 e = 0;
19257
19258 {
19259 int i;
19260
19261#ifdef FREECIV_JSON_CONNECTION
19262 /* Create the array. */
19263 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nationalities_count);
19264
19265 /* Enter array. */
19266 field_addr.sub_location = plocation_elem_new(0);
19267#endif /* FREECIV_JSON_CONNECTION */
19268
19269 for (i = 0; i < real_packet->nationalities_count; i++) {
19270#ifdef FREECIV_JSON_CONNECTION
19271 /* Next array element. */
19272 field_addr.sub_location->number = i;
19273#endif /* FREECIV_JSON_CONNECTION */
19274
19275 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation_id[i]);
19276 }
19277
19278#ifdef FREECIV_JSON_CONNECTION
19279 /* Exit array. */
19280 FC_FREE(field_addr.sub_location);
19281#endif /* FREECIV_JSON_CONNECTION */
19282 }
19283
19284 if (e) {
19285 log_packet_detailed("'nation_id' field error detected");
19286 }
19287
19288#ifdef FREECIV_JSON_CONNECTION
19289 field_addr.name = "nation_citizens";
19290#endif /* FREECIV_JSON_CONNECTION */
19291 e = 0;
19292
19293 {
19294 int i;
19295
19296#ifdef FREECIV_JSON_CONNECTION
19297 /* Create the array. */
19298 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nationalities_count);
19299
19300 /* Enter array. */
19301 field_addr.sub_location = plocation_elem_new(0);
19302#endif /* FREECIV_JSON_CONNECTION */
19303
19304 for (i = 0; i < real_packet->nationalities_count; i++) {
19305#ifdef FREECIV_JSON_CONNECTION
19306 /* Next array element. */
19307 field_addr.sub_location->number = i;
19308#endif /* FREECIV_JSON_CONNECTION */
19309
19310 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nation_citizens[i]);
19311 }
19312
19313#ifdef FREECIV_JSON_CONNECTION
19314 /* Exit array. */
19315 FC_FREE(field_addr.sub_location);
19316#endif /* FREECIV_JSON_CONNECTION */
19317 }
19318
19319 if (e) {
19320 log_packet_detailed("'nation_citizens' field error detected");
19321 }
19322#endif /* FREECIV_DELTA_PROTOCOL */
19323
19324 SEND_PACKET_END(PACKET_CITY_NATIONALITIES);
19325}
19326
19327 int send_packet_city_nationalities(struct connection *pc, const struct packet_city_nationalities *packet, bool force_to_send)
19328{
19329 if (!pc->used) {
19330 log_error("WARNING: trying to send data to the closed connection %s",
19331 conn_description(pc));
19332 return -1;
19333 }
19334 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_NATIONALITIES].force_to_send != nullptr, -1,
19335 "Handler for PACKET_CITY_NATIONALITIES not installed");
19336 return pc->phs.handlers->send[PACKET_CITY_NATIONALITIES].force_to_send(pc, packet, force_to_send);
19337}
19338
19339 void lsend_packet_city_nationalities(struct conn_list *dest, const struct packet_city_nationalities *packet, bool force_to_send)
19340{
19341 conn_list_iterate(dest, pconn) {
19342 send_packet_city_nationalities(pconn, packet, force_to_send);
19343 } conn_list_iterate_end;
19344}
19345
19346 static inline void init_packet_city_update_counters(struct packet_city_update_counters *packet)
19347{
19348 memset(packet, 0, sizeof(*packet));
19349}
19350
19351#define free_packet_city_update_counters(_packet) (void) 0
19352#define destroy_packet_city_update_counters free
19353
19354#ifdef FREECIV_DELTA_PROTOCOL
19355static genhash_val_t hash_packet_city_update_counters_100(const void *vkey)
19356{
19357 const struct packet_city_update_counters *key = (const struct packet_city_update_counters *) vkey;
19358 genhash_val_t result = 0;
19359
19360 result += key->city;
19361
19362 result &= 0xFFFFFFFF;
19363 return result;
19364}
19365
19366static bool cmp_packet_city_update_counters_100(const void *vkey1, const void *vkey2)
19367{
19368 const struct packet_city_update_counters *old = (const struct packet_city_update_counters *) vkey1;
19369 const struct packet_city_update_counters *real_packet = (const struct packet_city_update_counters *) vkey2;
19370 bool differ;
19371
19372 differ = (old->city != real_packet->city);
19373
19374 return !differ;
19375}
19376 BV_DEFINE(packet_city_update_counters_100_fields, 2);
19377#endif /* FREECIV_DELTA_PROTOCOL */
19378
19379 static struct packet_city_update_counters *receive_packet_city_update_counters_100(struct connection *pc)
19380{
19381#define FREE_PACKET_STRUCT(_packet) free_packet_city_update_counters(_packet)
19382 RECEIVE_PACKET_START(packet_city_update_counters, real_packet);
19383
19384#ifdef FREECIV_JSON_CONNECTION
19385 struct plocation field_addr;
19386 {
19387 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
19388 field_addr = *field_addr_tmp;
19389 FC_FREE(field_addr_tmp);
19390 }
19391#endif /* FREECIV_JSON_CONNECTION */
19392
19393#ifdef FREECIV_JSON_CONNECTION
19394 field_addr.name = "city";
19395#endif /* FREECIV_JSON_CONNECTION */
19396
19397 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city)) {
19398 RECEIVE_PACKET_FIELD_ERROR(city);
19399 }
19400
19401 log_packet_detailed("packet_city_update_counters_100: got info about (%d)",
19402 real_packet->city);
19403
19404#ifdef FREECIV_DELTA_PROTOCOL
19405 packet_city_update_counters_100_fields fields;
19406 struct packet_city_update_counters *old;
19407 struct genhash **hash = pc->phs.received + PACKET_CITY_UPDATE_COUNTERS;
19408
19409 if (nullptr == *hash) {
19410 *hash = genhash_new_full(hash_packet_city_update_counters_100, cmp_packet_city_update_counters_100,
19411 nullptr, nullptr, nullptr, destroy_packet_city_update_counters);
19412 }
19413
19414 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19415 *real_packet = *old;
19416 } else {
19417 /* packet is already initialized empty */
19418 log_packet_detailed(" no old info");
19419 }
19420
19421#ifdef FREECIV_JSON_CONNECTION
19422 field_addr.name = "fields";
19423#endif /* FREECIV_JSON_CONNECTION */
19424 DIO_BV_GET(&din, &field_addr, fields);
19425
19426 if (BV_ISSET(fields, 0)) {
19427 log_packet_detailed(" got field 'count'");
19428
19429#ifdef FREECIV_JSON_CONNECTION
19430 field_addr.name = "count";
19431#endif /* FREECIV_JSON_CONNECTION */
19432
19433 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->count)) {
19434 RECEIVE_PACKET_FIELD_ERROR(count);
19435 }
19436 }
19437
19438 if (BV_ISSET(fields, 1)) {
19439 log_packet_detailed(" got field 'counters'");
19440
19441#ifdef FREECIV_JSON_CONNECTION
19442 field_addr.name = "counters";
19443#endif /* FREECIV_JSON_CONNECTION */
19444
19445 {
19446 int i;
19447
19448 if (real_packet->count > MAX_COUNTERS) {
19449 RECEIVE_PACKET_FIELD_ERROR(counters, ": array truncated");
19450 }
19451
19452#ifdef FREECIV_JSON_CONNECTION
19453 /* Enter array. */
19454 field_addr.sub_location = plocation_elem_new(0);
19455#endif /* FREECIV_JSON_CONNECTION */
19456
19457 for (i = 0; i < real_packet->count; i++) {
19458#ifdef FREECIV_JSON_CONNECTION
19459 /* Next array element */
19460 field_addr.sub_location->number = i;
19461#endif /* FREECIV_JSON_CONNECTION */
19462
19463 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->counters[i])) {
19464 RECEIVE_PACKET_FIELD_ERROR(counters);
19465 }
19466 }
19467
19468#ifdef FREECIV_JSON_CONNECTION
19469 /* Exit array. */
19470 FC_FREE(field_addr.sub_location);
19471#endif /* FREECIV_JSON_CONNECTION */
19472 }
19473 }
19474
19475 if (nullptr == old) {
19476 old = fc_malloc(sizeof(*old));
19477 init_packet_city_update_counters(old);
19478 *old = *real_packet;
19479 genhash_insert(*hash, old, old);
19480 } else {
19481 *old = *real_packet;
19482 }
19483
19484#else /* FREECIV_DELTA_PROTOCOL */
19485#ifdef FREECIV_JSON_CONNECTION
19486 field_addr.name = "count";
19487#endif /* FREECIV_JSON_CONNECTION */
19488
19489 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->count)) {
19490 RECEIVE_PACKET_FIELD_ERROR(count);
19491 }
19492
19493#ifdef FREECIV_JSON_CONNECTION
19494 field_addr.name = "counters";
19495#endif /* FREECIV_JSON_CONNECTION */
19496
19497 {
19498 int i;
19499
19500 if (real_packet->count > MAX_COUNTERS) {
19501 RECEIVE_PACKET_FIELD_ERROR(counters, ": array truncated");
19502 }
19503
19504#ifdef FREECIV_JSON_CONNECTION
19505 /* Enter array. */
19506 field_addr.sub_location = plocation_elem_new(0);
19507#endif /* FREECIV_JSON_CONNECTION */
19508
19509 for (i = 0; i < real_packet->count; i++) {
19510#ifdef FREECIV_JSON_CONNECTION
19511 /* Next array element */
19512 field_addr.sub_location->number = i;
19513#endif /* FREECIV_JSON_CONNECTION */
19514
19515 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->counters[i])) {
19516 RECEIVE_PACKET_FIELD_ERROR(counters);
19517 }
19518 }
19519
19520#ifdef FREECIV_JSON_CONNECTION
19521 /* Exit array. */
19522 FC_FREE(field_addr.sub_location);
19523#endif /* FREECIV_JSON_CONNECTION */
19524 }
19525#endif /* FREECIV_DELTA_PROTOCOL */
19526
19527 RECEIVE_PACKET_END(real_packet);
19528#undef FREE_PACKET_STRUCT
19529}
19530
19531 static int send_packet_city_update_counters_100(struct connection *pc, const struct packet_city_update_counters *packet)
19532{
19533 const struct packet_city_update_counters *real_packet = packet;
19534 int e;
19535 SEND_PACKET_START(PACKET_CITY_UPDATE_COUNTERS);
19536
19537 log_packet_detailed("packet_city_update_counters_100: sending info about (%d)",
19538 real_packet->city);
19539
19540#ifdef FREECIV_DELTA_PROTOCOL
19541 packet_city_update_counters_100_fields fields;
19542 struct packet_city_update_counters *old;
19543 bool differ;
19544 int different = 0;
19545 struct genhash **hash = pc->phs.sent + PACKET_CITY_UPDATE_COUNTERS;
19546
19547 if (nullptr == *hash) {
19548 *hash = genhash_new_full(hash_packet_city_update_counters_100, cmp_packet_city_update_counters_100,
19549 nullptr, nullptr, nullptr, destroy_packet_city_update_counters);
19550 }
19551 BV_CLR_ALL(fields);
19552
19553 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
19554 old = fc_malloc(sizeof(*old));
19555 /* temporary bitcopy just to insert correctly */
19556 *old = *real_packet;
19557 genhash_insert(*hash, old, old);
19558 init_packet_city_update_counters(old);
19559 different = 1; /* Force to send. */
19560 }
19561
19562 differ = (old->count != real_packet->count);
19563 if (differ) {
19564 different++;
19565 BV_SET(fields, 0);
19566 }
19567
19568 differ = (old->count != real_packet->count);
19569 if (!differ) {
19570 int i;
19571
19572 for (i = 0; i < old->count; i++) {
19573 differ = (old->counters[i] != real_packet->counters[i]);
19574 if (differ) {
19575 break;
19576 }
19577 }
19578 }
19579 if (differ) {
19580 different++;
19581 BV_SET(fields, 1);
19582 }
19583
19584 if (different == 0) {
19585 log_packet_detailed(" no change -> discard");
19586 SEND_PACKET_DISCARD();
19587 }
19588#endif /* FREECIV_DELTA_PROTOCOL */
19589
19590#ifdef FREECIV_JSON_CONNECTION
19591 struct plocation field_addr;
19592 {
19593 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
19594 field_addr = *field_addr_tmp;
19595 FC_FREE(field_addr_tmp);
19596 }
19597#endif /* FREECIV_JSON_CONNECTION */
19598
19599#ifdef FREECIV_JSON_CONNECTION
19600 field_addr.name = "city";
19601#endif /* FREECIV_JSON_CONNECTION */
19602 e = 0;
19603
19604 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city);
19605
19606 if (e) {
19607 log_packet_detailed("'city' field error detected");
19608 }
19609
19610#ifdef FREECIV_DELTA_PROTOCOL
19611#ifdef FREECIV_JSON_CONNECTION
19612 field_addr.name = "fields";
19613#endif /* FREECIV_JSON_CONNECTION */
19614 e = 0;
19615 e |= DIO_BV_PUT(&dout, &field_addr, fields);
19616 if (e) {
19617 log_packet_detailed("fields bitvector error detected");
19618 }
19619
19620 if (BV_ISSET(fields, 0)) {
19621 log_packet_detailed(" field 'count' has changed");
19622
19623#ifdef FREECIV_JSON_CONNECTION
19624 field_addr.name = "count";
19625#endif /* FREECIV_JSON_CONNECTION */
19626 e = 0;
19627
19628 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->count);
19629
19630 if (e) {
19631 log_packet_detailed("'count' field error detected");
19632 }
19633 }
19634
19635 if (BV_ISSET(fields, 1)) {
19636 log_packet_detailed(" field 'counters' has changed");
19637
19638#ifdef FREECIV_JSON_CONNECTION
19639 field_addr.name = "counters";
19640#endif /* FREECIV_JSON_CONNECTION */
19641 e = 0;
19642
19643 {
19644 int i;
19645
19646#ifdef FREECIV_JSON_CONNECTION
19647 /* Create the array. */
19648 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->count);
19649
19650 /* Enter array. */
19651 field_addr.sub_location = plocation_elem_new(0);
19652#endif /* FREECIV_JSON_CONNECTION */
19653
19654 for (i = 0; i < real_packet->count; i++) {
19655#ifdef FREECIV_JSON_CONNECTION
19656 /* Next array element. */
19657 field_addr.sub_location->number = i;
19658#endif /* FREECIV_JSON_CONNECTION */
19659
19660 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->counters[i]);
19661 }
19662
19663#ifdef FREECIV_JSON_CONNECTION
19664 /* Exit array. */
19665 FC_FREE(field_addr.sub_location);
19666#endif /* FREECIV_JSON_CONNECTION */
19667 }
19668
19669 if (e) {
19670 log_packet_detailed("'counters' field error detected");
19671 }
19672 }
19673
19674 *old = *real_packet;
19675
19676#else /* FREECIV_DELTA_PROTOCOL */
19677#ifdef FREECIV_JSON_CONNECTION
19678 field_addr.name = "count";
19679#endif /* FREECIV_JSON_CONNECTION */
19680 e = 0;
19681
19682 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->count);
19683
19684 if (e) {
19685 log_packet_detailed("'count' field error detected");
19686 }
19687
19688#ifdef FREECIV_JSON_CONNECTION
19689 field_addr.name = "counters";
19690#endif /* FREECIV_JSON_CONNECTION */
19691 e = 0;
19692
19693 {
19694 int i;
19695
19696#ifdef FREECIV_JSON_CONNECTION
19697 /* Create the array. */
19698 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->count);
19699
19700 /* Enter array. */
19701 field_addr.sub_location = plocation_elem_new(0);
19702#endif /* FREECIV_JSON_CONNECTION */
19703
19704 for (i = 0; i < real_packet->count; i++) {
19705#ifdef FREECIV_JSON_CONNECTION
19706 /* Next array element. */
19707 field_addr.sub_location->number = i;
19708#endif /* FREECIV_JSON_CONNECTION */
19709
19710 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->counters[i]);
19711 }
19712
19713#ifdef FREECIV_JSON_CONNECTION
19714 /* Exit array. */
19715 FC_FREE(field_addr.sub_location);
19716#endif /* FREECIV_JSON_CONNECTION */
19717 }
19718
19719 if (e) {
19720 log_packet_detailed("'counters' field error detected");
19721 }
19722#endif /* FREECIV_DELTA_PROTOCOL */
19723
19724 SEND_PACKET_END(PACKET_CITY_UPDATE_COUNTERS);
19725}
19726
19727 int send_packet_city_update_counters(struct connection *pc, const struct packet_city_update_counters *packet)
19728{
19729 if (!pc->used) {
19730 log_error("WARNING: trying to send data to the closed connection %s",
19731 conn_description(pc));
19732 return -1;
19733 }
19734 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_UPDATE_COUNTERS].packet != nullptr, -1,
19735 "Handler for PACKET_CITY_UPDATE_COUNTERS not installed");
19736 return pc->phs.handlers->send[PACKET_CITY_UPDATE_COUNTERS].packet(pc, packet);
19737}
19738
19739 void lsend_packet_city_update_counters(struct conn_list *dest, const struct packet_city_update_counters *packet)
19740{
19741 conn_list_iterate(dest, pconn) {
19742 send_packet_city_update_counters(pconn, packet);
19743 } conn_list_iterate_end;
19744}
19745
19746 static inline void init_packet_city_short_info(struct packet_city_short_info *packet)
19747{
19748 memset(packet, 0, sizeof(*packet));
19749}
19750
19751#define free_packet_city_short_info(_packet) (void) 0
19752#define destroy_packet_city_short_info free
19753
19754#ifdef FREECIV_DELTA_PROTOCOL
19755static genhash_val_t hash_packet_city_short_info_100(const void *vkey)
19756{
19757 const struct packet_city_short_info *key = (const struct packet_city_short_info *) vkey;
19758 genhash_val_t result = 0;
19759
19760 result += key->id;
19761
19762 result &= 0xFFFFFFFF;
19763 return result;
19764}
19765
19766static bool cmp_packet_city_short_info_100(const void *vkey1, const void *vkey2)
19767{
19768 const struct packet_city_short_info *old = (const struct packet_city_short_info *) vkey1;
19769 const struct packet_city_short_info *real_packet = (const struct packet_city_short_info *) vkey2;
19770 bool differ;
19771
19772 differ = (old->id != real_packet->id);
19773
19774 return !differ;
19775}
19776 BV_DEFINE(packet_city_short_info_100_fields, 12);
19777#endif /* FREECIV_DELTA_PROTOCOL */
19778
19779 static struct packet_city_short_info *receive_packet_city_short_info_100(struct connection *pc)
19780{
19781#define FREE_PACKET_STRUCT(_packet) free_packet_city_short_info(_packet)
19782 RECEIVE_PACKET_START(packet_city_short_info, real_packet);
19783
19784#ifdef FREECIV_JSON_CONNECTION
19785 struct plocation field_addr;
19786 {
19787 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
19788 field_addr = *field_addr_tmp;
19789 FC_FREE(field_addr_tmp);
19790 }
19791#endif /* FREECIV_JSON_CONNECTION */
19792
19793#ifdef FREECIV_JSON_CONNECTION
19794 field_addr.name = "id";
19795#endif /* FREECIV_JSON_CONNECTION */
19796
19797 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
19798 RECEIVE_PACKET_FIELD_ERROR(id);
19799 }
19800
19801 log_packet_detailed("packet_city_short_info_100: got info about (%d)",
19802 real_packet->id);
19803
19804#ifdef FREECIV_DELTA_PROTOCOL
19805 packet_city_short_info_100_fields fields;
19806 struct packet_city_short_info *old;
19807 struct genhash **hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
19808
19809 if (nullptr == *hash) {
19810 *hash = genhash_new_full(hash_packet_city_short_info_100, cmp_packet_city_short_info_100,
19811 nullptr, nullptr, nullptr, destroy_packet_city_short_info);
19812 }
19813
19814 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
19815 *real_packet = *old;
19816 } else {
19817 /* packet is already initialized empty */
19818 log_packet_detailed(" no old info");
19819 }
19820
19821#ifdef FREECIV_JSON_CONNECTION
19822 field_addr.name = "fields";
19823#endif /* FREECIV_JSON_CONNECTION */
19824 DIO_BV_GET(&din, &field_addr, fields);
19825
19826 if (BV_ISSET(fields, 0)) {
19827 log_packet_detailed(" got field 'tile'");
19828
19829#ifdef FREECIV_JSON_CONNECTION
19830 field_addr.name = "tile";
19831#endif /* FREECIV_JSON_CONNECTION */
19832
19833 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
19834 RECEIVE_PACKET_FIELD_ERROR(tile);
19835 }
19836 }
19837
19838 if (BV_ISSET(fields, 1)) {
19839 log_packet_detailed(" got field 'owner'");
19840
19841#ifdef FREECIV_JSON_CONNECTION
19842 field_addr.name = "owner";
19843#endif /* FREECIV_JSON_CONNECTION */
19844
19845 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
19846 RECEIVE_PACKET_FIELD_ERROR(owner);
19847 }
19848 }
19849
19850 if (BV_ISSET(fields, 2)) {
19851 log_packet_detailed(" got field 'size'");
19852
19853#ifdef FREECIV_JSON_CONNECTION
19854 field_addr.name = "size";
19855#endif /* FREECIV_JSON_CONNECTION */
19856
19857 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
19858 RECEIVE_PACKET_FIELD_ERROR(size);
19859 }
19860 }
19861
19862 if (BV_ISSET(fields, 3)) {
19863 log_packet_detailed(" got field 'style'");
19864
19865#ifdef FREECIV_JSON_CONNECTION
19866 field_addr.name = "style";
19867#endif /* FREECIV_JSON_CONNECTION */
19868
19869 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
19870 RECEIVE_PACKET_FIELD_ERROR(style);
19871 }
19872 }
19873
19874 if (BV_ISSET(fields, 4)) {
19875 log_packet_detailed(" got field 'capital'");
19876
19877#ifdef FREECIV_JSON_CONNECTION
19878 field_addr.name = "capital";
19879#endif /* FREECIV_JSON_CONNECTION */
19880
19881 {
19882 int readin;
19883
19884 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
19885 RECEIVE_PACKET_FIELD_ERROR(capital);
19886 }
19887 real_packet->capital = readin;
19888 }
19889 }
19890
19891 real_packet->occupied = BV_ISSET(fields, 5);
19892
19893 if (BV_ISSET(fields, 6)) {
19894 log_packet_detailed(" got field 'walls'");
19895
19896#ifdef FREECIV_JSON_CONNECTION
19897 field_addr.name = "walls";
19898#endif /* FREECIV_JSON_CONNECTION */
19899
19900 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->walls)) {
19901 RECEIVE_PACKET_FIELD_ERROR(walls);
19902 }
19903 }
19904
19905 real_packet->happy = BV_ISSET(fields, 7);
19906
19907 real_packet->unhappy = BV_ISSET(fields, 8);
19908
19909 if (BV_ISSET(fields, 9)) {
19910 log_packet_detailed(" got field 'city_image'");
19911
19912#ifdef FREECIV_JSON_CONNECTION
19913 field_addr.name = "city_image";
19914#endif /* FREECIV_JSON_CONNECTION */
19915
19916 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->city_image)) {
19917 RECEIVE_PACKET_FIELD_ERROR(city_image);
19918 }
19919 }
19920
19921 if (BV_ISSET(fields, 10)) {
19922 log_packet_detailed(" got field 'improvements'");
19923
19924#ifdef FREECIV_JSON_CONNECTION
19925 field_addr.name = "improvements";
19926#endif /* FREECIV_JSON_CONNECTION */
19927
19928 if (!DIO_BV_GET(&din, &field_addr, real_packet->improvements)) {
19929 RECEIVE_PACKET_FIELD_ERROR(improvements);
19930 }
19931 }
19932
19933 if (BV_ISSET(fields, 11)) {
19934 log_packet_detailed(" got field 'name'");
19935
19936#ifdef FREECIV_JSON_CONNECTION
19937 field_addr.name = "name";
19938#endif /* FREECIV_JSON_CONNECTION */
19939
19940 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
19941 RECEIVE_PACKET_FIELD_ERROR(name);
19942 }
19943 }
19944
19945 if (nullptr == old) {
19946 old = fc_malloc(sizeof(*old));
19947 init_packet_city_short_info(old);
19948 *old = *real_packet;
19949 genhash_insert(*hash, old, old);
19950 } else {
19951 *old = *real_packet;
19952 }
19953
19954 hash = pc->phs.received + PACKET_CITY_INFO;
19955 if (nullptr != *hash) {
19956 genhash_remove(*hash, real_packet);
19957 }
19958
19959 hash = pc->phs.received + PACKET_WEB_CITY_INFO_ADDITION;
19960 if (nullptr != *hash) {
19961 genhash_remove(*hash, real_packet);
19962 }
19963
19964 hash = pc->phs.received + PACKET_CITY_NATIONALITIES;
19965 if (nullptr != *hash) {
19966 genhash_remove(*hash, real_packet);
19967 }
19968
19969 hash = pc->phs.received + PACKET_CITY_RALLY_POINT;
19970 if (nullptr != *hash) {
19971 genhash_remove(*hash, real_packet);
19972 }
19973
19974#else /* FREECIV_DELTA_PROTOCOL */
19975#ifdef FREECIV_JSON_CONNECTION
19976 field_addr.name = "tile";
19977#endif /* FREECIV_JSON_CONNECTION */
19978
19979 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
19980 RECEIVE_PACKET_FIELD_ERROR(tile);
19981 }
19982
19983#ifdef FREECIV_JSON_CONNECTION
19984 field_addr.name = "owner";
19985#endif /* FREECIV_JSON_CONNECTION */
19986
19987 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
19988 RECEIVE_PACKET_FIELD_ERROR(owner);
19989 }
19990
19991#ifdef FREECIV_JSON_CONNECTION
19992 field_addr.name = "size";
19993#endif /* FREECIV_JSON_CONNECTION */
19994
19995 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
19996 RECEIVE_PACKET_FIELD_ERROR(size);
19997 }
19998
19999#ifdef FREECIV_JSON_CONNECTION
20000 field_addr.name = "style";
20001#endif /* FREECIV_JSON_CONNECTION */
20002
20003 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
20004 RECEIVE_PACKET_FIELD_ERROR(style);
20005 }
20006
20007#ifdef FREECIV_JSON_CONNECTION
20008 field_addr.name = "capital";
20009#endif /* FREECIV_JSON_CONNECTION */
20010
20011 {
20012 int readin;
20013
20014 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
20015 RECEIVE_PACKET_FIELD_ERROR(capital);
20016 }
20017 real_packet->capital = readin;
20018 }
20019
20020#ifdef FREECIV_JSON_CONNECTION
20021 field_addr.name = "occupied";
20022#endif /* FREECIV_JSON_CONNECTION */
20023
20024 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->occupied)) {
20025 RECEIVE_PACKET_FIELD_ERROR(occupied);
20026 }
20027
20028#ifdef FREECIV_JSON_CONNECTION
20029 field_addr.name = "walls";
20030#endif /* FREECIV_JSON_CONNECTION */
20031
20032 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->walls)) {
20033 RECEIVE_PACKET_FIELD_ERROR(walls);
20034 }
20035
20036#ifdef FREECIV_JSON_CONNECTION
20037 field_addr.name = "happy";
20038#endif /* FREECIV_JSON_CONNECTION */
20039
20040 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->happy)) {
20041 RECEIVE_PACKET_FIELD_ERROR(happy);
20042 }
20043
20044#ifdef FREECIV_JSON_CONNECTION
20045 field_addr.name = "unhappy";
20046#endif /* FREECIV_JSON_CONNECTION */
20047
20048 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->unhappy)) {
20049 RECEIVE_PACKET_FIELD_ERROR(unhappy);
20050 }
20051
20052#ifdef FREECIV_JSON_CONNECTION
20053 field_addr.name = "city_image";
20054#endif /* FREECIV_JSON_CONNECTION */
20055
20056 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->city_image)) {
20057 RECEIVE_PACKET_FIELD_ERROR(city_image);
20058 }
20059
20060#ifdef FREECIV_JSON_CONNECTION
20061 field_addr.name = "improvements";
20062#endif /* FREECIV_JSON_CONNECTION */
20063
20064 if (!DIO_BV_GET(&din, &field_addr, real_packet->improvements)) {
20065 RECEIVE_PACKET_FIELD_ERROR(improvements);
20066 }
20067
20068#ifdef FREECIV_JSON_CONNECTION
20069 field_addr.name = "name";
20070#endif /* FREECIV_JSON_CONNECTION */
20071
20072 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
20073 RECEIVE_PACKET_FIELD_ERROR(name);
20074 }
20075#endif /* FREECIV_DELTA_PROTOCOL */
20076
20077 RECEIVE_PACKET_END(real_packet);
20078#undef FREE_PACKET_STRUCT
20079}
20080
20081 static int send_packet_city_short_info_100(struct connection *pc, const struct packet_city_short_info *packet)
20082{
20083 const struct packet_city_short_info *real_packet = packet;
20084 int e;
20085 SEND_PACKET_START(PACKET_CITY_SHORT_INFO);
20086
20087 log_packet_detailed("packet_city_short_info_100: sending info about (%d)",
20088 real_packet->id);
20089
20090#ifdef FREECIV_DELTA_PROTOCOL
20091 packet_city_short_info_100_fields fields;
20092 struct packet_city_short_info *old;
20093 bool differ;
20094 int different = 0;
20095 struct genhash **hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
20096
20097 if (nullptr == *hash) {
20098 *hash = genhash_new_full(hash_packet_city_short_info_100, cmp_packet_city_short_info_100,
20099 nullptr, nullptr, nullptr, destroy_packet_city_short_info);
20100 }
20101 BV_CLR_ALL(fields);
20102
20103 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20104 old = fc_malloc(sizeof(*old));
20105 /* temporary bitcopy just to insert correctly */
20106 *old = *real_packet;
20107 genhash_insert(*hash, old, old);
20108 init_packet_city_short_info(old);
20109 different = 1; /* Force to send. */
20110 }
20111
20112 differ = (old->tile != real_packet->tile);
20113 if (differ) {
20114 different++;
20115 BV_SET(fields, 0);
20116 }
20117
20118 differ = (old->owner != real_packet->owner);
20119 if (differ) {
20120 different++;
20121 BV_SET(fields, 1);
20122 }
20123
20124 differ = (old->size != real_packet->size);
20125 if (differ) {
20126 different++;
20127 BV_SET(fields, 2);
20128 }
20129
20130 differ = (old->style != real_packet->style);
20131 if (differ) {
20132 different++;
20133 BV_SET(fields, 3);
20134 }
20135
20136 differ = (old->capital != real_packet->capital);
20137 if (differ) {
20138 different++;
20139 BV_SET(fields, 4);
20140 }
20141
20142 differ = (old->occupied != real_packet->occupied);
20143 if (differ) {
20144 different++;
20145 }
20146 /* folded into head */
20147 if (real_packet->occupied) {
20148 BV_SET(fields, 5);
20149 }
20150
20151 differ = (old->walls != real_packet->walls);
20152 if (differ) {
20153 different++;
20154 BV_SET(fields, 6);
20155 }
20156
20157 differ = (old->happy != real_packet->happy);
20158 if (differ) {
20159 different++;
20160 }
20161 /* folded into head */
20162 if (real_packet->happy) {
20163 BV_SET(fields, 7);
20164 }
20165
20166 differ = (old->unhappy != real_packet->unhappy);
20167 if (differ) {
20168 different++;
20169 }
20170 /* folded into head */
20171 if (real_packet->unhappy) {
20172 BV_SET(fields, 8);
20173 }
20174
20175 differ = (old->city_image != real_packet->city_image);
20176 if (differ) {
20177 different++;
20178 BV_SET(fields, 9);
20179 }
20180
20181 differ = !BV_ARE_EQUAL(old->improvements, real_packet->improvements);
20182 if (differ) {
20183 different++;
20184 BV_SET(fields, 10);
20185 }
20186
20187 differ = (strcmp(old->name, real_packet->name) != 0);
20188 if (differ) {
20189 different++;
20190 BV_SET(fields, 11);
20191 }
20192
20193 if (different == 0) {
20194 log_packet_detailed(" no change -> discard");
20195 SEND_PACKET_DISCARD();
20196 }
20197#endif /* FREECIV_DELTA_PROTOCOL */
20198
20199#ifdef FREECIV_JSON_CONNECTION
20200 struct plocation field_addr;
20201 {
20202 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
20203 field_addr = *field_addr_tmp;
20204 FC_FREE(field_addr_tmp);
20205 }
20206#endif /* FREECIV_JSON_CONNECTION */
20207
20208#ifdef FREECIV_JSON_CONNECTION
20209 field_addr.name = "id";
20210#endif /* FREECIV_JSON_CONNECTION */
20211 e = 0;
20212
20213 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
20214
20215 if (e) {
20216 log_packet_detailed("'id' field error detected");
20217 }
20218
20219#ifdef FREECIV_DELTA_PROTOCOL
20220#ifdef FREECIV_JSON_CONNECTION
20221 field_addr.name = "fields";
20222#endif /* FREECIV_JSON_CONNECTION */
20223 e = 0;
20224 e |= DIO_BV_PUT(&dout, &field_addr, fields);
20225 if (e) {
20226 log_packet_detailed("fields bitvector error detected");
20227 }
20228
20229 if (BV_ISSET(fields, 0)) {
20230 log_packet_detailed(" field 'tile' has changed");
20231
20232#ifdef FREECIV_JSON_CONNECTION
20233 field_addr.name = "tile";
20234#endif /* FREECIV_JSON_CONNECTION */
20235 e = 0;
20236
20237 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
20238
20239 if (e) {
20240 log_packet_detailed("'tile' field error detected");
20241 }
20242 }
20243
20244 if (BV_ISSET(fields, 1)) {
20245 log_packet_detailed(" field 'owner' has changed");
20246
20247#ifdef FREECIV_JSON_CONNECTION
20248 field_addr.name = "owner";
20249#endif /* FREECIV_JSON_CONNECTION */
20250 e = 0;
20251
20252 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
20253
20254 if (e) {
20255 log_packet_detailed("'owner' field error detected");
20256 }
20257 }
20258
20259 if (BV_ISSET(fields, 2)) {
20260 log_packet_detailed(" field 'size' has changed");
20261
20262#ifdef FREECIV_JSON_CONNECTION
20263 field_addr.name = "size";
20264#endif /* FREECIV_JSON_CONNECTION */
20265 e = 0;
20266
20267 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
20268
20269 if (e) {
20270 log_packet_detailed("'size' field error detected");
20271 }
20272 }
20273
20274 if (BV_ISSET(fields, 3)) {
20275 log_packet_detailed(" field 'style' has changed");
20276
20277#ifdef FREECIV_JSON_CONNECTION
20278 field_addr.name = "style";
20279#endif /* FREECIV_JSON_CONNECTION */
20280 e = 0;
20281
20282 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
20283
20284 if (e) {
20285 log_packet_detailed("'style' field error detected");
20286 }
20287 }
20288
20289 if (BV_ISSET(fields, 4)) {
20290 log_packet_detailed(" field 'capital' has changed");
20291
20292#ifdef FREECIV_JSON_CONNECTION
20293 field_addr.name = "capital";
20294#endif /* FREECIV_JSON_CONNECTION */
20295 e = 0;
20296
20297 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->capital);
20298
20299 if (e) {
20300 log_packet_detailed("'capital' field error detected");
20301 }
20302 }
20303
20304 /* field 5 is folded into the header */
20305
20306 if (BV_ISSET(fields, 6)) {
20307 log_packet_detailed(" field 'walls' has changed");
20308
20309#ifdef FREECIV_JSON_CONNECTION
20310 field_addr.name = "walls";
20311#endif /* FREECIV_JSON_CONNECTION */
20312 e = 0;
20313
20314 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->walls);
20315
20316 if (e) {
20317 log_packet_detailed("'walls' field error detected");
20318 }
20319 }
20320
20321 /* field 7 is folded into the header */
20322
20323 /* field 8 is folded into the header */
20324
20325 if (BV_ISSET(fields, 9)) {
20326 log_packet_detailed(" field 'city_image' has changed");
20327
20328#ifdef FREECIV_JSON_CONNECTION
20329 field_addr.name = "city_image";
20330#endif /* FREECIV_JSON_CONNECTION */
20331 e = 0;
20332
20333 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->city_image);
20334
20335 if (e) {
20336 log_packet_detailed("'city_image' field error detected");
20337 }
20338 }
20339
20340 if (BV_ISSET(fields, 10)) {
20341 log_packet_detailed(" field 'improvements' has changed");
20342
20343#ifdef FREECIV_JSON_CONNECTION
20344 field_addr.name = "improvements";
20345#endif /* FREECIV_JSON_CONNECTION */
20346 e = 0;
20347
20348 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->improvements);
20349
20350 if (e) {
20351 log_packet_detailed("'improvements' field error detected");
20352 }
20353 }
20354
20355 if (BV_ISSET(fields, 11)) {
20356 log_packet_detailed(" field 'name' has changed");
20357
20358#ifdef FREECIV_JSON_CONNECTION
20359 field_addr.name = "name";
20360#endif /* FREECIV_JSON_CONNECTION */
20361 e = 0;
20362
20363 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
20364
20365 if (e) {
20366 log_packet_detailed("'name' field error detected");
20367 }
20368 }
20369
20370 *old = *real_packet;
20371
20372 hash = pc->phs.sent + PACKET_CITY_INFO;
20373 if (nullptr != *hash) {
20374 genhash_remove(*hash, real_packet);
20375 }
20376
20377 hash = pc->phs.sent + PACKET_WEB_CITY_INFO_ADDITION;
20378 if (nullptr != *hash) {
20379 genhash_remove(*hash, real_packet);
20380 }
20381
20382 hash = pc->phs.sent + PACKET_CITY_NATIONALITIES;
20383 if (nullptr != *hash) {
20384 genhash_remove(*hash, real_packet);
20385 }
20386
20387 hash = pc->phs.sent + PACKET_CITY_RALLY_POINT;
20388 if (nullptr != *hash) {
20389 genhash_remove(*hash, real_packet);
20390 }
20391
20392#else /* FREECIV_DELTA_PROTOCOL */
20393#ifdef FREECIV_JSON_CONNECTION
20394 field_addr.name = "tile";
20395#endif /* FREECIV_JSON_CONNECTION */
20396 e = 0;
20397
20398 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
20399
20400 if (e) {
20401 log_packet_detailed("'tile' field error detected");
20402 }
20403
20404#ifdef FREECIV_JSON_CONNECTION
20405 field_addr.name = "owner";
20406#endif /* FREECIV_JSON_CONNECTION */
20407 e = 0;
20408
20409 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
20410
20411 if (e) {
20412 log_packet_detailed("'owner' field error detected");
20413 }
20414
20415#ifdef FREECIV_JSON_CONNECTION
20416 field_addr.name = "size";
20417#endif /* FREECIV_JSON_CONNECTION */
20418 e = 0;
20419
20420 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
20421
20422 if (e) {
20423 log_packet_detailed("'size' field error detected");
20424 }
20425
20426#ifdef FREECIV_JSON_CONNECTION
20427 field_addr.name = "style";
20428#endif /* FREECIV_JSON_CONNECTION */
20429 e = 0;
20430
20431 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
20432
20433 if (e) {
20434 log_packet_detailed("'style' field error detected");
20435 }
20436
20437#ifdef FREECIV_JSON_CONNECTION
20438 field_addr.name = "capital";
20439#endif /* FREECIV_JSON_CONNECTION */
20440 e = 0;
20441
20442 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->capital);
20443
20444 if (e) {
20445 log_packet_detailed("'capital' field error detected");
20446 }
20447
20448#ifdef FREECIV_JSON_CONNECTION
20449 field_addr.name = "occupied";
20450#endif /* FREECIV_JSON_CONNECTION */
20451 e = 0;
20452
20453 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->occupied);
20454
20455 if (e) {
20456 log_packet_detailed("'occupied' field error detected");
20457 }
20458
20459#ifdef FREECIV_JSON_CONNECTION
20460 field_addr.name = "walls";
20461#endif /* FREECIV_JSON_CONNECTION */
20462 e = 0;
20463
20464 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->walls);
20465
20466 if (e) {
20467 log_packet_detailed("'walls' field error detected");
20468 }
20469
20470#ifdef FREECIV_JSON_CONNECTION
20471 field_addr.name = "happy";
20472#endif /* FREECIV_JSON_CONNECTION */
20473 e = 0;
20474
20475 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->happy);
20476
20477 if (e) {
20478 log_packet_detailed("'happy' field error detected");
20479 }
20480
20481#ifdef FREECIV_JSON_CONNECTION
20482 field_addr.name = "unhappy";
20483#endif /* FREECIV_JSON_CONNECTION */
20484 e = 0;
20485
20486 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->unhappy);
20487
20488 if (e) {
20489 log_packet_detailed("'unhappy' field error detected");
20490 }
20491
20492#ifdef FREECIV_JSON_CONNECTION
20493 field_addr.name = "city_image";
20494#endif /* FREECIV_JSON_CONNECTION */
20495 e = 0;
20496
20497 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->city_image);
20498
20499 if (e) {
20500 log_packet_detailed("'city_image' field error detected");
20501 }
20502
20503#ifdef FREECIV_JSON_CONNECTION
20504 field_addr.name = "improvements";
20505#endif /* FREECIV_JSON_CONNECTION */
20506 e = 0;
20507
20508 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->improvements);
20509
20510 if (e) {
20511 log_packet_detailed("'improvements' field error detected");
20512 }
20513
20514#ifdef FREECIV_JSON_CONNECTION
20515 field_addr.name = "name";
20516#endif /* FREECIV_JSON_CONNECTION */
20517 e = 0;
20518
20519 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
20520
20521 if (e) {
20522 log_packet_detailed("'name' field error detected");
20523 }
20524#endif /* FREECIV_DELTA_PROTOCOL */
20525
20526 SEND_PACKET_END(PACKET_CITY_SHORT_INFO);
20527}
20528
20529 int send_packet_city_short_info(struct connection *pc, const struct packet_city_short_info *packet)
20530{
20531 if (!pc->used) {
20532 log_error("WARNING: trying to send data to the closed connection %s",
20533 conn_description(pc));
20534 return -1;
20535 }
20536 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_SHORT_INFO].packet != nullptr, -1,
20537 "Handler for PACKET_CITY_SHORT_INFO not installed");
20538 return pc->phs.handlers->send[PACKET_CITY_SHORT_INFO].packet(pc, packet);
20539}
20540
20541 void lsend_packet_city_short_info(struct conn_list *dest, const struct packet_city_short_info *packet)
20542{
20543 conn_list_iterate(dest, pconn) {
20544 send_packet_city_short_info(pconn, packet);
20545 } conn_list_iterate_end;
20546}
20547
20548 static inline void init_packet_trade_route_info(struct packet_trade_route_info *packet)
20549{
20550 memset(packet, 0, sizeof(*packet));
20551}
20552
20553#define free_packet_trade_route_info(_packet) (void) 0
20554#define destroy_packet_trade_route_info free
20555
20556#ifdef FREECIV_DELTA_PROTOCOL
20557#define hash_packet_trade_route_info_100 hash_const
20558#define cmp_packet_trade_route_info_100 cmp_const
20559 BV_DEFINE(packet_trade_route_info_100_fields, 6);
20560#endif /* FREECIV_DELTA_PROTOCOL */
20561
20562 static struct packet_trade_route_info *receive_packet_trade_route_info_100(struct connection *pc)
20563{
20564#define FREE_PACKET_STRUCT(_packet) free_packet_trade_route_info(_packet)
20565 RECEIVE_PACKET_START(packet_trade_route_info, real_packet);
20566
20567#ifdef FREECIV_JSON_CONNECTION
20568 struct plocation field_addr;
20569 {
20570 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
20571 field_addr = *field_addr_tmp;
20572 FC_FREE(field_addr_tmp);
20573 }
20574#endif /* FREECIV_JSON_CONNECTION */
20575
20576 log_packet_detailed("packet_trade_route_info_100: got info about ()");
20577
20578#ifdef FREECIV_DELTA_PROTOCOL
20579 packet_trade_route_info_100_fields fields;
20580 struct packet_trade_route_info *old;
20581 struct genhash **hash = pc->phs.received + PACKET_TRADE_ROUTE_INFO;
20582
20583 if (nullptr == *hash) {
20584 *hash = genhash_new_full(hash_packet_trade_route_info_100, cmp_packet_trade_route_info_100,
20585 nullptr, nullptr, nullptr, destroy_packet_trade_route_info);
20586 }
20587
20588 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
20589 *real_packet = *old;
20590 } else {
20591 /* packet is already initialized empty */
20592 log_packet_detailed(" no old info");
20593 }
20594
20595#ifdef FREECIV_JSON_CONNECTION
20596 field_addr.name = "fields";
20597#endif /* FREECIV_JSON_CONNECTION */
20598 DIO_BV_GET(&din, &field_addr, fields);
20599
20600 if (BV_ISSET(fields, 0)) {
20601 log_packet_detailed(" got field 'city'");
20602
20603#ifdef FREECIV_JSON_CONNECTION
20604 field_addr.name = "city";
20605#endif /* FREECIV_JSON_CONNECTION */
20606
20607 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city)) {
20608 RECEIVE_PACKET_FIELD_ERROR(city);
20609 }
20610 }
20611
20612 if (BV_ISSET(fields, 1)) {
20613 log_packet_detailed(" got field 'index'");
20614
20615#ifdef FREECIV_JSON_CONNECTION
20616 field_addr.name = "index";
20617#endif /* FREECIV_JSON_CONNECTION */
20618
20619 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->index)) {
20620 RECEIVE_PACKET_FIELD_ERROR(index);
20621 }
20622 }
20623
20624 if (BV_ISSET(fields, 2)) {
20625 log_packet_detailed(" got field 'partner'");
20626
20627#ifdef FREECIV_JSON_CONNECTION
20628 field_addr.name = "partner";
20629#endif /* FREECIV_JSON_CONNECTION */
20630
20631 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->partner)) {
20632 RECEIVE_PACKET_FIELD_ERROR(partner);
20633 }
20634 }
20635
20636 if (BV_ISSET(fields, 3)) {
20637 log_packet_detailed(" got field 'value'");
20638
20639#ifdef FREECIV_JSON_CONNECTION
20640 field_addr.name = "value";
20641#endif /* FREECIV_JSON_CONNECTION */
20642
20643 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->value)) {
20644 RECEIVE_PACKET_FIELD_ERROR(value);
20645 }
20646 }
20647
20648 if (BV_ISSET(fields, 4)) {
20649 log_packet_detailed(" got field 'direction'");
20650
20651#ifdef FREECIV_JSON_CONNECTION
20652 field_addr.name = "direction";
20653#endif /* FREECIV_JSON_CONNECTION */
20654
20655 {
20656 int readin;
20657
20658 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
20659 RECEIVE_PACKET_FIELD_ERROR(direction);
20660 }
20661 real_packet->direction = readin;
20662 }
20663 }
20664
20665 if (BV_ISSET(fields, 5)) {
20666 log_packet_detailed(" got field 'goods'");
20667
20668#ifdef FREECIV_JSON_CONNECTION
20669 field_addr.name = "goods";
20670#endif /* FREECIV_JSON_CONNECTION */
20671
20672 {
20673 int readin;
20674
20675 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
20676 RECEIVE_PACKET_FIELD_ERROR(goods);
20677 }
20678 real_packet->goods = readin;
20679 }
20680 }
20681
20682 if (nullptr == old) {
20683 old = fc_malloc(sizeof(*old));
20684 init_packet_trade_route_info(old);
20685 *old = *real_packet;
20686 genhash_insert(*hash, old, old);
20687 } else {
20688 *old = *real_packet;
20689 }
20690
20691#else /* FREECIV_DELTA_PROTOCOL */
20692#ifdef FREECIV_JSON_CONNECTION
20693 field_addr.name = "city";
20694#endif /* FREECIV_JSON_CONNECTION */
20695
20696 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city)) {
20697 RECEIVE_PACKET_FIELD_ERROR(city);
20698 }
20699
20700#ifdef FREECIV_JSON_CONNECTION
20701 field_addr.name = "index";
20702#endif /* FREECIV_JSON_CONNECTION */
20703
20704 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->index)) {
20705 RECEIVE_PACKET_FIELD_ERROR(index);
20706 }
20707
20708#ifdef FREECIV_JSON_CONNECTION
20709 field_addr.name = "partner";
20710#endif /* FREECIV_JSON_CONNECTION */
20711
20712 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->partner)) {
20713 RECEIVE_PACKET_FIELD_ERROR(partner);
20714 }
20715
20716#ifdef FREECIV_JSON_CONNECTION
20717 field_addr.name = "value";
20718#endif /* FREECIV_JSON_CONNECTION */
20719
20720 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->value)) {
20721 RECEIVE_PACKET_FIELD_ERROR(value);
20722 }
20723
20724#ifdef FREECIV_JSON_CONNECTION
20725 field_addr.name = "direction";
20726#endif /* FREECIV_JSON_CONNECTION */
20727
20728 {
20729 int readin;
20730
20731 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
20732 RECEIVE_PACKET_FIELD_ERROR(direction);
20733 }
20734 real_packet->direction = readin;
20735 }
20736
20737#ifdef FREECIV_JSON_CONNECTION
20738 field_addr.name = "goods";
20739#endif /* FREECIV_JSON_CONNECTION */
20740
20741 {
20742 int readin;
20743
20744 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
20745 RECEIVE_PACKET_FIELD_ERROR(goods);
20746 }
20747 real_packet->goods = readin;
20748 }
20749#endif /* FREECIV_DELTA_PROTOCOL */
20750
20751 RECEIVE_PACKET_END(real_packet);
20752#undef FREE_PACKET_STRUCT
20753}
20754
20755 static int send_packet_trade_route_info_100(struct connection *pc, const struct packet_trade_route_info *packet)
20756{
20757 const struct packet_trade_route_info *real_packet = packet;
20758 int e;
20759 SEND_PACKET_START(PACKET_TRADE_ROUTE_INFO);
20760
20761 log_packet_detailed("packet_trade_route_info_100: sending info about ()");
20762
20763#ifdef FREECIV_DELTA_PROTOCOL
20764 packet_trade_route_info_100_fields fields;
20765 struct packet_trade_route_info *old;
20766 bool differ;
20767 struct genhash **hash = pc->phs.sent + PACKET_TRADE_ROUTE_INFO;
20768
20769 if (nullptr == *hash) {
20770 *hash = genhash_new_full(hash_packet_trade_route_info_100, cmp_packet_trade_route_info_100,
20771 nullptr, nullptr, nullptr, destroy_packet_trade_route_info);
20772 }
20773 BV_CLR_ALL(fields);
20774
20775 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
20776 old = fc_malloc(sizeof(*old));
20777 /* temporary bitcopy just to insert correctly */
20778 *old = *real_packet;
20779 genhash_insert(*hash, old, old);
20780 init_packet_trade_route_info(old);
20781 }
20782
20783 differ = (old->city != real_packet->city);
20784 if (differ) {
20785 BV_SET(fields, 0);
20786 }
20787
20788 differ = (old->index != real_packet->index);
20789 if (differ) {
20790 BV_SET(fields, 1);
20791 }
20792
20793 differ = (old->partner != real_packet->partner);
20794 if (differ) {
20795 BV_SET(fields, 2);
20796 }
20797
20798 differ = (old->value != real_packet->value);
20799 if (differ) {
20800 BV_SET(fields, 3);
20801 }
20802
20803 differ = (old->direction != real_packet->direction);
20804 if (differ) {
20805 BV_SET(fields, 4);
20806 }
20807
20808 differ = (old->goods != real_packet->goods);
20809 if (differ) {
20810 BV_SET(fields, 5);
20811 }
20812#endif /* FREECIV_DELTA_PROTOCOL */
20813
20814#ifdef FREECIV_JSON_CONNECTION
20815 struct plocation field_addr;
20816 {
20817 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
20818 field_addr = *field_addr_tmp;
20819 FC_FREE(field_addr_tmp);
20820 }
20821#endif /* FREECIV_JSON_CONNECTION */
20822
20823#ifdef FREECIV_DELTA_PROTOCOL
20824#ifdef FREECIV_JSON_CONNECTION
20825 field_addr.name = "fields";
20826#endif /* FREECIV_JSON_CONNECTION */
20827 e = 0;
20828 e |= DIO_BV_PUT(&dout, &field_addr, fields);
20829 if (e) {
20830 log_packet_detailed("fields bitvector error detected");
20831 }
20832
20833 if (BV_ISSET(fields, 0)) {
20834 log_packet_detailed(" field 'city' has changed");
20835
20836#ifdef FREECIV_JSON_CONNECTION
20837 field_addr.name = "city";
20838#endif /* FREECIV_JSON_CONNECTION */
20839 e = 0;
20840
20841 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city);
20842
20843 if (e) {
20844 log_packet_detailed("'city' field error detected");
20845 }
20846 }
20847
20848 if (BV_ISSET(fields, 1)) {
20849 log_packet_detailed(" field 'index' has changed");
20850
20851#ifdef FREECIV_JSON_CONNECTION
20852 field_addr.name = "index";
20853#endif /* FREECIV_JSON_CONNECTION */
20854 e = 0;
20855
20856 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->index);
20857
20858 if (e) {
20859 log_packet_detailed("'index' field error detected");
20860 }
20861 }
20862
20863 if (BV_ISSET(fields, 2)) {
20864 log_packet_detailed(" field 'partner' has changed");
20865
20866#ifdef FREECIV_JSON_CONNECTION
20867 field_addr.name = "partner";
20868#endif /* FREECIV_JSON_CONNECTION */
20869 e = 0;
20870
20871 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->partner);
20872
20873 if (e) {
20874 log_packet_detailed("'partner' field error detected");
20875 }
20876 }
20877
20878 if (BV_ISSET(fields, 3)) {
20879 log_packet_detailed(" field 'value' has changed");
20880
20881#ifdef FREECIV_JSON_CONNECTION
20882 field_addr.name = "value";
20883#endif /* FREECIV_JSON_CONNECTION */
20884 e = 0;
20885
20886 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->value);
20887
20888 if (e) {
20889 log_packet_detailed("'value' field error detected");
20890 }
20891 }
20892
20893 if (BV_ISSET(fields, 4)) {
20894 log_packet_detailed(" field 'direction' has changed");
20895
20896#ifdef FREECIV_JSON_CONNECTION
20897 field_addr.name = "direction";
20898#endif /* FREECIV_JSON_CONNECTION */
20899 e = 0;
20900
20901 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->direction);
20902
20903 if (e) {
20904 log_packet_detailed("'direction' field error detected");
20905 }
20906 }
20907
20908 if (BV_ISSET(fields, 5)) {
20909 log_packet_detailed(" field 'goods' has changed");
20910
20911#ifdef FREECIV_JSON_CONNECTION
20912 field_addr.name = "goods";
20913#endif /* FREECIV_JSON_CONNECTION */
20914 e = 0;
20915
20916 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->goods);
20917
20918 if (e) {
20919 log_packet_detailed("'goods' field error detected");
20920 }
20921 }
20922
20923 *old = *real_packet;
20924
20925#else /* FREECIV_DELTA_PROTOCOL */
20926#ifdef FREECIV_JSON_CONNECTION
20927 field_addr.name = "city";
20928#endif /* FREECIV_JSON_CONNECTION */
20929 e = 0;
20930
20931 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city);
20932
20933 if (e) {
20934 log_packet_detailed("'city' field error detected");
20935 }
20936
20937#ifdef FREECIV_JSON_CONNECTION
20938 field_addr.name = "index";
20939#endif /* FREECIV_JSON_CONNECTION */
20940 e = 0;
20941
20942 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->index);
20943
20944 if (e) {
20945 log_packet_detailed("'index' field error detected");
20946 }
20947
20948#ifdef FREECIV_JSON_CONNECTION
20949 field_addr.name = "partner";
20950#endif /* FREECIV_JSON_CONNECTION */
20951 e = 0;
20952
20953 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->partner);
20954
20955 if (e) {
20956 log_packet_detailed("'partner' field error detected");
20957 }
20958
20959#ifdef FREECIV_JSON_CONNECTION
20960 field_addr.name = "value";
20961#endif /* FREECIV_JSON_CONNECTION */
20962 e = 0;
20963
20964 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->value);
20965
20966 if (e) {
20967 log_packet_detailed("'value' field error detected");
20968 }
20969
20970#ifdef FREECIV_JSON_CONNECTION
20971 field_addr.name = "direction";
20972#endif /* FREECIV_JSON_CONNECTION */
20973 e = 0;
20974
20975 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->direction);
20976
20977 if (e) {
20978 log_packet_detailed("'direction' field error detected");
20979 }
20980
20981#ifdef FREECIV_JSON_CONNECTION
20982 field_addr.name = "goods";
20983#endif /* FREECIV_JSON_CONNECTION */
20984 e = 0;
20985
20986 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->goods);
20987
20988 if (e) {
20989 log_packet_detailed("'goods' field error detected");
20990 }
20991#endif /* FREECIV_DELTA_PROTOCOL */
20992
20993 SEND_PACKET_END(PACKET_TRADE_ROUTE_INFO);
20994}
20995
20996 int send_packet_trade_route_info(struct connection *pc, const struct packet_trade_route_info *packet)
20997{
20998 if (!pc->used) {
20999 log_error("WARNING: trying to send data to the closed connection %s",
21000 conn_description(pc));
21001 return -1;
21002 }
21003 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_TRADE_ROUTE_INFO].packet != nullptr, -1,
21004 "Handler for PACKET_TRADE_ROUTE_INFO not installed");
21005 return pc->phs.handlers->send[PACKET_TRADE_ROUTE_INFO].packet(pc, packet);
21006}
21007
21008 void lsend_packet_trade_route_info(struct conn_list *dest, const struct packet_trade_route_info *packet)
21009{
21010 conn_list_iterate(dest, pconn) {
21011 send_packet_trade_route_info(pconn, packet);
21012 } conn_list_iterate_end;
21013}
21014
21015 static inline void init_packet_city_sell(struct packet_city_sell *packet)
21016{
21017 memset(packet, 0, sizeof(*packet));
21018}
21019
21020#define free_packet_city_sell(_packet) (void) 0
21021#define destroy_packet_city_sell free
21022
21023#ifdef FREECIV_DELTA_PROTOCOL
21024#define hash_packet_city_sell_100 hash_const
21025#define cmp_packet_city_sell_100 cmp_const
21026 BV_DEFINE(packet_city_sell_100_fields, 2);
21027#endif /* FREECIV_DELTA_PROTOCOL */
21028
21029 static struct packet_city_sell *receive_packet_city_sell_100(struct connection *pc)
21030{
21031#define FREE_PACKET_STRUCT(_packet) free_packet_city_sell(_packet)
21032 RECEIVE_PACKET_START(packet_city_sell, real_packet);
21033
21034#ifdef FREECIV_JSON_CONNECTION
21035 struct plocation field_addr;
21036 {
21037 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21038 field_addr = *field_addr_tmp;
21039 FC_FREE(field_addr_tmp);
21040 }
21041#endif /* FREECIV_JSON_CONNECTION */
21042
21043 log_packet_detailed("packet_city_sell_100: got info about ()");
21044
21045#ifdef FREECIV_DELTA_PROTOCOL
21046 packet_city_sell_100_fields fields;
21047 struct packet_city_sell *old;
21048 struct genhash **hash = pc->phs.received + PACKET_CITY_SELL;
21049
21050 if (nullptr == *hash) {
21051 *hash = genhash_new_full(hash_packet_city_sell_100, cmp_packet_city_sell_100,
21052 nullptr, nullptr, nullptr, destroy_packet_city_sell);
21053 }
21054
21055 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21056 *real_packet = *old;
21057 } else {
21058 /* packet is already initialized empty */
21059 log_packet_detailed(" no old info");
21060 }
21061
21062#ifdef FREECIV_JSON_CONNECTION
21063 field_addr.name = "fields";
21064#endif /* FREECIV_JSON_CONNECTION */
21065 DIO_BV_GET(&din, &field_addr, fields);
21066
21067 if (BV_ISSET(fields, 0)) {
21068 log_packet_detailed(" got field 'city_id'");
21069
21070#ifdef FREECIV_JSON_CONNECTION
21071 field_addr.name = "city_id";
21072#endif /* FREECIV_JSON_CONNECTION */
21073
21074 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21075 RECEIVE_PACKET_FIELD_ERROR(city_id);
21076 }
21077 }
21078
21079 if (BV_ISSET(fields, 1)) {
21080 log_packet_detailed(" got field 'build_id'");
21081
21082#ifdef FREECIV_JSON_CONNECTION
21083 field_addr.name = "build_id";
21084#endif /* FREECIV_JSON_CONNECTION */
21085
21086 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->build_id)) {
21087 RECEIVE_PACKET_FIELD_ERROR(build_id);
21088 }
21089 }
21090
21091 if (nullptr == old) {
21092 old = fc_malloc(sizeof(*old));
21093 init_packet_city_sell(old);
21094 *old = *real_packet;
21095 genhash_insert(*hash, old, old);
21096 } else {
21097 *old = *real_packet;
21098 }
21099
21100#else /* FREECIV_DELTA_PROTOCOL */
21101#ifdef FREECIV_JSON_CONNECTION
21102 field_addr.name = "city_id";
21103#endif /* FREECIV_JSON_CONNECTION */
21104
21105 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21106 RECEIVE_PACKET_FIELD_ERROR(city_id);
21107 }
21108
21109#ifdef FREECIV_JSON_CONNECTION
21110 field_addr.name = "build_id";
21111#endif /* FREECIV_JSON_CONNECTION */
21112
21113 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->build_id)) {
21114 RECEIVE_PACKET_FIELD_ERROR(build_id);
21115 }
21116#endif /* FREECIV_DELTA_PROTOCOL */
21117
21118 RECEIVE_PACKET_END(real_packet);
21119#undef FREE_PACKET_STRUCT
21120}
21121
21122 static int send_packet_city_sell_100(struct connection *pc, const struct packet_city_sell *packet)
21123{
21124 const struct packet_city_sell *real_packet = packet;
21125 int e;
21126 SEND_PACKET_START(PACKET_CITY_SELL);
21127
21128 log_packet_detailed("packet_city_sell_100: sending info about ()");
21129
21130#ifdef FREECIV_DELTA_PROTOCOL
21131 packet_city_sell_100_fields fields;
21132 struct packet_city_sell *old;
21133 bool differ;
21134 struct genhash **hash = pc->phs.sent + PACKET_CITY_SELL;
21135
21136 if (nullptr == *hash) {
21137 *hash = genhash_new_full(hash_packet_city_sell_100, cmp_packet_city_sell_100,
21138 nullptr, nullptr, nullptr, destroy_packet_city_sell);
21139 }
21140 BV_CLR_ALL(fields);
21141
21142 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21143 old = fc_malloc(sizeof(*old));
21144 /* temporary bitcopy just to insert correctly */
21145 *old = *real_packet;
21146 genhash_insert(*hash, old, old);
21147 init_packet_city_sell(old);
21148 }
21149
21150 differ = (old->city_id != real_packet->city_id);
21151 if (differ) {
21152 BV_SET(fields, 0);
21153 }
21154
21155 differ = (old->build_id != real_packet->build_id);
21156 if (differ) {
21157 BV_SET(fields, 1);
21158 }
21159#endif /* FREECIV_DELTA_PROTOCOL */
21160
21161#ifdef FREECIV_JSON_CONNECTION
21162 struct plocation field_addr;
21163 {
21164 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21165 field_addr = *field_addr_tmp;
21166 FC_FREE(field_addr_tmp);
21167 }
21168#endif /* FREECIV_JSON_CONNECTION */
21169
21170#ifdef FREECIV_DELTA_PROTOCOL
21171#ifdef FREECIV_JSON_CONNECTION
21172 field_addr.name = "fields";
21173#endif /* FREECIV_JSON_CONNECTION */
21174 e = 0;
21175 e |= DIO_BV_PUT(&dout, &field_addr, fields);
21176 if (e) {
21177 log_packet_detailed("fields bitvector error detected");
21178 }
21179
21180 if (BV_ISSET(fields, 0)) {
21181 log_packet_detailed(" field 'city_id' has changed");
21182
21183#ifdef FREECIV_JSON_CONNECTION
21184 field_addr.name = "city_id";
21185#endif /* FREECIV_JSON_CONNECTION */
21186 e = 0;
21187
21188 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21189
21190 if (e) {
21191 log_packet_detailed("'city_id' field error detected");
21192 }
21193 }
21194
21195 if (BV_ISSET(fields, 1)) {
21196 log_packet_detailed(" field 'build_id' has changed");
21197
21198#ifdef FREECIV_JSON_CONNECTION
21199 field_addr.name = "build_id";
21200#endif /* FREECIV_JSON_CONNECTION */
21201 e = 0;
21202
21203 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->build_id);
21204
21205 if (e) {
21206 log_packet_detailed("'build_id' field error detected");
21207 }
21208 }
21209
21210 *old = *real_packet;
21211
21212#else /* FREECIV_DELTA_PROTOCOL */
21213#ifdef FREECIV_JSON_CONNECTION
21214 field_addr.name = "city_id";
21215#endif /* FREECIV_JSON_CONNECTION */
21216 e = 0;
21217
21218 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21219
21220 if (e) {
21221 log_packet_detailed("'city_id' field error detected");
21222 }
21223
21224#ifdef FREECIV_JSON_CONNECTION
21225 field_addr.name = "build_id";
21226#endif /* FREECIV_JSON_CONNECTION */
21227 e = 0;
21228
21229 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->build_id);
21230
21231 if (e) {
21232 log_packet_detailed("'build_id' field error detected");
21233 }
21234#endif /* FREECIV_DELTA_PROTOCOL */
21235
21236 SEND_PACKET_END(PACKET_CITY_SELL);
21237}
21238
21239 int send_packet_city_sell(struct connection *pc, const struct packet_city_sell *packet)
21240{
21241 if (!pc->used) {
21242 log_error("WARNING: trying to send data to the closed connection %s",
21243 conn_description(pc));
21244 return -1;
21245 }
21246 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_SELL].packet != nullptr, -1,
21247 "Handler for PACKET_CITY_SELL not installed");
21248 return pc->phs.handlers->send[PACKET_CITY_SELL].packet(pc, packet);
21249}
21250
21251 int dsend_packet_city_sell(struct connection *pc, int city_id, int build_id)
21252{
21253 struct packet_city_sell packet, *real_packet = &packet;
21254
21255 real_packet->city_id = city_id;
21256 real_packet->build_id = build_id;
21257
21258 return send_packet_city_sell(pc, real_packet);
21259}
21260
21261 static inline void init_packet_city_buy(struct packet_city_buy *packet)
21262{
21263 memset(packet, 0, sizeof(*packet));
21264}
21265
21266#define free_packet_city_buy(_packet) (void) 0
21267#define destroy_packet_city_buy free
21268
21269#ifdef FREECIV_DELTA_PROTOCOL
21270#define hash_packet_city_buy_100 hash_const
21271#define cmp_packet_city_buy_100 cmp_const
21272 BV_DEFINE(packet_city_buy_100_fields, 1);
21273#endif /* FREECIV_DELTA_PROTOCOL */
21274
21275 static struct packet_city_buy *receive_packet_city_buy_100(struct connection *pc)
21276{
21277#define FREE_PACKET_STRUCT(_packet) free_packet_city_buy(_packet)
21278 RECEIVE_PACKET_START(packet_city_buy, real_packet);
21279
21280#ifdef FREECIV_JSON_CONNECTION
21281 struct plocation field_addr;
21282 {
21283 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21284 field_addr = *field_addr_tmp;
21285 FC_FREE(field_addr_tmp);
21286 }
21287#endif /* FREECIV_JSON_CONNECTION */
21288
21289 log_packet_detailed("packet_city_buy_100: got info about ()");
21290
21291#ifdef FREECIV_DELTA_PROTOCOL
21292 packet_city_buy_100_fields fields;
21293 struct packet_city_buy *old;
21294 struct genhash **hash = pc->phs.received + PACKET_CITY_BUY;
21295
21296 if (nullptr == *hash) {
21297 *hash = genhash_new_full(hash_packet_city_buy_100, cmp_packet_city_buy_100,
21298 nullptr, nullptr, nullptr, destroy_packet_city_buy);
21299 }
21300
21301 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21302 *real_packet = *old;
21303 } else {
21304 /* packet is already initialized empty */
21305 log_packet_detailed(" no old info");
21306 }
21307
21308#ifdef FREECIV_JSON_CONNECTION
21309 field_addr.name = "fields";
21310#endif /* FREECIV_JSON_CONNECTION */
21311 DIO_BV_GET(&din, &field_addr, fields);
21312
21313 if (BV_ISSET(fields, 0)) {
21314 log_packet_detailed(" got field 'city_id'");
21315
21316#ifdef FREECIV_JSON_CONNECTION
21317 field_addr.name = "city_id";
21318#endif /* FREECIV_JSON_CONNECTION */
21319
21320 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21321 RECEIVE_PACKET_FIELD_ERROR(city_id);
21322 }
21323 }
21324
21325 if (nullptr == old) {
21326 old = fc_malloc(sizeof(*old));
21327 init_packet_city_buy(old);
21328 *old = *real_packet;
21329 genhash_insert(*hash, old, old);
21330 } else {
21331 *old = *real_packet;
21332 }
21333
21334#else /* FREECIV_DELTA_PROTOCOL */
21335#ifdef FREECIV_JSON_CONNECTION
21336 field_addr.name = "city_id";
21337#endif /* FREECIV_JSON_CONNECTION */
21338
21339 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21340 RECEIVE_PACKET_FIELD_ERROR(city_id);
21341 }
21342#endif /* FREECIV_DELTA_PROTOCOL */
21343
21344 RECEIVE_PACKET_END(real_packet);
21345#undef FREE_PACKET_STRUCT
21346}
21347
21348 static int send_packet_city_buy_100(struct connection *pc, const struct packet_city_buy *packet)
21349{
21350 const struct packet_city_buy *real_packet = packet;
21351 int e;
21352 SEND_PACKET_START(PACKET_CITY_BUY);
21353
21354 log_packet_detailed("packet_city_buy_100: sending info about ()");
21355
21356#ifdef FREECIV_DELTA_PROTOCOL
21357 packet_city_buy_100_fields fields;
21358 struct packet_city_buy *old;
21359 bool differ;
21360 struct genhash **hash = pc->phs.sent + PACKET_CITY_BUY;
21361
21362 if (nullptr == *hash) {
21363 *hash = genhash_new_full(hash_packet_city_buy_100, cmp_packet_city_buy_100,
21364 nullptr, nullptr, nullptr, destroy_packet_city_buy);
21365 }
21366 BV_CLR_ALL(fields);
21367
21368 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21369 old = fc_malloc(sizeof(*old));
21370 /* temporary bitcopy just to insert correctly */
21371 *old = *real_packet;
21372 genhash_insert(*hash, old, old);
21373 init_packet_city_buy(old);
21374 }
21375
21376 differ = (old->city_id != real_packet->city_id);
21377 if (differ) {
21378 BV_SET(fields, 0);
21379 }
21380#endif /* FREECIV_DELTA_PROTOCOL */
21381
21382#ifdef FREECIV_JSON_CONNECTION
21383 struct plocation field_addr;
21384 {
21385 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21386 field_addr = *field_addr_tmp;
21387 FC_FREE(field_addr_tmp);
21388 }
21389#endif /* FREECIV_JSON_CONNECTION */
21390
21391#ifdef FREECIV_DELTA_PROTOCOL
21392#ifdef FREECIV_JSON_CONNECTION
21393 field_addr.name = "fields";
21394#endif /* FREECIV_JSON_CONNECTION */
21395 e = 0;
21396 e |= DIO_BV_PUT(&dout, &field_addr, fields);
21397 if (e) {
21398 log_packet_detailed("fields bitvector error detected");
21399 }
21400
21401 if (BV_ISSET(fields, 0)) {
21402 log_packet_detailed(" field 'city_id' has changed");
21403
21404#ifdef FREECIV_JSON_CONNECTION
21405 field_addr.name = "city_id";
21406#endif /* FREECIV_JSON_CONNECTION */
21407 e = 0;
21408
21409 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21410
21411 if (e) {
21412 log_packet_detailed("'city_id' field error detected");
21413 }
21414 }
21415
21416 *old = *real_packet;
21417
21418#else /* FREECIV_DELTA_PROTOCOL */
21419#ifdef FREECIV_JSON_CONNECTION
21420 field_addr.name = "city_id";
21421#endif /* FREECIV_JSON_CONNECTION */
21422 e = 0;
21423
21424 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21425
21426 if (e) {
21427 log_packet_detailed("'city_id' field error detected");
21428 }
21429#endif /* FREECIV_DELTA_PROTOCOL */
21430
21431 SEND_PACKET_END(PACKET_CITY_BUY);
21432}
21433
21434 int send_packet_city_buy(struct connection *pc, const struct packet_city_buy *packet)
21435{
21436 if (!pc->used) {
21437 log_error("WARNING: trying to send data to the closed connection %s",
21438 conn_description(pc));
21439 return -1;
21440 }
21441 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_BUY].packet != nullptr, -1,
21442 "Handler for PACKET_CITY_BUY not installed");
21443 return pc->phs.handlers->send[PACKET_CITY_BUY].packet(pc, packet);
21444}
21445
21446 int dsend_packet_city_buy(struct connection *pc, int city_id)
21447{
21448 struct packet_city_buy packet, *real_packet = &packet;
21449
21450 real_packet->city_id = city_id;
21451
21452 return send_packet_city_buy(pc, real_packet);
21453}
21454
21455 static inline void init_packet_city_change(struct packet_city_change *packet)
21456{
21457 memset(packet, 0, sizeof(*packet));
21458}
21459
21460#define free_packet_city_change(_packet) (void) 0
21461#define destroy_packet_city_change free
21462
21463#ifdef FREECIV_DELTA_PROTOCOL
21464#define hash_packet_city_change_100 hash_const
21465#define cmp_packet_city_change_100 cmp_const
21466 BV_DEFINE(packet_city_change_100_fields, 3);
21467#endif /* FREECIV_DELTA_PROTOCOL */
21468
21469 static struct packet_city_change *receive_packet_city_change_100(struct connection *pc)
21470{
21471#define FREE_PACKET_STRUCT(_packet) free_packet_city_change(_packet)
21472 RECEIVE_PACKET_START(packet_city_change, real_packet);
21473
21474#ifdef FREECIV_JSON_CONNECTION
21475 struct plocation field_addr;
21476 {
21477 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21478 field_addr = *field_addr_tmp;
21479 FC_FREE(field_addr_tmp);
21480 }
21481#endif /* FREECIV_JSON_CONNECTION */
21482
21483 log_packet_detailed("packet_city_change_100: got info about ()");
21484
21485#ifdef FREECIV_DELTA_PROTOCOL
21486 packet_city_change_100_fields fields;
21487 struct packet_city_change *old;
21488 struct genhash **hash = pc->phs.received + PACKET_CITY_CHANGE;
21489
21490 if (nullptr == *hash) {
21491 *hash = genhash_new_full(hash_packet_city_change_100, cmp_packet_city_change_100,
21492 nullptr, nullptr, nullptr, destroy_packet_city_change);
21493 }
21494
21495 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21496 *real_packet = *old;
21497 } else {
21498 /* packet is already initialized empty */
21499 log_packet_detailed(" no old info");
21500 }
21501
21502#ifdef FREECIV_JSON_CONNECTION
21503 field_addr.name = "fields";
21504#endif /* FREECIV_JSON_CONNECTION */
21505 DIO_BV_GET(&din, &field_addr, fields);
21506
21507 if (BV_ISSET(fields, 0)) {
21508 log_packet_detailed(" got field 'city_id'");
21509
21510#ifdef FREECIV_JSON_CONNECTION
21511 field_addr.name = "city_id";
21512#endif /* FREECIV_JSON_CONNECTION */
21513
21514 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21515 RECEIVE_PACKET_FIELD_ERROR(city_id);
21516 }
21517 }
21518
21519 if (BV_ISSET(fields, 1)) {
21520 log_packet_detailed(" got field 'production_kind'");
21521
21522#ifdef FREECIV_JSON_CONNECTION
21523 field_addr.name = "production_kind";
21524#endif /* FREECIV_JSON_CONNECTION */
21525
21526 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_kind)) {
21527 RECEIVE_PACKET_FIELD_ERROR(production_kind);
21528 }
21529 }
21530
21531 if (BV_ISSET(fields, 2)) {
21532 log_packet_detailed(" got field 'production_value'");
21533
21534#ifdef FREECIV_JSON_CONNECTION
21535 field_addr.name = "production_value";
21536#endif /* FREECIV_JSON_CONNECTION */
21537
21538 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_value)) {
21539 RECEIVE_PACKET_FIELD_ERROR(production_value);
21540 }
21541 }
21542
21543 if (nullptr == old) {
21544 old = fc_malloc(sizeof(*old));
21545 init_packet_city_change(old);
21546 *old = *real_packet;
21547 genhash_insert(*hash, old, old);
21548 } else {
21549 *old = *real_packet;
21550 }
21551
21552#else /* FREECIV_DELTA_PROTOCOL */
21553#ifdef FREECIV_JSON_CONNECTION
21554 field_addr.name = "city_id";
21555#endif /* FREECIV_JSON_CONNECTION */
21556
21557 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21558 RECEIVE_PACKET_FIELD_ERROR(city_id);
21559 }
21560
21561#ifdef FREECIV_JSON_CONNECTION
21562 field_addr.name = "production_kind";
21563#endif /* FREECIV_JSON_CONNECTION */
21564
21565 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_kind)) {
21566 RECEIVE_PACKET_FIELD_ERROR(production_kind);
21567 }
21568
21569#ifdef FREECIV_JSON_CONNECTION
21570 field_addr.name = "production_value";
21571#endif /* FREECIV_JSON_CONNECTION */
21572
21573 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_value)) {
21574 RECEIVE_PACKET_FIELD_ERROR(production_value);
21575 }
21576#endif /* FREECIV_DELTA_PROTOCOL */
21577
21578 RECEIVE_PACKET_END(real_packet);
21579#undef FREE_PACKET_STRUCT
21580}
21581
21582 static int send_packet_city_change_100(struct connection *pc, const struct packet_city_change *packet)
21583{
21584 const struct packet_city_change *real_packet = packet;
21585 int e;
21586 SEND_PACKET_START(PACKET_CITY_CHANGE);
21587
21588 log_packet_detailed("packet_city_change_100: sending info about ()");
21589
21590#ifdef FREECIV_DELTA_PROTOCOL
21591 packet_city_change_100_fields fields;
21592 struct packet_city_change *old;
21593 bool differ;
21594 struct genhash **hash = pc->phs.sent + PACKET_CITY_CHANGE;
21595
21596 if (nullptr == *hash) {
21597 *hash = genhash_new_full(hash_packet_city_change_100, cmp_packet_city_change_100,
21598 nullptr, nullptr, nullptr, destroy_packet_city_change);
21599 }
21600 BV_CLR_ALL(fields);
21601
21602 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21603 old = fc_malloc(sizeof(*old));
21604 /* temporary bitcopy just to insert correctly */
21605 *old = *real_packet;
21606 genhash_insert(*hash, old, old);
21607 init_packet_city_change(old);
21608 }
21609
21610 differ = (old->city_id != real_packet->city_id);
21611 if (differ) {
21612 BV_SET(fields, 0);
21613 }
21614
21615 differ = (old->production_kind != real_packet->production_kind);
21616 if (differ) {
21617 BV_SET(fields, 1);
21618 }
21619
21620 differ = (old->production_value != real_packet->production_value);
21621 if (differ) {
21622 BV_SET(fields, 2);
21623 }
21624#endif /* FREECIV_DELTA_PROTOCOL */
21625
21626#ifdef FREECIV_JSON_CONNECTION
21627 struct plocation field_addr;
21628 {
21629 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21630 field_addr = *field_addr_tmp;
21631 FC_FREE(field_addr_tmp);
21632 }
21633#endif /* FREECIV_JSON_CONNECTION */
21634
21635#ifdef FREECIV_DELTA_PROTOCOL
21636#ifdef FREECIV_JSON_CONNECTION
21637 field_addr.name = "fields";
21638#endif /* FREECIV_JSON_CONNECTION */
21639 e = 0;
21640 e |= DIO_BV_PUT(&dout, &field_addr, fields);
21641 if (e) {
21642 log_packet_detailed("fields bitvector error detected");
21643 }
21644
21645 if (BV_ISSET(fields, 0)) {
21646 log_packet_detailed(" field 'city_id' has changed");
21647
21648#ifdef FREECIV_JSON_CONNECTION
21649 field_addr.name = "city_id";
21650#endif /* FREECIV_JSON_CONNECTION */
21651 e = 0;
21652
21653 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21654
21655 if (e) {
21656 log_packet_detailed("'city_id' field error detected");
21657 }
21658 }
21659
21660 if (BV_ISSET(fields, 1)) {
21661 log_packet_detailed(" field 'production_kind' has changed");
21662
21663#ifdef FREECIV_JSON_CONNECTION
21664 field_addr.name = "production_kind";
21665#endif /* FREECIV_JSON_CONNECTION */
21666 e = 0;
21667
21668 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_kind);
21669
21670 if (e) {
21671 log_packet_detailed("'production_kind' field error detected");
21672 }
21673 }
21674
21675 if (BV_ISSET(fields, 2)) {
21676 log_packet_detailed(" field 'production_value' has changed");
21677
21678#ifdef FREECIV_JSON_CONNECTION
21679 field_addr.name = "production_value";
21680#endif /* FREECIV_JSON_CONNECTION */
21681 e = 0;
21682
21683 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_value);
21684
21685 if (e) {
21686 log_packet_detailed("'production_value' field error detected");
21687 }
21688 }
21689
21690 *old = *real_packet;
21691
21692#else /* FREECIV_DELTA_PROTOCOL */
21693#ifdef FREECIV_JSON_CONNECTION
21694 field_addr.name = "city_id";
21695#endif /* FREECIV_JSON_CONNECTION */
21696 e = 0;
21697
21698 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21699
21700 if (e) {
21701 log_packet_detailed("'city_id' field error detected");
21702 }
21703
21704#ifdef FREECIV_JSON_CONNECTION
21705 field_addr.name = "production_kind";
21706#endif /* FREECIV_JSON_CONNECTION */
21707 e = 0;
21708
21709 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_kind);
21710
21711 if (e) {
21712 log_packet_detailed("'production_kind' field error detected");
21713 }
21714
21715#ifdef FREECIV_JSON_CONNECTION
21716 field_addr.name = "production_value";
21717#endif /* FREECIV_JSON_CONNECTION */
21718 e = 0;
21719
21720 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_value);
21721
21722 if (e) {
21723 log_packet_detailed("'production_value' field error detected");
21724 }
21725#endif /* FREECIV_DELTA_PROTOCOL */
21726
21727 SEND_PACKET_END(PACKET_CITY_CHANGE);
21728}
21729
21730 int send_packet_city_change(struct connection *pc, const struct packet_city_change *packet)
21731{
21732 if (!pc->used) {
21733 log_error("WARNING: trying to send data to the closed connection %s",
21734 conn_description(pc));
21735 return -1;
21736 }
21737 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_CHANGE].packet != nullptr, -1,
21738 "Handler for PACKET_CITY_CHANGE not installed");
21739 return pc->phs.handlers->send[PACKET_CITY_CHANGE].packet(pc, packet);
21740}
21741
21742 int dsend_packet_city_change(struct connection *pc, int city_id, int production_kind, int production_value)
21743{
21744 struct packet_city_change packet, *real_packet = &packet;
21745
21746 real_packet->city_id = city_id;
21747 real_packet->production_kind = production_kind;
21748 real_packet->production_value = production_value;
21749
21750 return send_packet_city_change(pc, real_packet);
21751}
21752
21753 static inline void init_packet_city_worklist(struct packet_city_worklist *packet)
21754{
21755 memset(packet, 0, sizeof(*packet));
21756}
21757
21758#define free_packet_city_worklist(_packet) (void) 0
21759#define destroy_packet_city_worklist free
21760
21761#ifdef FREECIV_DELTA_PROTOCOL
21762#define hash_packet_city_worklist_100 hash_const
21763#define cmp_packet_city_worklist_100 cmp_const
21764 BV_DEFINE(packet_city_worklist_100_fields, 2);
21765#endif /* FREECIV_DELTA_PROTOCOL */
21766
21767 static struct packet_city_worklist *receive_packet_city_worklist_100(struct connection *pc)
21768{
21769#define FREE_PACKET_STRUCT(_packet) free_packet_city_worklist(_packet)
21770 RECEIVE_PACKET_START(packet_city_worklist, real_packet);
21771
21772#ifdef FREECIV_JSON_CONNECTION
21773 struct plocation field_addr;
21774 {
21775 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21776 field_addr = *field_addr_tmp;
21777 FC_FREE(field_addr_tmp);
21778 }
21779#endif /* FREECIV_JSON_CONNECTION */
21780
21781 log_packet_detailed("packet_city_worklist_100: got info about ()");
21782
21783#ifdef FREECIV_DELTA_PROTOCOL
21784 packet_city_worklist_100_fields fields;
21785 struct packet_city_worklist *old;
21786 struct genhash **hash = pc->phs.received + PACKET_CITY_WORKLIST;
21787
21788 if (nullptr == *hash) {
21789 *hash = genhash_new_full(hash_packet_city_worklist_100, cmp_packet_city_worklist_100,
21790 nullptr, nullptr, nullptr, destroy_packet_city_worklist);
21791 }
21792
21793 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
21794 *real_packet = *old;
21795 } else {
21796 /* packet is already initialized empty */
21797 log_packet_detailed(" no old info");
21798 }
21799
21800#ifdef FREECIV_JSON_CONNECTION
21801 field_addr.name = "fields";
21802#endif /* FREECIV_JSON_CONNECTION */
21803 DIO_BV_GET(&din, &field_addr, fields);
21804
21805 if (BV_ISSET(fields, 0)) {
21806 log_packet_detailed(" got field 'city_id'");
21807
21808#ifdef FREECIV_JSON_CONNECTION
21809 field_addr.name = "city_id";
21810#endif /* FREECIV_JSON_CONNECTION */
21811
21812 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21813 RECEIVE_PACKET_FIELD_ERROR(city_id);
21814 }
21815 }
21816
21817 if (BV_ISSET(fields, 1)) {
21818 log_packet_detailed(" got field 'worklist'");
21819
21820#ifdef FREECIV_JSON_CONNECTION
21821 field_addr.name = "worklist";
21822#endif /* FREECIV_JSON_CONNECTION */
21823
21824 if (!DIO_GET(worklist, &din, &field_addr, &real_packet->worklist)) {
21825 RECEIVE_PACKET_FIELD_ERROR(worklist);
21826 }
21827 }
21828
21829 if (nullptr == old) {
21830 old = fc_malloc(sizeof(*old));
21831 init_packet_city_worklist(old);
21832 *old = *real_packet;
21833 genhash_insert(*hash, old, old);
21834 } else {
21835 *old = *real_packet;
21836 }
21837
21838#else /* FREECIV_DELTA_PROTOCOL */
21839#ifdef FREECIV_JSON_CONNECTION
21840 field_addr.name = "city_id";
21841#endif /* FREECIV_JSON_CONNECTION */
21842
21843 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
21844 RECEIVE_PACKET_FIELD_ERROR(city_id);
21845 }
21846
21847#ifdef FREECIV_JSON_CONNECTION
21848 field_addr.name = "worklist";
21849#endif /* FREECIV_JSON_CONNECTION */
21850
21851 if (!DIO_GET(worklist, &din, &field_addr, &real_packet->worklist)) {
21852 RECEIVE_PACKET_FIELD_ERROR(worklist);
21853 }
21854#endif /* FREECIV_DELTA_PROTOCOL */
21855
21856 RECEIVE_PACKET_END(real_packet);
21857#undef FREE_PACKET_STRUCT
21858}
21859
21860 static int send_packet_city_worklist_100(struct connection *pc, const struct packet_city_worklist *packet)
21861{
21862 const struct packet_city_worklist *real_packet = packet;
21863 int e;
21864 SEND_PACKET_START(PACKET_CITY_WORKLIST);
21865
21866 log_packet_detailed("packet_city_worklist_100: sending info about ()");
21867
21868#ifdef FREECIV_DELTA_PROTOCOL
21869 packet_city_worklist_100_fields fields;
21870 struct packet_city_worklist *old;
21871 bool differ;
21872 struct genhash **hash = pc->phs.sent + PACKET_CITY_WORKLIST;
21873
21874 if (nullptr == *hash) {
21875 *hash = genhash_new_full(hash_packet_city_worklist_100, cmp_packet_city_worklist_100,
21876 nullptr, nullptr, nullptr, destroy_packet_city_worklist);
21877 }
21878 BV_CLR_ALL(fields);
21879
21880 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
21881 old = fc_malloc(sizeof(*old));
21882 /* temporary bitcopy just to insert correctly */
21883 *old = *real_packet;
21884 genhash_insert(*hash, old, old);
21885 init_packet_city_worklist(old);
21886 }
21887
21888 differ = (old->city_id != real_packet->city_id);
21889 if (differ) {
21890 BV_SET(fields, 0);
21891 }
21892
21893 differ = !are_worklists_equal(&old->worklist, &real_packet->worklist);
21894 if (differ) {
21895 BV_SET(fields, 1);
21896 }
21897#endif /* FREECIV_DELTA_PROTOCOL */
21898
21899#ifdef FREECIV_JSON_CONNECTION
21900 struct plocation field_addr;
21901 {
21902 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
21903 field_addr = *field_addr_tmp;
21904 FC_FREE(field_addr_tmp);
21905 }
21906#endif /* FREECIV_JSON_CONNECTION */
21907
21908#ifdef FREECIV_DELTA_PROTOCOL
21909#ifdef FREECIV_JSON_CONNECTION
21910 field_addr.name = "fields";
21911#endif /* FREECIV_JSON_CONNECTION */
21912 e = 0;
21913 e |= DIO_BV_PUT(&dout, &field_addr, fields);
21914 if (e) {
21915 log_packet_detailed("fields bitvector error detected");
21916 }
21917
21918 if (BV_ISSET(fields, 0)) {
21919 log_packet_detailed(" field 'city_id' has changed");
21920
21921#ifdef FREECIV_JSON_CONNECTION
21922 field_addr.name = "city_id";
21923#endif /* FREECIV_JSON_CONNECTION */
21924 e = 0;
21925
21926 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21927
21928 if (e) {
21929 log_packet_detailed("'city_id' field error detected");
21930 }
21931 }
21932
21933 if (BV_ISSET(fields, 1)) {
21934 log_packet_detailed(" field 'worklist' has changed");
21935
21936#ifdef FREECIV_JSON_CONNECTION
21937 field_addr.name = "worklist";
21938#endif /* FREECIV_JSON_CONNECTION */
21939 e = 0;
21940
21941 e |= DIO_PUT(worklist, &dout, &field_addr, &real_packet->worklist);
21942
21943 if (e) {
21944 log_packet_detailed("'worklist' field error detected");
21945 }
21946 }
21947
21948 *old = *real_packet;
21949
21950#else /* FREECIV_DELTA_PROTOCOL */
21951#ifdef FREECIV_JSON_CONNECTION
21952 field_addr.name = "city_id";
21953#endif /* FREECIV_JSON_CONNECTION */
21954 e = 0;
21955
21956 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
21957
21958 if (e) {
21959 log_packet_detailed("'city_id' field error detected");
21960 }
21961
21962#ifdef FREECIV_JSON_CONNECTION
21963 field_addr.name = "worklist";
21964#endif /* FREECIV_JSON_CONNECTION */
21965 e = 0;
21966
21967 e |= DIO_PUT(worklist, &dout, &field_addr, &real_packet->worklist);
21968
21969 if (e) {
21970 log_packet_detailed("'worklist' field error detected");
21971 }
21972#endif /* FREECIV_DELTA_PROTOCOL */
21973
21974 SEND_PACKET_END(PACKET_CITY_WORKLIST);
21975}
21976
21977 int send_packet_city_worklist(struct connection *pc, const struct packet_city_worklist *packet)
21978{
21979 if (!pc->used) {
21980 log_error("WARNING: trying to send data to the closed connection %s",
21981 conn_description(pc));
21982 return -1;
21983 }
21984 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_WORKLIST].packet != nullptr, -1,
21985 "Handler for PACKET_CITY_WORKLIST not installed");
21986 return pc->phs.handlers->send[PACKET_CITY_WORKLIST].packet(pc, packet);
21987}
21988
21989 int dsend_packet_city_worklist(struct connection *pc, int city_id, const struct worklist *worklist)
21990{
21991 struct packet_city_worklist packet, *real_packet = &packet;
21992
21993 real_packet->city_id = city_id;
21994 worklist_copy(&real_packet->worklist, worklist);
21995
21996 return send_packet_city_worklist(pc, real_packet);
21997}
21998
21999 static inline void init_packet_city_make_specialist(struct packet_city_make_specialist *packet)
22000{
22001 memset(packet, 0, sizeof(*packet));
22002}
22003
22004#define free_packet_city_make_specialist(_packet) (void) 0
22005#define destroy_packet_city_make_specialist free
22006
22007#ifdef FREECIV_DELTA_PROTOCOL
22008#define hash_packet_city_make_specialist_100 hash_const
22009#define cmp_packet_city_make_specialist_100 cmp_const
22010 BV_DEFINE(packet_city_make_specialist_100_fields, 2);
22011#endif /* FREECIV_DELTA_PROTOCOL */
22012
22013 static struct packet_city_make_specialist *receive_packet_city_make_specialist_100(struct connection *pc)
22014{
22015#define FREE_PACKET_STRUCT(_packet) free_packet_city_make_specialist(_packet)
22016 RECEIVE_PACKET_START(packet_city_make_specialist, real_packet);
22017
22018#ifdef FREECIV_JSON_CONNECTION
22019 struct plocation field_addr;
22020 {
22021 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22022 field_addr = *field_addr_tmp;
22023 FC_FREE(field_addr_tmp);
22024 }
22025#endif /* FREECIV_JSON_CONNECTION */
22026
22027 log_packet_detailed("packet_city_make_specialist_100: got info about ()");
22028
22029#ifdef FREECIV_DELTA_PROTOCOL
22030 packet_city_make_specialist_100_fields fields;
22031 struct packet_city_make_specialist *old;
22032 struct genhash **hash = pc->phs.received + PACKET_CITY_MAKE_SPECIALIST;
22033
22034 if (nullptr == *hash) {
22035 *hash = genhash_new_full(hash_packet_city_make_specialist_100, cmp_packet_city_make_specialist_100,
22036 nullptr, nullptr, nullptr, destroy_packet_city_make_specialist);
22037 }
22038
22039 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22040 *real_packet = *old;
22041 } else {
22042 /* packet is already initialized empty */
22043 log_packet_detailed(" no old info");
22044 }
22045
22046#ifdef FREECIV_JSON_CONNECTION
22047 field_addr.name = "fields";
22048#endif /* FREECIV_JSON_CONNECTION */
22049 DIO_BV_GET(&din, &field_addr, fields);
22050
22051 if (BV_ISSET(fields, 0)) {
22052 log_packet_detailed(" got field 'city_id'");
22053
22054#ifdef FREECIV_JSON_CONNECTION
22055 field_addr.name = "city_id";
22056#endif /* FREECIV_JSON_CONNECTION */
22057
22058 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22059 RECEIVE_PACKET_FIELD_ERROR(city_id);
22060 }
22061 }
22062
22063 if (BV_ISSET(fields, 1)) {
22064 log_packet_detailed(" got field 'tile_id'");
22065
22066#ifdef FREECIV_JSON_CONNECTION
22067 field_addr.name = "tile_id";
22068#endif /* FREECIV_JSON_CONNECTION */
22069
22070 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile_id)) {
22071 RECEIVE_PACKET_FIELD_ERROR(tile_id);
22072 }
22073 }
22074
22075 if (nullptr == old) {
22076 old = fc_malloc(sizeof(*old));
22077 init_packet_city_make_specialist(old);
22078 *old = *real_packet;
22079 genhash_insert(*hash, old, old);
22080 } else {
22081 *old = *real_packet;
22082 }
22083
22084#else /* FREECIV_DELTA_PROTOCOL */
22085#ifdef FREECIV_JSON_CONNECTION
22086 field_addr.name = "city_id";
22087#endif /* FREECIV_JSON_CONNECTION */
22088
22089 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22090 RECEIVE_PACKET_FIELD_ERROR(city_id);
22091 }
22092
22093#ifdef FREECIV_JSON_CONNECTION
22094 field_addr.name = "tile_id";
22095#endif /* FREECIV_JSON_CONNECTION */
22096
22097 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile_id)) {
22098 RECEIVE_PACKET_FIELD_ERROR(tile_id);
22099 }
22100#endif /* FREECIV_DELTA_PROTOCOL */
22101
22102 RECEIVE_PACKET_END(real_packet);
22103#undef FREE_PACKET_STRUCT
22104}
22105
22106 static int send_packet_city_make_specialist_100(struct connection *pc, const struct packet_city_make_specialist *packet)
22107{
22108 const struct packet_city_make_specialist *real_packet = packet;
22109 int e;
22110 SEND_PACKET_START(PACKET_CITY_MAKE_SPECIALIST);
22111
22112 log_packet_detailed("packet_city_make_specialist_100: sending info about ()");
22113
22114#ifdef FREECIV_DELTA_PROTOCOL
22115 packet_city_make_specialist_100_fields fields;
22116 struct packet_city_make_specialist *old;
22117 bool differ;
22118 struct genhash **hash = pc->phs.sent + PACKET_CITY_MAKE_SPECIALIST;
22119
22120 if (nullptr == *hash) {
22121 *hash = genhash_new_full(hash_packet_city_make_specialist_100, cmp_packet_city_make_specialist_100,
22122 nullptr, nullptr, nullptr, destroy_packet_city_make_specialist);
22123 }
22124 BV_CLR_ALL(fields);
22125
22126 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22127 old = fc_malloc(sizeof(*old));
22128 /* temporary bitcopy just to insert correctly */
22129 *old = *real_packet;
22130 genhash_insert(*hash, old, old);
22131 init_packet_city_make_specialist(old);
22132 }
22133
22134 differ = (old->city_id != real_packet->city_id);
22135 if (differ) {
22136 BV_SET(fields, 0);
22137 }
22138
22139 differ = (old->tile_id != real_packet->tile_id);
22140 if (differ) {
22141 BV_SET(fields, 1);
22142 }
22143#endif /* FREECIV_DELTA_PROTOCOL */
22144
22145#ifdef FREECIV_JSON_CONNECTION
22146 struct plocation field_addr;
22147 {
22148 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22149 field_addr = *field_addr_tmp;
22150 FC_FREE(field_addr_tmp);
22151 }
22152#endif /* FREECIV_JSON_CONNECTION */
22153
22154#ifdef FREECIV_DELTA_PROTOCOL
22155#ifdef FREECIV_JSON_CONNECTION
22156 field_addr.name = "fields";
22157#endif /* FREECIV_JSON_CONNECTION */
22158 e = 0;
22159 e |= DIO_BV_PUT(&dout, &field_addr, fields);
22160 if (e) {
22161 log_packet_detailed("fields bitvector error detected");
22162 }
22163
22164 if (BV_ISSET(fields, 0)) {
22165 log_packet_detailed(" field 'city_id' has changed");
22166
22167#ifdef FREECIV_JSON_CONNECTION
22168 field_addr.name = "city_id";
22169#endif /* FREECIV_JSON_CONNECTION */
22170 e = 0;
22171
22172 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22173
22174 if (e) {
22175 log_packet_detailed("'city_id' field error detected");
22176 }
22177 }
22178
22179 if (BV_ISSET(fields, 1)) {
22180 log_packet_detailed(" field 'tile_id' has changed");
22181
22182#ifdef FREECIV_JSON_CONNECTION
22183 field_addr.name = "tile_id";
22184#endif /* FREECIV_JSON_CONNECTION */
22185 e = 0;
22186
22187 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile_id);
22188
22189 if (e) {
22190 log_packet_detailed("'tile_id' field error detected");
22191 }
22192 }
22193
22194 *old = *real_packet;
22195
22196#else /* FREECIV_DELTA_PROTOCOL */
22197#ifdef FREECIV_JSON_CONNECTION
22198 field_addr.name = "city_id";
22199#endif /* FREECIV_JSON_CONNECTION */
22200 e = 0;
22201
22202 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22203
22204 if (e) {
22205 log_packet_detailed("'city_id' field error detected");
22206 }
22207
22208#ifdef FREECIV_JSON_CONNECTION
22209 field_addr.name = "tile_id";
22210#endif /* FREECIV_JSON_CONNECTION */
22211 e = 0;
22212
22213 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile_id);
22214
22215 if (e) {
22216 log_packet_detailed("'tile_id' field error detected");
22217 }
22218#endif /* FREECIV_DELTA_PROTOCOL */
22219
22220 SEND_PACKET_END(PACKET_CITY_MAKE_SPECIALIST);
22221}
22222
22223 int send_packet_city_make_specialist(struct connection *pc, const struct packet_city_make_specialist *packet)
22224{
22225 if (!pc->used) {
22226 log_error("WARNING: trying to send data to the closed connection %s",
22227 conn_description(pc));
22228 return -1;
22229 }
22230 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_MAKE_SPECIALIST].packet != nullptr, -1,
22231 "Handler for PACKET_CITY_MAKE_SPECIALIST not installed");
22232 return pc->phs.handlers->send[PACKET_CITY_MAKE_SPECIALIST].packet(pc, packet);
22233}
22234
22235 int dsend_packet_city_make_specialist(struct connection *pc, int city_id, int tile_id)
22236{
22237 struct packet_city_make_specialist packet, *real_packet = &packet;
22238
22239 real_packet->city_id = city_id;
22240 real_packet->tile_id = tile_id;
22241
22242 return send_packet_city_make_specialist(pc, real_packet);
22243}
22244
22245 static inline void init_packet_city_make_worker(struct packet_city_make_worker *packet)
22246{
22247 memset(packet, 0, sizeof(*packet));
22248}
22249
22250#define free_packet_city_make_worker(_packet) (void) 0
22251#define destroy_packet_city_make_worker free
22252
22253#ifdef FREECIV_DELTA_PROTOCOL
22254#define hash_packet_city_make_worker_100 hash_const
22255#define cmp_packet_city_make_worker_100 cmp_const
22256 BV_DEFINE(packet_city_make_worker_100_fields, 2);
22257#endif /* FREECIV_DELTA_PROTOCOL */
22258
22259 static struct packet_city_make_worker *receive_packet_city_make_worker_100(struct connection *pc)
22260{
22261#define FREE_PACKET_STRUCT(_packet) free_packet_city_make_worker(_packet)
22262 RECEIVE_PACKET_START(packet_city_make_worker, real_packet);
22263
22264#ifdef FREECIV_JSON_CONNECTION
22265 struct plocation field_addr;
22266 {
22267 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22268 field_addr = *field_addr_tmp;
22269 FC_FREE(field_addr_tmp);
22270 }
22271#endif /* FREECIV_JSON_CONNECTION */
22272
22273 log_packet_detailed("packet_city_make_worker_100: got info about ()");
22274
22275#ifdef FREECIV_DELTA_PROTOCOL
22276 packet_city_make_worker_100_fields fields;
22277 struct packet_city_make_worker *old;
22278 struct genhash **hash = pc->phs.received + PACKET_CITY_MAKE_WORKER;
22279
22280 if (nullptr == *hash) {
22281 *hash = genhash_new_full(hash_packet_city_make_worker_100, cmp_packet_city_make_worker_100,
22282 nullptr, nullptr, nullptr, destroy_packet_city_make_worker);
22283 }
22284
22285 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22286 *real_packet = *old;
22287 } else {
22288 /* packet is already initialized empty */
22289 log_packet_detailed(" no old info");
22290 }
22291
22292#ifdef FREECIV_JSON_CONNECTION
22293 field_addr.name = "fields";
22294#endif /* FREECIV_JSON_CONNECTION */
22295 DIO_BV_GET(&din, &field_addr, fields);
22296
22297 if (BV_ISSET(fields, 0)) {
22298 log_packet_detailed(" got field 'city_id'");
22299
22300#ifdef FREECIV_JSON_CONNECTION
22301 field_addr.name = "city_id";
22302#endif /* FREECIV_JSON_CONNECTION */
22303
22304 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22305 RECEIVE_PACKET_FIELD_ERROR(city_id);
22306 }
22307 }
22308
22309 if (BV_ISSET(fields, 1)) {
22310 log_packet_detailed(" got field 'tile_id'");
22311
22312#ifdef FREECIV_JSON_CONNECTION
22313 field_addr.name = "tile_id";
22314#endif /* FREECIV_JSON_CONNECTION */
22315
22316 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile_id)) {
22317 RECEIVE_PACKET_FIELD_ERROR(tile_id);
22318 }
22319 }
22320
22321 if (nullptr == old) {
22322 old = fc_malloc(sizeof(*old));
22323 init_packet_city_make_worker(old);
22324 *old = *real_packet;
22325 genhash_insert(*hash, old, old);
22326 } else {
22327 *old = *real_packet;
22328 }
22329
22330#else /* FREECIV_DELTA_PROTOCOL */
22331#ifdef FREECIV_JSON_CONNECTION
22332 field_addr.name = "city_id";
22333#endif /* FREECIV_JSON_CONNECTION */
22334
22335 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22336 RECEIVE_PACKET_FIELD_ERROR(city_id);
22337 }
22338
22339#ifdef FREECIV_JSON_CONNECTION
22340 field_addr.name = "tile_id";
22341#endif /* FREECIV_JSON_CONNECTION */
22342
22343 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile_id)) {
22344 RECEIVE_PACKET_FIELD_ERROR(tile_id);
22345 }
22346#endif /* FREECIV_DELTA_PROTOCOL */
22347
22348 RECEIVE_PACKET_END(real_packet);
22349#undef FREE_PACKET_STRUCT
22350}
22351
22352 static int send_packet_city_make_worker_100(struct connection *pc, const struct packet_city_make_worker *packet)
22353{
22354 const struct packet_city_make_worker *real_packet = packet;
22355 int e;
22356 SEND_PACKET_START(PACKET_CITY_MAKE_WORKER);
22357
22358 log_packet_detailed("packet_city_make_worker_100: sending info about ()");
22359
22360#ifdef FREECIV_DELTA_PROTOCOL
22361 packet_city_make_worker_100_fields fields;
22362 struct packet_city_make_worker *old;
22363 bool differ;
22364 struct genhash **hash = pc->phs.sent + PACKET_CITY_MAKE_WORKER;
22365
22366 if (nullptr == *hash) {
22367 *hash = genhash_new_full(hash_packet_city_make_worker_100, cmp_packet_city_make_worker_100,
22368 nullptr, nullptr, nullptr, destroy_packet_city_make_worker);
22369 }
22370 BV_CLR_ALL(fields);
22371
22372 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22373 old = fc_malloc(sizeof(*old));
22374 /* temporary bitcopy just to insert correctly */
22375 *old = *real_packet;
22376 genhash_insert(*hash, old, old);
22377 init_packet_city_make_worker(old);
22378 }
22379
22380 differ = (old->city_id != real_packet->city_id);
22381 if (differ) {
22382 BV_SET(fields, 0);
22383 }
22384
22385 differ = (old->tile_id != real_packet->tile_id);
22386 if (differ) {
22387 BV_SET(fields, 1);
22388 }
22389#endif /* FREECIV_DELTA_PROTOCOL */
22390
22391#ifdef FREECIV_JSON_CONNECTION
22392 struct plocation field_addr;
22393 {
22394 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22395 field_addr = *field_addr_tmp;
22396 FC_FREE(field_addr_tmp);
22397 }
22398#endif /* FREECIV_JSON_CONNECTION */
22399
22400#ifdef FREECIV_DELTA_PROTOCOL
22401#ifdef FREECIV_JSON_CONNECTION
22402 field_addr.name = "fields";
22403#endif /* FREECIV_JSON_CONNECTION */
22404 e = 0;
22405 e |= DIO_BV_PUT(&dout, &field_addr, fields);
22406 if (e) {
22407 log_packet_detailed("fields bitvector error detected");
22408 }
22409
22410 if (BV_ISSET(fields, 0)) {
22411 log_packet_detailed(" field 'city_id' has changed");
22412
22413#ifdef FREECIV_JSON_CONNECTION
22414 field_addr.name = "city_id";
22415#endif /* FREECIV_JSON_CONNECTION */
22416 e = 0;
22417
22418 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22419
22420 if (e) {
22421 log_packet_detailed("'city_id' field error detected");
22422 }
22423 }
22424
22425 if (BV_ISSET(fields, 1)) {
22426 log_packet_detailed(" field 'tile_id' has changed");
22427
22428#ifdef FREECIV_JSON_CONNECTION
22429 field_addr.name = "tile_id";
22430#endif /* FREECIV_JSON_CONNECTION */
22431 e = 0;
22432
22433 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile_id);
22434
22435 if (e) {
22436 log_packet_detailed("'tile_id' field error detected");
22437 }
22438 }
22439
22440 *old = *real_packet;
22441
22442#else /* FREECIV_DELTA_PROTOCOL */
22443#ifdef FREECIV_JSON_CONNECTION
22444 field_addr.name = "city_id";
22445#endif /* FREECIV_JSON_CONNECTION */
22446 e = 0;
22447
22448 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22449
22450 if (e) {
22451 log_packet_detailed("'city_id' field error detected");
22452 }
22453
22454#ifdef FREECIV_JSON_CONNECTION
22455 field_addr.name = "tile_id";
22456#endif /* FREECIV_JSON_CONNECTION */
22457 e = 0;
22458
22459 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile_id);
22460
22461 if (e) {
22462 log_packet_detailed("'tile_id' field error detected");
22463 }
22464#endif /* FREECIV_DELTA_PROTOCOL */
22465
22466 SEND_PACKET_END(PACKET_CITY_MAKE_WORKER);
22467}
22468
22469 int send_packet_city_make_worker(struct connection *pc, const struct packet_city_make_worker *packet)
22470{
22471 if (!pc->used) {
22472 log_error("WARNING: trying to send data to the closed connection %s",
22473 conn_description(pc));
22474 return -1;
22475 }
22476 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_MAKE_WORKER].packet != nullptr, -1,
22477 "Handler for PACKET_CITY_MAKE_WORKER not installed");
22478 return pc->phs.handlers->send[PACKET_CITY_MAKE_WORKER].packet(pc, packet);
22479}
22480
22481 int dsend_packet_city_make_worker(struct connection *pc, int city_id, int tile_id)
22482{
22483 struct packet_city_make_worker packet, *real_packet = &packet;
22484
22485 real_packet->city_id = city_id;
22486 real_packet->tile_id = tile_id;
22487
22488 return send_packet_city_make_worker(pc, real_packet);
22489}
22490
22491 static inline void init_packet_city_change_specialist(struct packet_city_change_specialist *packet)
22492{
22493 memset(packet, 0, sizeof(*packet));
22494}
22495
22496#define free_packet_city_change_specialist(_packet) (void) 0
22497#define destroy_packet_city_change_specialist free
22498
22499#ifdef FREECIV_DELTA_PROTOCOL
22500#define hash_packet_city_change_specialist_100 hash_const
22501#define cmp_packet_city_change_specialist_100 cmp_const
22502 BV_DEFINE(packet_city_change_specialist_100_fields, 3);
22503#endif /* FREECIV_DELTA_PROTOCOL */
22504
22505 static struct packet_city_change_specialist *receive_packet_city_change_specialist_100(struct connection *pc)
22506{
22507#define FREE_PACKET_STRUCT(_packet) free_packet_city_change_specialist(_packet)
22508 RECEIVE_PACKET_START(packet_city_change_specialist, real_packet);
22509
22510#ifdef FREECIV_JSON_CONNECTION
22511 struct plocation field_addr;
22512 {
22513 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22514 field_addr = *field_addr_tmp;
22515 FC_FREE(field_addr_tmp);
22516 }
22517#endif /* FREECIV_JSON_CONNECTION */
22518
22519 log_packet_detailed("packet_city_change_specialist_100: got info about ()");
22520
22521#ifdef FREECIV_DELTA_PROTOCOL
22522 packet_city_change_specialist_100_fields fields;
22523 struct packet_city_change_specialist *old;
22524 struct genhash **hash = pc->phs.received + PACKET_CITY_CHANGE_SPECIALIST;
22525
22526 if (nullptr == *hash) {
22527 *hash = genhash_new_full(hash_packet_city_change_specialist_100, cmp_packet_city_change_specialist_100,
22528 nullptr, nullptr, nullptr, destroy_packet_city_change_specialist);
22529 }
22530
22531 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22532 *real_packet = *old;
22533 } else {
22534 /* packet is already initialized empty */
22535 log_packet_detailed(" no old info");
22536 }
22537
22538#ifdef FREECIV_JSON_CONNECTION
22539 field_addr.name = "fields";
22540#endif /* FREECIV_JSON_CONNECTION */
22541 DIO_BV_GET(&din, &field_addr, fields);
22542
22543 if (BV_ISSET(fields, 0)) {
22544 log_packet_detailed(" got field 'city_id'");
22545
22546#ifdef FREECIV_JSON_CONNECTION
22547 field_addr.name = "city_id";
22548#endif /* FREECIV_JSON_CONNECTION */
22549
22550 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22551 RECEIVE_PACKET_FIELD_ERROR(city_id);
22552 }
22553 }
22554
22555 if (BV_ISSET(fields, 1)) {
22556 log_packet_detailed(" got field 'from'");
22557
22558#ifdef FREECIV_JSON_CONNECTION
22559 field_addr.name = "from";
22560#endif /* FREECIV_JSON_CONNECTION */
22561
22562 {
22563 int readin;
22564
22565 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
22566 RECEIVE_PACKET_FIELD_ERROR(from);
22567 }
22568 real_packet->from = readin;
22569 }
22570 }
22571
22572 if (BV_ISSET(fields, 2)) {
22573 log_packet_detailed(" got field 'to'");
22574
22575#ifdef FREECIV_JSON_CONNECTION
22576 field_addr.name = "to";
22577#endif /* FREECIV_JSON_CONNECTION */
22578
22579 {
22580 int readin;
22581
22582 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
22583 RECEIVE_PACKET_FIELD_ERROR(to);
22584 }
22585 real_packet->to = readin;
22586 }
22587 }
22588
22589 if (nullptr == old) {
22590 old = fc_malloc(sizeof(*old));
22591 init_packet_city_change_specialist(old);
22592 *old = *real_packet;
22593 genhash_insert(*hash, old, old);
22594 } else {
22595 *old = *real_packet;
22596 }
22597
22598#else /* FREECIV_DELTA_PROTOCOL */
22599#ifdef FREECIV_JSON_CONNECTION
22600 field_addr.name = "city_id";
22601#endif /* FREECIV_JSON_CONNECTION */
22602
22603 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22604 RECEIVE_PACKET_FIELD_ERROR(city_id);
22605 }
22606
22607#ifdef FREECIV_JSON_CONNECTION
22608 field_addr.name = "from";
22609#endif /* FREECIV_JSON_CONNECTION */
22610
22611 {
22612 int readin;
22613
22614 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
22615 RECEIVE_PACKET_FIELD_ERROR(from);
22616 }
22617 real_packet->from = readin;
22618 }
22619
22620#ifdef FREECIV_JSON_CONNECTION
22621 field_addr.name = "to";
22622#endif /* FREECIV_JSON_CONNECTION */
22623
22624 {
22625 int readin;
22626
22627 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
22628 RECEIVE_PACKET_FIELD_ERROR(to);
22629 }
22630 real_packet->to = readin;
22631 }
22632#endif /* FREECIV_DELTA_PROTOCOL */
22633
22634 RECEIVE_PACKET_END(real_packet);
22635#undef FREE_PACKET_STRUCT
22636}
22637
22638 static int send_packet_city_change_specialist_100(struct connection *pc, const struct packet_city_change_specialist *packet)
22639{
22640 const struct packet_city_change_specialist *real_packet = packet;
22641 int e;
22642 SEND_PACKET_START(PACKET_CITY_CHANGE_SPECIALIST);
22643
22644 log_packet_detailed("packet_city_change_specialist_100: sending info about ()");
22645
22646#ifdef FREECIV_DELTA_PROTOCOL
22647 packet_city_change_specialist_100_fields fields;
22648 struct packet_city_change_specialist *old;
22649 bool differ;
22650 struct genhash **hash = pc->phs.sent + PACKET_CITY_CHANGE_SPECIALIST;
22651
22652 if (nullptr == *hash) {
22653 *hash = genhash_new_full(hash_packet_city_change_specialist_100, cmp_packet_city_change_specialist_100,
22654 nullptr, nullptr, nullptr, destroy_packet_city_change_specialist);
22655 }
22656 BV_CLR_ALL(fields);
22657
22658 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22659 old = fc_malloc(sizeof(*old));
22660 /* temporary bitcopy just to insert correctly */
22661 *old = *real_packet;
22662 genhash_insert(*hash, old, old);
22663 init_packet_city_change_specialist(old);
22664 }
22665
22666 differ = (old->city_id != real_packet->city_id);
22667 if (differ) {
22668 BV_SET(fields, 0);
22669 }
22670
22671 differ = (old->from != real_packet->from);
22672 if (differ) {
22673 BV_SET(fields, 1);
22674 }
22675
22676 differ = (old->to != real_packet->to);
22677 if (differ) {
22678 BV_SET(fields, 2);
22679 }
22680#endif /* FREECIV_DELTA_PROTOCOL */
22681
22682#ifdef FREECIV_JSON_CONNECTION
22683 struct plocation field_addr;
22684 {
22685 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22686 field_addr = *field_addr_tmp;
22687 FC_FREE(field_addr_tmp);
22688 }
22689#endif /* FREECIV_JSON_CONNECTION */
22690
22691#ifdef FREECIV_DELTA_PROTOCOL
22692#ifdef FREECIV_JSON_CONNECTION
22693 field_addr.name = "fields";
22694#endif /* FREECIV_JSON_CONNECTION */
22695 e = 0;
22696 e |= DIO_BV_PUT(&dout, &field_addr, fields);
22697 if (e) {
22698 log_packet_detailed("fields bitvector error detected");
22699 }
22700
22701 if (BV_ISSET(fields, 0)) {
22702 log_packet_detailed(" field 'city_id' has changed");
22703
22704#ifdef FREECIV_JSON_CONNECTION
22705 field_addr.name = "city_id";
22706#endif /* FREECIV_JSON_CONNECTION */
22707 e = 0;
22708
22709 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22710
22711 if (e) {
22712 log_packet_detailed("'city_id' field error detected");
22713 }
22714 }
22715
22716 if (BV_ISSET(fields, 1)) {
22717 log_packet_detailed(" field 'from' has changed");
22718
22719#ifdef FREECIV_JSON_CONNECTION
22720 field_addr.name = "from";
22721#endif /* FREECIV_JSON_CONNECTION */
22722 e = 0;
22723
22724 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->from);
22725
22726 if (e) {
22727 log_packet_detailed("'from' field error detected");
22728 }
22729 }
22730
22731 if (BV_ISSET(fields, 2)) {
22732 log_packet_detailed(" field 'to' has changed");
22733
22734#ifdef FREECIV_JSON_CONNECTION
22735 field_addr.name = "to";
22736#endif /* FREECIV_JSON_CONNECTION */
22737 e = 0;
22738
22739 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->to);
22740
22741 if (e) {
22742 log_packet_detailed("'to' field error detected");
22743 }
22744 }
22745
22746 *old = *real_packet;
22747
22748#else /* FREECIV_DELTA_PROTOCOL */
22749#ifdef FREECIV_JSON_CONNECTION
22750 field_addr.name = "city_id";
22751#endif /* FREECIV_JSON_CONNECTION */
22752 e = 0;
22753
22754 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22755
22756 if (e) {
22757 log_packet_detailed("'city_id' field error detected");
22758 }
22759
22760#ifdef FREECIV_JSON_CONNECTION
22761 field_addr.name = "from";
22762#endif /* FREECIV_JSON_CONNECTION */
22763 e = 0;
22764
22765 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->from);
22766
22767 if (e) {
22768 log_packet_detailed("'from' field error detected");
22769 }
22770
22771#ifdef FREECIV_JSON_CONNECTION
22772 field_addr.name = "to";
22773#endif /* FREECIV_JSON_CONNECTION */
22774 e = 0;
22775
22776 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->to);
22777
22778 if (e) {
22779 log_packet_detailed("'to' field error detected");
22780 }
22781#endif /* FREECIV_DELTA_PROTOCOL */
22782
22783 SEND_PACKET_END(PACKET_CITY_CHANGE_SPECIALIST);
22784}
22785
22786 int send_packet_city_change_specialist(struct connection *pc, const struct packet_city_change_specialist *packet)
22787{
22788 if (!pc->used) {
22789 log_error("WARNING: trying to send data to the closed connection %s",
22790 conn_description(pc));
22791 return -1;
22792 }
22793 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_CHANGE_SPECIALIST].packet != nullptr, -1,
22794 "Handler for PACKET_CITY_CHANGE_SPECIALIST not installed");
22795 return pc->phs.handlers->send[PACKET_CITY_CHANGE_SPECIALIST].packet(pc, packet);
22796}
22797
22798 int dsend_packet_city_change_specialist(struct connection *pc, int city_id, Specialist_type_id from, Specialist_type_id to)
22799{
22800 struct packet_city_change_specialist packet, *real_packet = &packet;
22801
22802 real_packet->city_id = city_id;
22803 real_packet->from = from;
22804 real_packet->to = to;
22805
22806 return send_packet_city_change_specialist(pc, real_packet);
22807}
22808
22809 static inline void init_packet_city_rename(struct packet_city_rename *packet)
22810{
22811 memset(packet, 0, sizeof(*packet));
22812}
22813
22814#define free_packet_city_rename(_packet) (void) 0
22815#define destroy_packet_city_rename free
22816
22817#ifdef FREECIV_DELTA_PROTOCOL
22818#define hash_packet_city_rename_100 hash_const
22819#define cmp_packet_city_rename_100 cmp_const
22820 BV_DEFINE(packet_city_rename_100_fields, 2);
22821#endif /* FREECIV_DELTA_PROTOCOL */
22822
22823 static struct packet_city_rename *receive_packet_city_rename_100(struct connection *pc)
22824{
22825#define FREE_PACKET_STRUCT(_packet) free_packet_city_rename(_packet)
22826 RECEIVE_PACKET_START(packet_city_rename, real_packet);
22827
22828#ifdef FREECIV_JSON_CONNECTION
22829 struct plocation field_addr;
22830 {
22831 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22832 field_addr = *field_addr_tmp;
22833 FC_FREE(field_addr_tmp);
22834 }
22835#endif /* FREECIV_JSON_CONNECTION */
22836
22837 log_packet_detailed("packet_city_rename_100: got info about ()");
22838
22839#ifdef FREECIV_DELTA_PROTOCOL
22840 packet_city_rename_100_fields fields;
22841 struct packet_city_rename *old;
22842 struct genhash **hash = pc->phs.received + PACKET_CITY_RENAME;
22843
22844 if (nullptr == *hash) {
22845 *hash = genhash_new_full(hash_packet_city_rename_100, cmp_packet_city_rename_100,
22846 nullptr, nullptr, nullptr, destroy_packet_city_rename);
22847 }
22848
22849 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
22850 *real_packet = *old;
22851 } else {
22852 /* packet is already initialized empty */
22853 log_packet_detailed(" no old info");
22854 }
22855
22856#ifdef FREECIV_JSON_CONNECTION
22857 field_addr.name = "fields";
22858#endif /* FREECIV_JSON_CONNECTION */
22859 DIO_BV_GET(&din, &field_addr, fields);
22860
22861 if (BV_ISSET(fields, 0)) {
22862 log_packet_detailed(" got field 'city_id'");
22863
22864#ifdef FREECIV_JSON_CONNECTION
22865 field_addr.name = "city_id";
22866#endif /* FREECIV_JSON_CONNECTION */
22867
22868 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22869 RECEIVE_PACKET_FIELD_ERROR(city_id);
22870 }
22871 }
22872
22873 if (BV_ISSET(fields, 1)) {
22874 log_packet_detailed(" got field 'name'");
22875
22876#ifdef FREECIV_JSON_CONNECTION
22877 field_addr.name = "name";
22878#endif /* FREECIV_JSON_CONNECTION */
22879
22880 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
22881 RECEIVE_PACKET_FIELD_ERROR(name);
22882 }
22883 }
22884
22885 if (nullptr == old) {
22886 old = fc_malloc(sizeof(*old));
22887 init_packet_city_rename(old);
22888 *old = *real_packet;
22889 genhash_insert(*hash, old, old);
22890 } else {
22891 *old = *real_packet;
22892 }
22893
22894#else /* FREECIV_DELTA_PROTOCOL */
22895#ifdef FREECIV_JSON_CONNECTION
22896 field_addr.name = "city_id";
22897#endif /* FREECIV_JSON_CONNECTION */
22898
22899 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
22900 RECEIVE_PACKET_FIELD_ERROR(city_id);
22901 }
22902
22903#ifdef FREECIV_JSON_CONNECTION
22904 field_addr.name = "name";
22905#endif /* FREECIV_JSON_CONNECTION */
22906
22907 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
22908 RECEIVE_PACKET_FIELD_ERROR(name);
22909 }
22910#endif /* FREECIV_DELTA_PROTOCOL */
22911
22912 RECEIVE_PACKET_END(real_packet);
22913#undef FREE_PACKET_STRUCT
22914}
22915
22916 static int send_packet_city_rename_100(struct connection *pc, const struct packet_city_rename *packet)
22917{
22918 const struct packet_city_rename *real_packet = packet;
22919 int e;
22920 SEND_PACKET_START(PACKET_CITY_RENAME);
22921
22922 log_packet_detailed("packet_city_rename_100: sending info about ()");
22923
22924#ifdef FREECIV_DELTA_PROTOCOL
22925 packet_city_rename_100_fields fields;
22926 struct packet_city_rename *old;
22927 bool differ;
22928 struct genhash **hash = pc->phs.sent + PACKET_CITY_RENAME;
22929
22930 if (nullptr == *hash) {
22931 *hash = genhash_new_full(hash_packet_city_rename_100, cmp_packet_city_rename_100,
22932 nullptr, nullptr, nullptr, destroy_packet_city_rename);
22933 }
22934 BV_CLR_ALL(fields);
22935
22936 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
22937 old = fc_malloc(sizeof(*old));
22938 /* temporary bitcopy just to insert correctly */
22939 *old = *real_packet;
22940 genhash_insert(*hash, old, old);
22941 init_packet_city_rename(old);
22942 }
22943
22944 differ = (old->city_id != real_packet->city_id);
22945 if (differ) {
22946 BV_SET(fields, 0);
22947 }
22948
22949 differ = (strcmp(old->name, real_packet->name) != 0);
22950 if (differ) {
22951 BV_SET(fields, 1);
22952 }
22953#endif /* FREECIV_DELTA_PROTOCOL */
22954
22955#ifdef FREECIV_JSON_CONNECTION
22956 struct plocation field_addr;
22957 {
22958 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
22959 field_addr = *field_addr_tmp;
22960 FC_FREE(field_addr_tmp);
22961 }
22962#endif /* FREECIV_JSON_CONNECTION */
22963
22964#ifdef FREECIV_DELTA_PROTOCOL
22965#ifdef FREECIV_JSON_CONNECTION
22966 field_addr.name = "fields";
22967#endif /* FREECIV_JSON_CONNECTION */
22968 e = 0;
22969 e |= DIO_BV_PUT(&dout, &field_addr, fields);
22970 if (e) {
22971 log_packet_detailed("fields bitvector error detected");
22972 }
22973
22974 if (BV_ISSET(fields, 0)) {
22975 log_packet_detailed(" field 'city_id' has changed");
22976
22977#ifdef FREECIV_JSON_CONNECTION
22978 field_addr.name = "city_id";
22979#endif /* FREECIV_JSON_CONNECTION */
22980 e = 0;
22981
22982 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
22983
22984 if (e) {
22985 log_packet_detailed("'city_id' field error detected");
22986 }
22987 }
22988
22989 if (BV_ISSET(fields, 1)) {
22990 log_packet_detailed(" field 'name' has changed");
22991
22992#ifdef FREECIV_JSON_CONNECTION
22993 field_addr.name = "name";
22994#endif /* FREECIV_JSON_CONNECTION */
22995 e = 0;
22996
22997 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
22998
22999 if (e) {
23000 log_packet_detailed("'name' field error detected");
23001 }
23002 }
23003
23004 *old = *real_packet;
23005
23006#else /* FREECIV_DELTA_PROTOCOL */
23007#ifdef FREECIV_JSON_CONNECTION
23008 field_addr.name = "city_id";
23009#endif /* FREECIV_JSON_CONNECTION */
23010 e = 0;
23011
23012 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
23013
23014 if (e) {
23015 log_packet_detailed("'city_id' field error detected");
23016 }
23017
23018#ifdef FREECIV_JSON_CONNECTION
23019 field_addr.name = "name";
23020#endif /* FREECIV_JSON_CONNECTION */
23021 e = 0;
23022
23023 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
23024
23025 if (e) {
23026 log_packet_detailed("'name' field error detected");
23027 }
23028#endif /* FREECIV_DELTA_PROTOCOL */
23029
23030 SEND_PACKET_END(PACKET_CITY_RENAME);
23031}
23032
23033 int send_packet_city_rename(struct connection *pc, const struct packet_city_rename *packet)
23034{
23035 if (!pc->used) {
23036 log_error("WARNING: trying to send data to the closed connection %s",
23037 conn_description(pc));
23038 return -1;
23039 }
23040 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_RENAME].packet != nullptr, -1,
23041 "Handler for PACKET_CITY_RENAME not installed");
23042 return pc->phs.handlers->send[PACKET_CITY_RENAME].packet(pc, packet);
23043}
23044
23045 int dsend_packet_city_rename(struct connection *pc, int city_id, const char *name)
23046{
23047 struct packet_city_rename packet, *real_packet = &packet;
23048
23049 real_packet->city_id = city_id;
23050 sz_strlcpy(real_packet->name, name);
23051
23052 return send_packet_city_rename(pc, real_packet);
23053}
23054
23055 static inline void init_packet_city_options_req(struct packet_city_options_req *packet)
23056{
23057 memset(packet, 0, sizeof(*packet));
23058}
23059
23060#define free_packet_city_options_req(_packet) (void) 0
23061#define destroy_packet_city_options_req free
23062
23063#ifdef FREECIV_DELTA_PROTOCOL
23064#define hash_packet_city_options_req_100 hash_const
23065#define cmp_packet_city_options_req_100 cmp_const
23066 BV_DEFINE(packet_city_options_req_100_fields, 2);
23067#endif /* FREECIV_DELTA_PROTOCOL */
23068
23069 static struct packet_city_options_req *receive_packet_city_options_req_100(struct connection *pc)
23070{
23071#define FREE_PACKET_STRUCT(_packet) free_packet_city_options_req(_packet)
23072 RECEIVE_PACKET_START(packet_city_options_req, real_packet);
23073
23074#ifdef FREECIV_JSON_CONNECTION
23075 struct plocation field_addr;
23076 {
23077 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23078 field_addr = *field_addr_tmp;
23079 FC_FREE(field_addr_tmp);
23080 }
23081#endif /* FREECIV_JSON_CONNECTION */
23082
23083 log_packet_detailed("packet_city_options_req_100: got info about ()");
23084
23085#ifdef FREECIV_DELTA_PROTOCOL
23086 packet_city_options_req_100_fields fields;
23087 struct packet_city_options_req *old;
23088 struct genhash **hash = pc->phs.received + PACKET_CITY_OPTIONS_REQ;
23089
23090 if (nullptr == *hash) {
23091 *hash = genhash_new_full(hash_packet_city_options_req_100, cmp_packet_city_options_req_100,
23092 nullptr, nullptr, nullptr, destroy_packet_city_options_req);
23093 }
23094
23095 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23096 *real_packet = *old;
23097 } else {
23098 /* packet is already initialized empty */
23099 log_packet_detailed(" no old info");
23100 }
23101
23102#ifdef FREECIV_JSON_CONNECTION
23103 field_addr.name = "fields";
23104#endif /* FREECIV_JSON_CONNECTION */
23105 DIO_BV_GET(&din, &field_addr, fields);
23106
23107 if (BV_ISSET(fields, 0)) {
23108 log_packet_detailed(" got field 'city_id'");
23109
23110#ifdef FREECIV_JSON_CONNECTION
23111 field_addr.name = "city_id";
23112#endif /* FREECIV_JSON_CONNECTION */
23113
23114 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
23115 RECEIVE_PACKET_FIELD_ERROR(city_id);
23116 }
23117 }
23118
23119 if (BV_ISSET(fields, 1)) {
23120 log_packet_detailed(" got field 'options'");
23121
23122#ifdef FREECIV_JSON_CONNECTION
23123 field_addr.name = "options";
23124#endif /* FREECIV_JSON_CONNECTION */
23125
23126 if (!DIO_BV_GET(&din, &field_addr, real_packet->options)) {
23127 RECEIVE_PACKET_FIELD_ERROR(options);
23128 }
23129 }
23130
23131 if (nullptr == old) {
23132 old = fc_malloc(sizeof(*old));
23133 init_packet_city_options_req(old);
23134 *old = *real_packet;
23135 genhash_insert(*hash, old, old);
23136 } else {
23137 *old = *real_packet;
23138 }
23139
23140#else /* FREECIV_DELTA_PROTOCOL */
23141#ifdef FREECIV_JSON_CONNECTION
23142 field_addr.name = "city_id";
23143#endif /* FREECIV_JSON_CONNECTION */
23144
23145 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
23146 RECEIVE_PACKET_FIELD_ERROR(city_id);
23147 }
23148
23149#ifdef FREECIV_JSON_CONNECTION
23150 field_addr.name = "options";
23151#endif /* FREECIV_JSON_CONNECTION */
23152
23153 if (!DIO_BV_GET(&din, &field_addr, real_packet->options)) {
23154 RECEIVE_PACKET_FIELD_ERROR(options);
23155 }
23156#endif /* FREECIV_DELTA_PROTOCOL */
23157
23158 RECEIVE_PACKET_END(real_packet);
23159#undef FREE_PACKET_STRUCT
23160}
23161
23162 static int send_packet_city_options_req_100(struct connection *pc, const struct packet_city_options_req *packet)
23163{
23164 const struct packet_city_options_req *real_packet = packet;
23165 int e;
23166 SEND_PACKET_START(PACKET_CITY_OPTIONS_REQ);
23167
23168 log_packet_detailed("packet_city_options_req_100: sending info about ()");
23169
23170#ifdef FREECIV_DELTA_PROTOCOL
23171 packet_city_options_req_100_fields fields;
23172 struct packet_city_options_req *old;
23173 bool differ;
23174 struct genhash **hash = pc->phs.sent + PACKET_CITY_OPTIONS_REQ;
23175
23176 if (nullptr == *hash) {
23177 *hash = genhash_new_full(hash_packet_city_options_req_100, cmp_packet_city_options_req_100,
23178 nullptr, nullptr, nullptr, destroy_packet_city_options_req);
23179 }
23180 BV_CLR_ALL(fields);
23181
23182 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23183 old = fc_malloc(sizeof(*old));
23184 /* temporary bitcopy just to insert correctly */
23185 *old = *real_packet;
23186 genhash_insert(*hash, old, old);
23187 init_packet_city_options_req(old);
23188 }
23189
23190 differ = (old->city_id != real_packet->city_id);
23191 if (differ) {
23192 BV_SET(fields, 0);
23193 }
23194
23195 differ = !BV_ARE_EQUAL(old->options, real_packet->options);
23196 if (differ) {
23197 BV_SET(fields, 1);
23198 }
23199#endif /* FREECIV_DELTA_PROTOCOL */
23200
23201#ifdef FREECIV_JSON_CONNECTION
23202 struct plocation field_addr;
23203 {
23204 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23205 field_addr = *field_addr_tmp;
23206 FC_FREE(field_addr_tmp);
23207 }
23208#endif /* FREECIV_JSON_CONNECTION */
23209
23210#ifdef FREECIV_DELTA_PROTOCOL
23211#ifdef FREECIV_JSON_CONNECTION
23212 field_addr.name = "fields";
23213#endif /* FREECIV_JSON_CONNECTION */
23214 e = 0;
23215 e |= DIO_BV_PUT(&dout, &field_addr, fields);
23216 if (e) {
23217 log_packet_detailed("fields bitvector error detected");
23218 }
23219
23220 if (BV_ISSET(fields, 0)) {
23221 log_packet_detailed(" field 'city_id' has changed");
23222
23223#ifdef FREECIV_JSON_CONNECTION
23224 field_addr.name = "city_id";
23225#endif /* FREECIV_JSON_CONNECTION */
23226 e = 0;
23227
23228 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
23229
23230 if (e) {
23231 log_packet_detailed("'city_id' field error detected");
23232 }
23233 }
23234
23235 if (BV_ISSET(fields, 1)) {
23236 log_packet_detailed(" field 'options' has changed");
23237
23238#ifdef FREECIV_JSON_CONNECTION
23239 field_addr.name = "options";
23240#endif /* FREECIV_JSON_CONNECTION */
23241 e = 0;
23242
23243 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->options);
23244
23245 if (e) {
23246 log_packet_detailed("'options' field error detected");
23247 }
23248 }
23249
23250 *old = *real_packet;
23251
23252#else /* FREECIV_DELTA_PROTOCOL */
23253#ifdef FREECIV_JSON_CONNECTION
23254 field_addr.name = "city_id";
23255#endif /* FREECIV_JSON_CONNECTION */
23256 e = 0;
23257
23258 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
23259
23260 if (e) {
23261 log_packet_detailed("'city_id' field error detected");
23262 }
23263
23264#ifdef FREECIV_JSON_CONNECTION
23265 field_addr.name = "options";
23266#endif /* FREECIV_JSON_CONNECTION */
23267 e = 0;
23268
23269 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->options);
23270
23271 if (e) {
23272 log_packet_detailed("'options' field error detected");
23273 }
23274#endif /* FREECIV_DELTA_PROTOCOL */
23275
23276 SEND_PACKET_END(PACKET_CITY_OPTIONS_REQ);
23277}
23278
23279 int send_packet_city_options_req(struct connection *pc, const struct packet_city_options_req *packet)
23280{
23281 if (!pc->used) {
23282 log_error("WARNING: trying to send data to the closed connection %s",
23283 conn_description(pc));
23284 return -1;
23285 }
23286 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_OPTIONS_REQ].packet != nullptr, -1,
23287 "Handler for PACKET_CITY_OPTIONS_REQ not installed");
23288 return pc->phs.handlers->send[PACKET_CITY_OPTIONS_REQ].packet(pc, packet);
23289}
23290
23291 int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options)
23292{
23293 struct packet_city_options_req packet, *real_packet = &packet;
23294
23295 real_packet->city_id = city_id;
23296 real_packet->options = options;
23297
23298 return send_packet_city_options_req(pc, real_packet);
23299}
23300
23301 static inline void init_packet_city_refresh(struct packet_city_refresh *packet)
23302{
23303 memset(packet, 0, sizeof(*packet));
23304}
23305
23306#define free_packet_city_refresh(_packet) (void) 0
23307#define destroy_packet_city_refresh free
23308
23309#ifdef FREECIV_DELTA_PROTOCOL
23310#define hash_packet_city_refresh_100 hash_const
23311#define cmp_packet_city_refresh_100 cmp_const
23312 BV_DEFINE(packet_city_refresh_100_fields, 1);
23313#endif /* FREECIV_DELTA_PROTOCOL */
23314
23315 static struct packet_city_refresh *receive_packet_city_refresh_100(struct connection *pc)
23316{
23317#define FREE_PACKET_STRUCT(_packet) free_packet_city_refresh(_packet)
23318 RECEIVE_PACKET_START(packet_city_refresh, real_packet);
23319
23320#ifdef FREECIV_JSON_CONNECTION
23321 struct plocation field_addr;
23322 {
23323 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23324 field_addr = *field_addr_tmp;
23325 FC_FREE(field_addr_tmp);
23326 }
23327#endif /* FREECIV_JSON_CONNECTION */
23328
23329 log_packet_detailed("packet_city_refresh_100: got info about ()");
23330
23331#ifdef FREECIV_DELTA_PROTOCOL
23332 packet_city_refresh_100_fields fields;
23333 struct packet_city_refresh *old;
23334 struct genhash **hash = pc->phs.received + PACKET_CITY_REFRESH;
23335
23336 if (nullptr == *hash) {
23337 *hash = genhash_new_full(hash_packet_city_refresh_100, cmp_packet_city_refresh_100,
23338 nullptr, nullptr, nullptr, destroy_packet_city_refresh);
23339 }
23340
23341 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23342 *real_packet = *old;
23343 } else {
23344 /* packet is already initialized empty */
23345 log_packet_detailed(" no old info");
23346 }
23347
23348#ifdef FREECIV_JSON_CONNECTION
23349 field_addr.name = "fields";
23350#endif /* FREECIV_JSON_CONNECTION */
23351 DIO_BV_GET(&din, &field_addr, fields);
23352
23353 if (BV_ISSET(fields, 0)) {
23354 log_packet_detailed(" got field 'city_id'");
23355
23356#ifdef FREECIV_JSON_CONNECTION
23357 field_addr.name = "city_id";
23358#endif /* FREECIV_JSON_CONNECTION */
23359
23360 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
23361 RECEIVE_PACKET_FIELD_ERROR(city_id);
23362 }
23363 }
23364
23365 if (nullptr == old) {
23366 old = fc_malloc(sizeof(*old));
23367 init_packet_city_refresh(old);
23368 *old = *real_packet;
23369 genhash_insert(*hash, old, old);
23370 } else {
23371 *old = *real_packet;
23372 }
23373
23374#else /* FREECIV_DELTA_PROTOCOL */
23375#ifdef FREECIV_JSON_CONNECTION
23376 field_addr.name = "city_id";
23377#endif /* FREECIV_JSON_CONNECTION */
23378
23379 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
23380 RECEIVE_PACKET_FIELD_ERROR(city_id);
23381 }
23382#endif /* FREECIV_DELTA_PROTOCOL */
23383
23384 RECEIVE_PACKET_END(real_packet);
23385#undef FREE_PACKET_STRUCT
23386}
23387
23388 static int send_packet_city_refresh_100(struct connection *pc, const struct packet_city_refresh *packet)
23389{
23390 const struct packet_city_refresh *real_packet = packet;
23391 int e;
23392 SEND_PACKET_START(PACKET_CITY_REFRESH);
23393
23394 log_packet_detailed("packet_city_refresh_100: sending info about ()");
23395
23396#ifdef FREECIV_DELTA_PROTOCOL
23397 packet_city_refresh_100_fields fields;
23398 struct packet_city_refresh *old;
23399 bool differ;
23400 struct genhash **hash = pc->phs.sent + PACKET_CITY_REFRESH;
23401
23402 if (nullptr == *hash) {
23403 *hash = genhash_new_full(hash_packet_city_refresh_100, cmp_packet_city_refresh_100,
23404 nullptr, nullptr, nullptr, destroy_packet_city_refresh);
23405 }
23406 BV_CLR_ALL(fields);
23407
23408 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23409 old = fc_malloc(sizeof(*old));
23410 /* temporary bitcopy just to insert correctly */
23411 *old = *real_packet;
23412 genhash_insert(*hash, old, old);
23413 init_packet_city_refresh(old);
23414 }
23415
23416 differ = (old->city_id != real_packet->city_id);
23417 if (differ) {
23418 BV_SET(fields, 0);
23419 }
23420#endif /* FREECIV_DELTA_PROTOCOL */
23421
23422#ifdef FREECIV_JSON_CONNECTION
23423 struct plocation field_addr;
23424 {
23425 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23426 field_addr = *field_addr_tmp;
23427 FC_FREE(field_addr_tmp);
23428 }
23429#endif /* FREECIV_JSON_CONNECTION */
23430
23431#ifdef FREECIV_DELTA_PROTOCOL
23432#ifdef FREECIV_JSON_CONNECTION
23433 field_addr.name = "fields";
23434#endif /* FREECIV_JSON_CONNECTION */
23435 e = 0;
23436 e |= DIO_BV_PUT(&dout, &field_addr, fields);
23437 if (e) {
23438 log_packet_detailed("fields bitvector error detected");
23439 }
23440
23441 if (BV_ISSET(fields, 0)) {
23442 log_packet_detailed(" field 'city_id' has changed");
23443
23444#ifdef FREECIV_JSON_CONNECTION
23445 field_addr.name = "city_id";
23446#endif /* FREECIV_JSON_CONNECTION */
23447 e = 0;
23448
23449 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
23450
23451 if (e) {
23452 log_packet_detailed("'city_id' field error detected");
23453 }
23454 }
23455
23456 *old = *real_packet;
23457
23458#else /* FREECIV_DELTA_PROTOCOL */
23459#ifdef FREECIV_JSON_CONNECTION
23460 field_addr.name = "city_id";
23461#endif /* FREECIV_JSON_CONNECTION */
23462 e = 0;
23463
23464 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
23465
23466 if (e) {
23467 log_packet_detailed("'city_id' field error detected");
23468 }
23469#endif /* FREECIV_DELTA_PROTOCOL */
23470
23471 SEND_PACKET_END(PACKET_CITY_REFRESH);
23472}
23473
23474 int send_packet_city_refresh(struct connection *pc, const struct packet_city_refresh *packet)
23475{
23476 if (!pc->used) {
23477 log_error("WARNING: trying to send data to the closed connection %s",
23478 conn_description(pc));
23479 return -1;
23480 }
23481 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_REFRESH].packet != nullptr, -1,
23482 "Handler for PACKET_CITY_REFRESH not installed");
23483 return pc->phs.handlers->send[PACKET_CITY_REFRESH].packet(pc, packet);
23484}
23485
23486 int dsend_packet_city_refresh(struct connection *pc, int city_id)
23487{
23488 struct packet_city_refresh packet, *real_packet = &packet;
23489
23490 real_packet->city_id = city_id;
23491
23492 return send_packet_city_refresh(pc, real_packet);
23493}
23494
23495 static inline void init_packet_city_name_suggestion_req(struct packet_city_name_suggestion_req *packet)
23496{
23497 memset(packet, 0, sizeof(*packet));
23498}
23499
23500#define free_packet_city_name_suggestion_req(_packet) (void) 0
23501#define destroy_packet_city_name_suggestion_req free
23502
23503#ifdef FREECIV_DELTA_PROTOCOL
23504#define hash_packet_city_name_suggestion_req_100 hash_const
23505#define cmp_packet_city_name_suggestion_req_100 cmp_const
23506 BV_DEFINE(packet_city_name_suggestion_req_100_fields, 1);
23507#endif /* FREECIV_DELTA_PROTOCOL */
23508
23509 static struct packet_city_name_suggestion_req *receive_packet_city_name_suggestion_req_100(struct connection *pc)
23510{
23511#define FREE_PACKET_STRUCT(_packet) free_packet_city_name_suggestion_req(_packet)
23512 RECEIVE_PACKET_START(packet_city_name_suggestion_req, real_packet);
23513
23514#ifdef FREECIV_JSON_CONNECTION
23515 struct plocation field_addr;
23516 {
23517 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23518 field_addr = *field_addr_tmp;
23519 FC_FREE(field_addr_tmp);
23520 }
23521#endif /* FREECIV_JSON_CONNECTION */
23522
23523 log_packet_detailed("packet_city_name_suggestion_req_100: got info about ()");
23524
23525#ifdef FREECIV_DELTA_PROTOCOL
23526 packet_city_name_suggestion_req_100_fields fields;
23527 struct packet_city_name_suggestion_req *old;
23528 struct genhash **hash = pc->phs.received + PACKET_CITY_NAME_SUGGESTION_REQ;
23529
23530 if (nullptr == *hash) {
23531 *hash = genhash_new_full(hash_packet_city_name_suggestion_req_100, cmp_packet_city_name_suggestion_req_100,
23532 nullptr, nullptr, nullptr, destroy_packet_city_name_suggestion_req);
23533 }
23534
23535 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23536 *real_packet = *old;
23537 } else {
23538 /* packet is already initialized empty */
23539 log_packet_detailed(" no old info");
23540 }
23541
23542#ifdef FREECIV_JSON_CONNECTION
23543 field_addr.name = "fields";
23544#endif /* FREECIV_JSON_CONNECTION */
23545 DIO_BV_GET(&din, &field_addr, fields);
23546
23547 if (BV_ISSET(fields, 0)) {
23548 log_packet_detailed(" got field 'unit_id'");
23549
23550#ifdef FREECIV_JSON_CONNECTION
23551 field_addr.name = "unit_id";
23552#endif /* FREECIV_JSON_CONNECTION */
23553
23554 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
23555 RECEIVE_PACKET_FIELD_ERROR(unit_id);
23556 }
23557 }
23558
23559 if (nullptr == old) {
23560 old = fc_malloc(sizeof(*old));
23561 init_packet_city_name_suggestion_req(old);
23562 *old = *real_packet;
23563 genhash_insert(*hash, old, old);
23564 } else {
23565 *old = *real_packet;
23566 }
23567
23568#else /* FREECIV_DELTA_PROTOCOL */
23569#ifdef FREECIV_JSON_CONNECTION
23570 field_addr.name = "unit_id";
23571#endif /* FREECIV_JSON_CONNECTION */
23572
23573 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
23574 RECEIVE_PACKET_FIELD_ERROR(unit_id);
23575 }
23576#endif /* FREECIV_DELTA_PROTOCOL */
23577
23578 RECEIVE_PACKET_END(real_packet);
23579#undef FREE_PACKET_STRUCT
23580}
23581
23582 static int send_packet_city_name_suggestion_req_100(struct connection *pc, const struct packet_city_name_suggestion_req *packet)
23583{
23584 const struct packet_city_name_suggestion_req *real_packet = packet;
23585 int e;
23586 SEND_PACKET_START(PACKET_CITY_NAME_SUGGESTION_REQ);
23587
23588 log_packet_detailed("packet_city_name_suggestion_req_100: sending info about ()");
23589
23590#ifdef FREECIV_DELTA_PROTOCOL
23591 packet_city_name_suggestion_req_100_fields fields;
23592 struct packet_city_name_suggestion_req *old;
23593 bool differ;
23594 struct genhash **hash = pc->phs.sent + PACKET_CITY_NAME_SUGGESTION_REQ;
23595
23596 if (nullptr == *hash) {
23597 *hash = genhash_new_full(hash_packet_city_name_suggestion_req_100, cmp_packet_city_name_suggestion_req_100,
23598 nullptr, nullptr, nullptr, destroy_packet_city_name_suggestion_req);
23599 }
23600 BV_CLR_ALL(fields);
23601
23602 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23603 old = fc_malloc(sizeof(*old));
23604 /* temporary bitcopy just to insert correctly */
23605 *old = *real_packet;
23606 genhash_insert(*hash, old, old);
23607 init_packet_city_name_suggestion_req(old);
23608 }
23609
23610 differ = (old->unit_id != real_packet->unit_id);
23611 if (differ) {
23612 BV_SET(fields, 0);
23613 }
23614#endif /* FREECIV_DELTA_PROTOCOL */
23615
23616#ifdef FREECIV_JSON_CONNECTION
23617 struct plocation field_addr;
23618 {
23619 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23620 field_addr = *field_addr_tmp;
23621 FC_FREE(field_addr_tmp);
23622 }
23623#endif /* FREECIV_JSON_CONNECTION */
23624
23625#ifdef FREECIV_DELTA_PROTOCOL
23626#ifdef FREECIV_JSON_CONNECTION
23627 field_addr.name = "fields";
23628#endif /* FREECIV_JSON_CONNECTION */
23629 e = 0;
23630 e |= DIO_BV_PUT(&dout, &field_addr, fields);
23631 if (e) {
23632 log_packet_detailed("fields bitvector error detected");
23633 }
23634
23635 if (BV_ISSET(fields, 0)) {
23636 log_packet_detailed(" field 'unit_id' has changed");
23637
23638#ifdef FREECIV_JSON_CONNECTION
23639 field_addr.name = "unit_id";
23640#endif /* FREECIV_JSON_CONNECTION */
23641 e = 0;
23642
23643 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
23644
23645 if (e) {
23646 log_packet_detailed("'unit_id' field error detected");
23647 }
23648 }
23649
23650 *old = *real_packet;
23651
23652#else /* FREECIV_DELTA_PROTOCOL */
23653#ifdef FREECIV_JSON_CONNECTION
23654 field_addr.name = "unit_id";
23655#endif /* FREECIV_JSON_CONNECTION */
23656 e = 0;
23657
23658 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
23659
23660 if (e) {
23661 log_packet_detailed("'unit_id' field error detected");
23662 }
23663#endif /* FREECIV_DELTA_PROTOCOL */
23664
23665 SEND_PACKET_END(PACKET_CITY_NAME_SUGGESTION_REQ);
23666}
23667
23668 int send_packet_city_name_suggestion_req(struct connection *pc, const struct packet_city_name_suggestion_req *packet)
23669{
23670 if (!pc->used) {
23671 log_error("WARNING: trying to send data to the closed connection %s",
23672 conn_description(pc));
23673 return -1;
23674 }
23675 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_REQ].packet != nullptr, -1,
23676 "Handler for PACKET_CITY_NAME_SUGGESTION_REQ not installed");
23677 return pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_REQ].packet(pc, packet);
23678}
23679
23680 int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
23681{
23682 struct packet_city_name_suggestion_req packet, *real_packet = &packet;
23683
23684 real_packet->unit_id = unit_id;
23685
23686 return send_packet_city_name_suggestion_req(pc, real_packet);
23687}
23688
23689 static inline void init_packet_city_name_suggestion_info(struct packet_city_name_suggestion_info *packet)
23690{
23691 memset(packet, 0, sizeof(*packet));
23692}
23693
23694#define free_packet_city_name_suggestion_info(_packet) (void) 0
23695#define destroy_packet_city_name_suggestion_info free
23696
23697#ifdef FREECIV_DELTA_PROTOCOL
23698#define hash_packet_city_name_suggestion_info_100 hash_const
23699#define cmp_packet_city_name_suggestion_info_100 cmp_const
23700 BV_DEFINE(packet_city_name_suggestion_info_100_fields, 2);
23701#endif /* FREECIV_DELTA_PROTOCOL */
23702
23703 static struct packet_city_name_suggestion_info *receive_packet_city_name_suggestion_info_100(struct connection *pc)
23704{
23705#define FREE_PACKET_STRUCT(_packet) free_packet_city_name_suggestion_info(_packet)
23706 RECEIVE_PACKET_START(packet_city_name_suggestion_info, real_packet);
23707
23708#ifdef FREECIV_JSON_CONNECTION
23709 struct plocation field_addr;
23710 {
23711 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23712 field_addr = *field_addr_tmp;
23713 FC_FREE(field_addr_tmp);
23714 }
23715#endif /* FREECIV_JSON_CONNECTION */
23716
23717 log_packet_detailed("packet_city_name_suggestion_info_100: got info about ()");
23718
23719#ifdef FREECIV_DELTA_PROTOCOL
23720 packet_city_name_suggestion_info_100_fields fields;
23721 struct packet_city_name_suggestion_info *old;
23722 struct genhash **hash = pc->phs.received + PACKET_CITY_NAME_SUGGESTION_INFO;
23723
23724 if (nullptr == *hash) {
23725 *hash = genhash_new_full(hash_packet_city_name_suggestion_info_100, cmp_packet_city_name_suggestion_info_100,
23726 nullptr, nullptr, nullptr, destroy_packet_city_name_suggestion_info);
23727 }
23728
23729 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23730 *real_packet = *old;
23731 } else {
23732 /* packet is already initialized empty */
23733 log_packet_detailed(" no old info");
23734 }
23735
23736#ifdef FREECIV_JSON_CONNECTION
23737 field_addr.name = "fields";
23738#endif /* FREECIV_JSON_CONNECTION */
23739 DIO_BV_GET(&din, &field_addr, fields);
23740
23741 if (BV_ISSET(fields, 0)) {
23742 log_packet_detailed(" got field 'unit_id'");
23743
23744#ifdef FREECIV_JSON_CONNECTION
23745 field_addr.name = "unit_id";
23746#endif /* FREECIV_JSON_CONNECTION */
23747
23748 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
23749 RECEIVE_PACKET_FIELD_ERROR(unit_id);
23750 }
23751 }
23752
23753 if (BV_ISSET(fields, 1)) {
23754 log_packet_detailed(" got field 'name'");
23755
23756#ifdef FREECIV_JSON_CONNECTION
23757 field_addr.name = "name";
23758#endif /* FREECIV_JSON_CONNECTION */
23759
23760 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
23761 RECEIVE_PACKET_FIELD_ERROR(name);
23762 }
23763 }
23764
23765 if (nullptr == old) {
23766 old = fc_malloc(sizeof(*old));
23767 init_packet_city_name_suggestion_info(old);
23768 *old = *real_packet;
23769 genhash_insert(*hash, old, old);
23770 } else {
23771 *old = *real_packet;
23772 }
23773
23774#else /* FREECIV_DELTA_PROTOCOL */
23775#ifdef FREECIV_JSON_CONNECTION
23776 field_addr.name = "unit_id";
23777#endif /* FREECIV_JSON_CONNECTION */
23778
23779 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
23780 RECEIVE_PACKET_FIELD_ERROR(unit_id);
23781 }
23782
23783#ifdef FREECIV_JSON_CONNECTION
23784 field_addr.name = "name";
23785#endif /* FREECIV_JSON_CONNECTION */
23786
23787 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
23788 RECEIVE_PACKET_FIELD_ERROR(name);
23789 }
23790#endif /* FREECIV_DELTA_PROTOCOL */
23791
23792 RECEIVE_PACKET_END(real_packet);
23793#undef FREE_PACKET_STRUCT
23794}
23795
23796 static int send_packet_city_name_suggestion_info_100(struct connection *pc, const struct packet_city_name_suggestion_info *packet)
23797{
23798 const struct packet_city_name_suggestion_info *real_packet = packet;
23799 int e;
23800 SEND_PACKET_START(PACKET_CITY_NAME_SUGGESTION_INFO);
23801
23802 log_packet_detailed("packet_city_name_suggestion_info_100: sending info about ()");
23803
23804#ifdef FREECIV_DELTA_PROTOCOL
23805 packet_city_name_suggestion_info_100_fields fields;
23806 struct packet_city_name_suggestion_info *old;
23807 bool differ;
23808 struct genhash **hash = pc->phs.sent + PACKET_CITY_NAME_SUGGESTION_INFO;
23809
23810 if (nullptr == *hash) {
23811 *hash = genhash_new_full(hash_packet_city_name_suggestion_info_100, cmp_packet_city_name_suggestion_info_100,
23812 nullptr, nullptr, nullptr, destroy_packet_city_name_suggestion_info);
23813 }
23814 BV_CLR_ALL(fields);
23815
23816 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
23817 old = fc_malloc(sizeof(*old));
23818 /* temporary bitcopy just to insert correctly */
23819 *old = *real_packet;
23820 genhash_insert(*hash, old, old);
23821 init_packet_city_name_suggestion_info(old);
23822 }
23823
23824 differ = (old->unit_id != real_packet->unit_id);
23825 if (differ) {
23826 BV_SET(fields, 0);
23827 }
23828
23829 differ = (strcmp(old->name, real_packet->name) != 0);
23830 if (differ) {
23831 BV_SET(fields, 1);
23832 }
23833#endif /* FREECIV_DELTA_PROTOCOL */
23834
23835#ifdef FREECIV_JSON_CONNECTION
23836 struct plocation field_addr;
23837 {
23838 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23839 field_addr = *field_addr_tmp;
23840 FC_FREE(field_addr_tmp);
23841 }
23842#endif /* FREECIV_JSON_CONNECTION */
23843
23844#ifdef FREECIV_DELTA_PROTOCOL
23845#ifdef FREECIV_JSON_CONNECTION
23846 field_addr.name = "fields";
23847#endif /* FREECIV_JSON_CONNECTION */
23848 e = 0;
23849 e |= DIO_BV_PUT(&dout, &field_addr, fields);
23850 if (e) {
23851 log_packet_detailed("fields bitvector error detected");
23852 }
23853
23854 if (BV_ISSET(fields, 0)) {
23855 log_packet_detailed(" field 'unit_id' has changed");
23856
23857#ifdef FREECIV_JSON_CONNECTION
23858 field_addr.name = "unit_id";
23859#endif /* FREECIV_JSON_CONNECTION */
23860 e = 0;
23861
23862 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
23863
23864 if (e) {
23865 log_packet_detailed("'unit_id' field error detected");
23866 }
23867 }
23868
23869 if (BV_ISSET(fields, 1)) {
23870 log_packet_detailed(" field 'name' has changed");
23871
23872#ifdef FREECIV_JSON_CONNECTION
23873 field_addr.name = "name";
23874#endif /* FREECIV_JSON_CONNECTION */
23875 e = 0;
23876
23877 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
23878
23879 if (e) {
23880 log_packet_detailed("'name' field error detected");
23881 }
23882 }
23883
23884 *old = *real_packet;
23885
23886#else /* FREECIV_DELTA_PROTOCOL */
23887#ifdef FREECIV_JSON_CONNECTION
23888 field_addr.name = "unit_id";
23889#endif /* FREECIV_JSON_CONNECTION */
23890 e = 0;
23891
23892 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
23893
23894 if (e) {
23895 log_packet_detailed("'unit_id' field error detected");
23896 }
23897
23898#ifdef FREECIV_JSON_CONNECTION
23899 field_addr.name = "name";
23900#endif /* FREECIV_JSON_CONNECTION */
23901 e = 0;
23902
23903 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
23904
23905 if (e) {
23906 log_packet_detailed("'name' field error detected");
23907 }
23908#endif /* FREECIV_DELTA_PROTOCOL */
23909
23910 SEND_PACKET_END(PACKET_CITY_NAME_SUGGESTION_INFO);
23911}
23912
23913 int send_packet_city_name_suggestion_info(struct connection *pc, const struct packet_city_name_suggestion_info *packet)
23914{
23915 if (!pc->used) {
23916 log_error("WARNING: trying to send data to the closed connection %s",
23917 conn_description(pc));
23918 return -1;
23919 }
23920 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_INFO].packet != nullptr, -1,
23921 "Handler for PACKET_CITY_NAME_SUGGESTION_INFO not installed");
23922 return pc->phs.handlers->send[PACKET_CITY_NAME_SUGGESTION_INFO].packet(pc, packet);
23923}
23924
23925 void lsend_packet_city_name_suggestion_info(struct conn_list *dest, const struct packet_city_name_suggestion_info *packet)
23926{
23927 conn_list_iterate(dest, pconn) {
23928 send_packet_city_name_suggestion_info(pconn, packet);
23929 } conn_list_iterate_end;
23930}
23931
23932 int dsend_packet_city_name_suggestion_info(struct connection *pc, int unit_id, const char *name)
23933{
23934 struct packet_city_name_suggestion_info packet, *real_packet = &packet;
23935
23936 real_packet->unit_id = unit_id;
23937 sz_strlcpy(real_packet->name, name);
23938
23939 return send_packet_city_name_suggestion_info(pc, real_packet);
23940}
23941
23942 void dlsend_packet_city_name_suggestion_info(struct conn_list *dest, int unit_id, const char *name)
23943{
23944 struct packet_city_name_suggestion_info packet, *real_packet = &packet;
23945
23946 real_packet->unit_id = unit_id;
23947 sz_strlcpy(real_packet->name, name);
23948
23949 lsend_packet_city_name_suggestion_info(dest, real_packet);
23950}
23951
23952 static inline void init_packet_city_sabotage_list(struct packet_city_sabotage_list *packet)
23953{
23954 memset(packet, 0, sizeof(*packet));
23955}
23956
23957#define free_packet_city_sabotage_list(_packet) (void) 0
23958#define destroy_packet_city_sabotage_list free
23959
23960#ifdef FREECIV_DELTA_PROTOCOL
23961#define hash_packet_city_sabotage_list_100 hash_const
23962#define cmp_packet_city_sabotage_list_100 cmp_const
23963 BV_DEFINE(packet_city_sabotage_list_100_fields, 5);
23964#endif /* FREECIV_DELTA_PROTOCOL */
23965
23966 static struct packet_city_sabotage_list *receive_packet_city_sabotage_list_100(struct connection *pc)
23967{
23968#define FREE_PACKET_STRUCT(_packet) free_packet_city_sabotage_list(_packet)
23969 RECEIVE_PACKET_START(packet_city_sabotage_list, real_packet);
23970
23971#ifdef FREECIV_JSON_CONNECTION
23972 struct plocation field_addr;
23973 {
23974 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
23975 field_addr = *field_addr_tmp;
23976 FC_FREE(field_addr_tmp);
23977 }
23978#endif /* FREECIV_JSON_CONNECTION */
23979
23980 log_packet_detailed("packet_city_sabotage_list_100: got info about ()");
23981
23982#ifdef FREECIV_DELTA_PROTOCOL
23983 packet_city_sabotage_list_100_fields fields;
23984 struct packet_city_sabotage_list *old;
23985 struct genhash **hash = pc->phs.received + PACKET_CITY_SABOTAGE_LIST;
23986
23987 if (nullptr == *hash) {
23988 *hash = genhash_new_full(hash_packet_city_sabotage_list_100, cmp_packet_city_sabotage_list_100,
23989 nullptr, nullptr, nullptr, destroy_packet_city_sabotage_list);
23990 }
23991
23992 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
23993 *real_packet = *old;
23994 } else {
23995 /* packet is already initialized empty */
23996 log_packet_detailed(" no old info");
23997 }
23998
23999#ifdef FREECIV_JSON_CONNECTION
24000 field_addr.name = "fields";
24001#endif /* FREECIV_JSON_CONNECTION */
24002 DIO_BV_GET(&din, &field_addr, fields);
24003
24004 if (BV_ISSET(fields, 0)) {
24005 log_packet_detailed(" got field 'actor_id'");
24006
24007#ifdef FREECIV_JSON_CONNECTION
24008 field_addr.name = "actor_id";
24009#endif /* FREECIV_JSON_CONNECTION */
24010
24011 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
24012 RECEIVE_PACKET_FIELD_ERROR(actor_id);
24013 }
24014 }
24015
24016 if (BV_ISSET(fields, 1)) {
24017 log_packet_detailed(" got field 'city_id'");
24018
24019#ifdef FREECIV_JSON_CONNECTION
24020 field_addr.name = "city_id";
24021#endif /* FREECIV_JSON_CONNECTION */
24022
24023 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
24024 RECEIVE_PACKET_FIELD_ERROR(city_id);
24025 }
24026 }
24027
24028 if (BV_ISSET(fields, 2)) {
24029 log_packet_detailed(" got field 'improvements'");
24030
24031#ifdef FREECIV_JSON_CONNECTION
24032 field_addr.name = "improvements";
24033#endif /* FREECIV_JSON_CONNECTION */
24034
24035 if (!DIO_BV_GET(&din, &field_addr, real_packet->improvements)) {
24036 RECEIVE_PACKET_FIELD_ERROR(improvements);
24037 }
24038 }
24039
24040 if (BV_ISSET(fields, 3)) {
24041 log_packet_detailed(" got field 'act_id'");
24042
24043#ifdef FREECIV_JSON_CONNECTION
24044 field_addr.name = "act_id";
24045#endif /* FREECIV_JSON_CONNECTION */
24046
24047 {
24048 int readin;
24049
24050 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
24051 RECEIVE_PACKET_FIELD_ERROR(act_id);
24052 }
24053 real_packet->act_id = readin;
24054 }
24055 }
24056
24057 if (BV_ISSET(fields, 4)) {
24058 log_packet_detailed(" got field 'request_kind'");
24059
24060#ifdef FREECIV_JSON_CONNECTION
24061 field_addr.name = "request_kind";
24062#endif /* FREECIV_JSON_CONNECTION */
24063
24064 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
24065 RECEIVE_PACKET_FIELD_ERROR(request_kind);
24066 }
24067 }
24068
24069 if (nullptr == old) {
24070 old = fc_malloc(sizeof(*old));
24071 init_packet_city_sabotage_list(old);
24072 *old = *real_packet;
24073 genhash_insert(*hash, old, old);
24074 } else {
24075 *old = *real_packet;
24076 }
24077
24078#else /* FREECIV_DELTA_PROTOCOL */
24079#ifdef FREECIV_JSON_CONNECTION
24080 field_addr.name = "actor_id";
24081#endif /* FREECIV_JSON_CONNECTION */
24082
24083 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
24084 RECEIVE_PACKET_FIELD_ERROR(actor_id);
24085 }
24086
24087#ifdef FREECIV_JSON_CONNECTION
24088 field_addr.name = "city_id";
24089#endif /* FREECIV_JSON_CONNECTION */
24090
24091 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
24092 RECEIVE_PACKET_FIELD_ERROR(city_id);
24093 }
24094
24095#ifdef FREECIV_JSON_CONNECTION
24096 field_addr.name = "improvements";
24097#endif /* FREECIV_JSON_CONNECTION */
24098
24099 if (!DIO_BV_GET(&din, &field_addr, real_packet->improvements)) {
24100 RECEIVE_PACKET_FIELD_ERROR(improvements);
24101 }
24102
24103#ifdef FREECIV_JSON_CONNECTION
24104 field_addr.name = "act_id";
24105#endif /* FREECIV_JSON_CONNECTION */
24106
24107 {
24108 int readin;
24109
24110 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
24111 RECEIVE_PACKET_FIELD_ERROR(act_id);
24112 }
24113 real_packet->act_id = readin;
24114 }
24115
24116#ifdef FREECIV_JSON_CONNECTION
24117 field_addr.name = "request_kind";
24118#endif /* FREECIV_JSON_CONNECTION */
24119
24120 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
24121 RECEIVE_PACKET_FIELD_ERROR(request_kind);
24122 }
24123#endif /* FREECIV_DELTA_PROTOCOL */
24124
24125 RECEIVE_PACKET_END(real_packet);
24126#undef FREE_PACKET_STRUCT
24127}
24128
24129 static int send_packet_city_sabotage_list_100(struct connection *pc, const struct packet_city_sabotage_list *packet)
24130{
24131 const struct packet_city_sabotage_list *real_packet = packet;
24132 int e;
24133 SEND_PACKET_START(PACKET_CITY_SABOTAGE_LIST);
24134
24135 log_packet_detailed("packet_city_sabotage_list_100: sending info about ()");
24136
24137#ifdef FREECIV_DELTA_PROTOCOL
24138 packet_city_sabotage_list_100_fields fields;
24139 struct packet_city_sabotage_list *old;
24140 bool differ;
24141 struct genhash **hash = pc->phs.sent + PACKET_CITY_SABOTAGE_LIST;
24142
24143 if (nullptr == *hash) {
24144 *hash = genhash_new_full(hash_packet_city_sabotage_list_100, cmp_packet_city_sabotage_list_100,
24145 nullptr, nullptr, nullptr, destroy_packet_city_sabotage_list);
24146 }
24147 BV_CLR_ALL(fields);
24148
24149 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
24150 old = fc_malloc(sizeof(*old));
24151 /* temporary bitcopy just to insert correctly */
24152 *old = *real_packet;
24153 genhash_insert(*hash, old, old);
24154 init_packet_city_sabotage_list(old);
24155 }
24156
24157 differ = (old->actor_id != real_packet->actor_id);
24158 if (differ) {
24159 BV_SET(fields, 0);
24160 }
24161
24162 differ = (old->city_id != real_packet->city_id);
24163 if (differ) {
24164 BV_SET(fields, 1);
24165 }
24166
24167 differ = !BV_ARE_EQUAL(old->improvements, real_packet->improvements);
24168 if (differ) {
24169 BV_SET(fields, 2);
24170 }
24171
24172 differ = (old->act_id != real_packet->act_id);
24173 if (differ) {
24174 BV_SET(fields, 3);
24175 }
24176
24177 differ = (old->request_kind != real_packet->request_kind);
24178 if (differ) {
24179 BV_SET(fields, 4);
24180 }
24181#endif /* FREECIV_DELTA_PROTOCOL */
24182
24183#ifdef FREECIV_JSON_CONNECTION
24184 struct plocation field_addr;
24185 {
24186 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
24187 field_addr = *field_addr_tmp;
24188 FC_FREE(field_addr_tmp);
24189 }
24190#endif /* FREECIV_JSON_CONNECTION */
24191
24192#ifdef FREECIV_DELTA_PROTOCOL
24193#ifdef FREECIV_JSON_CONNECTION
24194 field_addr.name = "fields";
24195#endif /* FREECIV_JSON_CONNECTION */
24196 e = 0;
24197 e |= DIO_BV_PUT(&dout, &field_addr, fields);
24198 if (e) {
24199 log_packet_detailed("fields bitvector error detected");
24200 }
24201
24202 if (BV_ISSET(fields, 0)) {
24203 log_packet_detailed(" field 'actor_id' has changed");
24204
24205#ifdef FREECIV_JSON_CONNECTION
24206 field_addr.name = "actor_id";
24207#endif /* FREECIV_JSON_CONNECTION */
24208 e = 0;
24209
24210 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
24211
24212 if (e) {
24213 log_packet_detailed("'actor_id' field error detected");
24214 }
24215 }
24216
24217 if (BV_ISSET(fields, 1)) {
24218 log_packet_detailed(" field 'city_id' has changed");
24219
24220#ifdef FREECIV_JSON_CONNECTION
24221 field_addr.name = "city_id";
24222#endif /* FREECIV_JSON_CONNECTION */
24223 e = 0;
24224
24225 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
24226
24227 if (e) {
24228 log_packet_detailed("'city_id' field error detected");
24229 }
24230 }
24231
24232 if (BV_ISSET(fields, 2)) {
24233 log_packet_detailed(" field 'improvements' has changed");
24234
24235#ifdef FREECIV_JSON_CONNECTION
24236 field_addr.name = "improvements";
24237#endif /* FREECIV_JSON_CONNECTION */
24238 e = 0;
24239
24240 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->improvements);
24241
24242 if (e) {
24243 log_packet_detailed("'improvements' field error detected");
24244 }
24245 }
24246
24247 if (BV_ISSET(fields, 3)) {
24248 log_packet_detailed(" field 'act_id' has changed");
24249
24250#ifdef FREECIV_JSON_CONNECTION
24251 field_addr.name = "act_id";
24252#endif /* FREECIV_JSON_CONNECTION */
24253 e = 0;
24254
24255 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->act_id);
24256
24257 if (e) {
24258 log_packet_detailed("'act_id' field error detected");
24259 }
24260 }
24261
24262 if (BV_ISSET(fields, 4)) {
24263 log_packet_detailed(" field 'request_kind' has changed");
24264
24265#ifdef FREECIV_JSON_CONNECTION
24266 field_addr.name = "request_kind";
24267#endif /* FREECIV_JSON_CONNECTION */
24268 e = 0;
24269
24270 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
24271
24272 if (e) {
24273 log_packet_detailed("'request_kind' field error detected");
24274 }
24275 }
24276
24277 *old = *real_packet;
24278
24279#else /* FREECIV_DELTA_PROTOCOL */
24280#ifdef FREECIV_JSON_CONNECTION
24281 field_addr.name = "actor_id";
24282#endif /* FREECIV_JSON_CONNECTION */
24283 e = 0;
24284
24285 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
24286
24287 if (e) {
24288 log_packet_detailed("'actor_id' field error detected");
24289 }
24290
24291#ifdef FREECIV_JSON_CONNECTION
24292 field_addr.name = "city_id";
24293#endif /* FREECIV_JSON_CONNECTION */
24294 e = 0;
24295
24296 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
24297
24298 if (e) {
24299 log_packet_detailed("'city_id' field error detected");
24300 }
24301
24302#ifdef FREECIV_JSON_CONNECTION
24303 field_addr.name = "improvements";
24304#endif /* FREECIV_JSON_CONNECTION */
24305 e = 0;
24306
24307 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->improvements);
24308
24309 if (e) {
24310 log_packet_detailed("'improvements' field error detected");
24311 }
24312
24313#ifdef FREECIV_JSON_CONNECTION
24314 field_addr.name = "act_id";
24315#endif /* FREECIV_JSON_CONNECTION */
24316 e = 0;
24317
24318 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->act_id);
24319
24320 if (e) {
24321 log_packet_detailed("'act_id' field error detected");
24322 }
24323
24324#ifdef FREECIV_JSON_CONNECTION
24325 field_addr.name = "request_kind";
24326#endif /* FREECIV_JSON_CONNECTION */
24327 e = 0;
24328
24329 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
24330
24331 if (e) {
24332 log_packet_detailed("'request_kind' field error detected");
24333 }
24334#endif /* FREECIV_DELTA_PROTOCOL */
24335
24336 SEND_PACKET_END(PACKET_CITY_SABOTAGE_LIST);
24337}
24338
24339 int send_packet_city_sabotage_list(struct connection *pc, const struct packet_city_sabotage_list *packet)
24340{
24341 if (!pc->used) {
24342 log_error("WARNING: trying to send data to the closed connection %s",
24343 conn_description(pc));
24344 return -1;
24345 }
24346 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_SABOTAGE_LIST].packet != nullptr, -1,
24347 "Handler for PACKET_CITY_SABOTAGE_LIST not installed");
24348 return pc->phs.handlers->send[PACKET_CITY_SABOTAGE_LIST].packet(pc, packet);
24349}
24350
24351 void lsend_packet_city_sabotage_list(struct conn_list *dest, const struct packet_city_sabotage_list *packet)
24352{
24353 conn_list_iterate(dest, pconn) {
24354 send_packet_city_sabotage_list(pconn, packet);
24355 } conn_list_iterate_end;
24356}
24357
24358 static inline void init_packet_city_rally_point(struct packet_city_rally_point *packet)
24359{
24360 memset(packet, 0, sizeof(*packet));
24361}
24362
24363#define free_packet_city_rally_point(_packet) (void) 0
24364#define destroy_packet_city_rally_point free
24365
24366#ifdef FREECIV_DELTA_PROTOCOL
24367#define hash_packet_city_rally_point_100 hash_const
24368#define cmp_packet_city_rally_point_100 cmp_const
24369 BV_DEFINE(packet_city_rally_point_100_fields, 5);
24370#endif /* FREECIV_DELTA_PROTOCOL */
24371
24372 static struct packet_city_rally_point *receive_packet_city_rally_point_100(struct connection *pc)
24373{
24374#define FREE_PACKET_STRUCT(_packet) free_packet_city_rally_point(_packet)
24375 RECEIVE_PACKET_START(packet_city_rally_point, real_packet);
24376
24377#ifdef FREECIV_JSON_CONNECTION
24378 struct plocation field_addr;
24379 {
24380 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
24381 field_addr = *field_addr_tmp;
24382 FC_FREE(field_addr_tmp);
24383 }
24384#endif /* FREECIV_JSON_CONNECTION */
24385
24386 log_packet_detailed("packet_city_rally_point_100: got info about ()");
24387
24388#ifdef FREECIV_DELTA_PROTOCOL
24389 packet_city_rally_point_100_fields fields;
24390 struct packet_city_rally_point *old;
24391 struct genhash **hash = pc->phs.received + PACKET_CITY_RALLY_POINT;
24392
24393 if (nullptr == *hash) {
24394 *hash = genhash_new_full(hash_packet_city_rally_point_100, cmp_packet_city_rally_point_100,
24395 nullptr, nullptr, nullptr, destroy_packet_city_rally_point);
24396 }
24397
24398 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
24399 *real_packet = *old;
24400 } else {
24401 /* packet is already initialized empty */
24402 log_packet_detailed(" no old info");
24403 }
24404
24405#ifdef FREECIV_JSON_CONNECTION
24406 field_addr.name = "fields";
24407#endif /* FREECIV_JSON_CONNECTION */
24408 DIO_BV_GET(&din, &field_addr, fields);
24409
24410 if (BV_ISSET(fields, 0)) {
24411 log_packet_detailed(" got field 'id'");
24412
24413#ifdef FREECIV_JSON_CONNECTION
24414 field_addr.name = "id";
24415#endif /* FREECIV_JSON_CONNECTION */
24416
24417 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
24418 RECEIVE_PACKET_FIELD_ERROR(id);
24419 }
24420 }
24421
24422 if (BV_ISSET(fields, 1)) {
24423 log_packet_detailed(" got field 'length'");
24424
24425#ifdef FREECIV_JSON_CONNECTION
24426 field_addr.name = "length";
24427#endif /* FREECIV_JSON_CONNECTION */
24428
24429 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->length)) {
24430 RECEIVE_PACKET_FIELD_ERROR(length);
24431 }
24432 }
24433
24434 real_packet->persistent = BV_ISSET(fields, 2);
24435
24436 real_packet->vigilant = BV_ISSET(fields, 3);
24437
24438 if (BV_ISSET(fields, 4)) {
24439 log_packet_detailed(" got field 'orders'");
24440
24441#ifdef FREECIV_JSON_CONNECTION
24442 field_addr.name = "orders";
24443#endif /* FREECIV_JSON_CONNECTION */
24444
24445 {
24446 int i;
24447
24448 if (real_packet->length > MAX_LEN_ROUTE) {
24449 RECEIVE_PACKET_FIELD_ERROR(orders, ": array truncated");
24450 }
24451
24452#ifdef FREECIV_JSON_CONNECTION
24453 /* Enter array. */
24454 field_addr.sub_location = plocation_elem_new(0);
24455#endif /* FREECIV_JSON_CONNECTION */
24456
24457 for (i = 0; i < real_packet->length; i++) {
24458#ifdef FREECIV_JSON_CONNECTION
24459 /* Next array element */
24460 field_addr.sub_location->number = i;
24461#endif /* FREECIV_JSON_CONNECTION */
24462
24463 if (!DIO_GET(unit_order, &din, &field_addr, &real_packet->orders[i])) {
24464 RECEIVE_PACKET_FIELD_ERROR(orders);
24465 }
24466 }
24467
24468#ifdef FREECIV_JSON_CONNECTION
24469 /* Exit array. */
24470 FC_FREE(field_addr.sub_location);
24471#endif /* FREECIV_JSON_CONNECTION */
24472 }
24473 }
24474
24475 if (nullptr == old) {
24476 old = fc_malloc(sizeof(*old));
24477 init_packet_city_rally_point(old);
24478 *old = *real_packet;
24479 genhash_insert(*hash, old, old);
24480 } else {
24481 *old = *real_packet;
24482 }
24483
24484#else /* FREECIV_DELTA_PROTOCOL */
24485#ifdef FREECIV_JSON_CONNECTION
24486 field_addr.name = "id";
24487#endif /* FREECIV_JSON_CONNECTION */
24488
24489 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
24490 RECEIVE_PACKET_FIELD_ERROR(id);
24491 }
24492
24493#ifdef FREECIV_JSON_CONNECTION
24494 field_addr.name = "length";
24495#endif /* FREECIV_JSON_CONNECTION */
24496
24497 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->length)) {
24498 RECEIVE_PACKET_FIELD_ERROR(length);
24499 }
24500
24501#ifdef FREECIV_JSON_CONNECTION
24502 field_addr.name = "persistent";
24503#endif /* FREECIV_JSON_CONNECTION */
24504
24505 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->persistent)) {
24506 RECEIVE_PACKET_FIELD_ERROR(persistent);
24507 }
24508
24509#ifdef FREECIV_JSON_CONNECTION
24510 field_addr.name = "vigilant";
24511#endif /* FREECIV_JSON_CONNECTION */
24512
24513 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->vigilant)) {
24514 RECEIVE_PACKET_FIELD_ERROR(vigilant);
24515 }
24516
24517#ifdef FREECIV_JSON_CONNECTION
24518 field_addr.name = "orders";
24519#endif /* FREECIV_JSON_CONNECTION */
24520
24521 {
24522 int i;
24523
24524 if (real_packet->length > MAX_LEN_ROUTE) {
24525 RECEIVE_PACKET_FIELD_ERROR(orders, ": array truncated");
24526 }
24527
24528#ifdef FREECIV_JSON_CONNECTION
24529 /* Enter array. */
24530 field_addr.sub_location = plocation_elem_new(0);
24531#endif /* FREECIV_JSON_CONNECTION */
24532
24533 for (i = 0; i < real_packet->length; i++) {
24534#ifdef FREECIV_JSON_CONNECTION
24535 /* Next array element */
24536 field_addr.sub_location->number = i;
24537#endif /* FREECIV_JSON_CONNECTION */
24538
24539 if (!DIO_GET(unit_order, &din, &field_addr, &real_packet->orders[i])) {
24540 RECEIVE_PACKET_FIELD_ERROR(orders);
24541 }
24542 }
24543
24544#ifdef FREECIV_JSON_CONNECTION
24545 /* Exit array. */
24546 FC_FREE(field_addr.sub_location);
24547#endif /* FREECIV_JSON_CONNECTION */
24548 }
24549#endif /* FREECIV_DELTA_PROTOCOL */
24550
24551 RECEIVE_PACKET_END(real_packet);
24552#undef FREE_PACKET_STRUCT
24553}
24554
24555 static int send_packet_city_rally_point_100(struct connection *pc, const struct packet_city_rally_point *packet, bool force_to_send)
24556{
24557 const struct packet_city_rally_point *real_packet = packet;
24558 int e;
24559 SEND_PACKET_START(PACKET_CITY_RALLY_POINT);
24560
24561 log_packet_detailed("packet_city_rally_point_100: sending info about ()");
24562
24563#ifdef FREECIV_DELTA_PROTOCOL
24564 packet_city_rally_point_100_fields fields;
24565 struct packet_city_rally_point *old;
24566 bool differ;
24567 int different = force_to_send;
24568 struct genhash **hash = pc->phs.sent + PACKET_CITY_RALLY_POINT;
24569
24570 if (nullptr == *hash) {
24571 *hash = genhash_new_full(hash_packet_city_rally_point_100, cmp_packet_city_rally_point_100,
24572 nullptr, nullptr, nullptr, destroy_packet_city_rally_point);
24573 }
24574 BV_CLR_ALL(fields);
24575
24576 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
24577 old = fc_malloc(sizeof(*old));
24578 /* temporary bitcopy just to insert correctly */
24579 *old = *real_packet;
24580 genhash_insert(*hash, old, old);
24581 init_packet_city_rally_point(old);
24582 different = 1; /* Force to send. */
24583 }
24584
24585 differ = (old->id != real_packet->id);
24586 if (differ) {
24587 different++;
24588 BV_SET(fields, 0);
24589 }
24590
24591 differ = (old->length != real_packet->length);
24592 if (differ) {
24593 different++;
24594 BV_SET(fields, 1);
24595 }
24596
24597 differ = (old->persistent != real_packet->persistent);
24598 if (differ) {
24599 different++;
24600 }
24601 /* folded into head */
24602 if (real_packet->persistent) {
24603 BV_SET(fields, 2);
24604 }
24605
24606 differ = (old->vigilant != real_packet->vigilant);
24607 if (differ) {
24608 different++;
24609 }
24610 /* folded into head */
24611 if (real_packet->vigilant) {
24612 BV_SET(fields, 3);
24613 }
24614
24615 differ = (old->length != real_packet->length);
24616 if (!differ) {
24617 int i;
24618
24619 for (i = 0; i < old->length; i++) {
24620 differ = !are_unit_orders_equal(&old->orders[i], &real_packet->orders[i]);
24621 if (differ) {
24622 break;
24623 }
24624 }
24625 }
24626 if (differ) {
24627 different++;
24628 BV_SET(fields, 4);
24629 }
24630
24631 if (different == 0) {
24632 log_packet_detailed(" no change -> discard");
24633 SEND_PACKET_DISCARD();
24634 }
24635#endif /* FREECIV_DELTA_PROTOCOL */
24636
24637#ifdef FREECIV_JSON_CONNECTION
24638 struct plocation field_addr;
24639 {
24640 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
24641 field_addr = *field_addr_tmp;
24642 FC_FREE(field_addr_tmp);
24643 }
24644#endif /* FREECIV_JSON_CONNECTION */
24645
24646#ifdef FREECIV_DELTA_PROTOCOL
24647#ifdef FREECIV_JSON_CONNECTION
24648 field_addr.name = "fields";
24649#endif /* FREECIV_JSON_CONNECTION */
24650 e = 0;
24651 e |= DIO_BV_PUT(&dout, &field_addr, fields);
24652 if (e) {
24653 log_packet_detailed("fields bitvector error detected");
24654 }
24655
24656 if (BV_ISSET(fields, 0)) {
24657 log_packet_detailed(" field 'id' has changed");
24658
24659#ifdef FREECIV_JSON_CONNECTION
24660 field_addr.name = "id";
24661#endif /* FREECIV_JSON_CONNECTION */
24662 e = 0;
24663
24664 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
24665
24666 if (e) {
24667 log_packet_detailed("'id' field error detected");
24668 }
24669 }
24670
24671 if (BV_ISSET(fields, 1)) {
24672 log_packet_detailed(" field 'length' has changed");
24673
24674#ifdef FREECIV_JSON_CONNECTION
24675 field_addr.name = "length";
24676#endif /* FREECIV_JSON_CONNECTION */
24677 e = 0;
24678
24679 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->length);
24680
24681 if (e) {
24682 log_packet_detailed("'length' field error detected");
24683 }
24684 }
24685
24686 /* field 2 is folded into the header */
24687
24688 /* field 3 is folded into the header */
24689
24690 if (BV_ISSET(fields, 4)) {
24691 log_packet_detailed(" field 'orders' has changed");
24692
24693#ifdef FREECIV_JSON_CONNECTION
24694 field_addr.name = "orders";
24695#endif /* FREECIV_JSON_CONNECTION */
24696 e = 0;
24697
24698 {
24699 int i;
24700
24701#ifdef FREECIV_JSON_CONNECTION
24702 /* Create the array. */
24703 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->length);
24704
24705 /* Enter array. */
24706 field_addr.sub_location = plocation_elem_new(0);
24707#endif /* FREECIV_JSON_CONNECTION */
24708
24709 for (i = 0; i < real_packet->length; i++) {
24710#ifdef FREECIV_JSON_CONNECTION
24711 /* Next array element. */
24712 field_addr.sub_location->number = i;
24713#endif /* FREECIV_JSON_CONNECTION */
24714
24715 e |= DIO_PUT(unit_order, &dout, &field_addr, &real_packet->orders[i]);
24716 }
24717
24718#ifdef FREECIV_JSON_CONNECTION
24719 /* Exit array. */
24720 FC_FREE(field_addr.sub_location);
24721#endif /* FREECIV_JSON_CONNECTION */
24722 }
24723
24724 if (e) {
24725 log_packet_detailed("'orders' field error detected");
24726 }
24727 }
24728
24729 *old = *real_packet;
24730
24731#else /* FREECIV_DELTA_PROTOCOL */
24732#ifdef FREECIV_JSON_CONNECTION
24733 field_addr.name = "id";
24734#endif /* FREECIV_JSON_CONNECTION */
24735 e = 0;
24736
24737 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
24738
24739 if (e) {
24740 log_packet_detailed("'id' field error detected");
24741 }
24742
24743#ifdef FREECIV_JSON_CONNECTION
24744 field_addr.name = "length";
24745#endif /* FREECIV_JSON_CONNECTION */
24746 e = 0;
24747
24748 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->length);
24749
24750 if (e) {
24751 log_packet_detailed("'length' field error detected");
24752 }
24753
24754#ifdef FREECIV_JSON_CONNECTION
24755 field_addr.name = "persistent";
24756#endif /* FREECIV_JSON_CONNECTION */
24757 e = 0;
24758
24759 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->persistent);
24760
24761 if (e) {
24762 log_packet_detailed("'persistent' field error detected");
24763 }
24764
24765#ifdef FREECIV_JSON_CONNECTION
24766 field_addr.name = "vigilant";
24767#endif /* FREECIV_JSON_CONNECTION */
24768 e = 0;
24769
24770 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->vigilant);
24771
24772 if (e) {
24773 log_packet_detailed("'vigilant' field error detected");
24774 }
24775
24776#ifdef FREECIV_JSON_CONNECTION
24777 field_addr.name = "orders";
24778#endif /* FREECIV_JSON_CONNECTION */
24779 e = 0;
24780
24781 {
24782 int i;
24783
24784#ifdef FREECIV_JSON_CONNECTION
24785 /* Create the array. */
24786 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->length);
24787
24788 /* Enter array. */
24789 field_addr.sub_location = plocation_elem_new(0);
24790#endif /* FREECIV_JSON_CONNECTION */
24791
24792 for (i = 0; i < real_packet->length; i++) {
24793#ifdef FREECIV_JSON_CONNECTION
24794 /* Next array element. */
24795 field_addr.sub_location->number = i;
24796#endif /* FREECIV_JSON_CONNECTION */
24797
24798 e |= DIO_PUT(unit_order, &dout, &field_addr, &real_packet->orders[i]);
24799 }
24800
24801#ifdef FREECIV_JSON_CONNECTION
24802 /* Exit array. */
24803 FC_FREE(field_addr.sub_location);
24804#endif /* FREECIV_JSON_CONNECTION */
24805 }
24806
24807 if (e) {
24808 log_packet_detailed("'orders' field error detected");
24809 }
24810#endif /* FREECIV_DELTA_PROTOCOL */
24811
24812 SEND_PACKET_END(PACKET_CITY_RALLY_POINT);
24813}
24814
24815 int send_packet_city_rally_point(struct connection *pc, const struct packet_city_rally_point *packet, bool force_to_send)
24816{
24817 if (!pc->used) {
24818 log_error("WARNING: trying to send data to the closed connection %s",
24819 conn_description(pc));
24820 return -1;
24821 }
24822 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CITY_RALLY_POINT].force_to_send != nullptr, -1,
24823 "Handler for PACKET_CITY_RALLY_POINT not installed");
24824 return pc->phs.handlers->send[PACKET_CITY_RALLY_POINT].force_to_send(pc, packet, force_to_send);
24825}
24826
24827 void lsend_packet_city_rally_point(struct conn_list *dest, const struct packet_city_rally_point *packet, bool force_to_send)
24828{
24829 conn_list_iterate(dest, pconn) {
24830 send_packet_city_rally_point(pconn, packet, force_to_send);
24831 } conn_list_iterate_end;
24832}
24833
24834 static inline void init_packet_worker_task(struct packet_worker_task *packet)
24835{
24836 memset(packet, 0, sizeof(*packet));
24837}
24838
24839#define free_packet_worker_task(_packet) (void) 0
24840#define destroy_packet_worker_task free
24841
24842#ifdef FREECIV_DELTA_PROTOCOL
24843#define hash_packet_worker_task_100 hash_const
24844#define cmp_packet_worker_task_100 cmp_const
24845 BV_DEFINE(packet_worker_task_100_fields, 5);
24846#endif /* FREECIV_DELTA_PROTOCOL */
24847
24848 static struct packet_worker_task *receive_packet_worker_task_100(struct connection *pc)
24849{
24850#define FREE_PACKET_STRUCT(_packet) free_packet_worker_task(_packet)
24851 RECEIVE_PACKET_START(packet_worker_task, real_packet);
24852
24853#ifdef FREECIV_JSON_CONNECTION
24854 struct plocation field_addr;
24855 {
24856 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
24857 field_addr = *field_addr_tmp;
24858 FC_FREE(field_addr_tmp);
24859 }
24860#endif /* FREECIV_JSON_CONNECTION */
24861
24862 log_packet_detailed("packet_worker_task_100: got info about ()");
24863
24864#ifdef FREECIV_DELTA_PROTOCOL
24865 packet_worker_task_100_fields fields;
24866 struct packet_worker_task *old;
24867 struct genhash **hash = pc->phs.received + PACKET_WORKER_TASK;
24868
24869 if (nullptr == *hash) {
24870 *hash = genhash_new_full(hash_packet_worker_task_100, cmp_packet_worker_task_100,
24871 nullptr, nullptr, nullptr, destroy_packet_worker_task);
24872 }
24873
24874 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
24875 *real_packet = *old;
24876 } else {
24877 /* packet is already initialized empty */
24878 log_packet_detailed(" no old info");
24879 }
24880
24881#ifdef FREECIV_JSON_CONNECTION
24882 field_addr.name = "fields";
24883#endif /* FREECIV_JSON_CONNECTION */
24884 DIO_BV_GET(&din, &field_addr, fields);
24885
24886 if (BV_ISSET(fields, 0)) {
24887 log_packet_detailed(" got field 'city_id'");
24888
24889#ifdef FREECIV_JSON_CONNECTION
24890 field_addr.name = "city_id";
24891#endif /* FREECIV_JSON_CONNECTION */
24892
24893 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
24894 RECEIVE_PACKET_FIELD_ERROR(city_id);
24895 }
24896 }
24897
24898 if (BV_ISSET(fields, 1)) {
24899 log_packet_detailed(" got field 'tile_id'");
24900
24901#ifdef FREECIV_JSON_CONNECTION
24902 field_addr.name = "tile_id";
24903#endif /* FREECIV_JSON_CONNECTION */
24904
24905 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile_id)) {
24906 RECEIVE_PACKET_FIELD_ERROR(tile_id);
24907 }
24908 }
24909
24910 if (BV_ISSET(fields, 2)) {
24911 log_packet_detailed(" got field 'activity'");
24912
24913#ifdef FREECIV_JSON_CONNECTION
24914 field_addr.name = "activity";
24915#endif /* FREECIV_JSON_CONNECTION */
24916
24917 {
24918 int readin;
24919
24920 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
24921 RECEIVE_PACKET_FIELD_ERROR(activity);
24922 }
24923 real_packet->activity = readin;
24924 }
24925 }
24926
24927 if (BV_ISSET(fields, 3)) {
24928 log_packet_detailed(" got field 'tgt'");
24929
24930#ifdef FREECIV_JSON_CONNECTION
24931 field_addr.name = "tgt";
24932#endif /* FREECIV_JSON_CONNECTION */
24933
24934 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->tgt)) {
24935 RECEIVE_PACKET_FIELD_ERROR(tgt);
24936 }
24937 }
24938
24939 if (BV_ISSET(fields, 4)) {
24940 log_packet_detailed(" got field 'want'");
24941
24942#ifdef FREECIV_JSON_CONNECTION
24943 field_addr.name = "want";
24944#endif /* FREECIV_JSON_CONNECTION */
24945
24946 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->want)) {
24947 RECEIVE_PACKET_FIELD_ERROR(want);
24948 }
24949 }
24950
24951 if (nullptr == old) {
24952 old = fc_malloc(sizeof(*old));
24953 init_packet_worker_task(old);
24954 *old = *real_packet;
24955 genhash_insert(*hash, old, old);
24956 } else {
24957 *old = *real_packet;
24958 }
24959
24960#else /* FREECIV_DELTA_PROTOCOL */
24961#ifdef FREECIV_JSON_CONNECTION
24962 field_addr.name = "city_id";
24963#endif /* FREECIV_JSON_CONNECTION */
24964
24965 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->city_id)) {
24966 RECEIVE_PACKET_FIELD_ERROR(city_id);
24967 }
24968
24969#ifdef FREECIV_JSON_CONNECTION
24970 field_addr.name = "tile_id";
24971#endif /* FREECIV_JSON_CONNECTION */
24972
24973 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile_id)) {
24974 RECEIVE_PACKET_FIELD_ERROR(tile_id);
24975 }
24976
24977#ifdef FREECIV_JSON_CONNECTION
24978 field_addr.name = "activity";
24979#endif /* FREECIV_JSON_CONNECTION */
24980
24981 {
24982 int readin;
24983
24984 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
24985 RECEIVE_PACKET_FIELD_ERROR(activity);
24986 }
24987 real_packet->activity = readin;
24988 }
24989
24990#ifdef FREECIV_JSON_CONNECTION
24991 field_addr.name = "tgt";
24992#endif /* FREECIV_JSON_CONNECTION */
24993
24994 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->tgt)) {
24995 RECEIVE_PACKET_FIELD_ERROR(tgt);
24996 }
24997
24998#ifdef FREECIV_JSON_CONNECTION
24999 field_addr.name = "want";
25000#endif /* FREECIV_JSON_CONNECTION */
25001
25002 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->want)) {
25003 RECEIVE_PACKET_FIELD_ERROR(want);
25004 }
25005#endif /* FREECIV_DELTA_PROTOCOL */
25006
25007 RECEIVE_PACKET_END(real_packet);
25008#undef FREE_PACKET_STRUCT
25009}
25010
25011 static int send_packet_worker_task_100(struct connection *pc, const struct packet_worker_task *packet)
25012{
25013 const struct packet_worker_task *real_packet = packet;
25014 int e;
25015 SEND_PACKET_START(PACKET_WORKER_TASK);
25016
25017 log_packet_detailed("packet_worker_task_100: sending info about ()");
25018
25019#ifdef FREECIV_DELTA_PROTOCOL
25020 packet_worker_task_100_fields fields;
25021 struct packet_worker_task *old;
25022 bool differ;
25023 struct genhash **hash = pc->phs.sent + PACKET_WORKER_TASK;
25024
25025 if (nullptr == *hash) {
25026 *hash = genhash_new_full(hash_packet_worker_task_100, cmp_packet_worker_task_100,
25027 nullptr, nullptr, nullptr, destroy_packet_worker_task);
25028 }
25029 BV_CLR_ALL(fields);
25030
25031 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
25032 old = fc_malloc(sizeof(*old));
25033 /* temporary bitcopy just to insert correctly */
25034 *old = *real_packet;
25035 genhash_insert(*hash, old, old);
25036 init_packet_worker_task(old);
25037 }
25038
25039 differ = (old->city_id != real_packet->city_id);
25040 if (differ) {
25041 BV_SET(fields, 0);
25042 }
25043
25044 differ = (old->tile_id != real_packet->tile_id);
25045 if (differ) {
25046 BV_SET(fields, 1);
25047 }
25048
25049 differ = (old->activity != real_packet->activity);
25050 if (differ) {
25051 BV_SET(fields, 2);
25052 }
25053
25054 differ = (old->tgt != real_packet->tgt);
25055 if (differ) {
25056 BV_SET(fields, 3);
25057 }
25058
25059 differ = (old->want != real_packet->want);
25060 if (differ) {
25061 BV_SET(fields, 4);
25062 }
25063#endif /* FREECIV_DELTA_PROTOCOL */
25064
25065#ifdef FREECIV_JSON_CONNECTION
25066 struct plocation field_addr;
25067 {
25068 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
25069 field_addr = *field_addr_tmp;
25070 FC_FREE(field_addr_tmp);
25071 }
25072#endif /* FREECIV_JSON_CONNECTION */
25073
25074#ifdef FREECIV_DELTA_PROTOCOL
25075#ifdef FREECIV_JSON_CONNECTION
25076 field_addr.name = "fields";
25077#endif /* FREECIV_JSON_CONNECTION */
25078 e = 0;
25079 e |= DIO_BV_PUT(&dout, &field_addr, fields);
25080 if (e) {
25081 log_packet_detailed("fields bitvector error detected");
25082 }
25083
25084 if (BV_ISSET(fields, 0)) {
25085 log_packet_detailed(" field 'city_id' has changed");
25086
25087#ifdef FREECIV_JSON_CONNECTION
25088 field_addr.name = "city_id";
25089#endif /* FREECIV_JSON_CONNECTION */
25090 e = 0;
25091
25092 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
25093
25094 if (e) {
25095 log_packet_detailed("'city_id' field error detected");
25096 }
25097 }
25098
25099 if (BV_ISSET(fields, 1)) {
25100 log_packet_detailed(" field 'tile_id' has changed");
25101
25102#ifdef FREECIV_JSON_CONNECTION
25103 field_addr.name = "tile_id";
25104#endif /* FREECIV_JSON_CONNECTION */
25105 e = 0;
25106
25107 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile_id);
25108
25109 if (e) {
25110 log_packet_detailed("'tile_id' field error detected");
25111 }
25112 }
25113
25114 if (BV_ISSET(fields, 2)) {
25115 log_packet_detailed(" field 'activity' has changed");
25116
25117#ifdef FREECIV_JSON_CONNECTION
25118 field_addr.name = "activity";
25119#endif /* FREECIV_JSON_CONNECTION */
25120 e = 0;
25121
25122 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
25123
25124 if (e) {
25125 log_packet_detailed("'activity' field error detected");
25126 }
25127 }
25128
25129 if (BV_ISSET(fields, 3)) {
25130 log_packet_detailed(" field 'tgt' has changed");
25131
25132#ifdef FREECIV_JSON_CONNECTION
25133 field_addr.name = "tgt";
25134#endif /* FREECIV_JSON_CONNECTION */
25135 e = 0;
25136
25137 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->tgt);
25138
25139 if (e) {
25140 log_packet_detailed("'tgt' field error detected");
25141 }
25142 }
25143
25144 if (BV_ISSET(fields, 4)) {
25145 log_packet_detailed(" field 'want' has changed");
25146
25147#ifdef FREECIV_JSON_CONNECTION
25148 field_addr.name = "want";
25149#endif /* FREECIV_JSON_CONNECTION */
25150 e = 0;
25151
25152 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->want);
25153
25154 if (e) {
25155 log_packet_detailed("'want' field error detected");
25156 }
25157 }
25158
25159 *old = *real_packet;
25160
25161#else /* FREECIV_DELTA_PROTOCOL */
25162#ifdef FREECIV_JSON_CONNECTION
25163 field_addr.name = "city_id";
25164#endif /* FREECIV_JSON_CONNECTION */
25165 e = 0;
25166
25167 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->city_id);
25168
25169 if (e) {
25170 log_packet_detailed("'city_id' field error detected");
25171 }
25172
25173#ifdef FREECIV_JSON_CONNECTION
25174 field_addr.name = "tile_id";
25175#endif /* FREECIV_JSON_CONNECTION */
25176 e = 0;
25177
25178 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile_id);
25179
25180 if (e) {
25181 log_packet_detailed("'tile_id' field error detected");
25182 }
25183
25184#ifdef FREECIV_JSON_CONNECTION
25185 field_addr.name = "activity";
25186#endif /* FREECIV_JSON_CONNECTION */
25187 e = 0;
25188
25189 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
25190
25191 if (e) {
25192 log_packet_detailed("'activity' field error detected");
25193 }
25194
25195#ifdef FREECIV_JSON_CONNECTION
25196 field_addr.name = "tgt";
25197#endif /* FREECIV_JSON_CONNECTION */
25198 e = 0;
25199
25200 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->tgt);
25201
25202 if (e) {
25203 log_packet_detailed("'tgt' field error detected");
25204 }
25205
25206#ifdef FREECIV_JSON_CONNECTION
25207 field_addr.name = "want";
25208#endif /* FREECIV_JSON_CONNECTION */
25209 e = 0;
25210
25211 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->want);
25212
25213 if (e) {
25214 log_packet_detailed("'want' field error detected");
25215 }
25216#endif /* FREECIV_DELTA_PROTOCOL */
25217
25218 SEND_PACKET_END(PACKET_WORKER_TASK);
25219}
25220
25221 int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
25222{
25223 if (!pc->used) {
25224 log_error("WARNING: trying to send data to the closed connection %s",
25225 conn_description(pc));
25226 return -1;
25227 }
25228 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WORKER_TASK].packet != nullptr, -1,
25229 "Handler for PACKET_WORKER_TASK not installed");
25230 return pc->phs.handlers->send[PACKET_WORKER_TASK].packet(pc, packet);
25231}
25232
25233 void lsend_packet_worker_task(struct conn_list *dest, const struct packet_worker_task *packet)
25234{
25235 conn_list_iterate(dest, pconn) {
25236 send_packet_worker_task(pconn, packet);
25237 } conn_list_iterate_end;
25238}
25239
25240 static inline void init_packet_player_remove(struct packet_player_remove *packet)
25241{
25242 memset(packet, 0, sizeof(*packet));
25243}
25244
25245#define free_packet_player_remove(_packet) (void) 0
25246#define destroy_packet_player_remove free
25247
25248#ifdef FREECIV_DELTA_PROTOCOL
25249#define hash_packet_player_remove_100 hash_const
25250#define cmp_packet_player_remove_100 cmp_const
25251 BV_DEFINE(packet_player_remove_100_fields, 1);
25252#endif /* FREECIV_DELTA_PROTOCOL */
25253
25254 static struct packet_player_remove *receive_packet_player_remove_100(struct connection *pc)
25255{
25256#define FREE_PACKET_STRUCT(_packet) free_packet_player_remove(_packet)
25257 RECEIVE_PACKET_START(packet_player_remove, real_packet);
25258
25259#ifdef FREECIV_JSON_CONNECTION
25260 struct plocation field_addr;
25261 {
25262 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
25263 field_addr = *field_addr_tmp;
25264 FC_FREE(field_addr_tmp);
25265 }
25266#endif /* FREECIV_JSON_CONNECTION */
25267
25268 log_packet_detailed("packet_player_remove_100: got info about ()");
25269
25270#ifdef FREECIV_DELTA_PROTOCOL
25271 packet_player_remove_100_fields fields;
25272 struct packet_player_remove *old;
25273 struct genhash **hash = pc->phs.received + PACKET_PLAYER_REMOVE;
25274
25275 if (nullptr == *hash) {
25276 *hash = genhash_new_full(hash_packet_player_remove_100, cmp_packet_player_remove_100,
25277 nullptr, nullptr, nullptr, destroy_packet_player_remove);
25278 }
25279
25280 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
25281 *real_packet = *old;
25282 } else {
25283 /* packet is already initialized empty */
25284 log_packet_detailed(" no old info");
25285 }
25286
25287#ifdef FREECIV_JSON_CONNECTION
25288 field_addr.name = "fields";
25289#endif /* FREECIV_JSON_CONNECTION */
25290 DIO_BV_GET(&din, &field_addr, fields);
25291
25292 if (BV_ISSET(fields, 0)) {
25293 log_packet_detailed(" got field 'playerno'");
25294
25295#ifdef FREECIV_JSON_CONNECTION
25296 field_addr.name = "playerno";
25297#endif /* FREECIV_JSON_CONNECTION */
25298
25299 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->playerno)) {
25300 RECEIVE_PACKET_FIELD_ERROR(playerno);
25301 }
25302 }
25303
25304 if (nullptr == old) {
25305 old = fc_malloc(sizeof(*old));
25306 init_packet_player_remove(old);
25307 *old = *real_packet;
25308 genhash_insert(*hash, old, old);
25309 } else {
25310 *old = *real_packet;
25311 }
25312
25313 hash = pc->phs.received + PACKET_PLAYER_INFO;
25314 if (nullptr != *hash) {
25315 genhash_remove(*hash, real_packet);
25316 }
25317
25318#else /* FREECIV_DELTA_PROTOCOL */
25319#ifdef FREECIV_JSON_CONNECTION
25320 field_addr.name = "playerno";
25321#endif /* FREECIV_JSON_CONNECTION */
25322
25323 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->playerno)) {
25324 RECEIVE_PACKET_FIELD_ERROR(playerno);
25325 }
25326#endif /* FREECIV_DELTA_PROTOCOL */
25327
25328 RECEIVE_PACKET_END(real_packet);
25329#undef FREE_PACKET_STRUCT
25330}
25331
25332 static int send_packet_player_remove_100(struct connection *pc, const struct packet_player_remove *packet)
25333{
25334 const struct packet_player_remove *real_packet = packet;
25335 int e;
25336 SEND_PACKET_START(PACKET_PLAYER_REMOVE);
25337
25338 log_packet_detailed("packet_player_remove_100: sending info about ()");
25339
25340#ifdef FREECIV_DELTA_PROTOCOL
25341 packet_player_remove_100_fields fields;
25342 struct packet_player_remove *old;
25343 bool differ;
25344 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_REMOVE;
25345
25346 if (nullptr == *hash) {
25347 *hash = genhash_new_full(hash_packet_player_remove_100, cmp_packet_player_remove_100,
25348 nullptr, nullptr, nullptr, destroy_packet_player_remove);
25349 }
25350 BV_CLR_ALL(fields);
25351
25352 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
25353 old = fc_malloc(sizeof(*old));
25354 /* temporary bitcopy just to insert correctly */
25355 *old = *real_packet;
25356 genhash_insert(*hash, old, old);
25357 init_packet_player_remove(old);
25358 }
25359
25360 differ = (old->playerno != real_packet->playerno);
25361 if (differ) {
25362 BV_SET(fields, 0);
25363 }
25364#endif /* FREECIV_DELTA_PROTOCOL */
25365
25366#ifdef FREECIV_JSON_CONNECTION
25367 struct plocation field_addr;
25368 {
25369 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
25370 field_addr = *field_addr_tmp;
25371 FC_FREE(field_addr_tmp);
25372 }
25373#endif /* FREECIV_JSON_CONNECTION */
25374
25375#ifdef FREECIV_DELTA_PROTOCOL
25376#ifdef FREECIV_JSON_CONNECTION
25377 field_addr.name = "fields";
25378#endif /* FREECIV_JSON_CONNECTION */
25379 e = 0;
25380 e |= DIO_BV_PUT(&dout, &field_addr, fields);
25381 if (e) {
25382 log_packet_detailed("fields bitvector error detected");
25383 }
25384
25385 if (BV_ISSET(fields, 0)) {
25386 log_packet_detailed(" field 'playerno' has changed");
25387
25388#ifdef FREECIV_JSON_CONNECTION
25389 field_addr.name = "playerno";
25390#endif /* FREECIV_JSON_CONNECTION */
25391 e = 0;
25392
25393 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->playerno);
25394
25395 if (e) {
25396 log_packet_detailed("'playerno' field error detected");
25397 }
25398 }
25399
25400 *old = *real_packet;
25401
25402 hash = pc->phs.sent + PACKET_PLAYER_INFO;
25403 if (nullptr != *hash) {
25404 genhash_remove(*hash, real_packet);
25405 }
25406
25407#else /* FREECIV_DELTA_PROTOCOL */
25408#ifdef FREECIV_JSON_CONNECTION
25409 field_addr.name = "playerno";
25410#endif /* FREECIV_JSON_CONNECTION */
25411 e = 0;
25412
25413 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->playerno);
25414
25415 if (e) {
25416 log_packet_detailed("'playerno' field error detected");
25417 }
25418#endif /* FREECIV_DELTA_PROTOCOL */
25419
25420 SEND_PACKET_END(PACKET_PLAYER_REMOVE);
25421}
25422
25423 int send_packet_player_remove(struct connection *pc, const struct packet_player_remove *packet)
25424{
25425 if (!pc->used) {
25426 log_error("WARNING: trying to send data to the closed connection %s",
25427 conn_description(pc));
25428 return -1;
25429 }
25430 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_REMOVE].packet != nullptr, -1,
25431 "Handler for PACKET_PLAYER_REMOVE not installed");
25432 return pc->phs.handlers->send[PACKET_PLAYER_REMOVE].packet(pc, packet);
25433}
25434
25435 int dsend_packet_player_remove(struct connection *pc, int playerno)
25436{
25437 struct packet_player_remove packet, *real_packet = &packet;
25438
25439 real_packet->playerno = playerno;
25440
25441 return send_packet_player_remove(pc, real_packet);
25442}
25443
25444 static inline void init_packet_player_info(struct packet_player_info *packet)
25445{
25446 memset(packet, 0, sizeof(*packet));
25447}
25448
25449#define free_packet_player_info(_packet) (void) 0
25450#define destroy_packet_player_info free
25451
25452#ifdef FREECIV_DELTA_PROTOCOL
25453static genhash_val_t hash_packet_player_info_100(const void *vkey)
25454{
25455 const struct packet_player_info *key = (const struct packet_player_info *) vkey;
25456 genhash_val_t result = 0;
25457
25458 result += key->playerno;
25459
25460 result &= 0xFFFFFFFF;
25461 return result;
25462}
25463
25464static bool cmp_packet_player_info_100(const void *vkey1, const void *vkey2)
25465{
25466 const struct packet_player_info *old = (const struct packet_player_info *) vkey1;
25467 const struct packet_player_info *real_packet = (const struct packet_player_info *) vkey2;
25468 bool differ;
25469
25470 differ = (old->playerno != real_packet->playerno);
25471
25472 return !differ;
25473}
25474 BV_DEFINE(packet_player_info_100_fields, 47);
25475#endif /* FREECIV_DELTA_PROTOCOL */
25476
25477 static struct packet_player_info *receive_packet_player_info_100(struct connection *pc)
25478{
25479#define FREE_PACKET_STRUCT(_packet) free_packet_player_info(_packet)
25480 RECEIVE_PACKET_START(packet_player_info, real_packet);
25481
25482#ifdef FREECIV_JSON_CONNECTION
25483 struct plocation field_addr;
25484 {
25485 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
25486 field_addr = *field_addr_tmp;
25487 FC_FREE(field_addr_tmp);
25488 }
25489#endif /* FREECIV_JSON_CONNECTION */
25490
25491#ifdef FREECIV_JSON_CONNECTION
25492 field_addr.name = "playerno";
25493#endif /* FREECIV_JSON_CONNECTION */
25494
25495 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->playerno)) {
25496 RECEIVE_PACKET_FIELD_ERROR(playerno);
25497 }
25498
25499 log_packet_detailed("packet_player_info_100: got info about (%d)",
25500 real_packet->playerno);
25501
25502#ifdef FREECIV_DELTA_PROTOCOL
25503 packet_player_info_100_fields fields;
25504 struct packet_player_info *old;
25505 struct genhash **hash = pc->phs.received + PACKET_PLAYER_INFO;
25506
25507 if (nullptr == *hash) {
25508 *hash = genhash_new_full(hash_packet_player_info_100, cmp_packet_player_info_100,
25509 nullptr, nullptr, nullptr, destroy_packet_player_info);
25510 }
25511
25512 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
25513 *real_packet = *old;
25514 } else {
25515 /* packet is already initialized empty */
25516 log_packet_detailed(" no old info");
25517 }
25518
25519#ifdef FREECIV_JSON_CONNECTION
25520 field_addr.name = "fields";
25521#endif /* FREECIV_JSON_CONNECTION */
25522 DIO_BV_GET(&din, &field_addr, fields);
25523
25524 if (BV_ISSET(fields, 0)) {
25525 log_packet_detailed(" got field 'name'");
25526
25527#ifdef FREECIV_JSON_CONNECTION
25528 field_addr.name = "name";
25529#endif /* FREECIV_JSON_CONNECTION */
25530
25531 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
25532 RECEIVE_PACKET_FIELD_ERROR(name);
25533 }
25534 }
25535
25536 if (BV_ISSET(fields, 1)) {
25537 log_packet_detailed(" got field 'username'");
25538
25539#ifdef FREECIV_JSON_CONNECTION
25540 field_addr.name = "username";
25541#endif /* FREECIV_JSON_CONNECTION */
25542
25543 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
25544 RECEIVE_PACKET_FIELD_ERROR(username);
25545 }
25546 }
25547
25548 real_packet->unassigned_user = BV_ISSET(fields, 2);
25549
25550 if (BV_ISSET(fields, 3)) {
25551 log_packet_detailed(" got field 'score'");
25552
25553#ifdef FREECIV_JSON_CONNECTION
25554 field_addr.name = "score";
25555#endif /* FREECIV_JSON_CONNECTION */
25556
25557 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->score)) {
25558 RECEIVE_PACKET_FIELD_ERROR(score);
25559 }
25560 }
25561
25562 real_packet->is_male = BV_ISSET(fields, 4);
25563
25564 real_packet->was_created = BV_ISSET(fields, 5);
25565
25566 if (BV_ISSET(fields, 6)) {
25567 log_packet_detailed(" got field 'government'");
25568
25569#ifdef FREECIV_JSON_CONNECTION
25570 field_addr.name = "government";
25571#endif /* FREECIV_JSON_CONNECTION */
25572
25573 {
25574 int readin;
25575
25576 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
25577 RECEIVE_PACKET_FIELD_ERROR(government);
25578 }
25579 real_packet->government = readin;
25580 }
25581 }
25582
25583 if (BV_ISSET(fields, 7)) {
25584 log_packet_detailed(" got field 'target_government'");
25585
25586#ifdef FREECIV_JSON_CONNECTION
25587 field_addr.name = "target_government";
25588#endif /* FREECIV_JSON_CONNECTION */
25589
25590 {
25591 int readin;
25592
25593 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
25594 RECEIVE_PACKET_FIELD_ERROR(target_government);
25595 }
25596 real_packet->target_government = readin;
25597 }
25598 }
25599
25600 if (BV_ISSET(fields, 8)) {
25601 log_packet_detailed(" got field 'real_embassy'");
25602
25603#ifdef FREECIV_JSON_CONNECTION
25604 field_addr.name = "real_embassy";
25605#endif /* FREECIV_JSON_CONNECTION */
25606
25607 if (!DIO_BV_GET(&din, &field_addr, real_packet->real_embassy)) {
25608 RECEIVE_PACKET_FIELD_ERROR(real_embassy);
25609 }
25610 }
25611
25612 if (BV_ISSET(fields, 9)) {
25613 log_packet_detailed(" got field 'mood'");
25614
25615#ifdef FREECIV_JSON_CONNECTION
25616 field_addr.name = "mood";
25617#endif /* FREECIV_JSON_CONNECTION */
25618
25619 {
25620 int readin;
25621
25622 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
25623 RECEIVE_PACKET_FIELD_ERROR(mood);
25624 }
25625 real_packet->mood = readin;
25626 }
25627 }
25628
25629 if (BV_ISSET(fields, 10)) {
25630 log_packet_detailed(" got field 'style'");
25631
25632#ifdef FREECIV_JSON_CONNECTION
25633 field_addr.name = "style";
25634#endif /* FREECIV_JSON_CONNECTION */
25635
25636 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
25637 RECEIVE_PACKET_FIELD_ERROR(style);
25638 }
25639 }
25640
25641 if (BV_ISSET(fields, 11)) {
25642 log_packet_detailed(" got field 'music_style'");
25643
25644#ifdef FREECIV_JSON_CONNECTION
25645 field_addr.name = "music_style";
25646#endif /* FREECIV_JSON_CONNECTION */
25647
25648 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->music_style)) {
25649 RECEIVE_PACKET_FIELD_ERROR(music_style);
25650 }
25651 }
25652
25653 if (BV_ISSET(fields, 12)) {
25654 log_packet_detailed(" got field 'nation'");
25655
25656#ifdef FREECIV_JSON_CONNECTION
25657 field_addr.name = "nation";
25658#endif /* FREECIV_JSON_CONNECTION */
25659
25660 {
25661 int readin;
25662
25663 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
25664 RECEIVE_PACKET_FIELD_ERROR(nation);
25665 }
25666 real_packet->nation = readin;
25667 }
25668 }
25669
25670 if (BV_ISSET(fields, 13)) {
25671 log_packet_detailed(" got field 'team'");
25672
25673#ifdef FREECIV_JSON_CONNECTION
25674 field_addr.name = "team";
25675#endif /* FREECIV_JSON_CONNECTION */
25676
25677 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->team)) {
25678 RECEIVE_PACKET_FIELD_ERROR(team);
25679 }
25680 }
25681
25682 real_packet->is_ready = BV_ISSET(fields, 14);
25683
25684 real_packet->phase_done = BV_ISSET(fields, 15);
25685
25686 if (BV_ISSET(fields, 16)) {
25687 log_packet_detailed(" got field 'nturns_idle'");
25688
25689#ifdef FREECIV_JSON_CONNECTION
25690 field_addr.name = "nturns_idle";
25691#endif /* FREECIV_JSON_CONNECTION */
25692
25693 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nturns_idle)) {
25694 RECEIVE_PACKET_FIELD_ERROR(nturns_idle);
25695 }
25696 }
25697
25698 if (BV_ISSET(fields, 17)) {
25699 log_packet_detailed(" got field 'turns_alive'");
25700
25701#ifdef FREECIV_JSON_CONNECTION
25702 field_addr.name = "turns_alive";
25703#endif /* FREECIV_JSON_CONNECTION */
25704
25705 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turns_alive)) {
25706 RECEIVE_PACKET_FIELD_ERROR(turns_alive);
25707 }
25708 }
25709
25710 real_packet->is_alive = BV_ISSET(fields, 18);
25711
25712 if (BV_ISSET(fields, 19)) {
25713 log_packet_detailed(" got field 'autoselect_weight'");
25714
25715#ifdef FREECIV_JSON_CONNECTION
25716 field_addr.name = "autoselect_weight";
25717#endif /* FREECIV_JSON_CONNECTION */
25718
25719 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->autoselect_weight)) {
25720 RECEIVE_PACKET_FIELD_ERROR(autoselect_weight);
25721 }
25722 }
25723
25724 if (BV_ISSET(fields, 20)) {
25725 log_packet_detailed(" got field 'gold'");
25726
25727#ifdef FREECIV_JSON_CONNECTION
25728 field_addr.name = "gold";
25729#endif /* FREECIV_JSON_CONNECTION */
25730
25731 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->gold)) {
25732 RECEIVE_PACKET_FIELD_ERROR(gold);
25733 }
25734 }
25735
25736 if (BV_ISSET(fields, 21)) {
25737 log_packet_detailed(" got field 'tax'");
25738
25739#ifdef FREECIV_JSON_CONNECTION
25740 field_addr.name = "tax";
25741#endif /* FREECIV_JSON_CONNECTION */
25742
25743 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tax)) {
25744 RECEIVE_PACKET_FIELD_ERROR(tax);
25745 }
25746 }
25747
25748 if (BV_ISSET(fields, 22)) {
25749 log_packet_detailed(" got field 'science'");
25750
25751#ifdef FREECIV_JSON_CONNECTION
25752 field_addr.name = "science";
25753#endif /* FREECIV_JSON_CONNECTION */
25754
25755 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->science)) {
25756 RECEIVE_PACKET_FIELD_ERROR(science);
25757 }
25758 }
25759
25760 if (BV_ISSET(fields, 23)) {
25761 log_packet_detailed(" got field 'luxury'");
25762
25763#ifdef FREECIV_JSON_CONNECTION
25764 field_addr.name = "luxury";
25765#endif /* FREECIV_JSON_CONNECTION */
25766
25767 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->luxury)) {
25768 RECEIVE_PACKET_FIELD_ERROR(luxury);
25769 }
25770 }
25771
25772 if (BV_ISSET(fields, 24)) {
25773 log_packet_detailed(" got field 'infrapoints'");
25774
25775#ifdef FREECIV_JSON_CONNECTION
25776 field_addr.name = "infrapoints";
25777#endif /* FREECIV_JSON_CONNECTION */
25778
25779 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->infrapoints)) {
25780 RECEIVE_PACKET_FIELD_ERROR(infrapoints);
25781 }
25782 }
25783
25784 if (BV_ISSET(fields, 25)) {
25785 log_packet_detailed(" got field 'tech_upkeep'");
25786
25787#ifdef FREECIV_JSON_CONNECTION
25788 field_addr.name = "tech_upkeep";
25789#endif /* FREECIV_JSON_CONNECTION */
25790
25791 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech_upkeep)) {
25792 RECEIVE_PACKET_FIELD_ERROR(tech_upkeep);
25793 }
25794 }
25795
25796 if (BV_ISSET(fields, 26)) {
25797 log_packet_detailed(" got field 'science_cost'");
25798
25799#ifdef FREECIV_JSON_CONNECTION
25800 field_addr.name = "science_cost";
25801#endif /* FREECIV_JSON_CONNECTION */
25802
25803 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->science_cost)) {
25804 RECEIVE_PACKET_FIELD_ERROR(science_cost);
25805 }
25806 }
25807
25808 real_packet->is_connected = BV_ISSET(fields, 27);
25809
25810 if (BV_ISSET(fields, 28)) {
25811 log_packet_detailed(" got field 'revolution_finishes'");
25812
25813#ifdef FREECIV_JSON_CONNECTION
25814 field_addr.name = "revolution_finishes";
25815#endif /* FREECIV_JSON_CONNECTION */
25816
25817 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->revolution_finishes)) {
25818 RECEIVE_PACKET_FIELD_ERROR(revolution_finishes);
25819 }
25820 }
25821
25822 if (BV_ISSET(fields, 29)) {
25823 log_packet_detailed(" got field 'ai_skill_level'");
25824
25825#ifdef FREECIV_JSON_CONNECTION
25826 field_addr.name = "ai_skill_level";
25827#endif /* FREECIV_JSON_CONNECTION */
25828
25829 {
25830 int readin;
25831
25832 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
25833 RECEIVE_PACKET_FIELD_ERROR(ai_skill_level);
25834 }
25835 real_packet->ai_skill_level = readin;
25836 }
25837 }
25838
25839 if (BV_ISSET(fields, 30)) {
25840 log_packet_detailed(" got field 'barbarian_type'");
25841
25842#ifdef FREECIV_JSON_CONNECTION
25843 field_addr.name = "barbarian_type";
25844#endif /* FREECIV_JSON_CONNECTION */
25845
25846 {
25847 int readin;
25848
25849 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
25850 RECEIVE_PACKET_FIELD_ERROR(barbarian_type);
25851 }
25852 real_packet->barbarian_type = readin;
25853 }
25854 }
25855
25856 if (BV_ISSET(fields, 31)) {
25857 log_packet_detailed(" got field 'gives_shared_vision'");
25858
25859#ifdef FREECIV_JSON_CONNECTION
25860 field_addr.name = "gives_shared_vision";
25861#endif /* FREECIV_JSON_CONNECTION */
25862
25863 if (!DIO_BV_GET(&din, &field_addr, real_packet->gives_shared_vision)) {
25864 RECEIVE_PACKET_FIELD_ERROR(gives_shared_vision);
25865 }
25866 }
25867
25868 if (BV_ISSET(fields, 32)) {
25869 log_packet_detailed(" got field 'gives_shared_tiles'");
25870
25871#ifdef FREECIV_JSON_CONNECTION
25872 field_addr.name = "gives_shared_tiles";
25873#endif /* FREECIV_JSON_CONNECTION */
25874
25875 if (!DIO_BV_GET(&din, &field_addr, real_packet->gives_shared_tiles)) {
25876 RECEIVE_PACKET_FIELD_ERROR(gives_shared_tiles);
25877 }
25878 }
25879
25880 if (BV_ISSET(fields, 33)) {
25881 log_packet_detailed(" got field 'history'");
25882
25883#ifdef FREECIV_JSON_CONNECTION
25884 field_addr.name = "history";
25885#endif /* FREECIV_JSON_CONNECTION */
25886
25887 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->history)) {
25888 RECEIVE_PACKET_FIELD_ERROR(history);
25889 }
25890 }
25891
25892 if (BV_ISSET(fields, 34)) {
25893 log_packet_detailed(" got field 'culture'");
25894
25895#ifdef FREECIV_JSON_CONNECTION
25896 field_addr.name = "culture";
25897#endif /* FREECIV_JSON_CONNECTION */
25898
25899 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->culture)) {
25900 RECEIVE_PACKET_FIELD_ERROR(culture);
25901 }
25902 }
25903
25904 if (BV_ISSET(fields, 35)) {
25905 log_packet_detailed(" got field 'love'");
25906
25907#ifdef FREECIV_JSON_CONNECTION
25908 field_addr.name = "love";
25909#endif /* FREECIV_JSON_CONNECTION */
25910
25911 {
25912 int i;
25913
25914
25915#ifdef FREECIV_JSON_CONNECTION
25916 /* Enter array. */
25917 field_addr.sub_location = plocation_elem_new(0);
25918#endif /* FREECIV_JSON_CONNECTION */
25919
25920 for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
25921#ifdef FREECIV_JSON_CONNECTION
25922 /* Next array element */
25923 field_addr.sub_location->number = i;
25924#endif /* FREECIV_JSON_CONNECTION */
25925
25926 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->love[i])) {
25927 RECEIVE_PACKET_FIELD_ERROR(love);
25928 }
25929 }
25930
25931#ifdef FREECIV_JSON_CONNECTION
25932 /* Exit array. */
25933 FC_FREE(field_addr.sub_location);
25934#endif /* FREECIV_JSON_CONNECTION */
25935 }
25936 }
25937
25938 real_packet->color_valid = BV_ISSET(fields, 36);
25939
25940 real_packet->color_changeable = BV_ISSET(fields, 37);
25941
25942 if (BV_ISSET(fields, 38)) {
25943 log_packet_detailed(" got field 'color_red'");
25944
25945#ifdef FREECIV_JSON_CONNECTION
25946 field_addr.name = "color_red";
25947#endif /* FREECIV_JSON_CONNECTION */
25948
25949 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_red)) {
25950 RECEIVE_PACKET_FIELD_ERROR(color_red);
25951 }
25952 }
25953
25954 if (BV_ISSET(fields, 39)) {
25955 log_packet_detailed(" got field 'color_green'");
25956
25957#ifdef FREECIV_JSON_CONNECTION
25958 field_addr.name = "color_green";
25959#endif /* FREECIV_JSON_CONNECTION */
25960
25961 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_green)) {
25962 RECEIVE_PACKET_FIELD_ERROR(color_green);
25963 }
25964 }
25965
25966 if (BV_ISSET(fields, 40)) {
25967 log_packet_detailed(" got field 'color_blue'");
25968
25969#ifdef FREECIV_JSON_CONNECTION
25970 field_addr.name = "color_blue";
25971#endif /* FREECIV_JSON_CONNECTION */
25972
25973 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_blue)) {
25974 RECEIVE_PACKET_FIELD_ERROR(color_blue);
25975 }
25976 }
25977
25978 if (BV_ISSET(fields, 41)) {
25979 log_packet_detailed(" got field 'flags'");
25980
25981#ifdef FREECIV_JSON_CONNECTION
25982 field_addr.name = "flags";
25983#endif /* FREECIV_JSON_CONNECTION */
25984
25985 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
25986 RECEIVE_PACKET_FIELD_ERROR(flags);
25987 }
25988 }
25989
25990 if (BV_ISSET(fields, 42)) {
25991 log_packet_detailed(" got field 'wonders'");
25992
25993#ifdef FREECIV_JSON_CONNECTION
25994 field_addr.name = "wonders";
25995#endif /* FREECIV_JSON_CONNECTION */
25996
25997 FC_STATIC_ASSERT(B_LAST <= MAX_UINT16, packet_array_too_long_wonders);
25998#ifdef FREECIV_JSON_CONNECTION
25999 /* Enter array (start at initial element). */
26000 field_addr.sub_location = plocation_elem_new(0);
26001 /* Enter diff array element (start at the index address). */
26002 field_addr.sub_location->sub_location = plocation_field_new("index");
26003#endif /* FREECIV_JSON_CONNECTION */
26004
26005 while (TRUE) {
26006 int i;
26007
26008 /* Read next index */
26009#if B_LAST <= MAX_UINT8
26010 if (!DIO_GET(uint8, &din, &field_addr, &i)) {
26011#else
26012 if (!DIO_GET(uint16, &din, &field_addr, &i)) {
26013#endif
26014 RECEIVE_PACKET_FIELD_ERROR(wonders);
26015 }
26016
26017 if (i == B_LAST) {
26018 break;
26019 }
26020 if (i > B_LAST) {
26021 RECEIVE_PACKET_FIELD_ERROR(wonders,
26022 ": unexpected index %d "
26023 "> length %d in array diff",
26024 i,
26025 B_LAST);
26026 }
26027
26028#ifdef FREECIV_JSON_CONNECTION
26029 /* Content address. */
26030 field_addr.sub_location->sub_location->name = "data";
26031#endif /* FREECIV_JSON_CONNECTION */
26032
26033 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->wonders[i])) {
26034 RECEIVE_PACKET_FIELD_ERROR(wonders);
26035 }
26036
26037#ifdef FREECIV_JSON_CONNECTION
26038 /* Move to the next diff array element. */
26039 field_addr.sub_location->number++;
26040 /* Back to the index address. */
26041 field_addr.sub_location->sub_location->name = "index";
26042#endif /* FREECIV_JSON_CONNECTION */
26043 }
26044
26045#ifdef FREECIV_JSON_CONNECTION
26046 /* Exit diff array element. */
26047 FC_FREE(field_addr.sub_location->sub_location);
26048 /* Exit array. */
26049 FC_FREE(field_addr.sub_location);
26050#endif /* FREECIV_JSON_CONNECTION */
26051 }
26052
26053 if (BV_ISSET(fields, 43)) {
26054 log_packet_detailed(" got field 'multip_count'");
26055
26056#ifdef FREECIV_JSON_CONNECTION
26057 field_addr.name = "multip_count";
26058#endif /* FREECIV_JSON_CONNECTION */
26059
26060 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->multip_count)) {
26061 RECEIVE_PACKET_FIELD_ERROR(multip_count);
26062 }
26063 }
26064
26065 if (BV_ISSET(fields, 44)) {
26066 log_packet_detailed(" got field 'multiplier'");
26067
26068#ifdef FREECIV_JSON_CONNECTION
26069 field_addr.name = "multiplier";
26070#endif /* FREECIV_JSON_CONNECTION */
26071
26072 {
26073 int i;
26074
26075 if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
26076 RECEIVE_PACKET_FIELD_ERROR(multiplier, ": array truncated");
26077 }
26078
26079#ifdef FREECIV_JSON_CONNECTION
26080 /* Enter array. */
26081 field_addr.sub_location = plocation_elem_new(0);
26082#endif /* FREECIV_JSON_CONNECTION */
26083
26084 for (i = 0; i < real_packet->multip_count; i++) {
26085#ifdef FREECIV_JSON_CONNECTION
26086 /* Next array element */
26087 field_addr.sub_location->number = i;
26088#endif /* FREECIV_JSON_CONNECTION */
26089
26090 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->multiplier[i])) {
26091 RECEIVE_PACKET_FIELD_ERROR(multiplier);
26092 }
26093 }
26094
26095#ifdef FREECIV_JSON_CONNECTION
26096 /* Exit array. */
26097 FC_FREE(field_addr.sub_location);
26098#endif /* FREECIV_JSON_CONNECTION */
26099 }
26100 }
26101
26102 if (BV_ISSET(fields, 45)) {
26103 log_packet_detailed(" got field 'multiplier_target'");
26104
26105#ifdef FREECIV_JSON_CONNECTION
26106 field_addr.name = "multiplier_target";
26107#endif /* FREECIV_JSON_CONNECTION */
26108
26109 {
26110 int i;
26111
26112 if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
26113 RECEIVE_PACKET_FIELD_ERROR(multiplier_target, ": array truncated");
26114 }
26115
26116#ifdef FREECIV_JSON_CONNECTION
26117 /* Enter array. */
26118 field_addr.sub_location = plocation_elem_new(0);
26119#endif /* FREECIV_JSON_CONNECTION */
26120
26121 for (i = 0; i < real_packet->multip_count; i++) {
26122#ifdef FREECIV_JSON_CONNECTION
26123 /* Next array element */
26124 field_addr.sub_location->number = i;
26125#endif /* FREECIV_JSON_CONNECTION */
26126
26127 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->multiplier_target[i])) {
26128 RECEIVE_PACKET_FIELD_ERROR(multiplier_target);
26129 }
26130 }
26131
26132#ifdef FREECIV_JSON_CONNECTION
26133 /* Exit array. */
26134 FC_FREE(field_addr.sub_location);
26135#endif /* FREECIV_JSON_CONNECTION */
26136 }
26137 }
26138
26139 if (BV_ISSET(fields, 46)) {
26140 log_packet_detailed(" got field 'multiplier_changed'");
26141
26142#ifdef FREECIV_JSON_CONNECTION
26143 field_addr.name = "multiplier_changed";
26144#endif /* FREECIV_JSON_CONNECTION */
26145
26146 {
26147 int i;
26148
26149 if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
26150 RECEIVE_PACKET_FIELD_ERROR(multiplier_changed, ": array truncated");
26151 }
26152
26153#ifdef FREECIV_JSON_CONNECTION
26154 /* Enter array. */
26155 field_addr.sub_location = plocation_elem_new(0);
26156#endif /* FREECIV_JSON_CONNECTION */
26157
26158 for (i = 0; i < real_packet->multip_count; i++) {
26159#ifdef FREECIV_JSON_CONNECTION
26160 /* Next array element */
26161 field_addr.sub_location->number = i;
26162#endif /* FREECIV_JSON_CONNECTION */
26163
26164 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->multiplier_changed[i])) {
26165 RECEIVE_PACKET_FIELD_ERROR(multiplier_changed);
26166 }
26167 }
26168
26169#ifdef FREECIV_JSON_CONNECTION
26170 /* Exit array. */
26171 FC_FREE(field_addr.sub_location);
26172#endif /* FREECIV_JSON_CONNECTION */
26173 }
26174 }
26175
26176 if (nullptr == old) {
26177 old = fc_malloc(sizeof(*old));
26178 init_packet_player_info(old);
26179 *old = *real_packet;
26180 genhash_insert(*hash, old, old);
26181 } else {
26182 *old = *real_packet;
26183 }
26184
26185#else /* FREECIV_DELTA_PROTOCOL */
26186#ifdef FREECIV_JSON_CONNECTION
26187 field_addr.name = "name";
26188#endif /* FREECIV_JSON_CONNECTION */
26189
26190 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
26191 RECEIVE_PACKET_FIELD_ERROR(name);
26192 }
26193
26194#ifdef FREECIV_JSON_CONNECTION
26195 field_addr.name = "username";
26196#endif /* FREECIV_JSON_CONNECTION */
26197
26198 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
26199 RECEIVE_PACKET_FIELD_ERROR(username);
26200 }
26201
26202#ifdef FREECIV_JSON_CONNECTION
26203 field_addr.name = "unassigned_user";
26204#endif /* FREECIV_JSON_CONNECTION */
26205
26206 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->unassigned_user)) {
26207 RECEIVE_PACKET_FIELD_ERROR(unassigned_user);
26208 }
26209
26210#ifdef FREECIV_JSON_CONNECTION
26211 field_addr.name = "score";
26212#endif /* FREECIV_JSON_CONNECTION */
26213
26214 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->score)) {
26215 RECEIVE_PACKET_FIELD_ERROR(score);
26216 }
26217
26218#ifdef FREECIV_JSON_CONNECTION
26219 field_addr.name = "is_male";
26220#endif /* FREECIV_JSON_CONNECTION */
26221
26222 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_male)) {
26223 RECEIVE_PACKET_FIELD_ERROR(is_male);
26224 }
26225
26226#ifdef FREECIV_JSON_CONNECTION
26227 field_addr.name = "was_created";
26228#endif /* FREECIV_JSON_CONNECTION */
26229
26230 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->was_created)) {
26231 RECEIVE_PACKET_FIELD_ERROR(was_created);
26232 }
26233
26234#ifdef FREECIV_JSON_CONNECTION
26235 field_addr.name = "government";
26236#endif /* FREECIV_JSON_CONNECTION */
26237
26238 {
26239 int readin;
26240
26241 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
26242 RECEIVE_PACKET_FIELD_ERROR(government);
26243 }
26244 real_packet->government = readin;
26245 }
26246
26247#ifdef FREECIV_JSON_CONNECTION
26248 field_addr.name = "target_government";
26249#endif /* FREECIV_JSON_CONNECTION */
26250
26251 {
26252 int readin;
26253
26254 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
26255 RECEIVE_PACKET_FIELD_ERROR(target_government);
26256 }
26257 real_packet->target_government = readin;
26258 }
26259
26260#ifdef FREECIV_JSON_CONNECTION
26261 field_addr.name = "real_embassy";
26262#endif /* FREECIV_JSON_CONNECTION */
26263
26264 if (!DIO_BV_GET(&din, &field_addr, real_packet->real_embassy)) {
26265 RECEIVE_PACKET_FIELD_ERROR(real_embassy);
26266 }
26267
26268#ifdef FREECIV_JSON_CONNECTION
26269 field_addr.name = "mood";
26270#endif /* FREECIV_JSON_CONNECTION */
26271
26272 {
26273 int readin;
26274
26275 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
26276 RECEIVE_PACKET_FIELD_ERROR(mood);
26277 }
26278 real_packet->mood = readin;
26279 }
26280
26281#ifdef FREECIV_JSON_CONNECTION
26282 field_addr.name = "style";
26283#endif /* FREECIV_JSON_CONNECTION */
26284
26285 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
26286 RECEIVE_PACKET_FIELD_ERROR(style);
26287 }
26288
26289#ifdef FREECIV_JSON_CONNECTION
26290 field_addr.name = "music_style";
26291#endif /* FREECIV_JSON_CONNECTION */
26292
26293 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->music_style)) {
26294 RECEIVE_PACKET_FIELD_ERROR(music_style);
26295 }
26296
26297#ifdef FREECIV_JSON_CONNECTION
26298 field_addr.name = "nation";
26299#endif /* FREECIV_JSON_CONNECTION */
26300
26301 {
26302 int readin;
26303
26304 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
26305 RECEIVE_PACKET_FIELD_ERROR(nation);
26306 }
26307 real_packet->nation = readin;
26308 }
26309
26310#ifdef FREECIV_JSON_CONNECTION
26311 field_addr.name = "team";
26312#endif /* FREECIV_JSON_CONNECTION */
26313
26314 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->team)) {
26315 RECEIVE_PACKET_FIELD_ERROR(team);
26316 }
26317
26318#ifdef FREECIV_JSON_CONNECTION
26319 field_addr.name = "is_ready";
26320#endif /* FREECIV_JSON_CONNECTION */
26321
26322 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_ready)) {
26323 RECEIVE_PACKET_FIELD_ERROR(is_ready);
26324 }
26325
26326#ifdef FREECIV_JSON_CONNECTION
26327 field_addr.name = "phase_done";
26328#endif /* FREECIV_JSON_CONNECTION */
26329
26330 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->phase_done)) {
26331 RECEIVE_PACKET_FIELD_ERROR(phase_done);
26332 }
26333
26334#ifdef FREECIV_JSON_CONNECTION
26335 field_addr.name = "nturns_idle";
26336#endif /* FREECIV_JSON_CONNECTION */
26337
26338 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nturns_idle)) {
26339 RECEIVE_PACKET_FIELD_ERROR(nturns_idle);
26340 }
26341
26342#ifdef FREECIV_JSON_CONNECTION
26343 field_addr.name = "turns_alive";
26344#endif /* FREECIV_JSON_CONNECTION */
26345
26346 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turns_alive)) {
26347 RECEIVE_PACKET_FIELD_ERROR(turns_alive);
26348 }
26349
26350#ifdef FREECIV_JSON_CONNECTION
26351 field_addr.name = "is_alive";
26352#endif /* FREECIV_JSON_CONNECTION */
26353
26354 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_alive)) {
26355 RECEIVE_PACKET_FIELD_ERROR(is_alive);
26356 }
26357
26358#ifdef FREECIV_JSON_CONNECTION
26359 field_addr.name = "autoselect_weight";
26360#endif /* FREECIV_JSON_CONNECTION */
26361
26362 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->autoselect_weight)) {
26363 RECEIVE_PACKET_FIELD_ERROR(autoselect_weight);
26364 }
26365
26366#ifdef FREECIV_JSON_CONNECTION
26367 field_addr.name = "gold";
26368#endif /* FREECIV_JSON_CONNECTION */
26369
26370 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->gold)) {
26371 RECEIVE_PACKET_FIELD_ERROR(gold);
26372 }
26373
26374#ifdef FREECIV_JSON_CONNECTION
26375 field_addr.name = "tax";
26376#endif /* FREECIV_JSON_CONNECTION */
26377
26378 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tax)) {
26379 RECEIVE_PACKET_FIELD_ERROR(tax);
26380 }
26381
26382#ifdef FREECIV_JSON_CONNECTION
26383 field_addr.name = "science";
26384#endif /* FREECIV_JSON_CONNECTION */
26385
26386 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->science)) {
26387 RECEIVE_PACKET_FIELD_ERROR(science);
26388 }
26389
26390#ifdef FREECIV_JSON_CONNECTION
26391 field_addr.name = "luxury";
26392#endif /* FREECIV_JSON_CONNECTION */
26393
26394 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->luxury)) {
26395 RECEIVE_PACKET_FIELD_ERROR(luxury);
26396 }
26397
26398#ifdef FREECIV_JSON_CONNECTION
26399 field_addr.name = "infrapoints";
26400#endif /* FREECIV_JSON_CONNECTION */
26401
26402 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->infrapoints)) {
26403 RECEIVE_PACKET_FIELD_ERROR(infrapoints);
26404 }
26405
26406#ifdef FREECIV_JSON_CONNECTION
26407 field_addr.name = "tech_upkeep";
26408#endif /* FREECIV_JSON_CONNECTION */
26409
26410 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech_upkeep)) {
26411 RECEIVE_PACKET_FIELD_ERROR(tech_upkeep);
26412 }
26413
26414#ifdef FREECIV_JSON_CONNECTION
26415 field_addr.name = "science_cost";
26416#endif /* FREECIV_JSON_CONNECTION */
26417
26418 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->science_cost)) {
26419 RECEIVE_PACKET_FIELD_ERROR(science_cost);
26420 }
26421
26422#ifdef FREECIV_JSON_CONNECTION
26423 field_addr.name = "is_connected";
26424#endif /* FREECIV_JSON_CONNECTION */
26425
26426 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_connected)) {
26427 RECEIVE_PACKET_FIELD_ERROR(is_connected);
26428 }
26429
26430#ifdef FREECIV_JSON_CONNECTION
26431 field_addr.name = "revolution_finishes";
26432#endif /* FREECIV_JSON_CONNECTION */
26433
26434 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->revolution_finishes)) {
26435 RECEIVE_PACKET_FIELD_ERROR(revolution_finishes);
26436 }
26437
26438#ifdef FREECIV_JSON_CONNECTION
26439 field_addr.name = "ai_skill_level";
26440#endif /* FREECIV_JSON_CONNECTION */
26441
26442 {
26443 int readin;
26444
26445 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
26446 RECEIVE_PACKET_FIELD_ERROR(ai_skill_level);
26447 }
26448 real_packet->ai_skill_level = readin;
26449 }
26450
26451#ifdef FREECIV_JSON_CONNECTION
26452 field_addr.name = "barbarian_type";
26453#endif /* FREECIV_JSON_CONNECTION */
26454
26455 {
26456 int readin;
26457
26458 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
26459 RECEIVE_PACKET_FIELD_ERROR(barbarian_type);
26460 }
26461 real_packet->barbarian_type = readin;
26462 }
26463
26464#ifdef FREECIV_JSON_CONNECTION
26465 field_addr.name = "gives_shared_vision";
26466#endif /* FREECIV_JSON_CONNECTION */
26467
26468 if (!DIO_BV_GET(&din, &field_addr, real_packet->gives_shared_vision)) {
26469 RECEIVE_PACKET_FIELD_ERROR(gives_shared_vision);
26470 }
26471
26472#ifdef FREECIV_JSON_CONNECTION
26473 field_addr.name = "gives_shared_tiles";
26474#endif /* FREECIV_JSON_CONNECTION */
26475
26476 if (!DIO_BV_GET(&din, &field_addr, real_packet->gives_shared_tiles)) {
26477 RECEIVE_PACKET_FIELD_ERROR(gives_shared_tiles);
26478 }
26479
26480#ifdef FREECIV_JSON_CONNECTION
26481 field_addr.name = "history";
26482#endif /* FREECIV_JSON_CONNECTION */
26483
26484 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->history)) {
26485 RECEIVE_PACKET_FIELD_ERROR(history);
26486 }
26487
26488#ifdef FREECIV_JSON_CONNECTION
26489 field_addr.name = "culture";
26490#endif /* FREECIV_JSON_CONNECTION */
26491
26492 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->culture)) {
26493 RECEIVE_PACKET_FIELD_ERROR(culture);
26494 }
26495
26496#ifdef FREECIV_JSON_CONNECTION
26497 field_addr.name = "love";
26498#endif /* FREECIV_JSON_CONNECTION */
26499
26500 {
26501 int i;
26502
26503
26504#ifdef FREECIV_JSON_CONNECTION
26505 /* Enter array. */
26506 field_addr.sub_location = plocation_elem_new(0);
26507#endif /* FREECIV_JSON_CONNECTION */
26508
26509 for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
26510#ifdef FREECIV_JSON_CONNECTION
26511 /* Next array element */
26512 field_addr.sub_location->number = i;
26513#endif /* FREECIV_JSON_CONNECTION */
26514
26515 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->love[i])) {
26516 RECEIVE_PACKET_FIELD_ERROR(love);
26517 }
26518 }
26519
26520#ifdef FREECIV_JSON_CONNECTION
26521 /* Exit array. */
26522 FC_FREE(field_addr.sub_location);
26523#endif /* FREECIV_JSON_CONNECTION */
26524 }
26525
26526#ifdef FREECIV_JSON_CONNECTION
26527 field_addr.name = "color_valid";
26528#endif /* FREECIV_JSON_CONNECTION */
26529
26530 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->color_valid)) {
26531 RECEIVE_PACKET_FIELD_ERROR(color_valid);
26532 }
26533
26534#ifdef FREECIV_JSON_CONNECTION
26535 field_addr.name = "color_changeable";
26536#endif /* FREECIV_JSON_CONNECTION */
26537
26538 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->color_changeable)) {
26539 RECEIVE_PACKET_FIELD_ERROR(color_changeable);
26540 }
26541
26542#ifdef FREECIV_JSON_CONNECTION
26543 field_addr.name = "color_red";
26544#endif /* FREECIV_JSON_CONNECTION */
26545
26546 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_red)) {
26547 RECEIVE_PACKET_FIELD_ERROR(color_red);
26548 }
26549
26550#ifdef FREECIV_JSON_CONNECTION
26551 field_addr.name = "color_green";
26552#endif /* FREECIV_JSON_CONNECTION */
26553
26554 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_green)) {
26555 RECEIVE_PACKET_FIELD_ERROR(color_green);
26556 }
26557
26558#ifdef FREECIV_JSON_CONNECTION
26559 field_addr.name = "color_blue";
26560#endif /* FREECIV_JSON_CONNECTION */
26561
26562 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_blue)) {
26563 RECEIVE_PACKET_FIELD_ERROR(color_blue);
26564 }
26565
26566#ifdef FREECIV_JSON_CONNECTION
26567 field_addr.name = "flags";
26568#endif /* FREECIV_JSON_CONNECTION */
26569
26570 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
26571 RECEIVE_PACKET_FIELD_ERROR(flags);
26572 }
26573
26574#ifdef FREECIV_JSON_CONNECTION
26575 field_addr.name = "wonders";
26576#endif /* FREECIV_JSON_CONNECTION */
26577
26578 {
26579 int i;
26580
26581
26582#ifdef FREECIV_JSON_CONNECTION
26583 /* Enter array. */
26584 field_addr.sub_location = plocation_elem_new(0);
26585#endif /* FREECIV_JSON_CONNECTION */
26586
26587 for (i = 0; i < B_LAST; i++) {
26588#ifdef FREECIV_JSON_CONNECTION
26589 /* Next array element */
26590 field_addr.sub_location->number = i;
26591#endif /* FREECIV_JSON_CONNECTION */
26592
26593 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->wonders[i])) {
26594 RECEIVE_PACKET_FIELD_ERROR(wonders);
26595 }
26596 }
26597
26598#ifdef FREECIV_JSON_CONNECTION
26599 /* Exit array. */
26600 FC_FREE(field_addr.sub_location);
26601#endif /* FREECIV_JSON_CONNECTION */
26602 }
26603
26604#ifdef FREECIV_JSON_CONNECTION
26605 field_addr.name = "multip_count";
26606#endif /* FREECIV_JSON_CONNECTION */
26607
26608 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->multip_count)) {
26609 RECEIVE_PACKET_FIELD_ERROR(multip_count);
26610 }
26611
26612#ifdef FREECIV_JSON_CONNECTION
26613 field_addr.name = "multiplier";
26614#endif /* FREECIV_JSON_CONNECTION */
26615
26616 {
26617 int i;
26618
26619 if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
26620 RECEIVE_PACKET_FIELD_ERROR(multiplier, ": array truncated");
26621 }
26622
26623#ifdef FREECIV_JSON_CONNECTION
26624 /* Enter array. */
26625 field_addr.sub_location = plocation_elem_new(0);
26626#endif /* FREECIV_JSON_CONNECTION */
26627
26628 for (i = 0; i < real_packet->multip_count; i++) {
26629#ifdef FREECIV_JSON_CONNECTION
26630 /* Next array element */
26631 field_addr.sub_location->number = i;
26632#endif /* FREECIV_JSON_CONNECTION */
26633
26634 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->multiplier[i])) {
26635 RECEIVE_PACKET_FIELD_ERROR(multiplier);
26636 }
26637 }
26638
26639#ifdef FREECIV_JSON_CONNECTION
26640 /* Exit array. */
26641 FC_FREE(field_addr.sub_location);
26642#endif /* FREECIV_JSON_CONNECTION */
26643 }
26644
26645#ifdef FREECIV_JSON_CONNECTION
26646 field_addr.name = "multiplier_target";
26647#endif /* FREECIV_JSON_CONNECTION */
26648
26649 {
26650 int i;
26651
26652 if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
26653 RECEIVE_PACKET_FIELD_ERROR(multiplier_target, ": array truncated");
26654 }
26655
26656#ifdef FREECIV_JSON_CONNECTION
26657 /* Enter array. */
26658 field_addr.sub_location = plocation_elem_new(0);
26659#endif /* FREECIV_JSON_CONNECTION */
26660
26661 for (i = 0; i < real_packet->multip_count; i++) {
26662#ifdef FREECIV_JSON_CONNECTION
26663 /* Next array element */
26664 field_addr.sub_location->number = i;
26665#endif /* FREECIV_JSON_CONNECTION */
26666
26667 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->multiplier_target[i])) {
26668 RECEIVE_PACKET_FIELD_ERROR(multiplier_target);
26669 }
26670 }
26671
26672#ifdef FREECIV_JSON_CONNECTION
26673 /* Exit array. */
26674 FC_FREE(field_addr.sub_location);
26675#endif /* FREECIV_JSON_CONNECTION */
26676 }
26677
26678#ifdef FREECIV_JSON_CONNECTION
26679 field_addr.name = "multiplier_changed";
26680#endif /* FREECIV_JSON_CONNECTION */
26681
26682 {
26683 int i;
26684
26685 if (real_packet->multip_count > MAX_NUM_MULTIPLIERS) {
26686 RECEIVE_PACKET_FIELD_ERROR(multiplier_changed, ": array truncated");
26687 }
26688
26689#ifdef FREECIV_JSON_CONNECTION
26690 /* Enter array. */
26691 field_addr.sub_location = plocation_elem_new(0);
26692#endif /* FREECIV_JSON_CONNECTION */
26693
26694 for (i = 0; i < real_packet->multip_count; i++) {
26695#ifdef FREECIV_JSON_CONNECTION
26696 /* Next array element */
26697 field_addr.sub_location->number = i;
26698#endif /* FREECIV_JSON_CONNECTION */
26699
26700 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->multiplier_changed[i])) {
26701 RECEIVE_PACKET_FIELD_ERROR(multiplier_changed);
26702 }
26703 }
26704
26705#ifdef FREECIV_JSON_CONNECTION
26706 /* Exit array. */
26707 FC_FREE(field_addr.sub_location);
26708#endif /* FREECIV_JSON_CONNECTION */
26709 }
26710#endif /* FREECIV_DELTA_PROTOCOL */
26711
26712 RECEIVE_PACKET_END(real_packet);
26713#undef FREE_PACKET_STRUCT
26714}
26715
26716 static int send_packet_player_info_100(struct connection *pc, const struct packet_player_info *packet)
26717{
26718 const struct packet_player_info *real_packet = packet;
26719 int e;
26720 SEND_PACKET_START(PACKET_PLAYER_INFO);
26721
26722 log_packet_detailed("packet_player_info_100: sending info about (%d)",
26723 real_packet->playerno);
26724
26725#ifdef FREECIV_DELTA_PROTOCOL
26726 packet_player_info_100_fields fields;
26727 struct packet_player_info *old;
26728 bool differ;
26729 int different = 0;
26730 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_INFO;
26731
26732 if (nullptr == *hash) {
26733 *hash = genhash_new_full(hash_packet_player_info_100, cmp_packet_player_info_100,
26734 nullptr, nullptr, nullptr, destroy_packet_player_info);
26735 }
26736 BV_CLR_ALL(fields);
26737
26738 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
26739 old = fc_malloc(sizeof(*old));
26740 /* temporary bitcopy just to insert correctly */
26741 *old = *real_packet;
26742 genhash_insert(*hash, old, old);
26743 init_packet_player_info(old);
26744 different = 1; /* Force to send. */
26745 }
26746
26747 differ = (strcmp(old->name, real_packet->name) != 0);
26748 if (differ) {
26749 different++;
26750 BV_SET(fields, 0);
26751 }
26752
26753 differ = (strcmp(old->username, real_packet->username) != 0);
26754 if (differ) {
26755 different++;
26756 BV_SET(fields, 1);
26757 }
26758
26759 differ = (old->unassigned_user != real_packet->unassigned_user);
26760 if (differ) {
26761 different++;
26762 }
26763 /* folded into head */
26764 if (real_packet->unassigned_user) {
26765 BV_SET(fields, 2);
26766 }
26767
26768 differ = (old->score != real_packet->score);
26769 if (differ) {
26770 different++;
26771 BV_SET(fields, 3);
26772 }
26773
26774 differ = (old->is_male != real_packet->is_male);
26775 if (differ) {
26776 different++;
26777 }
26778 /* folded into head */
26779 if (real_packet->is_male) {
26780 BV_SET(fields, 4);
26781 }
26782
26783 differ = (old->was_created != real_packet->was_created);
26784 if (differ) {
26785 different++;
26786 }
26787 /* folded into head */
26788 if (real_packet->was_created) {
26789 BV_SET(fields, 5);
26790 }
26791
26792 differ = (old->government != real_packet->government);
26793 if (differ) {
26794 different++;
26795 BV_SET(fields, 6);
26796 }
26797
26798 differ = (old->target_government != real_packet->target_government);
26799 if (differ) {
26800 different++;
26801 BV_SET(fields, 7);
26802 }
26803
26804 differ = !BV_ARE_EQUAL(old->real_embassy, real_packet->real_embassy);
26805 if (differ) {
26806 different++;
26807 BV_SET(fields, 8);
26808 }
26809
26810 differ = (old->mood != real_packet->mood);
26811 if (differ) {
26812 different++;
26813 BV_SET(fields, 9);
26814 }
26815
26816 differ = (old->style != real_packet->style);
26817 if (differ) {
26818 different++;
26819 BV_SET(fields, 10);
26820 }
26821
26822 differ = (old->music_style != real_packet->music_style);
26823 if (differ) {
26824 different++;
26825 BV_SET(fields, 11);
26826 }
26827
26828 differ = (old->nation != real_packet->nation);
26829 if (differ) {
26830 different++;
26831 BV_SET(fields, 12);
26832 }
26833
26834 differ = (old->team != real_packet->team);
26835 if (differ) {
26836 different++;
26837 BV_SET(fields, 13);
26838 }
26839
26840 differ = (old->is_ready != real_packet->is_ready);
26841 if (differ) {
26842 different++;
26843 }
26844 /* folded into head */
26845 if (real_packet->is_ready) {
26846 BV_SET(fields, 14);
26847 }
26848
26849 differ = (old->phase_done != real_packet->phase_done);
26850 if (differ) {
26851 different++;
26852 }
26853 /* folded into head */
26854 if (real_packet->phase_done) {
26855 BV_SET(fields, 15);
26856 }
26857
26858 differ = (old->nturns_idle != real_packet->nturns_idle);
26859 if (differ) {
26860 different++;
26861 BV_SET(fields, 16);
26862 }
26863
26864 differ = (old->turns_alive != real_packet->turns_alive);
26865 if (differ) {
26866 different++;
26867 BV_SET(fields, 17);
26868 }
26869
26870 differ = (old->is_alive != real_packet->is_alive);
26871 if (differ) {
26872 different++;
26873 }
26874 /* folded into head */
26875 if (real_packet->is_alive) {
26876 BV_SET(fields, 18);
26877 }
26878
26879 differ = (old->autoselect_weight != real_packet->autoselect_weight);
26880 if (differ) {
26881 different++;
26882 BV_SET(fields, 19);
26883 }
26884
26885 differ = (old->gold != real_packet->gold);
26886 if (differ) {
26887 different++;
26888 BV_SET(fields, 20);
26889 }
26890
26891 differ = (old->tax != real_packet->tax);
26892 if (differ) {
26893 different++;
26894 BV_SET(fields, 21);
26895 }
26896
26897 differ = (old->science != real_packet->science);
26898 if (differ) {
26899 different++;
26900 BV_SET(fields, 22);
26901 }
26902
26903 differ = (old->luxury != real_packet->luxury);
26904 if (differ) {
26905 different++;
26906 BV_SET(fields, 23);
26907 }
26908
26909 differ = (old->infrapoints != real_packet->infrapoints);
26910 if (differ) {
26911 different++;
26912 BV_SET(fields, 24);
26913 }
26914
26915 differ = (old->tech_upkeep != real_packet->tech_upkeep);
26916 if (differ) {
26917 different++;
26918 BV_SET(fields, 25);
26919 }
26920
26921 differ = (old->science_cost != real_packet->science_cost);
26922 if (differ) {
26923 different++;
26924 BV_SET(fields, 26);
26925 }
26926
26927 differ = (old->is_connected != real_packet->is_connected);
26928 if (differ) {
26929 different++;
26930 }
26931 /* folded into head */
26932 if (real_packet->is_connected) {
26933 BV_SET(fields, 27);
26934 }
26935
26936 differ = (old->revolution_finishes != real_packet->revolution_finishes);
26937 if (differ) {
26938 different++;
26939 BV_SET(fields, 28);
26940 }
26941
26942 differ = (old->ai_skill_level != real_packet->ai_skill_level);
26943 if (differ) {
26944 different++;
26945 BV_SET(fields, 29);
26946 }
26947
26948 differ = (old->barbarian_type != real_packet->barbarian_type);
26949 if (differ) {
26950 different++;
26951 BV_SET(fields, 30);
26952 }
26953
26954 differ = !BV_ARE_EQUAL(old->gives_shared_vision, real_packet->gives_shared_vision);
26955 if (differ) {
26956 different++;
26957 BV_SET(fields, 31);
26958 }
26959
26960 differ = !BV_ARE_EQUAL(old->gives_shared_tiles, real_packet->gives_shared_tiles);
26961 if (differ) {
26962 different++;
26963 BV_SET(fields, 32);
26964 }
26965
26966 differ = (old->history != real_packet->history);
26967 if (differ) {
26968 different++;
26969 BV_SET(fields, 33);
26970 }
26971
26972 differ = (old->culture != real_packet->culture);
26973 if (differ) {
26974 different++;
26975 BV_SET(fields, 34);
26976 }
26977
26978 differ = FALSE;
26979 {
26980 int i;
26981
26982 for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
26983 differ = (old->love[i] != real_packet->love[i]);
26984 if (differ) {
26985 break;
26986 }
26987 }
26988 }
26989 if (differ) {
26990 different++;
26991 BV_SET(fields, 35);
26992 }
26993
26994 differ = (old->color_valid != real_packet->color_valid);
26995 if (differ) {
26996 different++;
26997 }
26998 /* folded into head */
26999 if (real_packet->color_valid) {
27000 BV_SET(fields, 36);
27001 }
27002
27003 differ = (old->color_changeable != real_packet->color_changeable);
27004 if (differ) {
27005 different++;
27006 }
27007 /* folded into head */
27008 if (real_packet->color_changeable) {
27009 BV_SET(fields, 37);
27010 }
27011
27012 differ = (old->color_red != real_packet->color_red);
27013 if (differ) {
27014 different++;
27015 BV_SET(fields, 38);
27016 }
27017
27018 differ = (old->color_green != real_packet->color_green);
27019 if (differ) {
27020 different++;
27021 BV_SET(fields, 39);
27022 }
27023
27024 differ = (old->color_blue != real_packet->color_blue);
27025 if (differ) {
27026 different++;
27027 BV_SET(fields, 40);
27028 }
27029
27030 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
27031 if (differ) {
27032 different++;
27033 BV_SET(fields, 41);
27034 }
27035
27036 differ = FALSE;
27037 {
27038 int i;
27039
27040 for (i = 0; i < B_LAST; i++) {
27041 differ = (old->wonders[i] != real_packet->wonders[i]);
27042 if (differ) {
27043 break;
27044 }
27045 }
27046 }
27047 if (differ) {
27048 different++;
27049 BV_SET(fields, 42);
27050 }
27051
27052 differ = (old->multip_count != real_packet->multip_count);
27053 if (differ) {
27054 different++;
27055 BV_SET(fields, 43);
27056 }
27057
27058 differ = (old->multip_count != real_packet->multip_count);
27059 if (!differ) {
27060 int i;
27061
27062 for (i = 0; i < old->multip_count; i++) {
27063 differ = (old->multiplier[i] != real_packet->multiplier[i]);
27064 if (differ) {
27065 break;
27066 }
27067 }
27068 }
27069 if (differ) {
27070 different++;
27071 BV_SET(fields, 44);
27072 }
27073
27074 differ = (old->multip_count != real_packet->multip_count);
27075 if (!differ) {
27076 int i;
27077
27078 for (i = 0; i < old->multip_count; i++) {
27079 differ = (old->multiplier_target[i] != real_packet->multiplier_target[i]);
27080 if (differ) {
27081 break;
27082 }
27083 }
27084 }
27085 if (differ) {
27086 different++;
27087 BV_SET(fields, 45);
27088 }
27089
27090 differ = (old->multip_count != real_packet->multip_count);
27091 if (!differ) {
27092 int i;
27093
27094 for (i = 0; i < old->multip_count; i++) {
27095 differ = (old->multiplier_changed[i] != real_packet->multiplier_changed[i]);
27096 if (differ) {
27097 break;
27098 }
27099 }
27100 }
27101 if (differ) {
27102 different++;
27103 BV_SET(fields, 46);
27104 }
27105
27106 if (different == 0) {
27107 log_packet_detailed(" no change -> discard");
27108 SEND_PACKET_DISCARD();
27109 }
27110#endif /* FREECIV_DELTA_PROTOCOL */
27111
27112#ifdef FREECIV_JSON_CONNECTION
27113 struct plocation field_addr;
27114 {
27115 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
27116 field_addr = *field_addr_tmp;
27117 FC_FREE(field_addr_tmp);
27118 }
27119#endif /* FREECIV_JSON_CONNECTION */
27120
27121#ifdef FREECIV_JSON_CONNECTION
27122 field_addr.name = "playerno";
27123#endif /* FREECIV_JSON_CONNECTION */
27124 e = 0;
27125
27126 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->playerno);
27127
27128 if (e) {
27129 log_packet_detailed("'playerno' field error detected");
27130 }
27131
27132#ifdef FREECIV_DELTA_PROTOCOL
27133#ifdef FREECIV_JSON_CONNECTION
27134 field_addr.name = "fields";
27135#endif /* FREECIV_JSON_CONNECTION */
27136 e = 0;
27137 e |= DIO_BV_PUT(&dout, &field_addr, fields);
27138 if (e) {
27139 log_packet_detailed("fields bitvector error detected");
27140 }
27141
27142 if (BV_ISSET(fields, 0)) {
27143 log_packet_detailed(" field 'name' has changed");
27144
27145#ifdef FREECIV_JSON_CONNECTION
27146 field_addr.name = "name";
27147#endif /* FREECIV_JSON_CONNECTION */
27148 e = 0;
27149
27150 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
27151
27152 if (e) {
27153 log_packet_detailed("'name' field error detected");
27154 }
27155 }
27156
27157 if (BV_ISSET(fields, 1)) {
27158 log_packet_detailed(" field 'username' has changed");
27159
27160#ifdef FREECIV_JSON_CONNECTION
27161 field_addr.name = "username";
27162#endif /* FREECIV_JSON_CONNECTION */
27163 e = 0;
27164
27165 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
27166
27167 if (e) {
27168 log_packet_detailed("'username' field error detected");
27169 }
27170 }
27171
27172 /* field 2 is folded into the header */
27173
27174 if (BV_ISSET(fields, 3)) {
27175 log_packet_detailed(" field 'score' has changed");
27176
27177#ifdef FREECIV_JSON_CONNECTION
27178 field_addr.name = "score";
27179#endif /* FREECIV_JSON_CONNECTION */
27180 e = 0;
27181
27182 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->score);
27183
27184 if (e) {
27185 log_packet_detailed("'score' field error detected");
27186 }
27187 }
27188
27189 /* field 4 is folded into the header */
27190
27191 /* field 5 is folded into the header */
27192
27193 if (BV_ISSET(fields, 6)) {
27194 log_packet_detailed(" field 'government' has changed");
27195
27196#ifdef FREECIV_JSON_CONNECTION
27197 field_addr.name = "government";
27198#endif /* FREECIV_JSON_CONNECTION */
27199 e = 0;
27200
27201 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government);
27202
27203 if (e) {
27204 log_packet_detailed("'government' field error detected");
27205 }
27206 }
27207
27208 if (BV_ISSET(fields, 7)) {
27209 log_packet_detailed(" field 'target_government' has changed");
27210
27211#ifdef FREECIV_JSON_CONNECTION
27212 field_addr.name = "target_government";
27213#endif /* FREECIV_JSON_CONNECTION */
27214 e = 0;
27215
27216 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_government);
27217
27218 if (e) {
27219 log_packet_detailed("'target_government' field error detected");
27220 }
27221 }
27222
27223 if (BV_ISSET(fields, 8)) {
27224 log_packet_detailed(" field 'real_embassy' has changed");
27225
27226#ifdef FREECIV_JSON_CONNECTION
27227 field_addr.name = "real_embassy";
27228#endif /* FREECIV_JSON_CONNECTION */
27229 e = 0;
27230
27231 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->real_embassy);
27232
27233 if (e) {
27234 log_packet_detailed("'real_embassy' field error detected");
27235 }
27236 }
27237
27238 if (BV_ISSET(fields, 9)) {
27239 log_packet_detailed(" field 'mood' has changed");
27240
27241#ifdef FREECIV_JSON_CONNECTION
27242 field_addr.name = "mood";
27243#endif /* FREECIV_JSON_CONNECTION */
27244 e = 0;
27245
27246 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->mood);
27247
27248 if (e) {
27249 log_packet_detailed("'mood' field error detected");
27250 }
27251 }
27252
27253 if (BV_ISSET(fields, 10)) {
27254 log_packet_detailed(" field 'style' has changed");
27255
27256#ifdef FREECIV_JSON_CONNECTION
27257 field_addr.name = "style";
27258#endif /* FREECIV_JSON_CONNECTION */
27259 e = 0;
27260
27261 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
27262
27263 if (e) {
27264 log_packet_detailed("'style' field error detected");
27265 }
27266 }
27267
27268 if (BV_ISSET(fields, 11)) {
27269 log_packet_detailed(" field 'music_style' has changed");
27270
27271#ifdef FREECIV_JSON_CONNECTION
27272 field_addr.name = "music_style";
27273#endif /* FREECIV_JSON_CONNECTION */
27274 e = 0;
27275
27276 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->music_style);
27277
27278 if (e) {
27279 log_packet_detailed("'music_style' field error detected");
27280 }
27281 }
27282
27283 if (BV_ISSET(fields, 12)) {
27284 log_packet_detailed(" field 'nation' has changed");
27285
27286#ifdef FREECIV_JSON_CONNECTION
27287 field_addr.name = "nation";
27288#endif /* FREECIV_JSON_CONNECTION */
27289 e = 0;
27290
27291 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation);
27292
27293 if (e) {
27294 log_packet_detailed("'nation' field error detected");
27295 }
27296 }
27297
27298 if (BV_ISSET(fields, 13)) {
27299 log_packet_detailed(" field 'team' has changed");
27300
27301#ifdef FREECIV_JSON_CONNECTION
27302 field_addr.name = "team";
27303#endif /* FREECIV_JSON_CONNECTION */
27304 e = 0;
27305
27306 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->team);
27307
27308 if (e) {
27309 log_packet_detailed("'team' field error detected");
27310 }
27311 }
27312
27313 /* field 14 is folded into the header */
27314
27315 /* field 15 is folded into the header */
27316
27317 if (BV_ISSET(fields, 16)) {
27318 log_packet_detailed(" field 'nturns_idle' has changed");
27319
27320#ifdef FREECIV_JSON_CONNECTION
27321 field_addr.name = "nturns_idle";
27322#endif /* FREECIV_JSON_CONNECTION */
27323 e = 0;
27324
27325 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nturns_idle);
27326
27327 if (e) {
27328 log_packet_detailed("'nturns_idle' field error detected");
27329 }
27330 }
27331
27332 if (BV_ISSET(fields, 17)) {
27333 log_packet_detailed(" field 'turns_alive' has changed");
27334
27335#ifdef FREECIV_JSON_CONNECTION
27336 field_addr.name = "turns_alive";
27337#endif /* FREECIV_JSON_CONNECTION */
27338 e = 0;
27339
27340 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turns_alive);
27341
27342 if (e) {
27343 log_packet_detailed("'turns_alive' field error detected");
27344 }
27345 }
27346
27347 /* field 18 is folded into the header */
27348
27349 if (BV_ISSET(fields, 19)) {
27350 log_packet_detailed(" field 'autoselect_weight' has changed");
27351
27352#ifdef FREECIV_JSON_CONNECTION
27353 field_addr.name = "autoselect_weight";
27354#endif /* FREECIV_JSON_CONNECTION */
27355 e = 0;
27356
27357 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->autoselect_weight);
27358
27359 if (e) {
27360 log_packet_detailed("'autoselect_weight' field error detected");
27361 }
27362 }
27363
27364 if (BV_ISSET(fields, 20)) {
27365 log_packet_detailed(" field 'gold' has changed");
27366
27367#ifdef FREECIV_JSON_CONNECTION
27368 field_addr.name = "gold";
27369#endif /* FREECIV_JSON_CONNECTION */
27370 e = 0;
27371
27372 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->gold);
27373
27374 if (e) {
27375 log_packet_detailed("'gold' field error detected");
27376 }
27377 }
27378
27379 if (BV_ISSET(fields, 21)) {
27380 log_packet_detailed(" field 'tax' has changed");
27381
27382#ifdef FREECIV_JSON_CONNECTION
27383 field_addr.name = "tax";
27384#endif /* FREECIV_JSON_CONNECTION */
27385 e = 0;
27386
27387 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tax);
27388
27389 if (e) {
27390 log_packet_detailed("'tax' field error detected");
27391 }
27392 }
27393
27394 if (BV_ISSET(fields, 22)) {
27395 log_packet_detailed(" field 'science' has changed");
27396
27397#ifdef FREECIV_JSON_CONNECTION
27398 field_addr.name = "science";
27399#endif /* FREECIV_JSON_CONNECTION */
27400 e = 0;
27401
27402 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->science);
27403
27404 if (e) {
27405 log_packet_detailed("'science' field error detected");
27406 }
27407 }
27408
27409 if (BV_ISSET(fields, 23)) {
27410 log_packet_detailed(" field 'luxury' has changed");
27411
27412#ifdef FREECIV_JSON_CONNECTION
27413 field_addr.name = "luxury";
27414#endif /* FREECIV_JSON_CONNECTION */
27415 e = 0;
27416
27417 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->luxury);
27418
27419 if (e) {
27420 log_packet_detailed("'luxury' field error detected");
27421 }
27422 }
27423
27424 if (BV_ISSET(fields, 24)) {
27425 log_packet_detailed(" field 'infrapoints' has changed");
27426
27427#ifdef FREECIV_JSON_CONNECTION
27428 field_addr.name = "infrapoints";
27429#endif /* FREECIV_JSON_CONNECTION */
27430 e = 0;
27431
27432 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->infrapoints);
27433
27434 if (e) {
27435 log_packet_detailed("'infrapoints' field error detected");
27436 }
27437 }
27438
27439 if (BV_ISSET(fields, 25)) {
27440 log_packet_detailed(" field 'tech_upkeep' has changed");
27441
27442#ifdef FREECIV_JSON_CONNECTION
27443 field_addr.name = "tech_upkeep";
27444#endif /* FREECIV_JSON_CONNECTION */
27445 e = 0;
27446
27447 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech_upkeep);
27448
27449 if (e) {
27450 log_packet_detailed("'tech_upkeep' field error detected");
27451 }
27452 }
27453
27454 if (BV_ISSET(fields, 26)) {
27455 log_packet_detailed(" field 'science_cost' has changed");
27456
27457#ifdef FREECIV_JSON_CONNECTION
27458 field_addr.name = "science_cost";
27459#endif /* FREECIV_JSON_CONNECTION */
27460 e = 0;
27461
27462 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->science_cost);
27463
27464 if (e) {
27465 log_packet_detailed("'science_cost' field error detected");
27466 }
27467 }
27468
27469 /* field 27 is folded into the header */
27470
27471 if (BV_ISSET(fields, 28)) {
27472 log_packet_detailed(" field 'revolution_finishes' has changed");
27473
27474#ifdef FREECIV_JSON_CONNECTION
27475 field_addr.name = "revolution_finishes";
27476#endif /* FREECIV_JSON_CONNECTION */
27477 e = 0;
27478
27479 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->revolution_finishes);
27480
27481 if (e) {
27482 log_packet_detailed("'revolution_finishes' field error detected");
27483 }
27484 }
27485
27486 if (BV_ISSET(fields, 29)) {
27487 log_packet_detailed(" field 'ai_skill_level' has changed");
27488
27489#ifdef FREECIV_JSON_CONNECTION
27490 field_addr.name = "ai_skill_level";
27491#endif /* FREECIV_JSON_CONNECTION */
27492 e = 0;
27493
27494 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ai_skill_level);
27495
27496 if (e) {
27497 log_packet_detailed("'ai_skill_level' field error detected");
27498 }
27499 }
27500
27501 if (BV_ISSET(fields, 30)) {
27502 log_packet_detailed(" field 'barbarian_type' has changed");
27503
27504#ifdef FREECIV_JSON_CONNECTION
27505 field_addr.name = "barbarian_type";
27506#endif /* FREECIV_JSON_CONNECTION */
27507 e = 0;
27508
27509 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->barbarian_type);
27510
27511 if (e) {
27512 log_packet_detailed("'barbarian_type' field error detected");
27513 }
27514 }
27515
27516 if (BV_ISSET(fields, 31)) {
27517 log_packet_detailed(" field 'gives_shared_vision' has changed");
27518
27519#ifdef FREECIV_JSON_CONNECTION
27520 field_addr.name = "gives_shared_vision";
27521#endif /* FREECIV_JSON_CONNECTION */
27522 e = 0;
27523
27524 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->gives_shared_vision);
27525
27526 if (e) {
27527 log_packet_detailed("'gives_shared_vision' field error detected");
27528 }
27529 }
27530
27531 if (BV_ISSET(fields, 32)) {
27532 log_packet_detailed(" field 'gives_shared_tiles' has changed");
27533
27534#ifdef FREECIV_JSON_CONNECTION
27535 field_addr.name = "gives_shared_tiles";
27536#endif /* FREECIV_JSON_CONNECTION */
27537 e = 0;
27538
27539 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->gives_shared_tiles);
27540
27541 if (e) {
27542 log_packet_detailed("'gives_shared_tiles' field error detected");
27543 }
27544 }
27545
27546 if (BV_ISSET(fields, 33)) {
27547 log_packet_detailed(" field 'history' has changed");
27548
27549#ifdef FREECIV_JSON_CONNECTION
27550 field_addr.name = "history";
27551#endif /* FREECIV_JSON_CONNECTION */
27552 e = 0;
27553
27554 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->history);
27555
27556 if (e) {
27557 log_packet_detailed("'history' field error detected");
27558 }
27559 }
27560
27561 if (BV_ISSET(fields, 34)) {
27562 log_packet_detailed(" field 'culture' has changed");
27563
27564#ifdef FREECIV_JSON_CONNECTION
27565 field_addr.name = "culture";
27566#endif /* FREECIV_JSON_CONNECTION */
27567 e = 0;
27568
27569 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->culture);
27570
27571 if (e) {
27572 log_packet_detailed("'culture' field error detected");
27573 }
27574 }
27575
27576 if (BV_ISSET(fields, 35)) {
27577 log_packet_detailed(" field 'love' has changed");
27578
27579#ifdef FREECIV_JSON_CONNECTION
27580 field_addr.name = "love";
27581#endif /* FREECIV_JSON_CONNECTION */
27582 e = 0;
27583
27584 {
27585 int i;
27586
27587#ifdef FREECIV_JSON_CONNECTION
27588 /* Create the array. */
27589 e |= DIO_PUT(farray, &dout, &field_addr, MAX_NUM_PLAYER_SLOTS);
27590
27591 /* Enter array. */
27592 field_addr.sub_location = plocation_elem_new(0);
27593#endif /* FREECIV_JSON_CONNECTION */
27594
27595 for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
27596#ifdef FREECIV_JSON_CONNECTION
27597 /* Next array element. */
27598 field_addr.sub_location->number = i;
27599#endif /* FREECIV_JSON_CONNECTION */
27600
27601 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->love[i]);
27602 }
27603
27604#ifdef FREECIV_JSON_CONNECTION
27605 /* Exit array. */
27606 FC_FREE(field_addr.sub_location);
27607#endif /* FREECIV_JSON_CONNECTION */
27608 }
27609
27610 if (e) {
27611 log_packet_detailed("'love' field error detected");
27612 }
27613 }
27614
27615 /* field 36 is folded into the header */
27616
27617 /* field 37 is folded into the header */
27618
27619 if (BV_ISSET(fields, 38)) {
27620 log_packet_detailed(" field 'color_red' has changed");
27621
27622#ifdef FREECIV_JSON_CONNECTION
27623 field_addr.name = "color_red";
27624#endif /* FREECIV_JSON_CONNECTION */
27625 e = 0;
27626
27627 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_red);
27628
27629 if (e) {
27630 log_packet_detailed("'color_red' field error detected");
27631 }
27632 }
27633
27634 if (BV_ISSET(fields, 39)) {
27635 log_packet_detailed(" field 'color_green' has changed");
27636
27637#ifdef FREECIV_JSON_CONNECTION
27638 field_addr.name = "color_green";
27639#endif /* FREECIV_JSON_CONNECTION */
27640 e = 0;
27641
27642 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_green);
27643
27644 if (e) {
27645 log_packet_detailed("'color_green' field error detected");
27646 }
27647 }
27648
27649 if (BV_ISSET(fields, 40)) {
27650 log_packet_detailed(" field 'color_blue' has changed");
27651
27652#ifdef FREECIV_JSON_CONNECTION
27653 field_addr.name = "color_blue";
27654#endif /* FREECIV_JSON_CONNECTION */
27655 e = 0;
27656
27657 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_blue);
27658
27659 if (e) {
27660 log_packet_detailed("'color_blue' field error detected");
27661 }
27662 }
27663
27664 if (BV_ISSET(fields, 41)) {
27665 log_packet_detailed(" field 'flags' has changed");
27666
27667#ifdef FREECIV_JSON_CONNECTION
27668 field_addr.name = "flags";
27669#endif /* FREECIV_JSON_CONNECTION */
27670 e = 0;
27671
27672 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
27673
27674 if (e) {
27675 log_packet_detailed("'flags' field error detected");
27676 }
27677 }
27678
27679 if (BV_ISSET(fields, 42)) {
27680 log_packet_detailed(" field 'wonders' has changed");
27681
27682#ifdef FREECIV_JSON_CONNECTION
27683 field_addr.name = "wonders";
27684#endif /* FREECIV_JSON_CONNECTION */
27685 e = 0;
27686
27687 {
27688 int i;
27689
27690 FC_STATIC_ASSERT(B_LAST <= MAX_UINT16, packet_array_too_long_wonders);
27691
27692#ifdef FREECIV_JSON_CONNECTION
27693 size_t count_i = 0;
27694
27695 /* Create the array. */
27696 e |= DIO_PUT(farray, &dout, &field_addr, 0);
27697
27698 /* Enter array. */
27699 field_addr.sub_location = plocation_elem_new(0);
27700#endif /* FREECIV_JSON_CONNECTION */
27701
27702 for (i = 0; i < B_LAST; i++) {
27703 differ = (old->wonders[i] != real_packet->wonders[i]);
27704
27705 if (!differ) {
27706 continue;
27707 }
27708
27709#ifdef FREECIV_JSON_CONNECTION
27710 /* Append next diff array element. */
27711 field_addr.sub_location->number = -1;
27712
27713 /* Create the diff array element. */
27714 e |= DIO_PUT(object, &dout, &field_addr);
27715
27716 /* Enter diff array element (start at the index address). */
27717 field_addr.sub_location->number = count_i++;
27718 field_addr.sub_location->sub_location = plocation_field_new("index");
27719#endif /* FREECIV_JSON_CONNECTION */
27720
27721 /* Write the index */
27722#if B_LAST <= MAX_UINT8
27723 e |= DIO_PUT(uint8, &dout, &field_addr, i);
27724#else
27725 e |= DIO_PUT(uint16, &dout, &field_addr, i);
27726#endif
27727
27728#ifdef FREECIV_JSON_CONNECTION
27729 /* Content address. */
27730 field_addr.sub_location->sub_location->name = "data";
27731#endif /* FREECIV_JSON_CONNECTION */
27732
27733 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->wonders[i]);
27734
27735#ifdef FREECIV_JSON_CONNECTION
27736 /* Exit diff array element. */
27737 FC_FREE(field_addr.sub_location->sub_location);
27738#endif /* FREECIV_JSON_CONNECTION */
27739 }
27740
27741#ifdef FREECIV_JSON_CONNECTION
27742 /* Append diff array element. */
27743 field_addr.sub_location->number = -1;
27744
27745 /* Create the terminating diff array element. */
27746 e |= DIO_PUT(object, &dout, &field_addr);
27747
27748 /* Enter diff array element (start at the index address). */
27749 field_addr.sub_location->number = count_i;
27750 field_addr.sub_location->sub_location = plocation_field_new("index");
27751#endif /* FREECIV_JSON_CONNECTION */
27752
27753 /* Write the sentinel value */
27754#if B_LAST <= MAX_UINT8
27755 e |= DIO_PUT(uint8, &dout, &field_addr, B_LAST);
27756#else
27757 e |= DIO_PUT(uint16, &dout, &field_addr, B_LAST);
27758#endif
27759
27760#ifdef FREECIV_JSON_CONNECTION
27761 /* Exit diff array element. */
27762 FC_FREE(field_addr.sub_location->sub_location);
27763 /* Exit array. */
27764 FC_FREE(field_addr.sub_location);
27765#endif /* FREECIV_JSON_CONNECTION */
27766 }
27767
27768 if (e) {
27769 log_packet_detailed("'wonders' field error detected");
27770 }
27771 }
27772
27773 if (BV_ISSET(fields, 43)) {
27774 log_packet_detailed(" field 'multip_count' has changed");
27775
27776#ifdef FREECIV_JSON_CONNECTION
27777 field_addr.name = "multip_count";
27778#endif /* FREECIV_JSON_CONNECTION */
27779 e = 0;
27780
27781 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->multip_count);
27782
27783 if (e) {
27784 log_packet_detailed("'multip_count' field error detected");
27785 }
27786 }
27787
27788 if (BV_ISSET(fields, 44)) {
27789 log_packet_detailed(" field 'multiplier' has changed");
27790
27791#ifdef FREECIV_JSON_CONNECTION
27792 field_addr.name = "multiplier";
27793#endif /* FREECIV_JSON_CONNECTION */
27794 e = 0;
27795
27796 {
27797 int i;
27798
27799#ifdef FREECIV_JSON_CONNECTION
27800 /* Create the array. */
27801 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->multip_count);
27802
27803 /* Enter array. */
27804 field_addr.sub_location = plocation_elem_new(0);
27805#endif /* FREECIV_JSON_CONNECTION */
27806
27807 for (i = 0; i < real_packet->multip_count; i++) {
27808#ifdef FREECIV_JSON_CONNECTION
27809 /* Next array element. */
27810 field_addr.sub_location->number = i;
27811#endif /* FREECIV_JSON_CONNECTION */
27812
27813 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->multiplier[i]);
27814 }
27815
27816#ifdef FREECIV_JSON_CONNECTION
27817 /* Exit array. */
27818 FC_FREE(field_addr.sub_location);
27819#endif /* FREECIV_JSON_CONNECTION */
27820 }
27821
27822 if (e) {
27823 log_packet_detailed("'multiplier' field error detected");
27824 }
27825 }
27826
27827 if (BV_ISSET(fields, 45)) {
27828 log_packet_detailed(" field 'multiplier_target' has changed");
27829
27830#ifdef FREECIV_JSON_CONNECTION
27831 field_addr.name = "multiplier_target";
27832#endif /* FREECIV_JSON_CONNECTION */
27833 e = 0;
27834
27835 {
27836 int i;
27837
27838#ifdef FREECIV_JSON_CONNECTION
27839 /* Create the array. */
27840 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->multip_count);
27841
27842 /* Enter array. */
27843 field_addr.sub_location = plocation_elem_new(0);
27844#endif /* FREECIV_JSON_CONNECTION */
27845
27846 for (i = 0; i < real_packet->multip_count; i++) {
27847#ifdef FREECIV_JSON_CONNECTION
27848 /* Next array element. */
27849 field_addr.sub_location->number = i;
27850#endif /* FREECIV_JSON_CONNECTION */
27851
27852 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->multiplier_target[i]);
27853 }
27854
27855#ifdef FREECIV_JSON_CONNECTION
27856 /* Exit array. */
27857 FC_FREE(field_addr.sub_location);
27858#endif /* FREECIV_JSON_CONNECTION */
27859 }
27860
27861 if (e) {
27862 log_packet_detailed("'multiplier_target' field error detected");
27863 }
27864 }
27865
27866 if (BV_ISSET(fields, 46)) {
27867 log_packet_detailed(" field 'multiplier_changed' has changed");
27868
27869#ifdef FREECIV_JSON_CONNECTION
27870 field_addr.name = "multiplier_changed";
27871#endif /* FREECIV_JSON_CONNECTION */
27872 e = 0;
27873
27874 {
27875 int i;
27876
27877#ifdef FREECIV_JSON_CONNECTION
27878 /* Create the array. */
27879 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->multip_count);
27880
27881 /* Enter array. */
27882 field_addr.sub_location = plocation_elem_new(0);
27883#endif /* FREECIV_JSON_CONNECTION */
27884
27885 for (i = 0; i < real_packet->multip_count; i++) {
27886#ifdef FREECIV_JSON_CONNECTION
27887 /* Next array element. */
27888 field_addr.sub_location->number = i;
27889#endif /* FREECIV_JSON_CONNECTION */
27890
27891 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->multiplier_changed[i]);
27892 }
27893
27894#ifdef FREECIV_JSON_CONNECTION
27895 /* Exit array. */
27896 FC_FREE(field_addr.sub_location);
27897#endif /* FREECIV_JSON_CONNECTION */
27898 }
27899
27900 if (e) {
27901 log_packet_detailed("'multiplier_changed' field error detected");
27902 }
27903 }
27904
27905 *old = *real_packet;
27906
27907#else /* FREECIV_DELTA_PROTOCOL */
27908#ifdef FREECIV_JSON_CONNECTION
27909 field_addr.name = "name";
27910#endif /* FREECIV_JSON_CONNECTION */
27911 e = 0;
27912
27913 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
27914
27915 if (e) {
27916 log_packet_detailed("'name' field error detected");
27917 }
27918
27919#ifdef FREECIV_JSON_CONNECTION
27920 field_addr.name = "username";
27921#endif /* FREECIV_JSON_CONNECTION */
27922 e = 0;
27923
27924 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
27925
27926 if (e) {
27927 log_packet_detailed("'username' field error detected");
27928 }
27929
27930#ifdef FREECIV_JSON_CONNECTION
27931 field_addr.name = "unassigned_user";
27932#endif /* FREECIV_JSON_CONNECTION */
27933 e = 0;
27934
27935 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->unassigned_user);
27936
27937 if (e) {
27938 log_packet_detailed("'unassigned_user' field error detected");
27939 }
27940
27941#ifdef FREECIV_JSON_CONNECTION
27942 field_addr.name = "score";
27943#endif /* FREECIV_JSON_CONNECTION */
27944 e = 0;
27945
27946 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->score);
27947
27948 if (e) {
27949 log_packet_detailed("'score' field error detected");
27950 }
27951
27952#ifdef FREECIV_JSON_CONNECTION
27953 field_addr.name = "is_male";
27954#endif /* FREECIV_JSON_CONNECTION */
27955 e = 0;
27956
27957 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_male);
27958
27959 if (e) {
27960 log_packet_detailed("'is_male' field error detected");
27961 }
27962
27963#ifdef FREECIV_JSON_CONNECTION
27964 field_addr.name = "was_created";
27965#endif /* FREECIV_JSON_CONNECTION */
27966 e = 0;
27967
27968 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->was_created);
27969
27970 if (e) {
27971 log_packet_detailed("'was_created' field error detected");
27972 }
27973
27974#ifdef FREECIV_JSON_CONNECTION
27975 field_addr.name = "government";
27976#endif /* FREECIV_JSON_CONNECTION */
27977 e = 0;
27978
27979 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government);
27980
27981 if (e) {
27982 log_packet_detailed("'government' field error detected");
27983 }
27984
27985#ifdef FREECIV_JSON_CONNECTION
27986 field_addr.name = "target_government";
27987#endif /* FREECIV_JSON_CONNECTION */
27988 e = 0;
27989
27990 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_government);
27991
27992 if (e) {
27993 log_packet_detailed("'target_government' field error detected");
27994 }
27995
27996#ifdef FREECIV_JSON_CONNECTION
27997 field_addr.name = "real_embassy";
27998#endif /* FREECIV_JSON_CONNECTION */
27999 e = 0;
28000
28001 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->real_embassy);
28002
28003 if (e) {
28004 log_packet_detailed("'real_embassy' field error detected");
28005 }
28006
28007#ifdef FREECIV_JSON_CONNECTION
28008 field_addr.name = "mood";
28009#endif /* FREECIV_JSON_CONNECTION */
28010 e = 0;
28011
28012 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->mood);
28013
28014 if (e) {
28015 log_packet_detailed("'mood' field error detected");
28016 }
28017
28018#ifdef FREECIV_JSON_CONNECTION
28019 field_addr.name = "style";
28020#endif /* FREECIV_JSON_CONNECTION */
28021 e = 0;
28022
28023 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
28024
28025 if (e) {
28026 log_packet_detailed("'style' field error detected");
28027 }
28028
28029#ifdef FREECIV_JSON_CONNECTION
28030 field_addr.name = "music_style";
28031#endif /* FREECIV_JSON_CONNECTION */
28032 e = 0;
28033
28034 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->music_style);
28035
28036 if (e) {
28037 log_packet_detailed("'music_style' field error detected");
28038 }
28039
28040#ifdef FREECIV_JSON_CONNECTION
28041 field_addr.name = "nation";
28042#endif /* FREECIV_JSON_CONNECTION */
28043 e = 0;
28044
28045 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation);
28046
28047 if (e) {
28048 log_packet_detailed("'nation' field error detected");
28049 }
28050
28051#ifdef FREECIV_JSON_CONNECTION
28052 field_addr.name = "team";
28053#endif /* FREECIV_JSON_CONNECTION */
28054 e = 0;
28055
28056 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->team);
28057
28058 if (e) {
28059 log_packet_detailed("'team' field error detected");
28060 }
28061
28062#ifdef FREECIV_JSON_CONNECTION
28063 field_addr.name = "is_ready";
28064#endif /* FREECIV_JSON_CONNECTION */
28065 e = 0;
28066
28067 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_ready);
28068
28069 if (e) {
28070 log_packet_detailed("'is_ready' field error detected");
28071 }
28072
28073#ifdef FREECIV_JSON_CONNECTION
28074 field_addr.name = "phase_done";
28075#endif /* FREECIV_JSON_CONNECTION */
28076 e = 0;
28077
28078 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->phase_done);
28079
28080 if (e) {
28081 log_packet_detailed("'phase_done' field error detected");
28082 }
28083
28084#ifdef FREECIV_JSON_CONNECTION
28085 field_addr.name = "nturns_idle";
28086#endif /* FREECIV_JSON_CONNECTION */
28087 e = 0;
28088
28089 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nturns_idle);
28090
28091 if (e) {
28092 log_packet_detailed("'nturns_idle' field error detected");
28093 }
28094
28095#ifdef FREECIV_JSON_CONNECTION
28096 field_addr.name = "turns_alive";
28097#endif /* FREECIV_JSON_CONNECTION */
28098 e = 0;
28099
28100 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turns_alive);
28101
28102 if (e) {
28103 log_packet_detailed("'turns_alive' field error detected");
28104 }
28105
28106#ifdef FREECIV_JSON_CONNECTION
28107 field_addr.name = "is_alive";
28108#endif /* FREECIV_JSON_CONNECTION */
28109 e = 0;
28110
28111 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_alive);
28112
28113 if (e) {
28114 log_packet_detailed("'is_alive' field error detected");
28115 }
28116
28117#ifdef FREECIV_JSON_CONNECTION
28118 field_addr.name = "autoselect_weight";
28119#endif /* FREECIV_JSON_CONNECTION */
28120 e = 0;
28121
28122 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->autoselect_weight);
28123
28124 if (e) {
28125 log_packet_detailed("'autoselect_weight' field error detected");
28126 }
28127
28128#ifdef FREECIV_JSON_CONNECTION
28129 field_addr.name = "gold";
28130#endif /* FREECIV_JSON_CONNECTION */
28131 e = 0;
28132
28133 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->gold);
28134
28135 if (e) {
28136 log_packet_detailed("'gold' field error detected");
28137 }
28138
28139#ifdef FREECIV_JSON_CONNECTION
28140 field_addr.name = "tax";
28141#endif /* FREECIV_JSON_CONNECTION */
28142 e = 0;
28143
28144 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tax);
28145
28146 if (e) {
28147 log_packet_detailed("'tax' field error detected");
28148 }
28149
28150#ifdef FREECIV_JSON_CONNECTION
28151 field_addr.name = "science";
28152#endif /* FREECIV_JSON_CONNECTION */
28153 e = 0;
28154
28155 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->science);
28156
28157 if (e) {
28158 log_packet_detailed("'science' field error detected");
28159 }
28160
28161#ifdef FREECIV_JSON_CONNECTION
28162 field_addr.name = "luxury";
28163#endif /* FREECIV_JSON_CONNECTION */
28164 e = 0;
28165
28166 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->luxury);
28167
28168 if (e) {
28169 log_packet_detailed("'luxury' field error detected");
28170 }
28171
28172#ifdef FREECIV_JSON_CONNECTION
28173 field_addr.name = "infrapoints";
28174#endif /* FREECIV_JSON_CONNECTION */
28175 e = 0;
28176
28177 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->infrapoints);
28178
28179 if (e) {
28180 log_packet_detailed("'infrapoints' field error detected");
28181 }
28182
28183#ifdef FREECIV_JSON_CONNECTION
28184 field_addr.name = "tech_upkeep";
28185#endif /* FREECIV_JSON_CONNECTION */
28186 e = 0;
28187
28188 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech_upkeep);
28189
28190 if (e) {
28191 log_packet_detailed("'tech_upkeep' field error detected");
28192 }
28193
28194#ifdef FREECIV_JSON_CONNECTION
28195 field_addr.name = "science_cost";
28196#endif /* FREECIV_JSON_CONNECTION */
28197 e = 0;
28198
28199 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->science_cost);
28200
28201 if (e) {
28202 log_packet_detailed("'science_cost' field error detected");
28203 }
28204
28205#ifdef FREECIV_JSON_CONNECTION
28206 field_addr.name = "is_connected";
28207#endif /* FREECIV_JSON_CONNECTION */
28208 e = 0;
28209
28210 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_connected);
28211
28212 if (e) {
28213 log_packet_detailed("'is_connected' field error detected");
28214 }
28215
28216#ifdef FREECIV_JSON_CONNECTION
28217 field_addr.name = "revolution_finishes";
28218#endif /* FREECIV_JSON_CONNECTION */
28219 e = 0;
28220
28221 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->revolution_finishes);
28222
28223 if (e) {
28224 log_packet_detailed("'revolution_finishes' field error detected");
28225 }
28226
28227#ifdef FREECIV_JSON_CONNECTION
28228 field_addr.name = "ai_skill_level";
28229#endif /* FREECIV_JSON_CONNECTION */
28230 e = 0;
28231
28232 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ai_skill_level);
28233
28234 if (e) {
28235 log_packet_detailed("'ai_skill_level' field error detected");
28236 }
28237
28238#ifdef FREECIV_JSON_CONNECTION
28239 field_addr.name = "barbarian_type";
28240#endif /* FREECIV_JSON_CONNECTION */
28241 e = 0;
28242
28243 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->barbarian_type);
28244
28245 if (e) {
28246 log_packet_detailed("'barbarian_type' field error detected");
28247 }
28248
28249#ifdef FREECIV_JSON_CONNECTION
28250 field_addr.name = "gives_shared_vision";
28251#endif /* FREECIV_JSON_CONNECTION */
28252 e = 0;
28253
28254 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->gives_shared_vision);
28255
28256 if (e) {
28257 log_packet_detailed("'gives_shared_vision' field error detected");
28258 }
28259
28260#ifdef FREECIV_JSON_CONNECTION
28261 field_addr.name = "gives_shared_tiles";
28262#endif /* FREECIV_JSON_CONNECTION */
28263 e = 0;
28264
28265 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->gives_shared_tiles);
28266
28267 if (e) {
28268 log_packet_detailed("'gives_shared_tiles' field error detected");
28269 }
28270
28271#ifdef FREECIV_JSON_CONNECTION
28272 field_addr.name = "history";
28273#endif /* FREECIV_JSON_CONNECTION */
28274 e = 0;
28275
28276 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->history);
28277
28278 if (e) {
28279 log_packet_detailed("'history' field error detected");
28280 }
28281
28282#ifdef FREECIV_JSON_CONNECTION
28283 field_addr.name = "culture";
28284#endif /* FREECIV_JSON_CONNECTION */
28285 e = 0;
28286
28287 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->culture);
28288
28289 if (e) {
28290 log_packet_detailed("'culture' field error detected");
28291 }
28292
28293#ifdef FREECIV_JSON_CONNECTION
28294 field_addr.name = "love";
28295#endif /* FREECIV_JSON_CONNECTION */
28296 e = 0;
28297
28298 {
28299 int i;
28300
28301#ifdef FREECIV_JSON_CONNECTION
28302 /* Create the array. */
28303 e |= DIO_PUT(farray, &dout, &field_addr, MAX_NUM_PLAYER_SLOTS);
28304
28305 /* Enter array. */
28306 field_addr.sub_location = plocation_elem_new(0);
28307#endif /* FREECIV_JSON_CONNECTION */
28308
28309 for (i = 0; i < MAX_NUM_PLAYER_SLOTS; i++) {
28310#ifdef FREECIV_JSON_CONNECTION
28311 /* Next array element. */
28312 field_addr.sub_location->number = i;
28313#endif /* FREECIV_JSON_CONNECTION */
28314
28315 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->love[i]);
28316 }
28317
28318#ifdef FREECIV_JSON_CONNECTION
28319 /* Exit array. */
28320 FC_FREE(field_addr.sub_location);
28321#endif /* FREECIV_JSON_CONNECTION */
28322 }
28323
28324 if (e) {
28325 log_packet_detailed("'love' field error detected");
28326 }
28327
28328#ifdef FREECIV_JSON_CONNECTION
28329 field_addr.name = "color_valid";
28330#endif /* FREECIV_JSON_CONNECTION */
28331 e = 0;
28332
28333 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->color_valid);
28334
28335 if (e) {
28336 log_packet_detailed("'color_valid' field error detected");
28337 }
28338
28339#ifdef FREECIV_JSON_CONNECTION
28340 field_addr.name = "color_changeable";
28341#endif /* FREECIV_JSON_CONNECTION */
28342 e = 0;
28343
28344 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->color_changeable);
28345
28346 if (e) {
28347 log_packet_detailed("'color_changeable' field error detected");
28348 }
28349
28350#ifdef FREECIV_JSON_CONNECTION
28351 field_addr.name = "color_red";
28352#endif /* FREECIV_JSON_CONNECTION */
28353 e = 0;
28354
28355 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_red);
28356
28357 if (e) {
28358 log_packet_detailed("'color_red' field error detected");
28359 }
28360
28361#ifdef FREECIV_JSON_CONNECTION
28362 field_addr.name = "color_green";
28363#endif /* FREECIV_JSON_CONNECTION */
28364 e = 0;
28365
28366 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_green);
28367
28368 if (e) {
28369 log_packet_detailed("'color_green' field error detected");
28370 }
28371
28372#ifdef FREECIV_JSON_CONNECTION
28373 field_addr.name = "color_blue";
28374#endif /* FREECIV_JSON_CONNECTION */
28375 e = 0;
28376
28377 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_blue);
28378
28379 if (e) {
28380 log_packet_detailed("'color_blue' field error detected");
28381 }
28382
28383#ifdef FREECIV_JSON_CONNECTION
28384 field_addr.name = "flags";
28385#endif /* FREECIV_JSON_CONNECTION */
28386 e = 0;
28387
28388 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
28389
28390 if (e) {
28391 log_packet_detailed("'flags' field error detected");
28392 }
28393
28394#ifdef FREECIV_JSON_CONNECTION
28395 field_addr.name = "wonders";
28396#endif /* FREECIV_JSON_CONNECTION */
28397 e = 0;
28398
28399 {
28400 int i;
28401
28402#ifdef FREECIV_JSON_CONNECTION
28403 /* Create the array. */
28404 e |= DIO_PUT(farray, &dout, &field_addr, B_LAST);
28405
28406 /* Enter array. */
28407 field_addr.sub_location = plocation_elem_new(0);
28408#endif /* FREECIV_JSON_CONNECTION */
28409
28410 for (i = 0; i < B_LAST; i++) {
28411#ifdef FREECIV_JSON_CONNECTION
28412 /* Next array element. */
28413 field_addr.sub_location->number = i;
28414#endif /* FREECIV_JSON_CONNECTION */
28415
28416 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->wonders[i]);
28417 }
28418
28419#ifdef FREECIV_JSON_CONNECTION
28420 /* Exit array. */
28421 FC_FREE(field_addr.sub_location);
28422#endif /* FREECIV_JSON_CONNECTION */
28423 }
28424
28425 if (e) {
28426 log_packet_detailed("'wonders' field error detected");
28427 }
28428
28429#ifdef FREECIV_JSON_CONNECTION
28430 field_addr.name = "multip_count";
28431#endif /* FREECIV_JSON_CONNECTION */
28432 e = 0;
28433
28434 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->multip_count);
28435
28436 if (e) {
28437 log_packet_detailed("'multip_count' field error detected");
28438 }
28439
28440#ifdef FREECIV_JSON_CONNECTION
28441 field_addr.name = "multiplier";
28442#endif /* FREECIV_JSON_CONNECTION */
28443 e = 0;
28444
28445 {
28446 int i;
28447
28448#ifdef FREECIV_JSON_CONNECTION
28449 /* Create the array. */
28450 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->multip_count);
28451
28452 /* Enter array. */
28453 field_addr.sub_location = plocation_elem_new(0);
28454#endif /* FREECIV_JSON_CONNECTION */
28455
28456 for (i = 0; i < real_packet->multip_count; i++) {
28457#ifdef FREECIV_JSON_CONNECTION
28458 /* Next array element. */
28459 field_addr.sub_location->number = i;
28460#endif /* FREECIV_JSON_CONNECTION */
28461
28462 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->multiplier[i]);
28463 }
28464
28465#ifdef FREECIV_JSON_CONNECTION
28466 /* Exit array. */
28467 FC_FREE(field_addr.sub_location);
28468#endif /* FREECIV_JSON_CONNECTION */
28469 }
28470
28471 if (e) {
28472 log_packet_detailed("'multiplier' field error detected");
28473 }
28474
28475#ifdef FREECIV_JSON_CONNECTION
28476 field_addr.name = "multiplier_target";
28477#endif /* FREECIV_JSON_CONNECTION */
28478 e = 0;
28479
28480 {
28481 int i;
28482
28483#ifdef FREECIV_JSON_CONNECTION
28484 /* Create the array. */
28485 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->multip_count);
28486
28487 /* Enter array. */
28488 field_addr.sub_location = plocation_elem_new(0);
28489#endif /* FREECIV_JSON_CONNECTION */
28490
28491 for (i = 0; i < real_packet->multip_count; i++) {
28492#ifdef FREECIV_JSON_CONNECTION
28493 /* Next array element. */
28494 field_addr.sub_location->number = i;
28495#endif /* FREECIV_JSON_CONNECTION */
28496
28497 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->multiplier_target[i]);
28498 }
28499
28500#ifdef FREECIV_JSON_CONNECTION
28501 /* Exit array. */
28502 FC_FREE(field_addr.sub_location);
28503#endif /* FREECIV_JSON_CONNECTION */
28504 }
28505
28506 if (e) {
28507 log_packet_detailed("'multiplier_target' field error detected");
28508 }
28509
28510#ifdef FREECIV_JSON_CONNECTION
28511 field_addr.name = "multiplier_changed";
28512#endif /* FREECIV_JSON_CONNECTION */
28513 e = 0;
28514
28515 {
28516 int i;
28517
28518#ifdef FREECIV_JSON_CONNECTION
28519 /* Create the array. */
28520 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->multip_count);
28521
28522 /* Enter array. */
28523 field_addr.sub_location = plocation_elem_new(0);
28524#endif /* FREECIV_JSON_CONNECTION */
28525
28526 for (i = 0; i < real_packet->multip_count; i++) {
28527#ifdef FREECIV_JSON_CONNECTION
28528 /* Next array element. */
28529 field_addr.sub_location->number = i;
28530#endif /* FREECIV_JSON_CONNECTION */
28531
28532 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->multiplier_changed[i]);
28533 }
28534
28535#ifdef FREECIV_JSON_CONNECTION
28536 /* Exit array. */
28537 FC_FREE(field_addr.sub_location);
28538#endif /* FREECIV_JSON_CONNECTION */
28539 }
28540
28541 if (e) {
28542 log_packet_detailed("'multiplier_changed' field error detected");
28543 }
28544#endif /* FREECIV_DELTA_PROTOCOL */
28545
28546 SEND_PACKET_END(PACKET_PLAYER_INFO);
28547}
28548
28549 int send_packet_player_info(struct connection *pc, const struct packet_player_info *packet)
28550{
28551 if (!pc->used) {
28552 log_error("WARNING: trying to send data to the closed connection %s",
28553 conn_description(pc));
28554 return -1;
28555 }
28556 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_INFO].packet != nullptr, -1,
28557 "Handler for PACKET_PLAYER_INFO not installed");
28558 return pc->phs.handlers->send[PACKET_PLAYER_INFO].packet(pc, packet);
28559}
28560
28561 static inline void init_packet_player_phase_done(struct packet_player_phase_done *packet)
28562{
28563 memset(packet, 0, sizeof(*packet));
28564}
28565
28566#define free_packet_player_phase_done(_packet) (void) 0
28567#define destroy_packet_player_phase_done free
28568
28569#ifdef FREECIV_DELTA_PROTOCOL
28570#define hash_packet_player_phase_done_100 hash_const
28571#define cmp_packet_player_phase_done_100 cmp_const
28572 BV_DEFINE(packet_player_phase_done_100_fields, 1);
28573#endif /* FREECIV_DELTA_PROTOCOL */
28574
28575 static struct packet_player_phase_done *receive_packet_player_phase_done_100(struct connection *pc)
28576{
28577#define FREE_PACKET_STRUCT(_packet) free_packet_player_phase_done(_packet)
28578 RECEIVE_PACKET_START(packet_player_phase_done, real_packet);
28579
28580#ifdef FREECIV_JSON_CONNECTION
28581 struct plocation field_addr;
28582 {
28583 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
28584 field_addr = *field_addr_tmp;
28585 FC_FREE(field_addr_tmp);
28586 }
28587#endif /* FREECIV_JSON_CONNECTION */
28588
28589 log_packet_detailed("packet_player_phase_done_100: got info about ()");
28590
28591#ifdef FREECIV_DELTA_PROTOCOL
28592 packet_player_phase_done_100_fields fields;
28593 struct packet_player_phase_done *old;
28594 struct genhash **hash = pc->phs.received + PACKET_PLAYER_PHASE_DONE;
28595
28596 if (nullptr == *hash) {
28597 *hash = genhash_new_full(hash_packet_player_phase_done_100, cmp_packet_player_phase_done_100,
28598 nullptr, nullptr, nullptr, destroy_packet_player_phase_done);
28599 }
28600
28601 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
28602 *real_packet = *old;
28603 } else {
28604 /* packet is already initialized empty */
28605 log_packet_detailed(" no old info");
28606 }
28607
28608#ifdef FREECIV_JSON_CONNECTION
28609 field_addr.name = "fields";
28610#endif /* FREECIV_JSON_CONNECTION */
28611 DIO_BV_GET(&din, &field_addr, fields);
28612
28613 if (BV_ISSET(fields, 0)) {
28614 log_packet_detailed(" got field 'turn'");
28615
28616#ifdef FREECIV_JSON_CONNECTION
28617 field_addr.name = "turn";
28618#endif /* FREECIV_JSON_CONNECTION */
28619
28620 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
28621 RECEIVE_PACKET_FIELD_ERROR(turn);
28622 }
28623 }
28624
28625 if (nullptr == old) {
28626 old = fc_malloc(sizeof(*old));
28627 init_packet_player_phase_done(old);
28628 *old = *real_packet;
28629 genhash_insert(*hash, old, old);
28630 } else {
28631 *old = *real_packet;
28632 }
28633
28634#else /* FREECIV_DELTA_PROTOCOL */
28635#ifdef FREECIV_JSON_CONNECTION
28636 field_addr.name = "turn";
28637#endif /* FREECIV_JSON_CONNECTION */
28638
28639 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
28640 RECEIVE_PACKET_FIELD_ERROR(turn);
28641 }
28642#endif /* FREECIV_DELTA_PROTOCOL */
28643
28644 RECEIVE_PACKET_END(real_packet);
28645#undef FREE_PACKET_STRUCT
28646}
28647
28648 static int send_packet_player_phase_done_100(struct connection *pc, const struct packet_player_phase_done *packet)
28649{
28650 const struct packet_player_phase_done *real_packet = packet;
28651 int e;
28652 SEND_PACKET_START(PACKET_PLAYER_PHASE_DONE);
28653
28654 log_packet_detailed("packet_player_phase_done_100: sending info about ()");
28655
28656#ifdef FREECIV_DELTA_PROTOCOL
28657 packet_player_phase_done_100_fields fields;
28658 struct packet_player_phase_done *old;
28659 bool differ;
28660 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_PHASE_DONE;
28661
28662 if (nullptr == *hash) {
28663 *hash = genhash_new_full(hash_packet_player_phase_done_100, cmp_packet_player_phase_done_100,
28664 nullptr, nullptr, nullptr, destroy_packet_player_phase_done);
28665 }
28666 BV_CLR_ALL(fields);
28667
28668 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
28669 old = fc_malloc(sizeof(*old));
28670 /* temporary bitcopy just to insert correctly */
28671 *old = *real_packet;
28672 genhash_insert(*hash, old, old);
28673 init_packet_player_phase_done(old);
28674 }
28675
28676 differ = (old->turn != real_packet->turn);
28677 if (differ) {
28678 BV_SET(fields, 0);
28679 }
28680#endif /* FREECIV_DELTA_PROTOCOL */
28681
28682#ifdef FREECIV_JSON_CONNECTION
28683 struct plocation field_addr;
28684 {
28685 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
28686 field_addr = *field_addr_tmp;
28687 FC_FREE(field_addr_tmp);
28688 }
28689#endif /* FREECIV_JSON_CONNECTION */
28690
28691#ifdef FREECIV_DELTA_PROTOCOL
28692#ifdef FREECIV_JSON_CONNECTION
28693 field_addr.name = "fields";
28694#endif /* FREECIV_JSON_CONNECTION */
28695 e = 0;
28696 e |= DIO_BV_PUT(&dout, &field_addr, fields);
28697 if (e) {
28698 log_packet_detailed("fields bitvector error detected");
28699 }
28700
28701 if (BV_ISSET(fields, 0)) {
28702 log_packet_detailed(" field 'turn' has changed");
28703
28704#ifdef FREECIV_JSON_CONNECTION
28705 field_addr.name = "turn";
28706#endif /* FREECIV_JSON_CONNECTION */
28707 e = 0;
28708
28709 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
28710
28711 if (e) {
28712 log_packet_detailed("'turn' field error detected");
28713 }
28714 }
28715
28716 *old = *real_packet;
28717
28718#else /* FREECIV_DELTA_PROTOCOL */
28719#ifdef FREECIV_JSON_CONNECTION
28720 field_addr.name = "turn";
28721#endif /* FREECIV_JSON_CONNECTION */
28722 e = 0;
28723
28724 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
28725
28726 if (e) {
28727 log_packet_detailed("'turn' field error detected");
28728 }
28729#endif /* FREECIV_DELTA_PROTOCOL */
28730
28731 SEND_PACKET_END(PACKET_PLAYER_PHASE_DONE);
28732}
28733
28734 int send_packet_player_phase_done(struct connection *pc, const struct packet_player_phase_done *packet)
28735{
28736 if (!pc->used) {
28737 log_error("WARNING: trying to send data to the closed connection %s",
28738 conn_description(pc));
28739 return -1;
28740 }
28741 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_PHASE_DONE].packet != nullptr, -1,
28742 "Handler for PACKET_PLAYER_PHASE_DONE not installed");
28743 return pc->phs.handlers->send[PACKET_PLAYER_PHASE_DONE].packet(pc, packet);
28744}
28745
28746 int dsend_packet_player_phase_done(struct connection *pc, int turn)
28747{
28748 struct packet_player_phase_done packet, *real_packet = &packet;
28749
28750 real_packet->turn = turn;
28751
28752 return send_packet_player_phase_done(pc, real_packet);
28753}
28754
28755 static inline void init_packet_player_rates(struct packet_player_rates *packet)
28756{
28757 memset(packet, 0, sizeof(*packet));
28758}
28759
28760#define free_packet_player_rates(_packet) (void) 0
28761#define destroy_packet_player_rates free
28762
28763#ifdef FREECIV_DELTA_PROTOCOL
28764#define hash_packet_player_rates_100 hash_const
28765#define cmp_packet_player_rates_100 cmp_const
28766 BV_DEFINE(packet_player_rates_100_fields, 3);
28767#endif /* FREECIV_DELTA_PROTOCOL */
28768
28769 static struct packet_player_rates *receive_packet_player_rates_100(struct connection *pc)
28770{
28771#define FREE_PACKET_STRUCT(_packet) free_packet_player_rates(_packet)
28772 RECEIVE_PACKET_START(packet_player_rates, real_packet);
28773
28774#ifdef FREECIV_JSON_CONNECTION
28775 struct plocation field_addr;
28776 {
28777 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
28778 field_addr = *field_addr_tmp;
28779 FC_FREE(field_addr_tmp);
28780 }
28781#endif /* FREECIV_JSON_CONNECTION */
28782
28783 log_packet_detailed("packet_player_rates_100: got info about ()");
28784
28785#ifdef FREECIV_DELTA_PROTOCOL
28786 packet_player_rates_100_fields fields;
28787 struct packet_player_rates *old;
28788 struct genhash **hash = pc->phs.received + PACKET_PLAYER_RATES;
28789
28790 if (nullptr == *hash) {
28791 *hash = genhash_new_full(hash_packet_player_rates_100, cmp_packet_player_rates_100,
28792 nullptr, nullptr, nullptr, destroy_packet_player_rates);
28793 }
28794
28795 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
28796 *real_packet = *old;
28797 } else {
28798 /* packet is already initialized empty */
28799 log_packet_detailed(" no old info");
28800 }
28801
28802#ifdef FREECIV_JSON_CONNECTION
28803 field_addr.name = "fields";
28804#endif /* FREECIV_JSON_CONNECTION */
28805 DIO_BV_GET(&din, &field_addr, fields);
28806
28807 if (BV_ISSET(fields, 0)) {
28808 log_packet_detailed(" got field 'tax'");
28809
28810#ifdef FREECIV_JSON_CONNECTION
28811 field_addr.name = "tax";
28812#endif /* FREECIV_JSON_CONNECTION */
28813
28814 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tax)) {
28815 RECEIVE_PACKET_FIELD_ERROR(tax);
28816 }
28817 }
28818
28819 if (BV_ISSET(fields, 1)) {
28820 log_packet_detailed(" got field 'luxury'");
28821
28822#ifdef FREECIV_JSON_CONNECTION
28823 field_addr.name = "luxury";
28824#endif /* FREECIV_JSON_CONNECTION */
28825
28826 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->luxury)) {
28827 RECEIVE_PACKET_FIELD_ERROR(luxury);
28828 }
28829 }
28830
28831 if (BV_ISSET(fields, 2)) {
28832 log_packet_detailed(" got field 'science'");
28833
28834#ifdef FREECIV_JSON_CONNECTION
28835 field_addr.name = "science";
28836#endif /* FREECIV_JSON_CONNECTION */
28837
28838 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->science)) {
28839 RECEIVE_PACKET_FIELD_ERROR(science);
28840 }
28841 }
28842
28843 if (nullptr == old) {
28844 old = fc_malloc(sizeof(*old));
28845 init_packet_player_rates(old);
28846 *old = *real_packet;
28847 genhash_insert(*hash, old, old);
28848 } else {
28849 *old = *real_packet;
28850 }
28851
28852#else /* FREECIV_DELTA_PROTOCOL */
28853#ifdef FREECIV_JSON_CONNECTION
28854 field_addr.name = "tax";
28855#endif /* FREECIV_JSON_CONNECTION */
28856
28857 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tax)) {
28858 RECEIVE_PACKET_FIELD_ERROR(tax);
28859 }
28860
28861#ifdef FREECIV_JSON_CONNECTION
28862 field_addr.name = "luxury";
28863#endif /* FREECIV_JSON_CONNECTION */
28864
28865 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->luxury)) {
28866 RECEIVE_PACKET_FIELD_ERROR(luxury);
28867 }
28868
28869#ifdef FREECIV_JSON_CONNECTION
28870 field_addr.name = "science";
28871#endif /* FREECIV_JSON_CONNECTION */
28872
28873 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->science)) {
28874 RECEIVE_PACKET_FIELD_ERROR(science);
28875 }
28876#endif /* FREECIV_DELTA_PROTOCOL */
28877
28878 RECEIVE_PACKET_END(real_packet);
28879#undef FREE_PACKET_STRUCT
28880}
28881
28882 static int send_packet_player_rates_100(struct connection *pc, const struct packet_player_rates *packet)
28883{
28884 const struct packet_player_rates *real_packet = packet;
28885 int e;
28886 SEND_PACKET_START(PACKET_PLAYER_RATES);
28887
28888 log_packet_detailed("packet_player_rates_100: sending info about ()");
28889
28890#ifdef FREECIV_DELTA_PROTOCOL
28891 packet_player_rates_100_fields fields;
28892 struct packet_player_rates *old;
28893 bool differ;
28894 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_RATES;
28895
28896 if (nullptr == *hash) {
28897 *hash = genhash_new_full(hash_packet_player_rates_100, cmp_packet_player_rates_100,
28898 nullptr, nullptr, nullptr, destroy_packet_player_rates);
28899 }
28900 BV_CLR_ALL(fields);
28901
28902 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
28903 old = fc_malloc(sizeof(*old));
28904 /* temporary bitcopy just to insert correctly */
28905 *old = *real_packet;
28906 genhash_insert(*hash, old, old);
28907 init_packet_player_rates(old);
28908 }
28909
28910 differ = (old->tax != real_packet->tax);
28911 if (differ) {
28912 BV_SET(fields, 0);
28913 }
28914
28915 differ = (old->luxury != real_packet->luxury);
28916 if (differ) {
28917 BV_SET(fields, 1);
28918 }
28919
28920 differ = (old->science != real_packet->science);
28921 if (differ) {
28922 BV_SET(fields, 2);
28923 }
28924#endif /* FREECIV_DELTA_PROTOCOL */
28925
28926#ifdef FREECIV_JSON_CONNECTION
28927 struct plocation field_addr;
28928 {
28929 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
28930 field_addr = *field_addr_tmp;
28931 FC_FREE(field_addr_tmp);
28932 }
28933#endif /* FREECIV_JSON_CONNECTION */
28934
28935#ifdef FREECIV_DELTA_PROTOCOL
28936#ifdef FREECIV_JSON_CONNECTION
28937 field_addr.name = "fields";
28938#endif /* FREECIV_JSON_CONNECTION */
28939 e = 0;
28940 e |= DIO_BV_PUT(&dout, &field_addr, fields);
28941 if (e) {
28942 log_packet_detailed("fields bitvector error detected");
28943 }
28944
28945 if (BV_ISSET(fields, 0)) {
28946 log_packet_detailed(" field 'tax' has changed");
28947
28948#ifdef FREECIV_JSON_CONNECTION
28949 field_addr.name = "tax";
28950#endif /* FREECIV_JSON_CONNECTION */
28951 e = 0;
28952
28953 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tax);
28954
28955 if (e) {
28956 log_packet_detailed("'tax' field error detected");
28957 }
28958 }
28959
28960 if (BV_ISSET(fields, 1)) {
28961 log_packet_detailed(" field 'luxury' has changed");
28962
28963#ifdef FREECIV_JSON_CONNECTION
28964 field_addr.name = "luxury";
28965#endif /* FREECIV_JSON_CONNECTION */
28966 e = 0;
28967
28968 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->luxury);
28969
28970 if (e) {
28971 log_packet_detailed("'luxury' field error detected");
28972 }
28973 }
28974
28975 if (BV_ISSET(fields, 2)) {
28976 log_packet_detailed(" field 'science' has changed");
28977
28978#ifdef FREECIV_JSON_CONNECTION
28979 field_addr.name = "science";
28980#endif /* FREECIV_JSON_CONNECTION */
28981 e = 0;
28982
28983 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->science);
28984
28985 if (e) {
28986 log_packet_detailed("'science' field error detected");
28987 }
28988 }
28989
28990 *old = *real_packet;
28991
28992#else /* FREECIV_DELTA_PROTOCOL */
28993#ifdef FREECIV_JSON_CONNECTION
28994 field_addr.name = "tax";
28995#endif /* FREECIV_JSON_CONNECTION */
28996 e = 0;
28997
28998 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tax);
28999
29000 if (e) {
29001 log_packet_detailed("'tax' field error detected");
29002 }
29003
29004#ifdef FREECIV_JSON_CONNECTION
29005 field_addr.name = "luxury";
29006#endif /* FREECIV_JSON_CONNECTION */
29007 e = 0;
29008
29009 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->luxury);
29010
29011 if (e) {
29012 log_packet_detailed("'luxury' field error detected");
29013 }
29014
29015#ifdef FREECIV_JSON_CONNECTION
29016 field_addr.name = "science";
29017#endif /* FREECIV_JSON_CONNECTION */
29018 e = 0;
29019
29020 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->science);
29021
29022 if (e) {
29023 log_packet_detailed("'science' field error detected");
29024 }
29025#endif /* FREECIV_DELTA_PROTOCOL */
29026
29027 SEND_PACKET_END(PACKET_PLAYER_RATES);
29028}
29029
29030 int send_packet_player_rates(struct connection *pc, const struct packet_player_rates *packet)
29031{
29032 if (!pc->used) {
29033 log_error("WARNING: trying to send data to the closed connection %s",
29034 conn_description(pc));
29035 return -1;
29036 }
29037 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_RATES].packet != nullptr, -1,
29038 "Handler for PACKET_PLAYER_RATES not installed");
29039 return pc->phs.handlers->send[PACKET_PLAYER_RATES].packet(pc, packet);
29040}
29041
29042 int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
29043{
29044 struct packet_player_rates packet, *real_packet = &packet;
29045
29046 real_packet->tax = tax;
29047 real_packet->luxury = luxury;
29048 real_packet->science = science;
29049
29050 return send_packet_player_rates(pc, real_packet);
29051}
29052
29053 static inline void init_packet_player_change_government(struct packet_player_change_government *packet)
29054{
29055 memset(packet, 0, sizeof(*packet));
29056}
29057
29058#define free_packet_player_change_government(_packet) (void) 0
29059#define destroy_packet_player_change_government free
29060
29061#ifdef FREECIV_DELTA_PROTOCOL
29062#define hash_packet_player_change_government_100 hash_const
29063#define cmp_packet_player_change_government_100 cmp_const
29064 BV_DEFINE(packet_player_change_government_100_fields, 1);
29065#endif /* FREECIV_DELTA_PROTOCOL */
29066
29067 static struct packet_player_change_government *receive_packet_player_change_government_100(struct connection *pc)
29068{
29069#define FREE_PACKET_STRUCT(_packet) free_packet_player_change_government(_packet)
29070 RECEIVE_PACKET_START(packet_player_change_government, real_packet);
29071
29072#ifdef FREECIV_JSON_CONNECTION
29073 struct plocation field_addr;
29074 {
29075 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29076 field_addr = *field_addr_tmp;
29077 FC_FREE(field_addr_tmp);
29078 }
29079#endif /* FREECIV_JSON_CONNECTION */
29080
29081 log_packet_detailed("packet_player_change_government_100: got info about ()");
29082
29083#ifdef FREECIV_DELTA_PROTOCOL
29084 packet_player_change_government_100_fields fields;
29085 struct packet_player_change_government *old;
29086 struct genhash **hash = pc->phs.received + PACKET_PLAYER_CHANGE_GOVERNMENT;
29087
29088 if (nullptr == *hash) {
29089 *hash = genhash_new_full(hash_packet_player_change_government_100, cmp_packet_player_change_government_100,
29090 nullptr, nullptr, nullptr, destroy_packet_player_change_government);
29091 }
29092
29093 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29094 *real_packet = *old;
29095 } else {
29096 /* packet is already initialized empty */
29097 log_packet_detailed(" no old info");
29098 }
29099
29100#ifdef FREECIV_JSON_CONNECTION
29101 field_addr.name = "fields";
29102#endif /* FREECIV_JSON_CONNECTION */
29103 DIO_BV_GET(&din, &field_addr, fields);
29104
29105 if (BV_ISSET(fields, 0)) {
29106 log_packet_detailed(" got field 'government'");
29107
29108#ifdef FREECIV_JSON_CONNECTION
29109 field_addr.name = "government";
29110#endif /* FREECIV_JSON_CONNECTION */
29111
29112 {
29113 int readin;
29114
29115 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
29116 RECEIVE_PACKET_FIELD_ERROR(government);
29117 }
29118 real_packet->government = readin;
29119 }
29120 }
29121
29122 if (nullptr == old) {
29123 old = fc_malloc(sizeof(*old));
29124 init_packet_player_change_government(old);
29125 *old = *real_packet;
29126 genhash_insert(*hash, old, old);
29127 } else {
29128 *old = *real_packet;
29129 }
29130
29131#else /* FREECIV_DELTA_PROTOCOL */
29132#ifdef FREECIV_JSON_CONNECTION
29133 field_addr.name = "government";
29134#endif /* FREECIV_JSON_CONNECTION */
29135
29136 {
29137 int readin;
29138
29139 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
29140 RECEIVE_PACKET_FIELD_ERROR(government);
29141 }
29142 real_packet->government = readin;
29143 }
29144#endif /* FREECIV_DELTA_PROTOCOL */
29145
29146 RECEIVE_PACKET_END(real_packet);
29147#undef FREE_PACKET_STRUCT
29148}
29149
29150 static int send_packet_player_change_government_100(struct connection *pc, const struct packet_player_change_government *packet)
29151{
29152 const struct packet_player_change_government *real_packet = packet;
29153 int e;
29154 SEND_PACKET_START(PACKET_PLAYER_CHANGE_GOVERNMENT);
29155
29156 log_packet_detailed("packet_player_change_government_100: sending info about ()");
29157
29158#ifdef FREECIV_DELTA_PROTOCOL
29159 packet_player_change_government_100_fields fields;
29160 struct packet_player_change_government *old;
29161 bool differ;
29162 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_CHANGE_GOVERNMENT;
29163
29164 if (nullptr == *hash) {
29165 *hash = genhash_new_full(hash_packet_player_change_government_100, cmp_packet_player_change_government_100,
29166 nullptr, nullptr, nullptr, destroy_packet_player_change_government);
29167 }
29168 BV_CLR_ALL(fields);
29169
29170 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29171 old = fc_malloc(sizeof(*old));
29172 /* temporary bitcopy just to insert correctly */
29173 *old = *real_packet;
29174 genhash_insert(*hash, old, old);
29175 init_packet_player_change_government(old);
29176 }
29177
29178 differ = (old->government != real_packet->government);
29179 if (differ) {
29180 BV_SET(fields, 0);
29181 }
29182#endif /* FREECIV_DELTA_PROTOCOL */
29183
29184#ifdef FREECIV_JSON_CONNECTION
29185 struct plocation field_addr;
29186 {
29187 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29188 field_addr = *field_addr_tmp;
29189 FC_FREE(field_addr_tmp);
29190 }
29191#endif /* FREECIV_JSON_CONNECTION */
29192
29193#ifdef FREECIV_DELTA_PROTOCOL
29194#ifdef FREECIV_JSON_CONNECTION
29195 field_addr.name = "fields";
29196#endif /* FREECIV_JSON_CONNECTION */
29197 e = 0;
29198 e |= DIO_BV_PUT(&dout, &field_addr, fields);
29199 if (e) {
29200 log_packet_detailed("fields bitvector error detected");
29201 }
29202
29203 if (BV_ISSET(fields, 0)) {
29204 log_packet_detailed(" field 'government' has changed");
29205
29206#ifdef FREECIV_JSON_CONNECTION
29207 field_addr.name = "government";
29208#endif /* FREECIV_JSON_CONNECTION */
29209 e = 0;
29210
29211 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government);
29212
29213 if (e) {
29214 log_packet_detailed("'government' field error detected");
29215 }
29216 }
29217
29218 *old = *real_packet;
29219
29220#else /* FREECIV_DELTA_PROTOCOL */
29221#ifdef FREECIV_JSON_CONNECTION
29222 field_addr.name = "government";
29223#endif /* FREECIV_JSON_CONNECTION */
29224 e = 0;
29225
29226 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government);
29227
29228 if (e) {
29229 log_packet_detailed("'government' field error detected");
29230 }
29231#endif /* FREECIV_DELTA_PROTOCOL */
29232
29233 SEND_PACKET_END(PACKET_PLAYER_CHANGE_GOVERNMENT);
29234}
29235
29236 int send_packet_player_change_government(struct connection *pc, const struct packet_player_change_government *packet)
29237{
29238 if (!pc->used) {
29239 log_error("WARNING: trying to send data to the closed connection %s",
29240 conn_description(pc));
29241 return -1;
29242 }
29243 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_CHANGE_GOVERNMENT].packet != nullptr, -1,
29244 "Handler for PACKET_PLAYER_CHANGE_GOVERNMENT not installed");
29245 return pc->phs.handlers->send[PACKET_PLAYER_CHANGE_GOVERNMENT].packet(pc, packet);
29246}
29247
29248 int dsend_packet_player_change_government(struct connection *pc, Government_type_id government)
29249{
29250 struct packet_player_change_government packet, *real_packet = &packet;
29251
29252 real_packet->government = government;
29253
29254 return send_packet_player_change_government(pc, real_packet);
29255}
29256
29257 static inline void init_packet_player_place_infra(struct packet_player_place_infra *packet)
29258{
29259 memset(packet, 0, sizeof(*packet));
29260}
29261
29262#define free_packet_player_place_infra(_packet) (void) 0
29263#define destroy_packet_player_place_infra free
29264
29265#ifdef FREECIV_DELTA_PROTOCOL
29266#define hash_packet_player_place_infra_100 hash_const
29267#define cmp_packet_player_place_infra_100 cmp_const
29268 BV_DEFINE(packet_player_place_infra_100_fields, 2);
29269#endif /* FREECIV_DELTA_PROTOCOL */
29270
29271 static struct packet_player_place_infra *receive_packet_player_place_infra_100(struct connection *pc)
29272{
29273#define FREE_PACKET_STRUCT(_packet) free_packet_player_place_infra(_packet)
29274 RECEIVE_PACKET_START(packet_player_place_infra, real_packet);
29275
29276#ifdef FREECIV_JSON_CONNECTION
29277 struct plocation field_addr;
29278 {
29279 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29280 field_addr = *field_addr_tmp;
29281 FC_FREE(field_addr_tmp);
29282 }
29283#endif /* FREECIV_JSON_CONNECTION */
29284
29285 log_packet_detailed("packet_player_place_infra_100: got info about ()");
29286
29287#ifdef FREECIV_DELTA_PROTOCOL
29288 packet_player_place_infra_100_fields fields;
29289 struct packet_player_place_infra *old;
29290 struct genhash **hash = pc->phs.received + PACKET_PLAYER_PLACE_INFRA;
29291
29292 if (nullptr == *hash) {
29293 *hash = genhash_new_full(hash_packet_player_place_infra_100, cmp_packet_player_place_infra_100,
29294 nullptr, nullptr, nullptr, destroy_packet_player_place_infra);
29295 }
29296
29297 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29298 *real_packet = *old;
29299 } else {
29300 /* packet is already initialized empty */
29301 log_packet_detailed(" no old info");
29302 }
29303
29304#ifdef FREECIV_JSON_CONNECTION
29305 field_addr.name = "fields";
29306#endif /* FREECIV_JSON_CONNECTION */
29307 DIO_BV_GET(&din, &field_addr, fields);
29308
29309 if (BV_ISSET(fields, 0)) {
29310 log_packet_detailed(" got field 'tile'");
29311
29312#ifdef FREECIV_JSON_CONNECTION
29313 field_addr.name = "tile";
29314#endif /* FREECIV_JSON_CONNECTION */
29315
29316 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
29317 RECEIVE_PACKET_FIELD_ERROR(tile);
29318 }
29319 }
29320
29321 if (BV_ISSET(fields, 1)) {
29322 log_packet_detailed(" got field 'extra'");
29323
29324#ifdef FREECIV_JSON_CONNECTION
29325 field_addr.name = "extra";
29326#endif /* FREECIV_JSON_CONNECTION */
29327
29328 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->extra)) {
29329 RECEIVE_PACKET_FIELD_ERROR(extra);
29330 }
29331 }
29332
29333 if (nullptr == old) {
29334 old = fc_malloc(sizeof(*old));
29335 init_packet_player_place_infra(old);
29336 *old = *real_packet;
29337 genhash_insert(*hash, old, old);
29338 } else {
29339 *old = *real_packet;
29340 }
29341
29342#else /* FREECIV_DELTA_PROTOCOL */
29343#ifdef FREECIV_JSON_CONNECTION
29344 field_addr.name = "tile";
29345#endif /* FREECIV_JSON_CONNECTION */
29346
29347 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
29348 RECEIVE_PACKET_FIELD_ERROR(tile);
29349 }
29350
29351#ifdef FREECIV_JSON_CONNECTION
29352 field_addr.name = "extra";
29353#endif /* FREECIV_JSON_CONNECTION */
29354
29355 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->extra)) {
29356 RECEIVE_PACKET_FIELD_ERROR(extra);
29357 }
29358#endif /* FREECIV_DELTA_PROTOCOL */
29359
29360 RECEIVE_PACKET_END(real_packet);
29361#undef FREE_PACKET_STRUCT
29362}
29363
29364 static int send_packet_player_place_infra_100(struct connection *pc, const struct packet_player_place_infra *packet)
29365{
29366 const struct packet_player_place_infra *real_packet = packet;
29367 int e;
29368 SEND_PACKET_START(PACKET_PLAYER_PLACE_INFRA);
29369
29370 log_packet_detailed("packet_player_place_infra_100: sending info about ()");
29371
29372#ifdef FREECIV_DELTA_PROTOCOL
29373 packet_player_place_infra_100_fields fields;
29374 struct packet_player_place_infra *old;
29375 bool differ;
29376 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_PLACE_INFRA;
29377
29378 if (nullptr == *hash) {
29379 *hash = genhash_new_full(hash_packet_player_place_infra_100, cmp_packet_player_place_infra_100,
29380 nullptr, nullptr, nullptr, destroy_packet_player_place_infra);
29381 }
29382 BV_CLR_ALL(fields);
29383
29384 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29385 old = fc_malloc(sizeof(*old));
29386 /* temporary bitcopy just to insert correctly */
29387 *old = *real_packet;
29388 genhash_insert(*hash, old, old);
29389 init_packet_player_place_infra(old);
29390 }
29391
29392 differ = (old->tile != real_packet->tile);
29393 if (differ) {
29394 BV_SET(fields, 0);
29395 }
29396
29397 differ = (old->extra != real_packet->extra);
29398 if (differ) {
29399 BV_SET(fields, 1);
29400 }
29401#endif /* FREECIV_DELTA_PROTOCOL */
29402
29403#ifdef FREECIV_JSON_CONNECTION
29404 struct plocation field_addr;
29405 {
29406 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29407 field_addr = *field_addr_tmp;
29408 FC_FREE(field_addr_tmp);
29409 }
29410#endif /* FREECIV_JSON_CONNECTION */
29411
29412#ifdef FREECIV_DELTA_PROTOCOL
29413#ifdef FREECIV_JSON_CONNECTION
29414 field_addr.name = "fields";
29415#endif /* FREECIV_JSON_CONNECTION */
29416 e = 0;
29417 e |= DIO_BV_PUT(&dout, &field_addr, fields);
29418 if (e) {
29419 log_packet_detailed("fields bitvector error detected");
29420 }
29421
29422 if (BV_ISSET(fields, 0)) {
29423 log_packet_detailed(" field 'tile' has changed");
29424
29425#ifdef FREECIV_JSON_CONNECTION
29426 field_addr.name = "tile";
29427#endif /* FREECIV_JSON_CONNECTION */
29428 e = 0;
29429
29430 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
29431
29432 if (e) {
29433 log_packet_detailed("'tile' field error detected");
29434 }
29435 }
29436
29437 if (BV_ISSET(fields, 1)) {
29438 log_packet_detailed(" field 'extra' has changed");
29439
29440#ifdef FREECIV_JSON_CONNECTION
29441 field_addr.name = "extra";
29442#endif /* FREECIV_JSON_CONNECTION */
29443 e = 0;
29444
29445 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->extra);
29446
29447 if (e) {
29448 log_packet_detailed("'extra' field error detected");
29449 }
29450 }
29451
29452 *old = *real_packet;
29453
29454#else /* FREECIV_DELTA_PROTOCOL */
29455#ifdef FREECIV_JSON_CONNECTION
29456 field_addr.name = "tile";
29457#endif /* FREECIV_JSON_CONNECTION */
29458 e = 0;
29459
29460 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
29461
29462 if (e) {
29463 log_packet_detailed("'tile' field error detected");
29464 }
29465
29466#ifdef FREECIV_JSON_CONNECTION
29467 field_addr.name = "extra";
29468#endif /* FREECIV_JSON_CONNECTION */
29469 e = 0;
29470
29471 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->extra);
29472
29473 if (e) {
29474 log_packet_detailed("'extra' field error detected");
29475 }
29476#endif /* FREECIV_DELTA_PROTOCOL */
29477
29478 SEND_PACKET_END(PACKET_PLAYER_PLACE_INFRA);
29479}
29480
29481 int send_packet_player_place_infra(struct connection *pc, const struct packet_player_place_infra *packet)
29482{
29483 if (!pc->used) {
29484 log_error("WARNING: trying to send data to the closed connection %s",
29485 conn_description(pc));
29486 return -1;
29487 }
29488 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_PLACE_INFRA].packet != nullptr, -1,
29489 "Handler for PACKET_PLAYER_PLACE_INFRA not installed");
29490 return pc->phs.handlers->send[PACKET_PLAYER_PLACE_INFRA].packet(pc, packet);
29491}
29492
29493 int dsend_packet_player_place_infra(struct connection *pc, int tile, int extra)
29494{
29495 struct packet_player_place_infra packet, *real_packet = &packet;
29496
29497 real_packet->tile = tile;
29498 real_packet->extra = extra;
29499
29500 return send_packet_player_place_infra(pc, real_packet);
29501}
29502
29503 static inline void init_packet_player_attribute_block(struct packet_player_attribute_block *packet)
29504{
29505 memset(packet, 0, sizeof(*packet));
29506}
29507
29508#define free_packet_player_attribute_block(_packet) (void) 0
29509#define destroy_packet_player_attribute_block free
29510
29511 static struct packet_player_attribute_block *receive_packet_player_attribute_block_100(struct connection *pc)
29512{
29513#define FREE_PACKET_STRUCT(_packet) free_packet_player_attribute_block(_packet)
29514 RECEIVE_PACKET_START(packet_player_attribute_block, real_packet);
29515
29516 log_packet_detailed("packet_player_attribute_block_100: got info about ()");
29517
29518 real_packet->__dummy = 0xff;
29519
29520 RECEIVE_PACKET_END(real_packet);
29521#undef FREE_PACKET_STRUCT
29522}
29523
29524 static int send_packet_player_attribute_block_100(struct connection *pc)
29525{
29526 SEND_PACKET_START(PACKET_PLAYER_ATTRIBUTE_BLOCK);
29527
29528 log_packet_detailed("packet_player_attribute_block_100: sending info about ()");
29529
29530 SEND_PACKET_END(PACKET_PLAYER_ATTRIBUTE_BLOCK);
29531}
29532
29533 int send_packet_player_attribute_block(struct connection *pc)
29534{
29535 if (!pc->used) {
29536 log_error("WARNING: trying to send data to the closed connection %s",
29537 conn_description(pc));
29538 return -1;
29539 }
29540 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_BLOCK].no_packet != nullptr, -1,
29541 "Handler for PACKET_PLAYER_ATTRIBUTE_BLOCK not installed");
29542 return pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_BLOCK].no_packet(pc);
29543}
29544
29545 static inline void init_packet_player_attribute_chunk(struct packet_player_attribute_chunk *packet)
29546{
29547 memset(packet, 0, sizeof(*packet));
29548}
29549
29550#define free_packet_player_attribute_chunk(_packet) (void) 0
29551#define destroy_packet_player_attribute_chunk free
29552
29553#ifdef FREECIV_DELTA_PROTOCOL
29554static genhash_val_t hash_packet_player_attribute_chunk_100(const void *vkey)
29555{
29556 const struct packet_player_attribute_chunk *key = (const struct packet_player_attribute_chunk *) vkey;
29557 genhash_val_t result = 0;
29558
29559 result += key->offset;
29560
29561 result &= 0xFFFFFFFF;
29562 return result;
29563}
29564
29565static bool cmp_packet_player_attribute_chunk_100(const void *vkey1, const void *vkey2)
29566{
29567 const struct packet_player_attribute_chunk *old = (const struct packet_player_attribute_chunk *) vkey1;
29568 const struct packet_player_attribute_chunk *real_packet = (const struct packet_player_attribute_chunk *) vkey2;
29569 bool differ;
29570
29571 differ = (old->offset != real_packet->offset);
29572
29573 return !differ;
29574}
29575 BV_DEFINE(packet_player_attribute_chunk_100_fields, 3);
29576#endif /* FREECIV_DELTA_PROTOCOL */
29577
29578 static struct packet_player_attribute_chunk *receive_packet_player_attribute_chunk_100(struct connection *pc)
29579{
29580#define FREE_PACKET_STRUCT(_packet) free_packet_player_attribute_chunk(_packet)
29581 RECEIVE_PACKET_START(packet_player_attribute_chunk, real_packet);
29582
29583#ifdef FREECIV_JSON_CONNECTION
29584 struct plocation field_addr;
29585 {
29586 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29587 field_addr = *field_addr_tmp;
29588 FC_FREE(field_addr_tmp);
29589 }
29590#endif /* FREECIV_JSON_CONNECTION */
29591
29592#ifdef FREECIV_JSON_CONNECTION
29593 field_addr.name = "offset";
29594#endif /* FREECIV_JSON_CONNECTION */
29595
29596 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->offset)) {
29597 RECEIVE_PACKET_FIELD_ERROR(offset);
29598 }
29599
29600 log_packet_detailed("packet_player_attribute_chunk_100: got info about (%d)",
29601 real_packet->offset);
29602
29603#ifdef FREECIV_DELTA_PROTOCOL
29604 packet_player_attribute_chunk_100_fields fields;
29605 struct packet_player_attribute_chunk *old;
29606 struct genhash **hash = pc->phs.received + PACKET_PLAYER_ATTRIBUTE_CHUNK;
29607
29608 if (nullptr == *hash) {
29609 *hash = genhash_new_full(hash_packet_player_attribute_chunk_100, cmp_packet_player_attribute_chunk_100,
29610 nullptr, nullptr, nullptr, destroy_packet_player_attribute_chunk);
29611 }
29612
29613 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29614 *real_packet = *old;
29615 } else {
29616 /* packet is already initialized empty */
29617 log_packet_detailed(" no old info");
29618 }
29619
29620#ifdef FREECIV_JSON_CONNECTION
29621 field_addr.name = "fields";
29622#endif /* FREECIV_JSON_CONNECTION */
29623 DIO_BV_GET(&din, &field_addr, fields);
29624
29625 if (BV_ISSET(fields, 0)) {
29626 log_packet_detailed(" got field 'total_length'");
29627
29628#ifdef FREECIV_JSON_CONNECTION
29629 field_addr.name = "total_length";
29630#endif /* FREECIV_JSON_CONNECTION */
29631
29632 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->total_length)) {
29633 RECEIVE_PACKET_FIELD_ERROR(total_length);
29634 }
29635 }
29636
29637 if (BV_ISSET(fields, 1)) {
29638 log_packet_detailed(" got field 'chunk_length'");
29639
29640#ifdef FREECIV_JSON_CONNECTION
29641 field_addr.name = "chunk_length";
29642#endif /* FREECIV_JSON_CONNECTION */
29643
29644 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->chunk_length)) {
29645 RECEIVE_PACKET_FIELD_ERROR(chunk_length);
29646 }
29647 }
29648
29649 if (BV_ISSET(fields, 2)) {
29650 log_packet_detailed(" got field 'data'");
29651
29652#ifdef FREECIV_JSON_CONNECTION
29653 field_addr.name = "data";
29654#endif /* FREECIV_JSON_CONNECTION */
29655
29656 if (real_packet->chunk_length > ATTRIBUTE_CHUNK_SIZE) {
29657 RECEIVE_PACKET_FIELD_ERROR(data, ": array truncated");
29658 }
29659 if (!DIO_GET(memory, &din, &field_addr, real_packet->data, real_packet->chunk_length)) {
29660 RECEIVE_PACKET_FIELD_ERROR(data);
29661 }
29662 }
29663
29664 if (nullptr == old) {
29665 old = fc_malloc(sizeof(*old));
29666 init_packet_player_attribute_chunk(old);
29667 *old = *real_packet;
29668 genhash_insert(*hash, old, old);
29669 } else {
29670 *old = *real_packet;
29671 }
29672
29673#else /* FREECIV_DELTA_PROTOCOL */
29674#ifdef FREECIV_JSON_CONNECTION
29675 field_addr.name = "total_length";
29676#endif /* FREECIV_JSON_CONNECTION */
29677
29678 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->total_length)) {
29679 RECEIVE_PACKET_FIELD_ERROR(total_length);
29680 }
29681
29682#ifdef FREECIV_JSON_CONNECTION
29683 field_addr.name = "chunk_length";
29684#endif /* FREECIV_JSON_CONNECTION */
29685
29686 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->chunk_length)) {
29687 RECEIVE_PACKET_FIELD_ERROR(chunk_length);
29688 }
29689
29690#ifdef FREECIV_JSON_CONNECTION
29691 field_addr.name = "data";
29692#endif /* FREECIV_JSON_CONNECTION */
29693
29694 if (real_packet->chunk_length > ATTRIBUTE_CHUNK_SIZE) {
29695 RECEIVE_PACKET_FIELD_ERROR(data, ": array truncated");
29696 }
29697 if (!DIO_GET(memory, &din, &field_addr, real_packet->data, real_packet->chunk_length)) {
29698 RECEIVE_PACKET_FIELD_ERROR(data);
29699 }
29700#endif /* FREECIV_DELTA_PROTOCOL */
29701
29702 RECEIVE_PACKET_END(real_packet);
29703#undef FREE_PACKET_STRUCT
29704}
29705
29706 static int send_packet_player_attribute_chunk_100(struct connection *pc, const struct packet_player_attribute_chunk *packet)
29707{
29708 /* copy packet for pre-send */
29709 struct packet_player_attribute_chunk packet_buf = *packet;
29710 const struct packet_player_attribute_chunk *real_packet = &packet_buf;
29711 int e;
29712 SEND_PACKET_START(PACKET_PLAYER_ATTRIBUTE_CHUNK);
29713
29714 log_packet_detailed("packet_player_attribute_chunk_100: sending info about (%d)",
29715 real_packet->offset);
29716
29717 pre_send_packet_player_attribute_chunk(pc, &packet_buf);
29718
29719#ifdef FREECIV_DELTA_PROTOCOL
29720 packet_player_attribute_chunk_100_fields fields;
29721 struct packet_player_attribute_chunk *old;
29722 bool differ;
29723 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_ATTRIBUTE_CHUNK;
29724
29725 if (nullptr == *hash) {
29726 *hash = genhash_new_full(hash_packet_player_attribute_chunk_100, cmp_packet_player_attribute_chunk_100,
29727 nullptr, nullptr, nullptr, destroy_packet_player_attribute_chunk);
29728 }
29729 BV_CLR_ALL(fields);
29730
29731 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
29732 old = fc_malloc(sizeof(*old));
29733 /* temporary bitcopy just to insert correctly */
29734 *old = *real_packet;
29735 genhash_insert(*hash, old, old);
29736 init_packet_player_attribute_chunk(old);
29737 }
29738
29739 differ = (old->total_length != real_packet->total_length);
29740 if (differ) {
29741 BV_SET(fields, 0);
29742 }
29743
29744 differ = (old->chunk_length != real_packet->chunk_length);
29745 if (differ) {
29746 BV_SET(fields, 1);
29747 }
29748
29749 differ = ((old->chunk_length != real_packet->chunk_length)
29750 || (memcmp(old->data, real_packet->data, real_packet->chunk_length) != 0));
29751 if (differ) {
29752 BV_SET(fields, 2);
29753 }
29754#endif /* FREECIV_DELTA_PROTOCOL */
29755
29756#ifdef FREECIV_JSON_CONNECTION
29757 struct plocation field_addr;
29758 {
29759 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29760 field_addr = *field_addr_tmp;
29761 FC_FREE(field_addr_tmp);
29762 }
29763#endif /* FREECIV_JSON_CONNECTION */
29764
29765#ifdef FREECIV_JSON_CONNECTION
29766 field_addr.name = "offset";
29767#endif /* FREECIV_JSON_CONNECTION */
29768 e = 0;
29769
29770 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->offset);
29771
29772 if (e) {
29773 log_packet_detailed("'offset' field error detected");
29774 }
29775
29776#ifdef FREECIV_DELTA_PROTOCOL
29777#ifdef FREECIV_JSON_CONNECTION
29778 field_addr.name = "fields";
29779#endif /* FREECIV_JSON_CONNECTION */
29780 e = 0;
29781 e |= DIO_BV_PUT(&dout, &field_addr, fields);
29782 if (e) {
29783 log_packet_detailed("fields bitvector error detected");
29784 }
29785
29786 if (BV_ISSET(fields, 0)) {
29787 log_packet_detailed(" field 'total_length' has changed");
29788
29789#ifdef FREECIV_JSON_CONNECTION
29790 field_addr.name = "total_length";
29791#endif /* FREECIV_JSON_CONNECTION */
29792 e = 0;
29793
29794 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->total_length);
29795
29796 if (e) {
29797 log_packet_detailed("'total_length' field error detected");
29798 }
29799 }
29800
29801 if (BV_ISSET(fields, 1)) {
29802 log_packet_detailed(" field 'chunk_length' has changed");
29803
29804#ifdef FREECIV_JSON_CONNECTION
29805 field_addr.name = "chunk_length";
29806#endif /* FREECIV_JSON_CONNECTION */
29807 e = 0;
29808
29809 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->chunk_length);
29810
29811 if (e) {
29812 log_packet_detailed("'chunk_length' field error detected");
29813 }
29814 }
29815
29816 if (BV_ISSET(fields, 2)) {
29817 log_packet_detailed(" field 'data' has changed");
29818
29819#ifdef FREECIV_JSON_CONNECTION
29820 field_addr.name = "data";
29821#endif /* FREECIV_JSON_CONNECTION */
29822 e = 0;
29823
29824 e |= DIO_PUT(memory, &dout, &field_addr, &real_packet->data, real_packet->chunk_length);
29825
29826 if (e) {
29827 log_packet_detailed("'data' field error detected");
29828 }
29829 }
29830
29831 *old = *real_packet;
29832
29833#else /* FREECIV_DELTA_PROTOCOL */
29834#ifdef FREECIV_JSON_CONNECTION
29835 field_addr.name = "total_length";
29836#endif /* FREECIV_JSON_CONNECTION */
29837 e = 0;
29838
29839 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->total_length);
29840
29841 if (e) {
29842 log_packet_detailed("'total_length' field error detected");
29843 }
29844
29845#ifdef FREECIV_JSON_CONNECTION
29846 field_addr.name = "chunk_length";
29847#endif /* FREECIV_JSON_CONNECTION */
29848 e = 0;
29849
29850 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->chunk_length);
29851
29852 if (e) {
29853 log_packet_detailed("'chunk_length' field error detected");
29854 }
29855
29856#ifdef FREECIV_JSON_CONNECTION
29857 field_addr.name = "data";
29858#endif /* FREECIV_JSON_CONNECTION */
29859 e = 0;
29860
29861 e |= DIO_PUT(memory, &dout, &field_addr, &real_packet->data, real_packet->chunk_length);
29862
29863 if (e) {
29864 log_packet_detailed("'data' field error detected");
29865 }
29866#endif /* FREECIV_DELTA_PROTOCOL */
29867
29868 SEND_PACKET_END(PACKET_PLAYER_ATTRIBUTE_CHUNK);
29869}
29870
29871 int send_packet_player_attribute_chunk(struct connection *pc, const struct packet_player_attribute_chunk *packet)
29872{
29873 if (!pc->used) {
29874 log_error("WARNING: trying to send data to the closed connection %s",
29875 conn_description(pc));
29876 return -1;
29877 }
29878 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_CHUNK].packet != nullptr, -1,
29879 "Handler for PACKET_PLAYER_ATTRIBUTE_CHUNK not installed");
29880 return pc->phs.handlers->send[PACKET_PLAYER_ATTRIBUTE_CHUNK].packet(pc, packet);
29881}
29882
29883 static inline void init_packet_player_diplstate(struct packet_player_diplstate *packet)
29884{
29885 memset(packet, 0, sizeof(*packet));
29886}
29887
29888#define free_packet_player_diplstate(_packet) (void) 0
29889#define destroy_packet_player_diplstate free
29890
29891#ifdef FREECIV_DELTA_PROTOCOL
29892static genhash_val_t hash_packet_player_diplstate_100(const void *vkey)
29893{
29894 const struct packet_player_diplstate *key = (const struct packet_player_diplstate *) vkey;
29895 genhash_val_t result = 0;
29896
29897 result += key->diplstate_id;
29898
29899 result &= 0xFFFFFFFF;
29900 return result;
29901}
29902
29903static bool cmp_packet_player_diplstate_100(const void *vkey1, const void *vkey2)
29904{
29905 const struct packet_player_diplstate *old = (const struct packet_player_diplstate *) vkey1;
29906 const struct packet_player_diplstate *real_packet = (const struct packet_player_diplstate *) vkey2;
29907 bool differ;
29908
29909 differ = (old->diplstate_id != real_packet->diplstate_id);
29910
29911 return !differ;
29912}
29913 BV_DEFINE(packet_player_diplstate_100_fields, 6);
29914#endif /* FREECIV_DELTA_PROTOCOL */
29915
29916 static struct packet_player_diplstate *receive_packet_player_diplstate_100(struct connection *pc)
29917{
29918#define FREE_PACKET_STRUCT(_packet) free_packet_player_diplstate(_packet)
29919 RECEIVE_PACKET_START(packet_player_diplstate, real_packet);
29920
29921#ifdef FREECIV_JSON_CONNECTION
29922 struct plocation field_addr;
29923 {
29924 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
29925 field_addr = *field_addr_tmp;
29926 FC_FREE(field_addr_tmp);
29927 }
29928#endif /* FREECIV_JSON_CONNECTION */
29929
29930#ifdef FREECIV_JSON_CONNECTION
29931 field_addr.name = "diplstate_id";
29932#endif /* FREECIV_JSON_CONNECTION */
29933
29934 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->diplstate_id)) {
29935 RECEIVE_PACKET_FIELD_ERROR(diplstate_id);
29936 }
29937
29938 log_packet_detailed("packet_player_diplstate_100: got info about (%d)",
29939 real_packet->diplstate_id);
29940
29941#ifdef FREECIV_DELTA_PROTOCOL
29942 packet_player_diplstate_100_fields fields;
29943 struct packet_player_diplstate *old;
29944 struct genhash **hash = pc->phs.received + PACKET_PLAYER_DIPLSTATE;
29945
29946 if (nullptr == *hash) {
29947 *hash = genhash_new_full(hash_packet_player_diplstate_100, cmp_packet_player_diplstate_100,
29948 nullptr, nullptr, nullptr, destroy_packet_player_diplstate);
29949 }
29950
29951 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
29952 *real_packet = *old;
29953 } else {
29954 /* packet is already initialized empty */
29955 log_packet_detailed(" no old info");
29956 }
29957
29958#ifdef FREECIV_JSON_CONNECTION
29959 field_addr.name = "fields";
29960#endif /* FREECIV_JSON_CONNECTION */
29961 DIO_BV_GET(&din, &field_addr, fields);
29962
29963 if (BV_ISSET(fields, 0)) {
29964 log_packet_detailed(" got field 'plr1'");
29965
29966#ifdef FREECIV_JSON_CONNECTION
29967 field_addr.name = "plr1";
29968#endif /* FREECIV_JSON_CONNECTION */
29969
29970 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->plr1)) {
29971 RECEIVE_PACKET_FIELD_ERROR(plr1);
29972 }
29973 }
29974
29975 if (BV_ISSET(fields, 1)) {
29976 log_packet_detailed(" got field 'plr2'");
29977
29978#ifdef FREECIV_JSON_CONNECTION
29979 field_addr.name = "plr2";
29980#endif /* FREECIV_JSON_CONNECTION */
29981
29982 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->plr2)) {
29983 RECEIVE_PACKET_FIELD_ERROR(plr2);
29984 }
29985 }
29986
29987 if (BV_ISSET(fields, 2)) {
29988 log_packet_detailed(" got field 'type'");
29989
29990#ifdef FREECIV_JSON_CONNECTION
29991 field_addr.name = "type";
29992#endif /* FREECIV_JSON_CONNECTION */
29993
29994 {
29995 int readin;
29996
29997 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
29998 RECEIVE_PACKET_FIELD_ERROR(type);
29999 }
30000 real_packet->type = readin;
30001 }
30002 }
30003
30004 if (BV_ISSET(fields, 3)) {
30005 log_packet_detailed(" got field 'turns_left'");
30006
30007#ifdef FREECIV_JSON_CONNECTION
30008 field_addr.name = "turns_left";
30009#endif /* FREECIV_JSON_CONNECTION */
30010
30011 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->turns_left)) {
30012 RECEIVE_PACKET_FIELD_ERROR(turns_left);
30013 }
30014 }
30015
30016 if (BV_ISSET(fields, 4)) {
30017 log_packet_detailed(" got field 'has_reason_to_cancel'");
30018
30019#ifdef FREECIV_JSON_CONNECTION
30020 field_addr.name = "has_reason_to_cancel";
30021#endif /* FREECIV_JSON_CONNECTION */
30022
30023 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->has_reason_to_cancel)) {
30024 RECEIVE_PACKET_FIELD_ERROR(has_reason_to_cancel);
30025 }
30026 }
30027
30028 if (BV_ISSET(fields, 5)) {
30029 log_packet_detailed(" got field 'contact_turns_left'");
30030
30031#ifdef FREECIV_JSON_CONNECTION
30032 field_addr.name = "contact_turns_left";
30033#endif /* FREECIV_JSON_CONNECTION */
30034
30035 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->contact_turns_left)) {
30036 RECEIVE_PACKET_FIELD_ERROR(contact_turns_left);
30037 }
30038 }
30039
30040 if (nullptr == old) {
30041 old = fc_malloc(sizeof(*old));
30042 init_packet_player_diplstate(old);
30043 *old = *real_packet;
30044 genhash_insert(*hash, old, old);
30045 } else {
30046 *old = *real_packet;
30047 }
30048
30049#else /* FREECIV_DELTA_PROTOCOL */
30050#ifdef FREECIV_JSON_CONNECTION
30051 field_addr.name = "plr1";
30052#endif /* FREECIV_JSON_CONNECTION */
30053
30054 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->plr1)) {
30055 RECEIVE_PACKET_FIELD_ERROR(plr1);
30056 }
30057
30058#ifdef FREECIV_JSON_CONNECTION
30059 field_addr.name = "plr2";
30060#endif /* FREECIV_JSON_CONNECTION */
30061
30062 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->plr2)) {
30063 RECEIVE_PACKET_FIELD_ERROR(plr2);
30064 }
30065
30066#ifdef FREECIV_JSON_CONNECTION
30067 field_addr.name = "type";
30068#endif /* FREECIV_JSON_CONNECTION */
30069
30070 {
30071 int readin;
30072
30073 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
30074 RECEIVE_PACKET_FIELD_ERROR(type);
30075 }
30076 real_packet->type = readin;
30077 }
30078
30079#ifdef FREECIV_JSON_CONNECTION
30080 field_addr.name = "turns_left";
30081#endif /* FREECIV_JSON_CONNECTION */
30082
30083 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->turns_left)) {
30084 RECEIVE_PACKET_FIELD_ERROR(turns_left);
30085 }
30086
30087#ifdef FREECIV_JSON_CONNECTION
30088 field_addr.name = "has_reason_to_cancel";
30089#endif /* FREECIV_JSON_CONNECTION */
30090
30091 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->has_reason_to_cancel)) {
30092 RECEIVE_PACKET_FIELD_ERROR(has_reason_to_cancel);
30093 }
30094
30095#ifdef FREECIV_JSON_CONNECTION
30096 field_addr.name = "contact_turns_left";
30097#endif /* FREECIV_JSON_CONNECTION */
30098
30099 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->contact_turns_left)) {
30100 RECEIVE_PACKET_FIELD_ERROR(contact_turns_left);
30101 }
30102#endif /* FREECIV_DELTA_PROTOCOL */
30103
30104 RECEIVE_PACKET_END(real_packet);
30105#undef FREE_PACKET_STRUCT
30106}
30107
30108 static int send_packet_player_diplstate_100(struct connection *pc, const struct packet_player_diplstate *packet)
30109{
30110 const struct packet_player_diplstate *real_packet = packet;
30111 int e;
30112 SEND_PACKET_START(PACKET_PLAYER_DIPLSTATE);
30113
30114 log_packet_detailed("packet_player_diplstate_100: sending info about (%d)",
30115 real_packet->diplstate_id);
30116
30117#ifdef FREECIV_DELTA_PROTOCOL
30118 packet_player_diplstate_100_fields fields;
30119 struct packet_player_diplstate *old;
30120 bool differ;
30121 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_DIPLSTATE;
30122
30123 if (nullptr == *hash) {
30124 *hash = genhash_new_full(hash_packet_player_diplstate_100, cmp_packet_player_diplstate_100,
30125 nullptr, nullptr, nullptr, destroy_packet_player_diplstate);
30126 }
30127 BV_CLR_ALL(fields);
30128
30129 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
30130 old = fc_malloc(sizeof(*old));
30131 /* temporary bitcopy just to insert correctly */
30132 *old = *real_packet;
30133 genhash_insert(*hash, old, old);
30134 init_packet_player_diplstate(old);
30135 }
30136
30137 differ = (old->plr1 != real_packet->plr1);
30138 if (differ) {
30139 BV_SET(fields, 0);
30140 }
30141
30142 differ = (old->plr2 != real_packet->plr2);
30143 if (differ) {
30144 BV_SET(fields, 1);
30145 }
30146
30147 differ = (old->type != real_packet->type);
30148 if (differ) {
30149 BV_SET(fields, 2);
30150 }
30151
30152 differ = (old->turns_left != real_packet->turns_left);
30153 if (differ) {
30154 BV_SET(fields, 3);
30155 }
30156
30157 differ = (old->has_reason_to_cancel != real_packet->has_reason_to_cancel);
30158 if (differ) {
30159 BV_SET(fields, 4);
30160 }
30161
30162 differ = (old->contact_turns_left != real_packet->contact_turns_left);
30163 if (differ) {
30164 BV_SET(fields, 5);
30165 }
30166#endif /* FREECIV_DELTA_PROTOCOL */
30167
30168#ifdef FREECIV_JSON_CONNECTION
30169 struct plocation field_addr;
30170 {
30171 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
30172 field_addr = *field_addr_tmp;
30173 FC_FREE(field_addr_tmp);
30174 }
30175#endif /* FREECIV_JSON_CONNECTION */
30176
30177#ifdef FREECIV_JSON_CONNECTION
30178 field_addr.name = "diplstate_id";
30179#endif /* FREECIV_JSON_CONNECTION */
30180 e = 0;
30181
30182 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->diplstate_id);
30183
30184 if (e) {
30185 log_packet_detailed("'diplstate_id' field error detected");
30186 }
30187
30188#ifdef FREECIV_DELTA_PROTOCOL
30189#ifdef FREECIV_JSON_CONNECTION
30190 field_addr.name = "fields";
30191#endif /* FREECIV_JSON_CONNECTION */
30192 e = 0;
30193 e |= DIO_BV_PUT(&dout, &field_addr, fields);
30194 if (e) {
30195 log_packet_detailed("fields bitvector error detected");
30196 }
30197
30198 if (BV_ISSET(fields, 0)) {
30199 log_packet_detailed(" field 'plr1' has changed");
30200
30201#ifdef FREECIV_JSON_CONNECTION
30202 field_addr.name = "plr1";
30203#endif /* FREECIV_JSON_CONNECTION */
30204 e = 0;
30205
30206 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->plr1);
30207
30208 if (e) {
30209 log_packet_detailed("'plr1' field error detected");
30210 }
30211 }
30212
30213 if (BV_ISSET(fields, 1)) {
30214 log_packet_detailed(" field 'plr2' has changed");
30215
30216#ifdef FREECIV_JSON_CONNECTION
30217 field_addr.name = "plr2";
30218#endif /* FREECIV_JSON_CONNECTION */
30219 e = 0;
30220
30221 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->plr2);
30222
30223 if (e) {
30224 log_packet_detailed("'plr2' field error detected");
30225 }
30226 }
30227
30228 if (BV_ISSET(fields, 2)) {
30229 log_packet_detailed(" field 'type' has changed");
30230
30231#ifdef FREECIV_JSON_CONNECTION
30232 field_addr.name = "type";
30233#endif /* FREECIV_JSON_CONNECTION */
30234 e = 0;
30235
30236 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
30237
30238 if (e) {
30239 log_packet_detailed("'type' field error detected");
30240 }
30241 }
30242
30243 if (BV_ISSET(fields, 3)) {
30244 log_packet_detailed(" field 'turns_left' has changed");
30245
30246#ifdef FREECIV_JSON_CONNECTION
30247 field_addr.name = "turns_left";
30248#endif /* FREECIV_JSON_CONNECTION */
30249 e = 0;
30250
30251 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->turns_left);
30252
30253 if (e) {
30254 log_packet_detailed("'turns_left' field error detected");
30255 }
30256 }
30257
30258 if (BV_ISSET(fields, 4)) {
30259 log_packet_detailed(" field 'has_reason_to_cancel' has changed");
30260
30261#ifdef FREECIV_JSON_CONNECTION
30262 field_addr.name = "has_reason_to_cancel";
30263#endif /* FREECIV_JSON_CONNECTION */
30264 e = 0;
30265
30266 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->has_reason_to_cancel);
30267
30268 if (e) {
30269 log_packet_detailed("'has_reason_to_cancel' field error detected");
30270 }
30271 }
30272
30273 if (BV_ISSET(fields, 5)) {
30274 log_packet_detailed(" field 'contact_turns_left' has changed");
30275
30276#ifdef FREECIV_JSON_CONNECTION
30277 field_addr.name = "contact_turns_left";
30278#endif /* FREECIV_JSON_CONNECTION */
30279 e = 0;
30280
30281 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->contact_turns_left);
30282
30283 if (e) {
30284 log_packet_detailed("'contact_turns_left' field error detected");
30285 }
30286 }
30287
30288 *old = *real_packet;
30289
30290#else /* FREECIV_DELTA_PROTOCOL */
30291#ifdef FREECIV_JSON_CONNECTION
30292 field_addr.name = "plr1";
30293#endif /* FREECIV_JSON_CONNECTION */
30294 e = 0;
30295
30296 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->plr1);
30297
30298 if (e) {
30299 log_packet_detailed("'plr1' field error detected");
30300 }
30301
30302#ifdef FREECIV_JSON_CONNECTION
30303 field_addr.name = "plr2";
30304#endif /* FREECIV_JSON_CONNECTION */
30305 e = 0;
30306
30307 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->plr2);
30308
30309 if (e) {
30310 log_packet_detailed("'plr2' field error detected");
30311 }
30312
30313#ifdef FREECIV_JSON_CONNECTION
30314 field_addr.name = "type";
30315#endif /* FREECIV_JSON_CONNECTION */
30316 e = 0;
30317
30318 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
30319
30320 if (e) {
30321 log_packet_detailed("'type' field error detected");
30322 }
30323
30324#ifdef FREECIV_JSON_CONNECTION
30325 field_addr.name = "turns_left";
30326#endif /* FREECIV_JSON_CONNECTION */
30327 e = 0;
30328
30329 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->turns_left);
30330
30331 if (e) {
30332 log_packet_detailed("'turns_left' field error detected");
30333 }
30334
30335#ifdef FREECIV_JSON_CONNECTION
30336 field_addr.name = "has_reason_to_cancel";
30337#endif /* FREECIV_JSON_CONNECTION */
30338 e = 0;
30339
30340 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->has_reason_to_cancel);
30341
30342 if (e) {
30343 log_packet_detailed("'has_reason_to_cancel' field error detected");
30344 }
30345
30346#ifdef FREECIV_JSON_CONNECTION
30347 field_addr.name = "contact_turns_left";
30348#endif /* FREECIV_JSON_CONNECTION */
30349 e = 0;
30350
30351 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->contact_turns_left);
30352
30353 if (e) {
30354 log_packet_detailed("'contact_turns_left' field error detected");
30355 }
30356#endif /* FREECIV_DELTA_PROTOCOL */
30357
30358 SEND_PACKET_END(PACKET_PLAYER_DIPLSTATE);
30359}
30360
30361 int send_packet_player_diplstate(struct connection *pc, const struct packet_player_diplstate *packet)
30362{
30363 if (!pc->used) {
30364 log_error("WARNING: trying to send data to the closed connection %s",
30365 conn_description(pc));
30366 return -1;
30367 }
30368 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_DIPLSTATE].packet != nullptr, -1,
30369 "Handler for PACKET_PLAYER_DIPLSTATE not installed");
30370 return pc->phs.handlers->send[PACKET_PLAYER_DIPLSTATE].packet(pc, packet);
30371}
30372
30373 static inline void init_packet_player_multiplier(struct packet_player_multiplier *packet)
30374{
30375 memset(packet, 0, sizeof(*packet));
30376}
30377
30378#define free_packet_player_multiplier(_packet) (void) 0
30379#define destroy_packet_player_multiplier free
30380
30381#ifdef FREECIV_DELTA_PROTOCOL
30382#define hash_packet_player_multiplier_100 hash_const
30383#define cmp_packet_player_multiplier_100 cmp_const
30384 BV_DEFINE(packet_player_multiplier_100_fields, 2);
30385#endif /* FREECIV_DELTA_PROTOCOL */
30386
30387 static struct packet_player_multiplier *receive_packet_player_multiplier_100(struct connection *pc)
30388{
30389#define FREE_PACKET_STRUCT(_packet) free_packet_player_multiplier(_packet)
30390 RECEIVE_PACKET_START(packet_player_multiplier, real_packet);
30391
30392#ifdef FREECIV_JSON_CONNECTION
30393 struct plocation field_addr;
30394 {
30395 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
30396 field_addr = *field_addr_tmp;
30397 FC_FREE(field_addr_tmp);
30398 }
30399#endif /* FREECIV_JSON_CONNECTION */
30400
30401 log_packet_detailed("packet_player_multiplier_100: got info about ()");
30402
30403#ifdef FREECIV_DELTA_PROTOCOL
30404 packet_player_multiplier_100_fields fields;
30405 struct packet_player_multiplier *old;
30406 struct genhash **hash = pc->phs.received + PACKET_PLAYER_MULTIPLIER;
30407
30408 if (nullptr == *hash) {
30409 *hash = genhash_new_full(hash_packet_player_multiplier_100, cmp_packet_player_multiplier_100,
30410 nullptr, nullptr, nullptr, destroy_packet_player_multiplier);
30411 }
30412
30413 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
30414 *real_packet = *old;
30415 } else {
30416 /* packet is already initialized empty */
30417 log_packet_detailed(" no old info");
30418 }
30419
30420#ifdef FREECIV_JSON_CONNECTION
30421 field_addr.name = "fields";
30422#endif /* FREECIV_JSON_CONNECTION */
30423 DIO_BV_GET(&din, &field_addr, fields);
30424
30425 if (BV_ISSET(fields, 0)) {
30426 log_packet_detailed(" got field 'count'");
30427
30428#ifdef FREECIV_JSON_CONNECTION
30429 field_addr.name = "count";
30430#endif /* FREECIV_JSON_CONNECTION */
30431
30432 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->count)) {
30433 RECEIVE_PACKET_FIELD_ERROR(count);
30434 }
30435 }
30436
30437 if (BV_ISSET(fields, 1)) {
30438 log_packet_detailed(" got field 'multipliers'");
30439
30440#ifdef FREECIV_JSON_CONNECTION
30441 field_addr.name = "multipliers";
30442#endif /* FREECIV_JSON_CONNECTION */
30443
30444 {
30445 int i;
30446
30447 if (real_packet->count > MAX_NUM_MULTIPLIERS) {
30448 RECEIVE_PACKET_FIELD_ERROR(multipliers, ": array truncated");
30449 }
30450
30451#ifdef FREECIV_JSON_CONNECTION
30452 /* Enter array. */
30453 field_addr.sub_location = plocation_elem_new(0);
30454#endif /* FREECIV_JSON_CONNECTION */
30455
30456 for (i = 0; i < real_packet->count; i++) {
30457#ifdef FREECIV_JSON_CONNECTION
30458 /* Next array element */
30459 field_addr.sub_location->number = i;
30460#endif /* FREECIV_JSON_CONNECTION */
30461
30462 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->multipliers[i])) {
30463 RECEIVE_PACKET_FIELD_ERROR(multipliers);
30464 }
30465 }
30466
30467#ifdef FREECIV_JSON_CONNECTION
30468 /* Exit array. */
30469 FC_FREE(field_addr.sub_location);
30470#endif /* FREECIV_JSON_CONNECTION */
30471 }
30472 }
30473
30474 if (nullptr == old) {
30475 old = fc_malloc(sizeof(*old));
30476 init_packet_player_multiplier(old);
30477 *old = *real_packet;
30478 genhash_insert(*hash, old, old);
30479 } else {
30480 *old = *real_packet;
30481 }
30482
30483#else /* FREECIV_DELTA_PROTOCOL */
30484#ifdef FREECIV_JSON_CONNECTION
30485 field_addr.name = "count";
30486#endif /* FREECIV_JSON_CONNECTION */
30487
30488 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->count)) {
30489 RECEIVE_PACKET_FIELD_ERROR(count);
30490 }
30491
30492#ifdef FREECIV_JSON_CONNECTION
30493 field_addr.name = "multipliers";
30494#endif /* FREECIV_JSON_CONNECTION */
30495
30496 {
30497 int i;
30498
30499 if (real_packet->count > MAX_NUM_MULTIPLIERS) {
30500 RECEIVE_PACKET_FIELD_ERROR(multipliers, ": array truncated");
30501 }
30502
30503#ifdef FREECIV_JSON_CONNECTION
30504 /* Enter array. */
30505 field_addr.sub_location = plocation_elem_new(0);
30506#endif /* FREECIV_JSON_CONNECTION */
30507
30508 for (i = 0; i < real_packet->count; i++) {
30509#ifdef FREECIV_JSON_CONNECTION
30510 /* Next array element */
30511 field_addr.sub_location->number = i;
30512#endif /* FREECIV_JSON_CONNECTION */
30513
30514 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->multipliers[i])) {
30515 RECEIVE_PACKET_FIELD_ERROR(multipliers);
30516 }
30517 }
30518
30519#ifdef FREECIV_JSON_CONNECTION
30520 /* Exit array. */
30521 FC_FREE(field_addr.sub_location);
30522#endif /* FREECIV_JSON_CONNECTION */
30523 }
30524#endif /* FREECIV_DELTA_PROTOCOL */
30525
30526 RECEIVE_PACKET_END(real_packet);
30527#undef FREE_PACKET_STRUCT
30528}
30529
30530 static int send_packet_player_multiplier_100(struct connection *pc, const struct packet_player_multiplier *packet)
30531{
30532 const struct packet_player_multiplier *real_packet = packet;
30533 int e;
30534 SEND_PACKET_START(PACKET_PLAYER_MULTIPLIER);
30535
30536 log_packet_detailed("packet_player_multiplier_100: sending info about ()");
30537
30538#ifdef FREECIV_DELTA_PROTOCOL
30539 packet_player_multiplier_100_fields fields;
30540 struct packet_player_multiplier *old;
30541 bool differ;
30542 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_MULTIPLIER;
30543
30544 if (nullptr == *hash) {
30545 *hash = genhash_new_full(hash_packet_player_multiplier_100, cmp_packet_player_multiplier_100,
30546 nullptr, nullptr, nullptr, destroy_packet_player_multiplier);
30547 }
30548 BV_CLR_ALL(fields);
30549
30550 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
30551 old = fc_malloc(sizeof(*old));
30552 /* temporary bitcopy just to insert correctly */
30553 *old = *real_packet;
30554 genhash_insert(*hash, old, old);
30555 init_packet_player_multiplier(old);
30556 }
30557
30558 differ = (old->count != real_packet->count);
30559 if (differ) {
30560 BV_SET(fields, 0);
30561 }
30562
30563 differ = (old->count != real_packet->count);
30564 if (!differ) {
30565 int i;
30566
30567 for (i = 0; i < old->count; i++) {
30568 differ = (old->multipliers[i] != real_packet->multipliers[i]);
30569 if (differ) {
30570 break;
30571 }
30572 }
30573 }
30574 if (differ) {
30575 BV_SET(fields, 1);
30576 }
30577#endif /* FREECIV_DELTA_PROTOCOL */
30578
30579#ifdef FREECIV_JSON_CONNECTION
30580 struct plocation field_addr;
30581 {
30582 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
30583 field_addr = *field_addr_tmp;
30584 FC_FREE(field_addr_tmp);
30585 }
30586#endif /* FREECIV_JSON_CONNECTION */
30587
30588#ifdef FREECIV_DELTA_PROTOCOL
30589#ifdef FREECIV_JSON_CONNECTION
30590 field_addr.name = "fields";
30591#endif /* FREECIV_JSON_CONNECTION */
30592 e = 0;
30593 e |= DIO_BV_PUT(&dout, &field_addr, fields);
30594 if (e) {
30595 log_packet_detailed("fields bitvector error detected");
30596 }
30597
30598 if (BV_ISSET(fields, 0)) {
30599 log_packet_detailed(" field 'count' has changed");
30600
30601#ifdef FREECIV_JSON_CONNECTION
30602 field_addr.name = "count";
30603#endif /* FREECIV_JSON_CONNECTION */
30604 e = 0;
30605
30606 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->count);
30607
30608 if (e) {
30609 log_packet_detailed("'count' field error detected");
30610 }
30611 }
30612
30613 if (BV_ISSET(fields, 1)) {
30614 log_packet_detailed(" field 'multipliers' has changed");
30615
30616#ifdef FREECIV_JSON_CONNECTION
30617 field_addr.name = "multipliers";
30618#endif /* FREECIV_JSON_CONNECTION */
30619 e = 0;
30620
30621 {
30622 int i;
30623
30624#ifdef FREECIV_JSON_CONNECTION
30625 /* Create the array. */
30626 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->count);
30627
30628 /* Enter array. */
30629 field_addr.sub_location = plocation_elem_new(0);
30630#endif /* FREECIV_JSON_CONNECTION */
30631
30632 for (i = 0; i < real_packet->count; i++) {
30633#ifdef FREECIV_JSON_CONNECTION
30634 /* Next array element. */
30635 field_addr.sub_location->number = i;
30636#endif /* FREECIV_JSON_CONNECTION */
30637
30638 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->multipliers[i]);
30639 }
30640
30641#ifdef FREECIV_JSON_CONNECTION
30642 /* Exit array. */
30643 FC_FREE(field_addr.sub_location);
30644#endif /* FREECIV_JSON_CONNECTION */
30645 }
30646
30647 if (e) {
30648 log_packet_detailed("'multipliers' field error detected");
30649 }
30650 }
30651
30652 *old = *real_packet;
30653
30654#else /* FREECIV_DELTA_PROTOCOL */
30655#ifdef FREECIV_JSON_CONNECTION
30656 field_addr.name = "count";
30657#endif /* FREECIV_JSON_CONNECTION */
30658 e = 0;
30659
30660 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->count);
30661
30662 if (e) {
30663 log_packet_detailed("'count' field error detected");
30664 }
30665
30666#ifdef FREECIV_JSON_CONNECTION
30667 field_addr.name = "multipliers";
30668#endif /* FREECIV_JSON_CONNECTION */
30669 e = 0;
30670
30671 {
30672 int i;
30673
30674#ifdef FREECIV_JSON_CONNECTION
30675 /* Create the array. */
30676 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->count);
30677
30678 /* Enter array. */
30679 field_addr.sub_location = plocation_elem_new(0);
30680#endif /* FREECIV_JSON_CONNECTION */
30681
30682 for (i = 0; i < real_packet->count; i++) {
30683#ifdef FREECIV_JSON_CONNECTION
30684 /* Next array element. */
30685 field_addr.sub_location->number = i;
30686#endif /* FREECIV_JSON_CONNECTION */
30687
30688 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->multipliers[i]);
30689 }
30690
30691#ifdef FREECIV_JSON_CONNECTION
30692 /* Exit array. */
30693 FC_FREE(field_addr.sub_location);
30694#endif /* FREECIV_JSON_CONNECTION */
30695 }
30696
30697 if (e) {
30698 log_packet_detailed("'multipliers' field error detected");
30699 }
30700#endif /* FREECIV_DELTA_PROTOCOL */
30701
30702 SEND_PACKET_END(PACKET_PLAYER_MULTIPLIER);
30703}
30704
30705 int send_packet_player_multiplier(struct connection *pc, const struct packet_player_multiplier *packet)
30706{
30707 if (!pc->used) {
30708 log_error("WARNING: trying to send data to the closed connection %s",
30709 conn_description(pc));
30710 return -1;
30711 }
30712 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_MULTIPLIER].packet != nullptr, -1,
30713 "Handler for PACKET_PLAYER_MULTIPLIER not installed");
30714 return pc->phs.handlers->send[PACKET_PLAYER_MULTIPLIER].packet(pc, packet);
30715}
30716
30717 static inline void init_packet_research_info(struct packet_research_info *packet)
30718{
30719 memset(packet, 0, sizeof(*packet));
30720}
30721
30722#define free_packet_research_info(_packet) (void) 0
30723#define destroy_packet_research_info free
30724
30725#ifdef FREECIV_DELTA_PROTOCOL
30726static genhash_val_t hash_packet_research_info_100(const void *vkey)
30727{
30728 const struct packet_research_info *key = (const struct packet_research_info *) vkey;
30729 genhash_val_t result = 0;
30730
30731 result += key->id;
30732
30733 result &= 0xFFFFFFFF;
30734 return result;
30735}
30736
30737static bool cmp_packet_research_info_100(const void *vkey1, const void *vkey2)
30738{
30739 const struct packet_research_info *old = (const struct packet_research_info *) vkey1;
30740 const struct packet_research_info *real_packet = (const struct packet_research_info *) vkey2;
30741 bool differ;
30742
30743 differ = (old->id != real_packet->id);
30744
30745 return !differ;
30746}
30747 BV_DEFINE(packet_research_info_100_fields, 8);
30748#endif /* FREECIV_DELTA_PROTOCOL */
30749
30750 static struct packet_research_info *receive_packet_research_info_100(struct connection *pc)
30751{
30752#define FREE_PACKET_STRUCT(_packet) free_packet_research_info(_packet)
30753 RECEIVE_PACKET_START(packet_research_info, real_packet);
30754
30755#ifdef FREECIV_JSON_CONNECTION
30756 struct plocation field_addr;
30757 {
30758 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
30759 field_addr = *field_addr_tmp;
30760 FC_FREE(field_addr_tmp);
30761 }
30762#endif /* FREECIV_JSON_CONNECTION */
30763
30764#ifdef FREECIV_JSON_CONNECTION
30765 field_addr.name = "id";
30766#endif /* FREECIV_JSON_CONNECTION */
30767
30768 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
30769 RECEIVE_PACKET_FIELD_ERROR(id);
30770 }
30771
30772 log_packet_detailed("packet_research_info_100: got info about (%d)",
30773 real_packet->id);
30774
30775#ifdef FREECIV_DELTA_PROTOCOL
30776 packet_research_info_100_fields fields;
30777 struct packet_research_info *old;
30778 struct genhash **hash = pc->phs.received + PACKET_RESEARCH_INFO;
30779
30780 if (nullptr == *hash) {
30781 *hash = genhash_new_full(hash_packet_research_info_100, cmp_packet_research_info_100,
30782 nullptr, nullptr, nullptr, destroy_packet_research_info);
30783 }
30784
30785 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
30786 *real_packet = *old;
30787 } else {
30788 /* packet is already initialized empty */
30789 log_packet_detailed(" no old info");
30790 }
30791
30792#ifdef FREECIV_JSON_CONNECTION
30793 field_addr.name = "fields";
30794#endif /* FREECIV_JSON_CONNECTION */
30795 DIO_BV_GET(&din, &field_addr, fields);
30796
30797 if (BV_ISSET(fields, 0)) {
30798 log_packet_detailed(" got field 'techs_researched'");
30799
30800#ifdef FREECIV_JSON_CONNECTION
30801 field_addr.name = "techs_researched";
30802#endif /* FREECIV_JSON_CONNECTION */
30803
30804 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->techs_researched)) {
30805 RECEIVE_PACKET_FIELD_ERROR(techs_researched);
30806 }
30807 }
30808
30809 if (BV_ISSET(fields, 1)) {
30810 log_packet_detailed(" got field 'future_tech'");
30811
30812#ifdef FREECIV_JSON_CONNECTION
30813 field_addr.name = "future_tech";
30814#endif /* FREECIV_JSON_CONNECTION */
30815
30816 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->future_tech)) {
30817 RECEIVE_PACKET_FIELD_ERROR(future_tech);
30818 }
30819 }
30820
30821 if (BV_ISSET(fields, 2)) {
30822 log_packet_detailed(" got field 'researching'");
30823
30824#ifdef FREECIV_JSON_CONNECTION
30825 field_addr.name = "researching";
30826#endif /* FREECIV_JSON_CONNECTION */
30827
30828 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->researching)) {
30829 RECEIVE_PACKET_FIELD_ERROR(researching);
30830 }
30831 }
30832
30833 if (BV_ISSET(fields, 3)) {
30834 log_packet_detailed(" got field 'researching_cost'");
30835
30836#ifdef FREECIV_JSON_CONNECTION
30837 field_addr.name = "researching_cost";
30838#endif /* FREECIV_JSON_CONNECTION */
30839
30840 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->researching_cost)) {
30841 RECEIVE_PACKET_FIELD_ERROR(researching_cost);
30842 }
30843 }
30844
30845 if (BV_ISSET(fields, 4)) {
30846 log_packet_detailed(" got field 'bulbs_researched'");
30847
30848#ifdef FREECIV_JSON_CONNECTION
30849 field_addr.name = "bulbs_researched";
30850#endif /* FREECIV_JSON_CONNECTION */
30851
30852 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->bulbs_researched)) {
30853 RECEIVE_PACKET_FIELD_ERROR(bulbs_researched);
30854 }
30855 }
30856
30857 if (BV_ISSET(fields, 5)) {
30858 log_packet_detailed(" got field 'tech_goal'");
30859
30860#ifdef FREECIV_JSON_CONNECTION
30861 field_addr.name = "tech_goal";
30862#endif /* FREECIV_JSON_CONNECTION */
30863
30864 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech_goal)) {
30865 RECEIVE_PACKET_FIELD_ERROR(tech_goal);
30866 }
30867 }
30868
30869 if (BV_ISSET(fields, 6)) {
30870 log_packet_detailed(" got field 'total_bulbs_prod'");
30871
30872#ifdef FREECIV_JSON_CONNECTION
30873 field_addr.name = "total_bulbs_prod";
30874#endif /* FREECIV_JSON_CONNECTION */
30875
30876 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->total_bulbs_prod)) {
30877 RECEIVE_PACKET_FIELD_ERROR(total_bulbs_prod);
30878 }
30879 }
30880
30881 if (BV_ISSET(fields, 7)) {
30882 log_packet_detailed(" got field 'inventions'");
30883
30884#ifdef FREECIV_JSON_CONNECTION
30885 field_addr.name = "inventions";
30886#endif /* FREECIV_JSON_CONNECTION */
30887
30888 if (!DIO_GET(string, &din, &field_addr, real_packet->inventions, sizeof(real_packet->inventions))) {
30889 RECEIVE_PACKET_FIELD_ERROR(inventions);
30890 }
30891 }
30892
30893 if (nullptr == old) {
30894 old = fc_malloc(sizeof(*old));
30895 init_packet_research_info(old);
30896 *old = *real_packet;
30897 genhash_insert(*hash, old, old);
30898 } else {
30899 *old = *real_packet;
30900 }
30901
30902#else /* FREECIV_DELTA_PROTOCOL */
30903#ifdef FREECIV_JSON_CONNECTION
30904 field_addr.name = "techs_researched";
30905#endif /* FREECIV_JSON_CONNECTION */
30906
30907 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->techs_researched)) {
30908 RECEIVE_PACKET_FIELD_ERROR(techs_researched);
30909 }
30910
30911#ifdef FREECIV_JSON_CONNECTION
30912 field_addr.name = "future_tech";
30913#endif /* FREECIV_JSON_CONNECTION */
30914
30915 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->future_tech)) {
30916 RECEIVE_PACKET_FIELD_ERROR(future_tech);
30917 }
30918
30919#ifdef FREECIV_JSON_CONNECTION
30920 field_addr.name = "researching";
30921#endif /* FREECIV_JSON_CONNECTION */
30922
30923 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->researching)) {
30924 RECEIVE_PACKET_FIELD_ERROR(researching);
30925 }
30926
30927#ifdef FREECIV_JSON_CONNECTION
30928 field_addr.name = "researching_cost";
30929#endif /* FREECIV_JSON_CONNECTION */
30930
30931 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->researching_cost)) {
30932 RECEIVE_PACKET_FIELD_ERROR(researching_cost);
30933 }
30934
30935#ifdef FREECIV_JSON_CONNECTION
30936 field_addr.name = "bulbs_researched";
30937#endif /* FREECIV_JSON_CONNECTION */
30938
30939 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->bulbs_researched)) {
30940 RECEIVE_PACKET_FIELD_ERROR(bulbs_researched);
30941 }
30942
30943#ifdef FREECIV_JSON_CONNECTION
30944 field_addr.name = "tech_goal";
30945#endif /* FREECIV_JSON_CONNECTION */
30946
30947 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech_goal)) {
30948 RECEIVE_PACKET_FIELD_ERROR(tech_goal);
30949 }
30950
30951#ifdef FREECIV_JSON_CONNECTION
30952 field_addr.name = "total_bulbs_prod";
30953#endif /* FREECIV_JSON_CONNECTION */
30954
30955 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->total_bulbs_prod)) {
30956 RECEIVE_PACKET_FIELD_ERROR(total_bulbs_prod);
30957 }
30958
30959#ifdef FREECIV_JSON_CONNECTION
30960 field_addr.name = "inventions";
30961#endif /* FREECIV_JSON_CONNECTION */
30962
30963 if (!DIO_GET(string, &din, &field_addr, real_packet->inventions, sizeof(real_packet->inventions))) {
30964 RECEIVE_PACKET_FIELD_ERROR(inventions);
30965 }
30966#endif /* FREECIV_DELTA_PROTOCOL */
30967
30968 RECEIVE_PACKET_END(real_packet);
30969#undef FREE_PACKET_STRUCT
30970}
30971
30972 static int send_packet_research_info_100(struct connection *pc, const struct packet_research_info *packet)
30973{
30974 const struct packet_research_info *real_packet = packet;
30975 int e;
30976 SEND_PACKET_START(PACKET_RESEARCH_INFO);
30977
30978 log_packet_detailed("packet_research_info_100: sending info about (%d)",
30979 real_packet->id);
30980
30981#ifdef FREECIV_DELTA_PROTOCOL
30982 packet_research_info_100_fields fields;
30983 struct packet_research_info *old;
30984 bool differ;
30985 int different = 0;
30986 struct genhash **hash = pc->phs.sent + PACKET_RESEARCH_INFO;
30987
30988 if (nullptr == *hash) {
30989 *hash = genhash_new_full(hash_packet_research_info_100, cmp_packet_research_info_100,
30990 nullptr, nullptr, nullptr, destroy_packet_research_info);
30991 }
30992 BV_CLR_ALL(fields);
30993
30994 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
30995 old = fc_malloc(sizeof(*old));
30996 /* temporary bitcopy just to insert correctly */
30997 *old = *real_packet;
30998 genhash_insert(*hash, old, old);
30999 init_packet_research_info(old);
31000 different = 1; /* Force to send. */
31001 }
31002
31003 differ = (old->techs_researched != real_packet->techs_researched);
31004 if (differ) {
31005 different++;
31006 BV_SET(fields, 0);
31007 }
31008
31009 differ = (old->future_tech != real_packet->future_tech);
31010 if (differ) {
31011 different++;
31012 BV_SET(fields, 1);
31013 }
31014
31015 differ = (old->researching != real_packet->researching);
31016 if (differ) {
31017 different++;
31018 BV_SET(fields, 2);
31019 }
31020
31021 differ = (old->researching_cost != real_packet->researching_cost);
31022 if (differ) {
31023 different++;
31024 BV_SET(fields, 3);
31025 }
31026
31027 differ = (old->bulbs_researched != real_packet->bulbs_researched);
31028 if (differ) {
31029 different++;
31030 BV_SET(fields, 4);
31031 }
31032
31033 differ = (old->tech_goal != real_packet->tech_goal);
31034 if (differ) {
31035 different++;
31036 BV_SET(fields, 5);
31037 }
31038
31039 differ = (old->total_bulbs_prod != real_packet->total_bulbs_prod);
31040 if (differ) {
31041 different++;
31042 BV_SET(fields, 6);
31043 }
31044
31045 differ = (strcmp(old->inventions, real_packet->inventions) != 0);
31046 if (differ) {
31047 different++;
31048 BV_SET(fields, 7);
31049 }
31050
31051 if (different == 0) {
31052 log_packet_detailed(" no change -> discard");
31053 SEND_PACKET_DISCARD();
31054 }
31055#endif /* FREECIV_DELTA_PROTOCOL */
31056
31057#ifdef FREECIV_JSON_CONNECTION
31058 struct plocation field_addr;
31059 {
31060 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31061 field_addr = *field_addr_tmp;
31062 FC_FREE(field_addr_tmp);
31063 }
31064#endif /* FREECIV_JSON_CONNECTION */
31065
31066#ifdef FREECIV_JSON_CONNECTION
31067 field_addr.name = "id";
31068#endif /* FREECIV_JSON_CONNECTION */
31069 e = 0;
31070
31071 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
31072
31073 if (e) {
31074 log_packet_detailed("'id' field error detected");
31075 }
31076
31077#ifdef FREECIV_DELTA_PROTOCOL
31078#ifdef FREECIV_JSON_CONNECTION
31079 field_addr.name = "fields";
31080#endif /* FREECIV_JSON_CONNECTION */
31081 e = 0;
31082 e |= DIO_BV_PUT(&dout, &field_addr, fields);
31083 if (e) {
31084 log_packet_detailed("fields bitvector error detected");
31085 }
31086
31087 if (BV_ISSET(fields, 0)) {
31088 log_packet_detailed(" field 'techs_researched' has changed");
31089
31090#ifdef FREECIV_JSON_CONNECTION
31091 field_addr.name = "techs_researched";
31092#endif /* FREECIV_JSON_CONNECTION */
31093 e = 0;
31094
31095 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->techs_researched);
31096
31097 if (e) {
31098 log_packet_detailed("'techs_researched' field error detected");
31099 }
31100 }
31101
31102 if (BV_ISSET(fields, 1)) {
31103 log_packet_detailed(" field 'future_tech' has changed");
31104
31105#ifdef FREECIV_JSON_CONNECTION
31106 field_addr.name = "future_tech";
31107#endif /* FREECIV_JSON_CONNECTION */
31108 e = 0;
31109
31110 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->future_tech);
31111
31112 if (e) {
31113 log_packet_detailed("'future_tech' field error detected");
31114 }
31115 }
31116
31117 if (BV_ISSET(fields, 2)) {
31118 log_packet_detailed(" field 'researching' has changed");
31119
31120#ifdef FREECIV_JSON_CONNECTION
31121 field_addr.name = "researching";
31122#endif /* FREECIV_JSON_CONNECTION */
31123 e = 0;
31124
31125 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->researching);
31126
31127 if (e) {
31128 log_packet_detailed("'researching' field error detected");
31129 }
31130 }
31131
31132 if (BV_ISSET(fields, 3)) {
31133 log_packet_detailed(" field 'researching_cost' has changed");
31134
31135#ifdef FREECIV_JSON_CONNECTION
31136 field_addr.name = "researching_cost";
31137#endif /* FREECIV_JSON_CONNECTION */
31138 e = 0;
31139
31140 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->researching_cost);
31141
31142 if (e) {
31143 log_packet_detailed("'researching_cost' field error detected");
31144 }
31145 }
31146
31147 if (BV_ISSET(fields, 4)) {
31148 log_packet_detailed(" field 'bulbs_researched' has changed");
31149
31150#ifdef FREECIV_JSON_CONNECTION
31151 field_addr.name = "bulbs_researched";
31152#endif /* FREECIV_JSON_CONNECTION */
31153 e = 0;
31154
31155 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->bulbs_researched);
31156
31157 if (e) {
31158 log_packet_detailed("'bulbs_researched' field error detected");
31159 }
31160 }
31161
31162 if (BV_ISSET(fields, 5)) {
31163 log_packet_detailed(" field 'tech_goal' has changed");
31164
31165#ifdef FREECIV_JSON_CONNECTION
31166 field_addr.name = "tech_goal";
31167#endif /* FREECIV_JSON_CONNECTION */
31168 e = 0;
31169
31170 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech_goal);
31171
31172 if (e) {
31173 log_packet_detailed("'tech_goal' field error detected");
31174 }
31175 }
31176
31177 if (BV_ISSET(fields, 6)) {
31178 log_packet_detailed(" field 'total_bulbs_prod' has changed");
31179
31180#ifdef FREECIV_JSON_CONNECTION
31181 field_addr.name = "total_bulbs_prod";
31182#endif /* FREECIV_JSON_CONNECTION */
31183 e = 0;
31184
31185 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->total_bulbs_prod);
31186
31187 if (e) {
31188 log_packet_detailed("'total_bulbs_prod' field error detected");
31189 }
31190 }
31191
31192 if (BV_ISSET(fields, 7)) {
31193 log_packet_detailed(" field 'inventions' has changed");
31194
31195#ifdef FREECIV_JSON_CONNECTION
31196 field_addr.name = "inventions";
31197#endif /* FREECIV_JSON_CONNECTION */
31198 e = 0;
31199
31200 e |= DIO_PUT(string, &dout, &field_addr, real_packet->inventions);
31201
31202 if (e) {
31203 log_packet_detailed("'inventions' field error detected");
31204 }
31205 }
31206
31207 *old = *real_packet;
31208
31209#else /* FREECIV_DELTA_PROTOCOL */
31210#ifdef FREECIV_JSON_CONNECTION
31211 field_addr.name = "techs_researched";
31212#endif /* FREECIV_JSON_CONNECTION */
31213 e = 0;
31214
31215 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->techs_researched);
31216
31217 if (e) {
31218 log_packet_detailed("'techs_researched' field error detected");
31219 }
31220
31221#ifdef FREECIV_JSON_CONNECTION
31222 field_addr.name = "future_tech";
31223#endif /* FREECIV_JSON_CONNECTION */
31224 e = 0;
31225
31226 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->future_tech);
31227
31228 if (e) {
31229 log_packet_detailed("'future_tech' field error detected");
31230 }
31231
31232#ifdef FREECIV_JSON_CONNECTION
31233 field_addr.name = "researching";
31234#endif /* FREECIV_JSON_CONNECTION */
31235 e = 0;
31236
31237 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->researching);
31238
31239 if (e) {
31240 log_packet_detailed("'researching' field error detected");
31241 }
31242
31243#ifdef FREECIV_JSON_CONNECTION
31244 field_addr.name = "researching_cost";
31245#endif /* FREECIV_JSON_CONNECTION */
31246 e = 0;
31247
31248 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->researching_cost);
31249
31250 if (e) {
31251 log_packet_detailed("'researching_cost' field error detected");
31252 }
31253
31254#ifdef FREECIV_JSON_CONNECTION
31255 field_addr.name = "bulbs_researched";
31256#endif /* FREECIV_JSON_CONNECTION */
31257 e = 0;
31258
31259 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->bulbs_researched);
31260
31261 if (e) {
31262 log_packet_detailed("'bulbs_researched' field error detected");
31263 }
31264
31265#ifdef FREECIV_JSON_CONNECTION
31266 field_addr.name = "tech_goal";
31267#endif /* FREECIV_JSON_CONNECTION */
31268 e = 0;
31269
31270 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech_goal);
31271
31272 if (e) {
31273 log_packet_detailed("'tech_goal' field error detected");
31274 }
31275
31276#ifdef FREECIV_JSON_CONNECTION
31277 field_addr.name = "total_bulbs_prod";
31278#endif /* FREECIV_JSON_CONNECTION */
31279 e = 0;
31280
31281 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->total_bulbs_prod);
31282
31283 if (e) {
31284 log_packet_detailed("'total_bulbs_prod' field error detected");
31285 }
31286
31287#ifdef FREECIV_JSON_CONNECTION
31288 field_addr.name = "inventions";
31289#endif /* FREECIV_JSON_CONNECTION */
31290 e = 0;
31291
31292 e |= DIO_PUT(string, &dout, &field_addr, real_packet->inventions);
31293
31294 if (e) {
31295 log_packet_detailed("'inventions' field error detected");
31296 }
31297#endif /* FREECIV_DELTA_PROTOCOL */
31298
31299 SEND_PACKET_END(PACKET_RESEARCH_INFO);
31300}
31301
31302 int send_packet_research_info(struct connection *pc, const struct packet_research_info *packet)
31303{
31304 if (!pc->used) {
31305 log_error("WARNING: trying to send data to the closed connection %s",
31306 conn_description(pc));
31307 return -1;
31308 }
31309 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RESEARCH_INFO].packet != nullptr, -1,
31310 "Handler for PACKET_RESEARCH_INFO not installed");
31311 return pc->phs.handlers->send[PACKET_RESEARCH_INFO].packet(pc, packet);
31312}
31313
31314 void lsend_packet_research_info(struct conn_list *dest, const struct packet_research_info *packet)
31315{
31316 conn_list_iterate(dest, pconn) {
31317 send_packet_research_info(pconn, packet);
31318 } conn_list_iterate_end;
31319}
31320
31321 static inline void init_packet_unknown_research(struct packet_unknown_research *packet)
31322{
31323 memset(packet, 0, sizeof(*packet));
31324}
31325
31326#define free_packet_unknown_research(_packet) (void) 0
31327#define destroy_packet_unknown_research free
31328
31329#ifdef FREECIV_DELTA_PROTOCOL
31330#define hash_packet_unknown_research_100 hash_const
31331#define cmp_packet_unknown_research_100 cmp_const
31332 BV_DEFINE(packet_unknown_research_100_fields, 1);
31333#endif /* FREECIV_DELTA_PROTOCOL */
31334
31335 static struct packet_unknown_research *receive_packet_unknown_research_100(struct connection *pc)
31336{
31337#define FREE_PACKET_STRUCT(_packet) free_packet_unknown_research(_packet)
31338 RECEIVE_PACKET_START(packet_unknown_research, real_packet);
31339
31340#ifdef FREECIV_JSON_CONNECTION
31341 struct plocation field_addr;
31342 {
31343 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31344 field_addr = *field_addr_tmp;
31345 FC_FREE(field_addr_tmp);
31346 }
31347#endif /* FREECIV_JSON_CONNECTION */
31348
31349 log_packet_detailed("packet_unknown_research_100: got info about ()");
31350
31351#ifdef FREECIV_DELTA_PROTOCOL
31352 packet_unknown_research_100_fields fields;
31353 struct packet_unknown_research *old;
31354 struct genhash **hash = pc->phs.received + PACKET_UNKNOWN_RESEARCH;
31355
31356 if (nullptr == *hash) {
31357 *hash = genhash_new_full(hash_packet_unknown_research_100, cmp_packet_unknown_research_100,
31358 nullptr, nullptr, nullptr, destroy_packet_unknown_research);
31359 }
31360
31361 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31362 *real_packet = *old;
31363 } else {
31364 /* packet is already initialized empty */
31365 log_packet_detailed(" no old info");
31366 }
31367
31368#ifdef FREECIV_JSON_CONNECTION
31369 field_addr.name = "fields";
31370#endif /* FREECIV_JSON_CONNECTION */
31371 DIO_BV_GET(&din, &field_addr, fields);
31372
31373 if (BV_ISSET(fields, 0)) {
31374 log_packet_detailed(" got field 'id'");
31375
31376#ifdef FREECIV_JSON_CONNECTION
31377 field_addr.name = "id";
31378#endif /* FREECIV_JSON_CONNECTION */
31379
31380 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
31381 RECEIVE_PACKET_FIELD_ERROR(id);
31382 }
31383 }
31384
31385 if (nullptr == old) {
31386 old = fc_malloc(sizeof(*old));
31387 init_packet_unknown_research(old);
31388 *old = *real_packet;
31389 genhash_insert(*hash, old, old);
31390 } else {
31391 *old = *real_packet;
31392 }
31393
31394 hash = pc->phs.received + PACKET_RESEARCH_INFO;
31395 if (nullptr != *hash) {
31396 genhash_remove(*hash, real_packet);
31397 }
31398
31399#else /* FREECIV_DELTA_PROTOCOL */
31400#ifdef FREECIV_JSON_CONNECTION
31401 field_addr.name = "id";
31402#endif /* FREECIV_JSON_CONNECTION */
31403
31404 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
31405 RECEIVE_PACKET_FIELD_ERROR(id);
31406 }
31407#endif /* FREECIV_DELTA_PROTOCOL */
31408
31409 RECEIVE_PACKET_END(real_packet);
31410#undef FREE_PACKET_STRUCT
31411}
31412
31413 static int send_packet_unknown_research_100(struct connection *pc, const struct packet_unknown_research *packet)
31414{
31415 const struct packet_unknown_research *real_packet = packet;
31416 int e;
31417 SEND_PACKET_START(PACKET_UNKNOWN_RESEARCH);
31418
31419 log_packet_detailed("packet_unknown_research_100: sending info about ()");
31420
31421#ifdef FREECIV_DELTA_PROTOCOL
31422 packet_unknown_research_100_fields fields;
31423 struct packet_unknown_research *old;
31424 bool differ;
31425 int different = 0;
31426 struct genhash **hash = pc->phs.sent + PACKET_UNKNOWN_RESEARCH;
31427
31428 if (nullptr == *hash) {
31429 *hash = genhash_new_full(hash_packet_unknown_research_100, cmp_packet_unknown_research_100,
31430 nullptr, nullptr, nullptr, destroy_packet_unknown_research);
31431 }
31432 BV_CLR_ALL(fields);
31433
31434 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
31435 old = fc_malloc(sizeof(*old));
31436 /* temporary bitcopy just to insert correctly */
31437 *old = *real_packet;
31438 genhash_insert(*hash, old, old);
31439 init_packet_unknown_research(old);
31440 different = 1; /* Force to send. */
31441 }
31442
31443 differ = (old->id != real_packet->id);
31444 if (differ) {
31445 different++;
31446 BV_SET(fields, 0);
31447 }
31448
31449 if (different == 0) {
31450 log_packet_detailed(" no change -> discard");
31451 SEND_PACKET_DISCARD();
31452 }
31453#endif /* FREECIV_DELTA_PROTOCOL */
31454
31455#ifdef FREECIV_JSON_CONNECTION
31456 struct plocation field_addr;
31457 {
31458 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31459 field_addr = *field_addr_tmp;
31460 FC_FREE(field_addr_tmp);
31461 }
31462#endif /* FREECIV_JSON_CONNECTION */
31463
31464#ifdef FREECIV_DELTA_PROTOCOL
31465#ifdef FREECIV_JSON_CONNECTION
31466 field_addr.name = "fields";
31467#endif /* FREECIV_JSON_CONNECTION */
31468 e = 0;
31469 e |= DIO_BV_PUT(&dout, &field_addr, fields);
31470 if (e) {
31471 log_packet_detailed("fields bitvector error detected");
31472 }
31473
31474 if (BV_ISSET(fields, 0)) {
31475 log_packet_detailed(" field 'id' has changed");
31476
31477#ifdef FREECIV_JSON_CONNECTION
31478 field_addr.name = "id";
31479#endif /* FREECIV_JSON_CONNECTION */
31480 e = 0;
31481
31482 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
31483
31484 if (e) {
31485 log_packet_detailed("'id' field error detected");
31486 }
31487 }
31488
31489 *old = *real_packet;
31490
31491 hash = pc->phs.sent + PACKET_RESEARCH_INFO;
31492 if (nullptr != *hash) {
31493 genhash_remove(*hash, real_packet);
31494 }
31495
31496#else /* FREECIV_DELTA_PROTOCOL */
31497#ifdef FREECIV_JSON_CONNECTION
31498 field_addr.name = "id";
31499#endif /* FREECIV_JSON_CONNECTION */
31500 e = 0;
31501
31502 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
31503
31504 if (e) {
31505 log_packet_detailed("'id' field error detected");
31506 }
31507#endif /* FREECIV_DELTA_PROTOCOL */
31508
31509 SEND_PACKET_END(PACKET_UNKNOWN_RESEARCH);
31510}
31511
31512 int send_packet_unknown_research(struct connection *pc, const struct packet_unknown_research *packet)
31513{
31514 if (!pc->used) {
31515 log_error("WARNING: trying to send data to the closed connection %s",
31516 conn_description(pc));
31517 return -1;
31518 }
31519 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNKNOWN_RESEARCH].packet != nullptr, -1,
31520 "Handler for PACKET_UNKNOWN_RESEARCH not installed");
31521 return pc->phs.handlers->send[PACKET_UNKNOWN_RESEARCH].packet(pc, packet);
31522}
31523
31524 static inline void init_packet_player_research(struct packet_player_research *packet)
31525{
31526 memset(packet, 0, sizeof(*packet));
31527}
31528
31529#define free_packet_player_research(_packet) (void) 0
31530#define destroy_packet_player_research free
31531
31532#ifdef FREECIV_DELTA_PROTOCOL
31533#define hash_packet_player_research_100 hash_const
31534#define cmp_packet_player_research_100 cmp_const
31535 BV_DEFINE(packet_player_research_100_fields, 1);
31536#endif /* FREECIV_DELTA_PROTOCOL */
31537
31538 static struct packet_player_research *receive_packet_player_research_100(struct connection *pc)
31539{
31540#define FREE_PACKET_STRUCT(_packet) free_packet_player_research(_packet)
31541 RECEIVE_PACKET_START(packet_player_research, real_packet);
31542
31543#ifdef FREECIV_JSON_CONNECTION
31544 struct plocation field_addr;
31545 {
31546 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31547 field_addr = *field_addr_tmp;
31548 FC_FREE(field_addr_tmp);
31549 }
31550#endif /* FREECIV_JSON_CONNECTION */
31551
31552 log_packet_detailed("packet_player_research_100: got info about ()");
31553
31554#ifdef FREECIV_DELTA_PROTOCOL
31555 packet_player_research_100_fields fields;
31556 struct packet_player_research *old;
31557 struct genhash **hash = pc->phs.received + PACKET_PLAYER_RESEARCH;
31558
31559 if (nullptr == *hash) {
31560 *hash = genhash_new_full(hash_packet_player_research_100, cmp_packet_player_research_100,
31561 nullptr, nullptr, nullptr, destroy_packet_player_research);
31562 }
31563
31564 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31565 *real_packet = *old;
31566 } else {
31567 /* packet is already initialized empty */
31568 log_packet_detailed(" no old info");
31569 }
31570
31571#ifdef FREECIV_JSON_CONNECTION
31572 field_addr.name = "fields";
31573#endif /* FREECIV_JSON_CONNECTION */
31574 DIO_BV_GET(&din, &field_addr, fields);
31575
31576 if (BV_ISSET(fields, 0)) {
31577 log_packet_detailed(" got field 'tech'");
31578
31579#ifdef FREECIV_JSON_CONNECTION
31580 field_addr.name = "tech";
31581#endif /* FREECIV_JSON_CONNECTION */
31582
31583 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech)) {
31584 RECEIVE_PACKET_FIELD_ERROR(tech);
31585 }
31586 }
31587
31588 if (nullptr == old) {
31589 old = fc_malloc(sizeof(*old));
31590 init_packet_player_research(old);
31591 *old = *real_packet;
31592 genhash_insert(*hash, old, old);
31593 } else {
31594 *old = *real_packet;
31595 }
31596
31597#else /* FREECIV_DELTA_PROTOCOL */
31598#ifdef FREECIV_JSON_CONNECTION
31599 field_addr.name = "tech";
31600#endif /* FREECIV_JSON_CONNECTION */
31601
31602 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech)) {
31603 RECEIVE_PACKET_FIELD_ERROR(tech);
31604 }
31605#endif /* FREECIV_DELTA_PROTOCOL */
31606
31607 RECEIVE_PACKET_END(real_packet);
31608#undef FREE_PACKET_STRUCT
31609}
31610
31611 static int send_packet_player_research_100(struct connection *pc, const struct packet_player_research *packet)
31612{
31613 const struct packet_player_research *real_packet = packet;
31614 int e;
31615 SEND_PACKET_START(PACKET_PLAYER_RESEARCH);
31616
31617 log_packet_detailed("packet_player_research_100: sending info about ()");
31618
31619#ifdef FREECIV_DELTA_PROTOCOL
31620 packet_player_research_100_fields fields;
31621 struct packet_player_research *old;
31622 bool differ;
31623 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_RESEARCH;
31624
31625 if (nullptr == *hash) {
31626 *hash = genhash_new_full(hash_packet_player_research_100, cmp_packet_player_research_100,
31627 nullptr, nullptr, nullptr, destroy_packet_player_research);
31628 }
31629 BV_CLR_ALL(fields);
31630
31631 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
31632 old = fc_malloc(sizeof(*old));
31633 /* temporary bitcopy just to insert correctly */
31634 *old = *real_packet;
31635 genhash_insert(*hash, old, old);
31636 init_packet_player_research(old);
31637 }
31638
31639 differ = (old->tech != real_packet->tech);
31640 if (differ) {
31641 BV_SET(fields, 0);
31642 }
31643#endif /* FREECIV_DELTA_PROTOCOL */
31644
31645#ifdef FREECIV_JSON_CONNECTION
31646 struct plocation field_addr;
31647 {
31648 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31649 field_addr = *field_addr_tmp;
31650 FC_FREE(field_addr_tmp);
31651 }
31652#endif /* FREECIV_JSON_CONNECTION */
31653
31654#ifdef FREECIV_DELTA_PROTOCOL
31655#ifdef FREECIV_JSON_CONNECTION
31656 field_addr.name = "fields";
31657#endif /* FREECIV_JSON_CONNECTION */
31658 e = 0;
31659 e |= DIO_BV_PUT(&dout, &field_addr, fields);
31660 if (e) {
31661 log_packet_detailed("fields bitvector error detected");
31662 }
31663
31664 if (BV_ISSET(fields, 0)) {
31665 log_packet_detailed(" field 'tech' has changed");
31666
31667#ifdef FREECIV_JSON_CONNECTION
31668 field_addr.name = "tech";
31669#endif /* FREECIV_JSON_CONNECTION */
31670 e = 0;
31671
31672 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech);
31673
31674 if (e) {
31675 log_packet_detailed("'tech' field error detected");
31676 }
31677 }
31678
31679 *old = *real_packet;
31680
31681#else /* FREECIV_DELTA_PROTOCOL */
31682#ifdef FREECIV_JSON_CONNECTION
31683 field_addr.name = "tech";
31684#endif /* FREECIV_JSON_CONNECTION */
31685 e = 0;
31686
31687 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech);
31688
31689 if (e) {
31690 log_packet_detailed("'tech' field error detected");
31691 }
31692#endif /* FREECIV_DELTA_PROTOCOL */
31693
31694 SEND_PACKET_END(PACKET_PLAYER_RESEARCH);
31695}
31696
31697 int send_packet_player_research(struct connection *pc, const struct packet_player_research *packet)
31698{
31699 if (!pc->used) {
31700 log_error("WARNING: trying to send data to the closed connection %s",
31701 conn_description(pc));
31702 return -1;
31703 }
31704 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_RESEARCH].packet != nullptr, -1,
31705 "Handler for PACKET_PLAYER_RESEARCH not installed");
31706 return pc->phs.handlers->send[PACKET_PLAYER_RESEARCH].packet(pc, packet);
31707}
31708
31709 int dsend_packet_player_research(struct connection *pc, int tech)
31710{
31711 struct packet_player_research packet, *real_packet = &packet;
31712
31713 real_packet->tech = tech;
31714
31715 return send_packet_player_research(pc, real_packet);
31716}
31717
31718 static inline void init_packet_player_tech_goal(struct packet_player_tech_goal *packet)
31719{
31720 memset(packet, 0, sizeof(*packet));
31721}
31722
31723#define free_packet_player_tech_goal(_packet) (void) 0
31724#define destroy_packet_player_tech_goal free
31725
31726#ifdef FREECIV_DELTA_PROTOCOL
31727#define hash_packet_player_tech_goal_100 hash_const
31728#define cmp_packet_player_tech_goal_100 cmp_const
31729 BV_DEFINE(packet_player_tech_goal_100_fields, 1);
31730#endif /* FREECIV_DELTA_PROTOCOL */
31731
31732 static struct packet_player_tech_goal *receive_packet_player_tech_goal_100(struct connection *pc)
31733{
31734#define FREE_PACKET_STRUCT(_packet) free_packet_player_tech_goal(_packet)
31735 RECEIVE_PACKET_START(packet_player_tech_goal, real_packet);
31736
31737#ifdef FREECIV_JSON_CONNECTION
31738 struct plocation field_addr;
31739 {
31740 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31741 field_addr = *field_addr_tmp;
31742 FC_FREE(field_addr_tmp);
31743 }
31744#endif /* FREECIV_JSON_CONNECTION */
31745
31746 log_packet_detailed("packet_player_tech_goal_100: got info about ()");
31747
31748#ifdef FREECIV_DELTA_PROTOCOL
31749 packet_player_tech_goal_100_fields fields;
31750 struct packet_player_tech_goal *old;
31751 struct genhash **hash = pc->phs.received + PACKET_PLAYER_TECH_GOAL;
31752
31753 if (nullptr == *hash) {
31754 *hash = genhash_new_full(hash_packet_player_tech_goal_100, cmp_packet_player_tech_goal_100,
31755 nullptr, nullptr, nullptr, destroy_packet_player_tech_goal);
31756 }
31757
31758 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31759 *real_packet = *old;
31760 } else {
31761 /* packet is already initialized empty */
31762 log_packet_detailed(" no old info");
31763 }
31764
31765#ifdef FREECIV_JSON_CONNECTION
31766 field_addr.name = "fields";
31767#endif /* FREECIV_JSON_CONNECTION */
31768 DIO_BV_GET(&din, &field_addr, fields);
31769
31770 if (BV_ISSET(fields, 0)) {
31771 log_packet_detailed(" got field 'tech'");
31772
31773#ifdef FREECIV_JSON_CONNECTION
31774 field_addr.name = "tech";
31775#endif /* FREECIV_JSON_CONNECTION */
31776
31777 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech)) {
31778 RECEIVE_PACKET_FIELD_ERROR(tech);
31779 }
31780 }
31781
31782 if (nullptr == old) {
31783 old = fc_malloc(sizeof(*old));
31784 init_packet_player_tech_goal(old);
31785 *old = *real_packet;
31786 genhash_insert(*hash, old, old);
31787 } else {
31788 *old = *real_packet;
31789 }
31790
31791#else /* FREECIV_DELTA_PROTOCOL */
31792#ifdef FREECIV_JSON_CONNECTION
31793 field_addr.name = "tech";
31794#endif /* FREECIV_JSON_CONNECTION */
31795
31796 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tech)) {
31797 RECEIVE_PACKET_FIELD_ERROR(tech);
31798 }
31799#endif /* FREECIV_DELTA_PROTOCOL */
31800
31801 RECEIVE_PACKET_END(real_packet);
31802#undef FREE_PACKET_STRUCT
31803}
31804
31805 static int send_packet_player_tech_goal_100(struct connection *pc, const struct packet_player_tech_goal *packet)
31806{
31807 const struct packet_player_tech_goal *real_packet = packet;
31808 int e;
31809 SEND_PACKET_START(PACKET_PLAYER_TECH_GOAL);
31810
31811 log_packet_detailed("packet_player_tech_goal_100: sending info about ()");
31812
31813#ifdef FREECIV_DELTA_PROTOCOL
31814 packet_player_tech_goal_100_fields fields;
31815 struct packet_player_tech_goal *old;
31816 bool differ;
31817 struct genhash **hash = pc->phs.sent + PACKET_PLAYER_TECH_GOAL;
31818
31819 if (nullptr == *hash) {
31820 *hash = genhash_new_full(hash_packet_player_tech_goal_100, cmp_packet_player_tech_goal_100,
31821 nullptr, nullptr, nullptr, destroy_packet_player_tech_goal);
31822 }
31823 BV_CLR_ALL(fields);
31824
31825 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
31826 old = fc_malloc(sizeof(*old));
31827 /* temporary bitcopy just to insert correctly */
31828 *old = *real_packet;
31829 genhash_insert(*hash, old, old);
31830 init_packet_player_tech_goal(old);
31831 }
31832
31833 differ = (old->tech != real_packet->tech);
31834 if (differ) {
31835 BV_SET(fields, 0);
31836 }
31837#endif /* FREECIV_DELTA_PROTOCOL */
31838
31839#ifdef FREECIV_JSON_CONNECTION
31840 struct plocation field_addr;
31841 {
31842 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31843 field_addr = *field_addr_tmp;
31844 FC_FREE(field_addr_tmp);
31845 }
31846#endif /* FREECIV_JSON_CONNECTION */
31847
31848#ifdef FREECIV_DELTA_PROTOCOL
31849#ifdef FREECIV_JSON_CONNECTION
31850 field_addr.name = "fields";
31851#endif /* FREECIV_JSON_CONNECTION */
31852 e = 0;
31853 e |= DIO_BV_PUT(&dout, &field_addr, fields);
31854 if (e) {
31855 log_packet_detailed("fields bitvector error detected");
31856 }
31857
31858 if (BV_ISSET(fields, 0)) {
31859 log_packet_detailed(" field 'tech' has changed");
31860
31861#ifdef FREECIV_JSON_CONNECTION
31862 field_addr.name = "tech";
31863#endif /* FREECIV_JSON_CONNECTION */
31864 e = 0;
31865
31866 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech);
31867
31868 if (e) {
31869 log_packet_detailed("'tech' field error detected");
31870 }
31871 }
31872
31873 *old = *real_packet;
31874
31875#else /* FREECIV_DELTA_PROTOCOL */
31876#ifdef FREECIV_JSON_CONNECTION
31877 field_addr.name = "tech";
31878#endif /* FREECIV_JSON_CONNECTION */
31879 e = 0;
31880
31881 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tech);
31882
31883 if (e) {
31884 log_packet_detailed("'tech' field error detected");
31885 }
31886#endif /* FREECIV_DELTA_PROTOCOL */
31887
31888 SEND_PACKET_END(PACKET_PLAYER_TECH_GOAL);
31889}
31890
31891 int send_packet_player_tech_goal(struct connection *pc, const struct packet_player_tech_goal *packet)
31892{
31893 if (!pc->used) {
31894 log_error("WARNING: trying to send data to the closed connection %s",
31895 conn_description(pc));
31896 return -1;
31897 }
31898 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAYER_TECH_GOAL].packet != nullptr, -1,
31899 "Handler for PACKET_PLAYER_TECH_GOAL not installed");
31900 return pc->phs.handlers->send[PACKET_PLAYER_TECH_GOAL].packet(pc, packet);
31901}
31902
31903 int dsend_packet_player_tech_goal(struct connection *pc, int tech)
31904{
31905 struct packet_player_tech_goal packet, *real_packet = &packet;
31906
31907 real_packet->tech = tech;
31908
31909 return send_packet_player_tech_goal(pc, real_packet);
31910}
31911
31912 static inline void init_packet_unit_remove(struct packet_unit_remove *packet)
31913{
31914 memset(packet, 0, sizeof(*packet));
31915}
31916
31917#define free_packet_unit_remove(_packet) (void) 0
31918#define destroy_packet_unit_remove free
31919
31920#ifdef FREECIV_DELTA_PROTOCOL
31921#define hash_packet_unit_remove_100 hash_const
31922#define cmp_packet_unit_remove_100 cmp_const
31923 BV_DEFINE(packet_unit_remove_100_fields, 1);
31924#endif /* FREECIV_DELTA_PROTOCOL */
31925
31926 static struct packet_unit_remove *receive_packet_unit_remove_100(struct connection *pc)
31927{
31928#define FREE_PACKET_STRUCT(_packet) free_packet_unit_remove(_packet)
31929 RECEIVE_PACKET_START(packet_unit_remove, real_packet);
31930
31931#ifdef FREECIV_JSON_CONNECTION
31932 struct plocation field_addr;
31933 {
31934 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
31935 field_addr = *field_addr_tmp;
31936 FC_FREE(field_addr_tmp);
31937 }
31938#endif /* FREECIV_JSON_CONNECTION */
31939
31940 log_packet_detailed("packet_unit_remove_100: got info about ()");
31941
31942#ifdef FREECIV_DELTA_PROTOCOL
31943 packet_unit_remove_100_fields fields;
31944 struct packet_unit_remove *old;
31945 struct genhash **hash = pc->phs.received + PACKET_UNIT_REMOVE;
31946
31947 if (nullptr == *hash) {
31948 *hash = genhash_new_full(hash_packet_unit_remove_100, cmp_packet_unit_remove_100,
31949 nullptr, nullptr, nullptr, destroy_packet_unit_remove);
31950 }
31951
31952 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
31953 *real_packet = *old;
31954 } else {
31955 /* packet is already initialized empty */
31956 log_packet_detailed(" no old info");
31957 }
31958
31959#ifdef FREECIV_JSON_CONNECTION
31960 field_addr.name = "fields";
31961#endif /* FREECIV_JSON_CONNECTION */
31962 DIO_BV_GET(&din, &field_addr, fields);
31963
31964 if (BV_ISSET(fields, 0)) {
31965 log_packet_detailed(" got field 'unit_id'");
31966
31967#ifdef FREECIV_JSON_CONNECTION
31968 field_addr.name = "unit_id";
31969#endif /* FREECIV_JSON_CONNECTION */
31970
31971 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
31972 RECEIVE_PACKET_FIELD_ERROR(unit_id);
31973 }
31974 }
31975
31976 if (nullptr == old) {
31977 old = fc_malloc(sizeof(*old));
31978 init_packet_unit_remove(old);
31979 *old = *real_packet;
31980 genhash_insert(*hash, old, old);
31981 } else {
31982 *old = *real_packet;
31983 }
31984
31985 hash = pc->phs.received + PACKET_UNIT_INFO;
31986 if (nullptr != *hash) {
31987 genhash_remove(*hash, real_packet);
31988 }
31989
31990 hash = pc->phs.received + PACKET_UNIT_SHORT_INFO;
31991 if (nullptr != *hash) {
31992 genhash_remove(*hash, real_packet);
31993 }
31994
31995#else /* FREECIV_DELTA_PROTOCOL */
31996#ifdef FREECIV_JSON_CONNECTION
31997 field_addr.name = "unit_id";
31998#endif /* FREECIV_JSON_CONNECTION */
31999
32000 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
32001 RECEIVE_PACKET_FIELD_ERROR(unit_id);
32002 }
32003#endif /* FREECIV_DELTA_PROTOCOL */
32004
32005 RECEIVE_PACKET_END(real_packet);
32006#undef FREE_PACKET_STRUCT
32007}
32008
32009 static int send_packet_unit_remove_100(struct connection *pc, const struct packet_unit_remove *packet)
32010{
32011 const struct packet_unit_remove *real_packet = packet;
32012 int e;
32013 SEND_PACKET_START(PACKET_UNIT_REMOVE);
32014
32015 log_packet_detailed("packet_unit_remove_100: sending info about ()");
32016
32017#ifdef FREECIV_DELTA_PROTOCOL
32018 packet_unit_remove_100_fields fields;
32019 struct packet_unit_remove *old;
32020 bool differ;
32021 struct genhash **hash = pc->phs.sent + PACKET_UNIT_REMOVE;
32022
32023 if (nullptr == *hash) {
32024 *hash = genhash_new_full(hash_packet_unit_remove_100, cmp_packet_unit_remove_100,
32025 nullptr, nullptr, nullptr, destroy_packet_unit_remove);
32026 }
32027 BV_CLR_ALL(fields);
32028
32029 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
32030 old = fc_malloc(sizeof(*old));
32031 /* temporary bitcopy just to insert correctly */
32032 *old = *real_packet;
32033 genhash_insert(*hash, old, old);
32034 init_packet_unit_remove(old);
32035 }
32036
32037 differ = (old->unit_id != real_packet->unit_id);
32038 if (differ) {
32039 BV_SET(fields, 0);
32040 }
32041#endif /* FREECIV_DELTA_PROTOCOL */
32042
32043#ifdef FREECIV_JSON_CONNECTION
32044 struct plocation field_addr;
32045 {
32046 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
32047 field_addr = *field_addr_tmp;
32048 FC_FREE(field_addr_tmp);
32049 }
32050#endif /* FREECIV_JSON_CONNECTION */
32051
32052#ifdef FREECIV_DELTA_PROTOCOL
32053#ifdef FREECIV_JSON_CONNECTION
32054 field_addr.name = "fields";
32055#endif /* FREECIV_JSON_CONNECTION */
32056 e = 0;
32057 e |= DIO_BV_PUT(&dout, &field_addr, fields);
32058 if (e) {
32059 log_packet_detailed("fields bitvector error detected");
32060 }
32061
32062 if (BV_ISSET(fields, 0)) {
32063 log_packet_detailed(" field 'unit_id' has changed");
32064
32065#ifdef FREECIV_JSON_CONNECTION
32066 field_addr.name = "unit_id";
32067#endif /* FREECIV_JSON_CONNECTION */
32068 e = 0;
32069
32070 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
32071
32072 if (e) {
32073 log_packet_detailed("'unit_id' field error detected");
32074 }
32075 }
32076
32077 *old = *real_packet;
32078
32079 hash = pc->phs.sent + PACKET_UNIT_INFO;
32080 if (nullptr != *hash) {
32081 genhash_remove(*hash, real_packet);
32082 }
32083
32084 hash = pc->phs.sent + PACKET_UNIT_SHORT_INFO;
32085 if (nullptr != *hash) {
32086 genhash_remove(*hash, real_packet);
32087 }
32088
32089#else /* FREECIV_DELTA_PROTOCOL */
32090#ifdef FREECIV_JSON_CONNECTION
32091 field_addr.name = "unit_id";
32092#endif /* FREECIV_JSON_CONNECTION */
32093 e = 0;
32094
32095 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
32096
32097 if (e) {
32098 log_packet_detailed("'unit_id' field error detected");
32099 }
32100#endif /* FREECIV_DELTA_PROTOCOL */
32101
32102 SEND_PACKET_END(PACKET_UNIT_REMOVE);
32103}
32104
32105 int send_packet_unit_remove(struct connection *pc, const struct packet_unit_remove *packet)
32106{
32107 if (!pc->used) {
32108 log_error("WARNING: trying to send data to the closed connection %s",
32109 conn_description(pc));
32110 return -1;
32111 }
32112 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_REMOVE].packet != nullptr, -1,
32113 "Handler for PACKET_UNIT_REMOVE not installed");
32114 return pc->phs.handlers->send[PACKET_UNIT_REMOVE].packet(pc, packet);
32115}
32116
32117 void lsend_packet_unit_remove(struct conn_list *dest, const struct packet_unit_remove *packet)
32118{
32119 conn_list_iterate(dest, pconn) {
32120 send_packet_unit_remove(pconn, packet);
32121 } conn_list_iterate_end;
32122}
32123
32124 int dsend_packet_unit_remove(struct connection *pc, int unit_id)
32125{
32126 struct packet_unit_remove packet, *real_packet = &packet;
32127
32128 real_packet->unit_id = unit_id;
32129
32130 return send_packet_unit_remove(pc, real_packet);
32131}
32132
32133 void dlsend_packet_unit_remove(struct conn_list *dest, int unit_id)
32134{
32135 struct packet_unit_remove packet, *real_packet = &packet;
32136
32137 real_packet->unit_id = unit_id;
32138
32139 lsend_packet_unit_remove(dest, real_packet);
32140}
32141
32142 static inline void init_packet_unit_info(struct packet_unit_info *packet)
32143{
32144 memset(packet, 0, sizeof(*packet));
32145}
32146
32147#define free_packet_unit_info(_packet) (void) 0
32148#define destroy_packet_unit_info free
32149
32150#ifdef FREECIV_DELTA_PROTOCOL
32151static genhash_val_t hash_packet_unit_info_100(const void *vkey)
32152{
32153 const struct packet_unit_info *key = (const struct packet_unit_info *) vkey;
32154 genhash_val_t result = 0;
32155
32156 result += key->id;
32157
32158 result &= 0xFFFFFFFF;
32159 return result;
32160}
32161
32162static bool cmp_packet_unit_info_100(const void *vkey1, const void *vkey2)
32163{
32164 const struct packet_unit_info *old = (const struct packet_unit_info *) vkey1;
32165 const struct packet_unit_info *real_packet = (const struct packet_unit_info *) vkey2;
32166 bool differ;
32167
32168 differ = (old->id != real_packet->id);
32169
32170 return !differ;
32171}
32172 BV_DEFINE(packet_unit_info_100_fields, 37);
32173#endif /* FREECIV_DELTA_PROTOCOL */
32174
32175 static struct packet_unit_info *receive_packet_unit_info_100(struct connection *pc)
32176{
32177#define FREE_PACKET_STRUCT(_packet) free_packet_unit_info(_packet)
32178 RECEIVE_PACKET_START(packet_unit_info, real_packet);
32179
32180#ifdef FREECIV_JSON_CONNECTION
32181 struct plocation field_addr;
32182 {
32183 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
32184 field_addr = *field_addr_tmp;
32185 FC_FREE(field_addr_tmp);
32186 }
32187#endif /* FREECIV_JSON_CONNECTION */
32188
32189#ifdef FREECIV_JSON_CONNECTION
32190 field_addr.name = "id";
32191#endif /* FREECIV_JSON_CONNECTION */
32192
32193 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
32194 RECEIVE_PACKET_FIELD_ERROR(id);
32195 }
32196
32197 log_packet_detailed("packet_unit_info_100: got info about (%d)",
32198 real_packet->id);
32199
32200#ifdef FREECIV_DELTA_PROTOCOL
32201 packet_unit_info_100_fields fields;
32202 struct packet_unit_info *old;
32203 struct genhash **hash = pc->phs.received + PACKET_UNIT_INFO;
32204
32205 if (nullptr == *hash) {
32206 *hash = genhash_new_full(hash_packet_unit_info_100, cmp_packet_unit_info_100,
32207 nullptr, nullptr, nullptr, destroy_packet_unit_info);
32208 }
32209
32210 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
32211 *real_packet = *old;
32212 } else {
32213 /* packet is already initialized empty */
32214 log_packet_detailed(" no old info");
32215 }
32216
32217#ifdef FREECIV_JSON_CONNECTION
32218 field_addr.name = "fields";
32219#endif /* FREECIV_JSON_CONNECTION */
32220 DIO_BV_GET(&din, &field_addr, fields);
32221
32222 if (BV_ISSET(fields, 0)) {
32223 log_packet_detailed(" got field 'owner'");
32224
32225#ifdef FREECIV_JSON_CONNECTION
32226 field_addr.name = "owner";
32227#endif /* FREECIV_JSON_CONNECTION */
32228
32229 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
32230 RECEIVE_PACKET_FIELD_ERROR(owner);
32231 }
32232 }
32233
32234 if (BV_ISSET(fields, 1)) {
32235 log_packet_detailed(" got field 'nationality'");
32236
32237#ifdef FREECIV_JSON_CONNECTION
32238 field_addr.name = "nationality";
32239#endif /* FREECIV_JSON_CONNECTION */
32240
32241 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nationality)) {
32242 RECEIVE_PACKET_FIELD_ERROR(nationality);
32243 }
32244 }
32245
32246 if (BV_ISSET(fields, 2)) {
32247 log_packet_detailed(" got field 'tile'");
32248
32249#ifdef FREECIV_JSON_CONNECTION
32250 field_addr.name = "tile";
32251#endif /* FREECIV_JSON_CONNECTION */
32252
32253 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
32254 RECEIVE_PACKET_FIELD_ERROR(tile);
32255 }
32256 }
32257
32258 if (BV_ISSET(fields, 3)) {
32259 log_packet_detailed(" got field 'facing'");
32260
32261#ifdef FREECIV_JSON_CONNECTION
32262 field_addr.name = "facing";
32263#endif /* FREECIV_JSON_CONNECTION */
32264
32265 {
32266 int readin;
32267
32268 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
32269 RECEIVE_PACKET_FIELD_ERROR(facing);
32270 }
32271 real_packet->facing = readin;
32272 }
32273 }
32274
32275 if (BV_ISSET(fields, 4)) {
32276 log_packet_detailed(" got field 'homecity'");
32277
32278#ifdef FREECIV_JSON_CONNECTION
32279 field_addr.name = "homecity";
32280#endif /* FREECIV_JSON_CONNECTION */
32281
32282 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->homecity)) {
32283 RECEIVE_PACKET_FIELD_ERROR(homecity);
32284 }
32285 }
32286
32287 if (BV_ISSET(fields, 5)) {
32288 log_packet_detailed(" got field 'upkeep'");
32289
32290#ifdef FREECIV_JSON_CONNECTION
32291 field_addr.name = "upkeep";
32292#endif /* FREECIV_JSON_CONNECTION */
32293
32294 {
32295 int i;
32296
32297
32298#ifdef FREECIV_JSON_CONNECTION
32299 /* Enter array. */
32300 field_addr.sub_location = plocation_elem_new(0);
32301#endif /* FREECIV_JSON_CONNECTION */
32302
32303 for (i = 0; i < O_LAST; i++) {
32304#ifdef FREECIV_JSON_CONNECTION
32305 /* Next array element */
32306 field_addr.sub_location->number = i;
32307#endif /* FREECIV_JSON_CONNECTION */
32308
32309 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->upkeep[i])) {
32310 RECEIVE_PACKET_FIELD_ERROR(upkeep);
32311 }
32312 }
32313
32314#ifdef FREECIV_JSON_CONNECTION
32315 /* Exit array. */
32316 FC_FREE(field_addr.sub_location);
32317#endif /* FREECIV_JSON_CONNECTION */
32318 }
32319 }
32320
32321 if (BV_ISSET(fields, 6)) {
32322 log_packet_detailed(" got field 'veteran'");
32323
32324#ifdef FREECIV_JSON_CONNECTION
32325 field_addr.name = "veteran";
32326#endif /* FREECIV_JSON_CONNECTION */
32327
32328 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran)) {
32329 RECEIVE_PACKET_FIELD_ERROR(veteran);
32330 }
32331 }
32332
32333 if (BV_ISSET(fields, 7)) {
32334 log_packet_detailed(" got field 'ssa_controller'");
32335
32336#ifdef FREECIV_JSON_CONNECTION
32337 field_addr.name = "ssa_controller";
32338#endif /* FREECIV_JSON_CONNECTION */
32339
32340 {
32341 int readin;
32342
32343 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32344 RECEIVE_PACKET_FIELD_ERROR(ssa_controller);
32345 }
32346 real_packet->ssa_controller = readin;
32347 }
32348 }
32349
32350 real_packet->paradropped = BV_ISSET(fields, 8);
32351
32352 real_packet->occupied = BV_ISSET(fields, 9);
32353
32354 real_packet->transported = BV_ISSET(fields, 10);
32355
32356 real_packet->done_moving = BV_ISSET(fields, 11);
32357
32358 real_packet->stay = BV_ISSET(fields, 12);
32359
32360 if (BV_ISSET(fields, 13)) {
32361 log_packet_detailed(" got field 'birth_turn'");
32362
32363#ifdef FREECIV_JSON_CONNECTION
32364 field_addr.name = "birth_turn";
32365#endif /* FREECIV_JSON_CONNECTION */
32366
32367 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->birth_turn)) {
32368 RECEIVE_PACKET_FIELD_ERROR(birth_turn);
32369 }
32370 }
32371
32372 if (BV_ISSET(fields, 14)) {
32373 log_packet_detailed(" got field 'current_form_turn'");
32374
32375#ifdef FREECIV_JSON_CONNECTION
32376 field_addr.name = "current_form_turn";
32377#endif /* FREECIV_JSON_CONNECTION */
32378
32379 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->current_form_turn)) {
32380 RECEIVE_PACKET_FIELD_ERROR(current_form_turn);
32381 }
32382 }
32383
32384 if (BV_ISSET(fields, 15)) {
32385 log_packet_detailed(" got field 'type'");
32386
32387#ifdef FREECIV_JSON_CONNECTION
32388 field_addr.name = "type";
32389#endif /* FREECIV_JSON_CONNECTION */
32390
32391 {
32392 int readin;
32393
32394 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
32395 RECEIVE_PACKET_FIELD_ERROR(type);
32396 }
32397 real_packet->type = readin;
32398 }
32399 }
32400
32401 if (BV_ISSET(fields, 16)) {
32402 log_packet_detailed(" got field 'transported_by'");
32403
32404#ifdef FREECIV_JSON_CONNECTION
32405 field_addr.name = "transported_by";
32406#endif /* FREECIV_JSON_CONNECTION */
32407
32408 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->transported_by)) {
32409 RECEIVE_PACKET_FIELD_ERROR(transported_by);
32410 }
32411 }
32412
32413 if (BV_ISSET(fields, 17)) {
32414 log_packet_detailed(" got field 'carrying'");
32415
32416#ifdef FREECIV_JSON_CONNECTION
32417 field_addr.name = "carrying";
32418#endif /* FREECIV_JSON_CONNECTION */
32419
32420 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->carrying)) {
32421 RECEIVE_PACKET_FIELD_ERROR(carrying);
32422 }
32423 }
32424
32425 if (BV_ISSET(fields, 18)) {
32426 log_packet_detailed(" got field 'movesleft'");
32427
32428#ifdef FREECIV_JSON_CONNECTION
32429 field_addr.name = "movesleft";
32430#endif /* FREECIV_JSON_CONNECTION */
32431
32432 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->movesleft)) {
32433 RECEIVE_PACKET_FIELD_ERROR(movesleft);
32434 }
32435 }
32436
32437 if (BV_ISSET(fields, 19)) {
32438 log_packet_detailed(" got field 'hp'");
32439
32440#ifdef FREECIV_JSON_CONNECTION
32441 field_addr.name = "hp";
32442#endif /* FREECIV_JSON_CONNECTION */
32443
32444 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
32445 RECEIVE_PACKET_FIELD_ERROR(hp);
32446 }
32447 }
32448
32449 if (BV_ISSET(fields, 20)) {
32450 log_packet_detailed(" got field 'fuel'");
32451
32452#ifdef FREECIV_JSON_CONNECTION
32453 field_addr.name = "fuel";
32454#endif /* FREECIV_JSON_CONNECTION */
32455
32456 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
32457 RECEIVE_PACKET_FIELD_ERROR(fuel);
32458 }
32459 }
32460
32461 if (BV_ISSET(fields, 21)) {
32462 log_packet_detailed(" got field 'activity_count'");
32463
32464#ifdef FREECIV_JSON_CONNECTION
32465 field_addr.name = "activity_count";
32466#endif /* FREECIV_JSON_CONNECTION */
32467
32468 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->activity_count)) {
32469 RECEIVE_PACKET_FIELD_ERROR(activity_count);
32470 }
32471 }
32472
32473 if (BV_ISSET(fields, 22)) {
32474 log_packet_detailed(" got field 'changed_from_count'");
32475
32476#ifdef FREECIV_JSON_CONNECTION
32477 field_addr.name = "changed_from_count";
32478#endif /* FREECIV_JSON_CONNECTION */
32479
32480 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->changed_from_count)) {
32481 RECEIVE_PACKET_FIELD_ERROR(changed_from_count);
32482 }
32483 }
32484
32485 if (BV_ISSET(fields, 23)) {
32486 log_packet_detailed(" got field 'goto_tile'");
32487
32488#ifdef FREECIV_JSON_CONNECTION
32489 field_addr.name = "goto_tile";
32490#endif /* FREECIV_JSON_CONNECTION */
32491
32492 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->goto_tile)) {
32493 RECEIVE_PACKET_FIELD_ERROR(goto_tile);
32494 }
32495 }
32496
32497 if (BV_ISSET(fields, 24)) {
32498 log_packet_detailed(" got field 'activity'");
32499
32500#ifdef FREECIV_JSON_CONNECTION
32501 field_addr.name = "activity";
32502#endif /* FREECIV_JSON_CONNECTION */
32503
32504 {
32505 int readin;
32506
32507 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32508 RECEIVE_PACKET_FIELD_ERROR(activity);
32509 }
32510 real_packet->activity = readin;
32511 }
32512 }
32513
32514 if (BV_ISSET(fields, 25)) {
32515 log_packet_detailed(" got field 'activity_tgt'");
32516
32517#ifdef FREECIV_JSON_CONNECTION
32518 field_addr.name = "activity_tgt";
32519#endif /* FREECIV_JSON_CONNECTION */
32520
32521 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->activity_tgt)) {
32522 RECEIVE_PACKET_FIELD_ERROR(activity_tgt);
32523 }
32524 }
32525
32526 if (BV_ISSET(fields, 26)) {
32527 log_packet_detailed(" got field 'changed_from'");
32528
32529#ifdef FREECIV_JSON_CONNECTION
32530 field_addr.name = "changed_from";
32531#endif /* FREECIV_JSON_CONNECTION */
32532
32533 {
32534 int readin;
32535
32536 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32537 RECEIVE_PACKET_FIELD_ERROR(changed_from);
32538 }
32539 real_packet->changed_from = readin;
32540 }
32541 }
32542
32543 if (BV_ISSET(fields, 27)) {
32544 log_packet_detailed(" got field 'changed_from_tgt'");
32545
32546#ifdef FREECIV_JSON_CONNECTION
32547 field_addr.name = "changed_from_tgt";
32548#endif /* FREECIV_JSON_CONNECTION */
32549
32550 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->changed_from_tgt)) {
32551 RECEIVE_PACKET_FIELD_ERROR(changed_from_tgt);
32552 }
32553 }
32554
32555 if (BV_ISSET(fields, 28)) {
32556 log_packet_detailed(" got field 'battlegroup'");
32557
32558#ifdef FREECIV_JSON_CONNECTION
32559 field_addr.name = "battlegroup";
32560#endif /* FREECIV_JSON_CONNECTION */
32561
32562 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->battlegroup)) {
32563 RECEIVE_PACKET_FIELD_ERROR(battlegroup);
32564 }
32565 }
32566
32567 real_packet->has_orders = BV_ISSET(fields, 29);
32568
32569 if (BV_ISSET(fields, 30)) {
32570 log_packet_detailed(" got field 'orders_length'");
32571
32572#ifdef FREECIV_JSON_CONNECTION
32573 field_addr.name = "orders_length";
32574#endif /* FREECIV_JSON_CONNECTION */
32575
32576 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->orders_length)) {
32577 RECEIVE_PACKET_FIELD_ERROR(orders_length);
32578 }
32579 }
32580
32581 if (BV_ISSET(fields, 31)) {
32582 log_packet_detailed(" got field 'orders_index'");
32583
32584#ifdef FREECIV_JSON_CONNECTION
32585 field_addr.name = "orders_index";
32586#endif /* FREECIV_JSON_CONNECTION */
32587
32588 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->orders_index)) {
32589 RECEIVE_PACKET_FIELD_ERROR(orders_index);
32590 }
32591 }
32592
32593 real_packet->orders_repeat = BV_ISSET(fields, 32);
32594
32595 real_packet->orders_vigilant = BV_ISSET(fields, 33);
32596
32597 if (BV_ISSET(fields, 34)) {
32598 log_packet_detailed(" got field 'orders'");
32599
32600#ifdef FREECIV_JSON_CONNECTION
32601 field_addr.name = "orders";
32602#endif /* FREECIV_JSON_CONNECTION */
32603
32604 {
32605 int i;
32606
32607 if (real_packet->orders_length > MAX_LEN_ROUTE) {
32608 RECEIVE_PACKET_FIELD_ERROR(orders, ": array truncated");
32609 }
32610
32611#ifdef FREECIV_JSON_CONNECTION
32612 /* Enter array. */
32613 field_addr.sub_location = plocation_elem_new(0);
32614#endif /* FREECIV_JSON_CONNECTION */
32615
32616 for (i = 0; i < real_packet->orders_length; i++) {
32617#ifdef FREECIV_JSON_CONNECTION
32618 /* Next array element */
32619 field_addr.sub_location->number = i;
32620#endif /* FREECIV_JSON_CONNECTION */
32621
32622 if (!DIO_GET(unit_order, &din, &field_addr, &real_packet->orders[i])) {
32623 RECEIVE_PACKET_FIELD_ERROR(orders);
32624 }
32625 }
32626
32627#ifdef FREECIV_JSON_CONNECTION
32628 /* Exit array. */
32629 FC_FREE(field_addr.sub_location);
32630#endif /* FREECIV_JSON_CONNECTION */
32631 }
32632 }
32633
32634 if (BV_ISSET(fields, 35)) {
32635 log_packet_detailed(" got field 'action_decision_want'");
32636
32637#ifdef FREECIV_JSON_CONNECTION
32638 field_addr.name = "action_decision_want";
32639#endif /* FREECIV_JSON_CONNECTION */
32640
32641 {
32642 int readin;
32643
32644 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32645 RECEIVE_PACKET_FIELD_ERROR(action_decision_want);
32646 }
32647 real_packet->action_decision_want = readin;
32648 }
32649 }
32650
32651 if (BV_ISSET(fields, 36)) {
32652 log_packet_detailed(" got field 'action_decision_tile'");
32653
32654#ifdef FREECIV_JSON_CONNECTION
32655 field_addr.name = "action_decision_tile";
32656#endif /* FREECIV_JSON_CONNECTION */
32657
32658 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->action_decision_tile)) {
32659 RECEIVE_PACKET_FIELD_ERROR(action_decision_tile);
32660 }
32661 }
32662
32663 if (nullptr == old) {
32664 old = fc_malloc(sizeof(*old));
32665 init_packet_unit_info(old);
32666 *old = *real_packet;
32667 genhash_insert(*hash, old, old);
32668 } else {
32669 *old = *real_packet;
32670 }
32671
32672 hash = pc->phs.received + PACKET_UNIT_SHORT_INFO;
32673 if (nullptr != *hash) {
32674 genhash_remove(*hash, real_packet);
32675 }
32676
32677#else /* FREECIV_DELTA_PROTOCOL */
32678#ifdef FREECIV_JSON_CONNECTION
32679 field_addr.name = "owner";
32680#endif /* FREECIV_JSON_CONNECTION */
32681
32682 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
32683 RECEIVE_PACKET_FIELD_ERROR(owner);
32684 }
32685
32686#ifdef FREECIV_JSON_CONNECTION
32687 field_addr.name = "nationality";
32688#endif /* FREECIV_JSON_CONNECTION */
32689
32690 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nationality)) {
32691 RECEIVE_PACKET_FIELD_ERROR(nationality);
32692 }
32693
32694#ifdef FREECIV_JSON_CONNECTION
32695 field_addr.name = "tile";
32696#endif /* FREECIV_JSON_CONNECTION */
32697
32698 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
32699 RECEIVE_PACKET_FIELD_ERROR(tile);
32700 }
32701
32702#ifdef FREECIV_JSON_CONNECTION
32703 field_addr.name = "facing";
32704#endif /* FREECIV_JSON_CONNECTION */
32705
32706 {
32707 int readin;
32708
32709 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
32710 RECEIVE_PACKET_FIELD_ERROR(facing);
32711 }
32712 real_packet->facing = readin;
32713 }
32714
32715#ifdef FREECIV_JSON_CONNECTION
32716 field_addr.name = "homecity";
32717#endif /* FREECIV_JSON_CONNECTION */
32718
32719 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->homecity)) {
32720 RECEIVE_PACKET_FIELD_ERROR(homecity);
32721 }
32722
32723#ifdef FREECIV_JSON_CONNECTION
32724 field_addr.name = "upkeep";
32725#endif /* FREECIV_JSON_CONNECTION */
32726
32727 {
32728 int i;
32729
32730
32731#ifdef FREECIV_JSON_CONNECTION
32732 /* Enter array. */
32733 field_addr.sub_location = plocation_elem_new(0);
32734#endif /* FREECIV_JSON_CONNECTION */
32735
32736 for (i = 0; i < O_LAST; i++) {
32737#ifdef FREECIV_JSON_CONNECTION
32738 /* Next array element */
32739 field_addr.sub_location->number = i;
32740#endif /* FREECIV_JSON_CONNECTION */
32741
32742 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->upkeep[i])) {
32743 RECEIVE_PACKET_FIELD_ERROR(upkeep);
32744 }
32745 }
32746
32747#ifdef FREECIV_JSON_CONNECTION
32748 /* Exit array. */
32749 FC_FREE(field_addr.sub_location);
32750#endif /* FREECIV_JSON_CONNECTION */
32751 }
32752
32753#ifdef FREECIV_JSON_CONNECTION
32754 field_addr.name = "veteran";
32755#endif /* FREECIV_JSON_CONNECTION */
32756
32757 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran)) {
32758 RECEIVE_PACKET_FIELD_ERROR(veteran);
32759 }
32760
32761#ifdef FREECIV_JSON_CONNECTION
32762 field_addr.name = "ssa_controller";
32763#endif /* FREECIV_JSON_CONNECTION */
32764
32765 {
32766 int readin;
32767
32768 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32769 RECEIVE_PACKET_FIELD_ERROR(ssa_controller);
32770 }
32771 real_packet->ssa_controller = readin;
32772 }
32773
32774#ifdef FREECIV_JSON_CONNECTION
32775 field_addr.name = "paradropped";
32776#endif /* FREECIV_JSON_CONNECTION */
32777
32778 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->paradropped)) {
32779 RECEIVE_PACKET_FIELD_ERROR(paradropped);
32780 }
32781
32782#ifdef FREECIV_JSON_CONNECTION
32783 field_addr.name = "occupied";
32784#endif /* FREECIV_JSON_CONNECTION */
32785
32786 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->occupied)) {
32787 RECEIVE_PACKET_FIELD_ERROR(occupied);
32788 }
32789
32790#ifdef FREECIV_JSON_CONNECTION
32791 field_addr.name = "transported";
32792#endif /* FREECIV_JSON_CONNECTION */
32793
32794 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->transported)) {
32795 RECEIVE_PACKET_FIELD_ERROR(transported);
32796 }
32797
32798#ifdef FREECIV_JSON_CONNECTION
32799 field_addr.name = "done_moving";
32800#endif /* FREECIV_JSON_CONNECTION */
32801
32802 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->done_moving)) {
32803 RECEIVE_PACKET_FIELD_ERROR(done_moving);
32804 }
32805
32806#ifdef FREECIV_JSON_CONNECTION
32807 field_addr.name = "stay";
32808#endif /* FREECIV_JSON_CONNECTION */
32809
32810 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->stay)) {
32811 RECEIVE_PACKET_FIELD_ERROR(stay);
32812 }
32813
32814#ifdef FREECIV_JSON_CONNECTION
32815 field_addr.name = "birth_turn";
32816#endif /* FREECIV_JSON_CONNECTION */
32817
32818 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->birth_turn)) {
32819 RECEIVE_PACKET_FIELD_ERROR(birth_turn);
32820 }
32821
32822#ifdef FREECIV_JSON_CONNECTION
32823 field_addr.name = "current_form_turn";
32824#endif /* FREECIV_JSON_CONNECTION */
32825
32826 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->current_form_turn)) {
32827 RECEIVE_PACKET_FIELD_ERROR(current_form_turn);
32828 }
32829
32830#ifdef FREECIV_JSON_CONNECTION
32831 field_addr.name = "type";
32832#endif /* FREECIV_JSON_CONNECTION */
32833
32834 {
32835 int readin;
32836
32837 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
32838 RECEIVE_PACKET_FIELD_ERROR(type);
32839 }
32840 real_packet->type = readin;
32841 }
32842
32843#ifdef FREECIV_JSON_CONNECTION
32844 field_addr.name = "transported_by";
32845#endif /* FREECIV_JSON_CONNECTION */
32846
32847 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->transported_by)) {
32848 RECEIVE_PACKET_FIELD_ERROR(transported_by);
32849 }
32850
32851#ifdef FREECIV_JSON_CONNECTION
32852 field_addr.name = "carrying";
32853#endif /* FREECIV_JSON_CONNECTION */
32854
32855 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->carrying)) {
32856 RECEIVE_PACKET_FIELD_ERROR(carrying);
32857 }
32858
32859#ifdef FREECIV_JSON_CONNECTION
32860 field_addr.name = "movesleft";
32861#endif /* FREECIV_JSON_CONNECTION */
32862
32863 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->movesleft)) {
32864 RECEIVE_PACKET_FIELD_ERROR(movesleft);
32865 }
32866
32867#ifdef FREECIV_JSON_CONNECTION
32868 field_addr.name = "hp";
32869#endif /* FREECIV_JSON_CONNECTION */
32870
32871 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
32872 RECEIVE_PACKET_FIELD_ERROR(hp);
32873 }
32874
32875#ifdef FREECIV_JSON_CONNECTION
32876 field_addr.name = "fuel";
32877#endif /* FREECIV_JSON_CONNECTION */
32878
32879 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
32880 RECEIVE_PACKET_FIELD_ERROR(fuel);
32881 }
32882
32883#ifdef FREECIV_JSON_CONNECTION
32884 field_addr.name = "activity_count";
32885#endif /* FREECIV_JSON_CONNECTION */
32886
32887 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->activity_count)) {
32888 RECEIVE_PACKET_FIELD_ERROR(activity_count);
32889 }
32890
32891#ifdef FREECIV_JSON_CONNECTION
32892 field_addr.name = "changed_from_count";
32893#endif /* FREECIV_JSON_CONNECTION */
32894
32895 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->changed_from_count)) {
32896 RECEIVE_PACKET_FIELD_ERROR(changed_from_count);
32897 }
32898
32899#ifdef FREECIV_JSON_CONNECTION
32900 field_addr.name = "goto_tile";
32901#endif /* FREECIV_JSON_CONNECTION */
32902
32903 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->goto_tile)) {
32904 RECEIVE_PACKET_FIELD_ERROR(goto_tile);
32905 }
32906
32907#ifdef FREECIV_JSON_CONNECTION
32908 field_addr.name = "activity";
32909#endif /* FREECIV_JSON_CONNECTION */
32910
32911 {
32912 int readin;
32913
32914 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32915 RECEIVE_PACKET_FIELD_ERROR(activity);
32916 }
32917 real_packet->activity = readin;
32918 }
32919
32920#ifdef FREECIV_JSON_CONNECTION
32921 field_addr.name = "activity_tgt";
32922#endif /* FREECIV_JSON_CONNECTION */
32923
32924 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->activity_tgt)) {
32925 RECEIVE_PACKET_FIELD_ERROR(activity_tgt);
32926 }
32927
32928#ifdef FREECIV_JSON_CONNECTION
32929 field_addr.name = "changed_from";
32930#endif /* FREECIV_JSON_CONNECTION */
32931
32932 {
32933 int readin;
32934
32935 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
32936 RECEIVE_PACKET_FIELD_ERROR(changed_from);
32937 }
32938 real_packet->changed_from = readin;
32939 }
32940
32941#ifdef FREECIV_JSON_CONNECTION
32942 field_addr.name = "changed_from_tgt";
32943#endif /* FREECIV_JSON_CONNECTION */
32944
32945 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->changed_from_tgt)) {
32946 RECEIVE_PACKET_FIELD_ERROR(changed_from_tgt);
32947 }
32948
32949#ifdef FREECIV_JSON_CONNECTION
32950 field_addr.name = "battlegroup";
32951#endif /* FREECIV_JSON_CONNECTION */
32952
32953 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->battlegroup)) {
32954 RECEIVE_PACKET_FIELD_ERROR(battlegroup);
32955 }
32956
32957#ifdef FREECIV_JSON_CONNECTION
32958 field_addr.name = "has_orders";
32959#endif /* FREECIV_JSON_CONNECTION */
32960
32961 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->has_orders)) {
32962 RECEIVE_PACKET_FIELD_ERROR(has_orders);
32963 }
32964
32965#ifdef FREECIV_JSON_CONNECTION
32966 field_addr.name = "orders_length";
32967#endif /* FREECIV_JSON_CONNECTION */
32968
32969 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->orders_length)) {
32970 RECEIVE_PACKET_FIELD_ERROR(orders_length);
32971 }
32972
32973#ifdef FREECIV_JSON_CONNECTION
32974 field_addr.name = "orders_index";
32975#endif /* FREECIV_JSON_CONNECTION */
32976
32977 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->orders_index)) {
32978 RECEIVE_PACKET_FIELD_ERROR(orders_index);
32979 }
32980
32981#ifdef FREECIV_JSON_CONNECTION
32982 field_addr.name = "orders_repeat";
32983#endif /* FREECIV_JSON_CONNECTION */
32984
32985 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->orders_repeat)) {
32986 RECEIVE_PACKET_FIELD_ERROR(orders_repeat);
32987 }
32988
32989#ifdef FREECIV_JSON_CONNECTION
32990 field_addr.name = "orders_vigilant";
32991#endif /* FREECIV_JSON_CONNECTION */
32992
32993 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->orders_vigilant)) {
32994 RECEIVE_PACKET_FIELD_ERROR(orders_vigilant);
32995 }
32996
32997#ifdef FREECIV_JSON_CONNECTION
32998 field_addr.name = "orders";
32999#endif /* FREECIV_JSON_CONNECTION */
33000
33001 {
33002 int i;
33003
33004 if (real_packet->orders_length > MAX_LEN_ROUTE) {
33005 RECEIVE_PACKET_FIELD_ERROR(orders, ": array truncated");
33006 }
33007
33008#ifdef FREECIV_JSON_CONNECTION
33009 /* Enter array. */
33010 field_addr.sub_location = plocation_elem_new(0);
33011#endif /* FREECIV_JSON_CONNECTION */
33012
33013 for (i = 0; i < real_packet->orders_length; i++) {
33014#ifdef FREECIV_JSON_CONNECTION
33015 /* Next array element */
33016 field_addr.sub_location->number = i;
33017#endif /* FREECIV_JSON_CONNECTION */
33018
33019 if (!DIO_GET(unit_order, &din, &field_addr, &real_packet->orders[i])) {
33020 RECEIVE_PACKET_FIELD_ERROR(orders);
33021 }
33022 }
33023
33024#ifdef FREECIV_JSON_CONNECTION
33025 /* Exit array. */
33026 FC_FREE(field_addr.sub_location);
33027#endif /* FREECIV_JSON_CONNECTION */
33028 }
33029
33030#ifdef FREECIV_JSON_CONNECTION
33031 field_addr.name = "action_decision_want";
33032#endif /* FREECIV_JSON_CONNECTION */
33033
33034 {
33035 int readin;
33036
33037 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
33038 RECEIVE_PACKET_FIELD_ERROR(action_decision_want);
33039 }
33040 real_packet->action_decision_want = readin;
33041 }
33042
33043#ifdef FREECIV_JSON_CONNECTION
33044 field_addr.name = "action_decision_tile";
33045#endif /* FREECIV_JSON_CONNECTION */
33046
33047 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->action_decision_tile)) {
33048 RECEIVE_PACKET_FIELD_ERROR(action_decision_tile);
33049 }
33050#endif /* FREECIV_DELTA_PROTOCOL */
33051
33052 RECEIVE_PACKET_END(real_packet);
33053#undef FREE_PACKET_STRUCT
33054}
33055
33056 static int send_packet_unit_info_100(struct connection *pc, const struct packet_unit_info *packet)
33057{
33058 const struct packet_unit_info *real_packet = packet;
33059 int e;
33060 SEND_PACKET_START(PACKET_UNIT_INFO);
33061
33062 log_packet_detailed("packet_unit_info_100: sending info about (%d)",
33063 real_packet->id);
33064
33065#ifdef FREECIV_DELTA_PROTOCOL
33066 packet_unit_info_100_fields fields;
33067 struct packet_unit_info *old;
33068 bool differ;
33069 int different = 0;
33070 struct genhash **hash = pc->phs.sent + PACKET_UNIT_INFO;
33071
33072 if (nullptr == *hash) {
33073 *hash = genhash_new_full(hash_packet_unit_info_100, cmp_packet_unit_info_100,
33074 nullptr, nullptr, nullptr, destroy_packet_unit_info);
33075 }
33076 BV_CLR_ALL(fields);
33077
33078 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
33079 old = fc_malloc(sizeof(*old));
33080 /* temporary bitcopy just to insert correctly */
33081 *old = *real_packet;
33082 genhash_insert(*hash, old, old);
33083 init_packet_unit_info(old);
33084 different = 1; /* Force to send. */
33085 }
33086
33087 differ = (old->owner != real_packet->owner);
33088 if (differ) {
33089 different++;
33090 BV_SET(fields, 0);
33091 }
33092
33093 differ = (old->nationality != real_packet->nationality);
33094 if (differ) {
33095 different++;
33096 BV_SET(fields, 1);
33097 }
33098
33099 differ = (old->tile != real_packet->tile);
33100 if (differ) {
33101 different++;
33102 BV_SET(fields, 2);
33103 }
33104
33105 differ = (old->facing != real_packet->facing);
33106 if (differ) {
33107 different++;
33108 BV_SET(fields, 3);
33109 }
33110
33111 differ = (old->homecity != real_packet->homecity);
33112 if (differ) {
33113 different++;
33114 BV_SET(fields, 4);
33115 }
33116
33117 differ = FALSE;
33118 {
33119 int i;
33120
33121 for (i = 0; i < O_LAST; i++) {
33122 differ = (old->upkeep[i] != real_packet->upkeep[i]);
33123 if (differ) {
33124 break;
33125 }
33126 }
33127 }
33128 if (differ) {
33129 different++;
33130 BV_SET(fields, 5);
33131 }
33132
33133 differ = (old->veteran != real_packet->veteran);
33134 if (differ) {
33135 different++;
33136 BV_SET(fields, 6);
33137 }
33138
33139 differ = (old->ssa_controller != real_packet->ssa_controller);
33140 if (differ) {
33141 different++;
33142 BV_SET(fields, 7);
33143 }
33144
33145 differ = (old->paradropped != real_packet->paradropped);
33146 if (differ) {
33147 different++;
33148 }
33149 /* folded into head */
33150 if (real_packet->paradropped) {
33151 BV_SET(fields, 8);
33152 }
33153
33154 differ = (old->occupied != real_packet->occupied);
33155 if (differ) {
33156 different++;
33157 }
33158 /* folded into head */
33159 if (real_packet->occupied) {
33160 BV_SET(fields, 9);
33161 }
33162
33163 differ = (old->transported != real_packet->transported);
33164 if (differ) {
33165 different++;
33166 }
33167 /* folded into head */
33168 if (real_packet->transported) {
33169 BV_SET(fields, 10);
33170 }
33171
33172 differ = (old->done_moving != real_packet->done_moving);
33173 if (differ) {
33174 different++;
33175 }
33176 /* folded into head */
33177 if (real_packet->done_moving) {
33178 BV_SET(fields, 11);
33179 }
33180
33181 differ = (old->stay != real_packet->stay);
33182 if (differ) {
33183 different++;
33184 }
33185 /* folded into head */
33186 if (real_packet->stay) {
33187 BV_SET(fields, 12);
33188 }
33189
33190 differ = (old->birth_turn != real_packet->birth_turn);
33191 if (differ) {
33192 different++;
33193 BV_SET(fields, 13);
33194 }
33195
33196 differ = (old->current_form_turn != real_packet->current_form_turn);
33197 if (differ) {
33198 different++;
33199 BV_SET(fields, 14);
33200 }
33201
33202 differ = (old->type != real_packet->type);
33203 if (differ) {
33204 different++;
33205 BV_SET(fields, 15);
33206 }
33207
33208 differ = (old->transported_by != real_packet->transported_by);
33209 if (differ) {
33210 different++;
33211 BV_SET(fields, 16);
33212 }
33213
33214 differ = (old->carrying != real_packet->carrying);
33215 if (differ) {
33216 different++;
33217 BV_SET(fields, 17);
33218 }
33219
33220 differ = (old->movesleft != real_packet->movesleft);
33221 if (differ) {
33222 different++;
33223 BV_SET(fields, 18);
33224 }
33225
33226 differ = (old->hp != real_packet->hp);
33227 if (differ) {
33228 different++;
33229 BV_SET(fields, 19);
33230 }
33231
33232 differ = (old->fuel != real_packet->fuel);
33233 if (differ) {
33234 different++;
33235 BV_SET(fields, 20);
33236 }
33237
33238 differ = (old->activity_count != real_packet->activity_count);
33239 if (differ) {
33240 different++;
33241 BV_SET(fields, 21);
33242 }
33243
33244 differ = (old->changed_from_count != real_packet->changed_from_count);
33245 if (differ) {
33246 different++;
33247 BV_SET(fields, 22);
33248 }
33249
33250 differ = (old->goto_tile != real_packet->goto_tile);
33251 if (differ) {
33252 different++;
33253 BV_SET(fields, 23);
33254 }
33255
33256 differ = (old->activity != real_packet->activity);
33257 if (differ) {
33258 different++;
33259 BV_SET(fields, 24);
33260 }
33261
33262 differ = (old->activity_tgt != real_packet->activity_tgt);
33263 if (differ) {
33264 different++;
33265 BV_SET(fields, 25);
33266 }
33267
33268 differ = (old->changed_from != real_packet->changed_from);
33269 if (differ) {
33270 different++;
33271 BV_SET(fields, 26);
33272 }
33273
33274 differ = (old->changed_from_tgt != real_packet->changed_from_tgt);
33275 if (differ) {
33276 different++;
33277 BV_SET(fields, 27);
33278 }
33279
33280 differ = (old->battlegroup != real_packet->battlegroup);
33281 if (differ) {
33282 different++;
33283 BV_SET(fields, 28);
33284 }
33285
33286 differ = (old->has_orders != real_packet->has_orders);
33287 if (differ) {
33288 different++;
33289 }
33290 /* folded into head */
33291 if (real_packet->has_orders) {
33292 BV_SET(fields, 29);
33293 }
33294
33295 differ = (old->orders_length != real_packet->orders_length);
33296 if (differ) {
33297 different++;
33298 BV_SET(fields, 30);
33299 }
33300
33301 differ = (old->orders_index != real_packet->orders_index);
33302 if (differ) {
33303 different++;
33304 BV_SET(fields, 31);
33305 }
33306
33307 differ = (old->orders_repeat != real_packet->orders_repeat);
33308 if (differ) {
33309 different++;
33310 }
33311 /* folded into head */
33312 if (real_packet->orders_repeat) {
33313 BV_SET(fields, 32);
33314 }
33315
33316 differ = (old->orders_vigilant != real_packet->orders_vigilant);
33317 if (differ) {
33318 different++;
33319 }
33320 /* folded into head */
33321 if (real_packet->orders_vigilant) {
33322 BV_SET(fields, 33);
33323 }
33324
33325 differ = (old->orders_length != real_packet->orders_length);
33326 if (!differ) {
33327 int i;
33328
33329 for (i = 0; i < old->orders_length; i++) {
33330 differ = !are_unit_orders_equal(&old->orders[i], &real_packet->orders[i]);
33331 if (differ) {
33332 break;
33333 }
33334 }
33335 }
33336 if (differ) {
33337 different++;
33338 BV_SET(fields, 34);
33339 }
33340
33341 differ = (old->action_decision_want != real_packet->action_decision_want);
33342 if (differ) {
33343 different++;
33344 BV_SET(fields, 35);
33345 }
33346
33347 differ = (old->action_decision_tile != real_packet->action_decision_tile);
33348 if (differ) {
33349 different++;
33350 BV_SET(fields, 36);
33351 }
33352
33353 if (different == 0) {
33354 log_packet_detailed(" no change -> discard");
33355 SEND_PACKET_DISCARD();
33356 }
33357#endif /* FREECIV_DELTA_PROTOCOL */
33358
33359#ifdef FREECIV_JSON_CONNECTION
33360 struct plocation field_addr;
33361 {
33362 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
33363 field_addr = *field_addr_tmp;
33364 FC_FREE(field_addr_tmp);
33365 }
33366#endif /* FREECIV_JSON_CONNECTION */
33367
33368#ifdef FREECIV_JSON_CONNECTION
33369 field_addr.name = "id";
33370#endif /* FREECIV_JSON_CONNECTION */
33371 e = 0;
33372
33373 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
33374
33375 if (e) {
33376 log_packet_detailed("'id' field error detected");
33377 }
33378
33379#ifdef FREECIV_DELTA_PROTOCOL
33380#ifdef FREECIV_JSON_CONNECTION
33381 field_addr.name = "fields";
33382#endif /* FREECIV_JSON_CONNECTION */
33383 e = 0;
33384 e |= DIO_BV_PUT(&dout, &field_addr, fields);
33385 if (e) {
33386 log_packet_detailed("fields bitvector error detected");
33387 }
33388
33389 if (BV_ISSET(fields, 0)) {
33390 log_packet_detailed(" field 'owner' has changed");
33391
33392#ifdef FREECIV_JSON_CONNECTION
33393 field_addr.name = "owner";
33394#endif /* FREECIV_JSON_CONNECTION */
33395 e = 0;
33396
33397 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
33398
33399 if (e) {
33400 log_packet_detailed("'owner' field error detected");
33401 }
33402 }
33403
33404 if (BV_ISSET(fields, 1)) {
33405 log_packet_detailed(" field 'nationality' has changed");
33406
33407#ifdef FREECIV_JSON_CONNECTION
33408 field_addr.name = "nationality";
33409#endif /* FREECIV_JSON_CONNECTION */
33410 e = 0;
33411
33412 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nationality);
33413
33414 if (e) {
33415 log_packet_detailed("'nationality' field error detected");
33416 }
33417 }
33418
33419 if (BV_ISSET(fields, 2)) {
33420 log_packet_detailed(" field 'tile' has changed");
33421
33422#ifdef FREECIV_JSON_CONNECTION
33423 field_addr.name = "tile";
33424#endif /* FREECIV_JSON_CONNECTION */
33425 e = 0;
33426
33427 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
33428
33429 if (e) {
33430 log_packet_detailed("'tile' field error detected");
33431 }
33432 }
33433
33434 if (BV_ISSET(fields, 3)) {
33435 log_packet_detailed(" field 'facing' has changed");
33436
33437#ifdef FREECIV_JSON_CONNECTION
33438 field_addr.name = "facing";
33439#endif /* FREECIV_JSON_CONNECTION */
33440 e = 0;
33441
33442 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->facing);
33443
33444 if (e) {
33445 log_packet_detailed("'facing' field error detected");
33446 }
33447 }
33448
33449 if (BV_ISSET(fields, 4)) {
33450 log_packet_detailed(" field 'homecity' has changed");
33451
33452#ifdef FREECIV_JSON_CONNECTION
33453 field_addr.name = "homecity";
33454#endif /* FREECIV_JSON_CONNECTION */
33455 e = 0;
33456
33457 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->homecity);
33458
33459 if (e) {
33460 log_packet_detailed("'homecity' field error detected");
33461 }
33462 }
33463
33464 if (BV_ISSET(fields, 5)) {
33465 log_packet_detailed(" field 'upkeep' has changed");
33466
33467#ifdef FREECIV_JSON_CONNECTION
33468 field_addr.name = "upkeep";
33469#endif /* FREECIV_JSON_CONNECTION */
33470 e = 0;
33471
33472 {
33473 int i;
33474
33475#ifdef FREECIV_JSON_CONNECTION
33476 /* Create the array. */
33477 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
33478
33479 /* Enter array. */
33480 field_addr.sub_location = plocation_elem_new(0);
33481#endif /* FREECIV_JSON_CONNECTION */
33482
33483 for (i = 0; i < O_LAST; i++) {
33484#ifdef FREECIV_JSON_CONNECTION
33485 /* Next array element. */
33486 field_addr.sub_location->number = i;
33487#endif /* FREECIV_JSON_CONNECTION */
33488
33489 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->upkeep[i]);
33490 }
33491
33492#ifdef FREECIV_JSON_CONNECTION
33493 /* Exit array. */
33494 FC_FREE(field_addr.sub_location);
33495#endif /* FREECIV_JSON_CONNECTION */
33496 }
33497
33498 if (e) {
33499 log_packet_detailed("'upkeep' field error detected");
33500 }
33501 }
33502
33503 if (BV_ISSET(fields, 6)) {
33504 log_packet_detailed(" field 'veteran' has changed");
33505
33506#ifdef FREECIV_JSON_CONNECTION
33507 field_addr.name = "veteran";
33508#endif /* FREECIV_JSON_CONNECTION */
33509 e = 0;
33510
33511 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran);
33512
33513 if (e) {
33514 log_packet_detailed("'veteran' field error detected");
33515 }
33516 }
33517
33518 if (BV_ISSET(fields, 7)) {
33519 log_packet_detailed(" field 'ssa_controller' has changed");
33520
33521#ifdef FREECIV_JSON_CONNECTION
33522 field_addr.name = "ssa_controller";
33523#endif /* FREECIV_JSON_CONNECTION */
33524 e = 0;
33525
33526 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ssa_controller);
33527
33528 if (e) {
33529 log_packet_detailed("'ssa_controller' field error detected");
33530 }
33531 }
33532
33533 /* field 8 is folded into the header */
33534
33535 /* field 9 is folded into the header */
33536
33537 /* field 10 is folded into the header */
33538
33539 /* field 11 is folded into the header */
33540
33541 /* field 12 is folded into the header */
33542
33543 if (BV_ISSET(fields, 13)) {
33544 log_packet_detailed(" field 'birth_turn' has changed");
33545
33546#ifdef FREECIV_JSON_CONNECTION
33547 field_addr.name = "birth_turn";
33548#endif /* FREECIV_JSON_CONNECTION */
33549 e = 0;
33550
33551 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->birth_turn);
33552
33553 if (e) {
33554 log_packet_detailed("'birth_turn' field error detected");
33555 }
33556 }
33557
33558 if (BV_ISSET(fields, 14)) {
33559 log_packet_detailed(" field 'current_form_turn' has changed");
33560
33561#ifdef FREECIV_JSON_CONNECTION
33562 field_addr.name = "current_form_turn";
33563#endif /* FREECIV_JSON_CONNECTION */
33564 e = 0;
33565
33566 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->current_form_turn);
33567
33568 if (e) {
33569 log_packet_detailed("'current_form_turn' field error detected");
33570 }
33571 }
33572
33573 if (BV_ISSET(fields, 15)) {
33574 log_packet_detailed(" field 'type' has changed");
33575
33576#ifdef FREECIV_JSON_CONNECTION
33577 field_addr.name = "type";
33578#endif /* FREECIV_JSON_CONNECTION */
33579 e = 0;
33580
33581 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
33582
33583 if (e) {
33584 log_packet_detailed("'type' field error detected");
33585 }
33586 }
33587
33588 if (BV_ISSET(fields, 16)) {
33589 log_packet_detailed(" field 'transported_by' has changed");
33590
33591#ifdef FREECIV_JSON_CONNECTION
33592 field_addr.name = "transported_by";
33593#endif /* FREECIV_JSON_CONNECTION */
33594 e = 0;
33595
33596 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->transported_by);
33597
33598 if (e) {
33599 log_packet_detailed("'transported_by' field error detected");
33600 }
33601 }
33602
33603 if (BV_ISSET(fields, 17)) {
33604 log_packet_detailed(" field 'carrying' has changed");
33605
33606#ifdef FREECIV_JSON_CONNECTION
33607 field_addr.name = "carrying";
33608#endif /* FREECIV_JSON_CONNECTION */
33609 e = 0;
33610
33611 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->carrying);
33612
33613 if (e) {
33614 log_packet_detailed("'carrying' field error detected");
33615 }
33616 }
33617
33618 if (BV_ISSET(fields, 18)) {
33619 log_packet_detailed(" field 'movesleft' has changed");
33620
33621#ifdef FREECIV_JSON_CONNECTION
33622 field_addr.name = "movesleft";
33623#endif /* FREECIV_JSON_CONNECTION */
33624 e = 0;
33625
33626 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->movesleft);
33627
33628 if (e) {
33629 log_packet_detailed("'movesleft' field error detected");
33630 }
33631 }
33632
33633 if (BV_ISSET(fields, 19)) {
33634 log_packet_detailed(" field 'hp' has changed");
33635
33636#ifdef FREECIV_JSON_CONNECTION
33637 field_addr.name = "hp";
33638#endif /* FREECIV_JSON_CONNECTION */
33639 e = 0;
33640
33641 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
33642
33643 if (e) {
33644 log_packet_detailed("'hp' field error detected");
33645 }
33646 }
33647
33648 if (BV_ISSET(fields, 20)) {
33649 log_packet_detailed(" field 'fuel' has changed");
33650
33651#ifdef FREECIV_JSON_CONNECTION
33652 field_addr.name = "fuel";
33653#endif /* FREECIV_JSON_CONNECTION */
33654 e = 0;
33655
33656 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
33657
33658 if (e) {
33659 log_packet_detailed("'fuel' field error detected");
33660 }
33661 }
33662
33663 if (BV_ISSET(fields, 21)) {
33664 log_packet_detailed(" field 'activity_count' has changed");
33665
33666#ifdef FREECIV_JSON_CONNECTION
33667 field_addr.name = "activity_count";
33668#endif /* FREECIV_JSON_CONNECTION */
33669 e = 0;
33670
33671 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->activity_count);
33672
33673 if (e) {
33674 log_packet_detailed("'activity_count' field error detected");
33675 }
33676 }
33677
33678 if (BV_ISSET(fields, 22)) {
33679 log_packet_detailed(" field 'changed_from_count' has changed");
33680
33681#ifdef FREECIV_JSON_CONNECTION
33682 field_addr.name = "changed_from_count";
33683#endif /* FREECIV_JSON_CONNECTION */
33684 e = 0;
33685
33686 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->changed_from_count);
33687
33688 if (e) {
33689 log_packet_detailed("'changed_from_count' field error detected");
33690 }
33691 }
33692
33693 if (BV_ISSET(fields, 23)) {
33694 log_packet_detailed(" field 'goto_tile' has changed");
33695
33696#ifdef FREECIV_JSON_CONNECTION
33697 field_addr.name = "goto_tile";
33698#endif /* FREECIV_JSON_CONNECTION */
33699 e = 0;
33700
33701 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->goto_tile);
33702
33703 if (e) {
33704 log_packet_detailed("'goto_tile' field error detected");
33705 }
33706 }
33707
33708 if (BV_ISSET(fields, 24)) {
33709 log_packet_detailed(" field 'activity' has changed");
33710
33711#ifdef FREECIV_JSON_CONNECTION
33712 field_addr.name = "activity";
33713#endif /* FREECIV_JSON_CONNECTION */
33714 e = 0;
33715
33716 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
33717
33718 if (e) {
33719 log_packet_detailed("'activity' field error detected");
33720 }
33721 }
33722
33723 if (BV_ISSET(fields, 25)) {
33724 log_packet_detailed(" field 'activity_tgt' has changed");
33725
33726#ifdef FREECIV_JSON_CONNECTION
33727 field_addr.name = "activity_tgt";
33728#endif /* FREECIV_JSON_CONNECTION */
33729 e = 0;
33730
33731 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->activity_tgt);
33732
33733 if (e) {
33734 log_packet_detailed("'activity_tgt' field error detected");
33735 }
33736 }
33737
33738 if (BV_ISSET(fields, 26)) {
33739 log_packet_detailed(" field 'changed_from' has changed");
33740
33741#ifdef FREECIV_JSON_CONNECTION
33742 field_addr.name = "changed_from";
33743#endif /* FREECIV_JSON_CONNECTION */
33744 e = 0;
33745
33746 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->changed_from);
33747
33748 if (e) {
33749 log_packet_detailed("'changed_from' field error detected");
33750 }
33751 }
33752
33753 if (BV_ISSET(fields, 27)) {
33754 log_packet_detailed(" field 'changed_from_tgt' has changed");
33755
33756#ifdef FREECIV_JSON_CONNECTION
33757 field_addr.name = "changed_from_tgt";
33758#endif /* FREECIV_JSON_CONNECTION */
33759 e = 0;
33760
33761 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->changed_from_tgt);
33762
33763 if (e) {
33764 log_packet_detailed("'changed_from_tgt' field error detected");
33765 }
33766 }
33767
33768 if (BV_ISSET(fields, 28)) {
33769 log_packet_detailed(" field 'battlegroup' has changed");
33770
33771#ifdef FREECIV_JSON_CONNECTION
33772 field_addr.name = "battlegroup";
33773#endif /* FREECIV_JSON_CONNECTION */
33774 e = 0;
33775
33776 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->battlegroup);
33777
33778 if (e) {
33779 log_packet_detailed("'battlegroup' field error detected");
33780 }
33781 }
33782
33783 /* field 29 is folded into the header */
33784
33785 if (BV_ISSET(fields, 30)) {
33786 log_packet_detailed(" field 'orders_length' has changed");
33787
33788#ifdef FREECIV_JSON_CONNECTION
33789 field_addr.name = "orders_length";
33790#endif /* FREECIV_JSON_CONNECTION */
33791 e = 0;
33792
33793 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->orders_length);
33794
33795 if (e) {
33796 log_packet_detailed("'orders_length' field error detected");
33797 }
33798 }
33799
33800 if (BV_ISSET(fields, 31)) {
33801 log_packet_detailed(" field 'orders_index' has changed");
33802
33803#ifdef FREECIV_JSON_CONNECTION
33804 field_addr.name = "orders_index";
33805#endif /* FREECIV_JSON_CONNECTION */
33806 e = 0;
33807
33808 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->orders_index);
33809
33810 if (e) {
33811 log_packet_detailed("'orders_index' field error detected");
33812 }
33813 }
33814
33815 /* field 32 is folded into the header */
33816
33817 /* field 33 is folded into the header */
33818
33819 if (BV_ISSET(fields, 34)) {
33820 log_packet_detailed(" field 'orders' has changed");
33821
33822#ifdef FREECIV_JSON_CONNECTION
33823 field_addr.name = "orders";
33824#endif /* FREECIV_JSON_CONNECTION */
33825 e = 0;
33826
33827 {
33828 int i;
33829
33830#ifdef FREECIV_JSON_CONNECTION
33831 /* Create the array. */
33832 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->orders_length);
33833
33834 /* Enter array. */
33835 field_addr.sub_location = plocation_elem_new(0);
33836#endif /* FREECIV_JSON_CONNECTION */
33837
33838 for (i = 0; i < real_packet->orders_length; i++) {
33839#ifdef FREECIV_JSON_CONNECTION
33840 /* Next array element. */
33841 field_addr.sub_location->number = i;
33842#endif /* FREECIV_JSON_CONNECTION */
33843
33844 e |= DIO_PUT(unit_order, &dout, &field_addr, &real_packet->orders[i]);
33845 }
33846
33847#ifdef FREECIV_JSON_CONNECTION
33848 /* Exit array. */
33849 FC_FREE(field_addr.sub_location);
33850#endif /* FREECIV_JSON_CONNECTION */
33851 }
33852
33853 if (e) {
33854 log_packet_detailed("'orders' field error detected");
33855 }
33856 }
33857
33858 if (BV_ISSET(fields, 35)) {
33859 log_packet_detailed(" field 'action_decision_want' has changed");
33860
33861#ifdef FREECIV_JSON_CONNECTION
33862 field_addr.name = "action_decision_want";
33863#endif /* FREECIV_JSON_CONNECTION */
33864 e = 0;
33865
33866 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_decision_want);
33867
33868 if (e) {
33869 log_packet_detailed("'action_decision_want' field error detected");
33870 }
33871 }
33872
33873 if (BV_ISSET(fields, 36)) {
33874 log_packet_detailed(" field 'action_decision_tile' has changed");
33875
33876#ifdef FREECIV_JSON_CONNECTION
33877 field_addr.name = "action_decision_tile";
33878#endif /* FREECIV_JSON_CONNECTION */
33879 e = 0;
33880
33881 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->action_decision_tile);
33882
33883 if (e) {
33884 log_packet_detailed("'action_decision_tile' field error detected");
33885 }
33886 }
33887
33888 *old = *real_packet;
33889
33890 hash = pc->phs.sent + PACKET_UNIT_SHORT_INFO;
33891 if (nullptr != *hash) {
33892 genhash_remove(*hash, real_packet);
33893 }
33894
33895#else /* FREECIV_DELTA_PROTOCOL */
33896#ifdef FREECIV_JSON_CONNECTION
33897 field_addr.name = "owner";
33898#endif /* FREECIV_JSON_CONNECTION */
33899 e = 0;
33900
33901 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
33902
33903 if (e) {
33904 log_packet_detailed("'owner' field error detected");
33905 }
33906
33907#ifdef FREECIV_JSON_CONNECTION
33908 field_addr.name = "nationality";
33909#endif /* FREECIV_JSON_CONNECTION */
33910 e = 0;
33911
33912 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nationality);
33913
33914 if (e) {
33915 log_packet_detailed("'nationality' field error detected");
33916 }
33917
33918#ifdef FREECIV_JSON_CONNECTION
33919 field_addr.name = "tile";
33920#endif /* FREECIV_JSON_CONNECTION */
33921 e = 0;
33922
33923 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
33924
33925 if (e) {
33926 log_packet_detailed("'tile' field error detected");
33927 }
33928
33929#ifdef FREECIV_JSON_CONNECTION
33930 field_addr.name = "facing";
33931#endif /* FREECIV_JSON_CONNECTION */
33932 e = 0;
33933
33934 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->facing);
33935
33936 if (e) {
33937 log_packet_detailed("'facing' field error detected");
33938 }
33939
33940#ifdef FREECIV_JSON_CONNECTION
33941 field_addr.name = "homecity";
33942#endif /* FREECIV_JSON_CONNECTION */
33943 e = 0;
33944
33945 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->homecity);
33946
33947 if (e) {
33948 log_packet_detailed("'homecity' field error detected");
33949 }
33950
33951#ifdef FREECIV_JSON_CONNECTION
33952 field_addr.name = "upkeep";
33953#endif /* FREECIV_JSON_CONNECTION */
33954 e = 0;
33955
33956 {
33957 int i;
33958
33959#ifdef FREECIV_JSON_CONNECTION
33960 /* Create the array. */
33961 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
33962
33963 /* Enter array. */
33964 field_addr.sub_location = plocation_elem_new(0);
33965#endif /* FREECIV_JSON_CONNECTION */
33966
33967 for (i = 0; i < O_LAST; i++) {
33968#ifdef FREECIV_JSON_CONNECTION
33969 /* Next array element. */
33970 field_addr.sub_location->number = i;
33971#endif /* FREECIV_JSON_CONNECTION */
33972
33973 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->upkeep[i]);
33974 }
33975
33976#ifdef FREECIV_JSON_CONNECTION
33977 /* Exit array. */
33978 FC_FREE(field_addr.sub_location);
33979#endif /* FREECIV_JSON_CONNECTION */
33980 }
33981
33982 if (e) {
33983 log_packet_detailed("'upkeep' field error detected");
33984 }
33985
33986#ifdef FREECIV_JSON_CONNECTION
33987 field_addr.name = "veteran";
33988#endif /* FREECIV_JSON_CONNECTION */
33989 e = 0;
33990
33991 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran);
33992
33993 if (e) {
33994 log_packet_detailed("'veteran' field error detected");
33995 }
33996
33997#ifdef FREECIV_JSON_CONNECTION
33998 field_addr.name = "ssa_controller";
33999#endif /* FREECIV_JSON_CONNECTION */
34000 e = 0;
34001
34002 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ssa_controller);
34003
34004 if (e) {
34005 log_packet_detailed("'ssa_controller' field error detected");
34006 }
34007
34008#ifdef FREECIV_JSON_CONNECTION
34009 field_addr.name = "paradropped";
34010#endif /* FREECIV_JSON_CONNECTION */
34011 e = 0;
34012
34013 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->paradropped);
34014
34015 if (e) {
34016 log_packet_detailed("'paradropped' field error detected");
34017 }
34018
34019#ifdef FREECIV_JSON_CONNECTION
34020 field_addr.name = "occupied";
34021#endif /* FREECIV_JSON_CONNECTION */
34022 e = 0;
34023
34024 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->occupied);
34025
34026 if (e) {
34027 log_packet_detailed("'occupied' field error detected");
34028 }
34029
34030#ifdef FREECIV_JSON_CONNECTION
34031 field_addr.name = "transported";
34032#endif /* FREECIV_JSON_CONNECTION */
34033 e = 0;
34034
34035 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->transported);
34036
34037 if (e) {
34038 log_packet_detailed("'transported' field error detected");
34039 }
34040
34041#ifdef FREECIV_JSON_CONNECTION
34042 field_addr.name = "done_moving";
34043#endif /* FREECIV_JSON_CONNECTION */
34044 e = 0;
34045
34046 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->done_moving);
34047
34048 if (e) {
34049 log_packet_detailed("'done_moving' field error detected");
34050 }
34051
34052#ifdef FREECIV_JSON_CONNECTION
34053 field_addr.name = "stay";
34054#endif /* FREECIV_JSON_CONNECTION */
34055 e = 0;
34056
34057 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->stay);
34058
34059 if (e) {
34060 log_packet_detailed("'stay' field error detected");
34061 }
34062
34063#ifdef FREECIV_JSON_CONNECTION
34064 field_addr.name = "birth_turn";
34065#endif /* FREECIV_JSON_CONNECTION */
34066 e = 0;
34067
34068 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->birth_turn);
34069
34070 if (e) {
34071 log_packet_detailed("'birth_turn' field error detected");
34072 }
34073
34074#ifdef FREECIV_JSON_CONNECTION
34075 field_addr.name = "current_form_turn";
34076#endif /* FREECIV_JSON_CONNECTION */
34077 e = 0;
34078
34079 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->current_form_turn);
34080
34081 if (e) {
34082 log_packet_detailed("'current_form_turn' field error detected");
34083 }
34084
34085#ifdef FREECIV_JSON_CONNECTION
34086 field_addr.name = "type";
34087#endif /* FREECIV_JSON_CONNECTION */
34088 e = 0;
34089
34090 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
34091
34092 if (e) {
34093 log_packet_detailed("'type' field error detected");
34094 }
34095
34096#ifdef FREECIV_JSON_CONNECTION
34097 field_addr.name = "transported_by";
34098#endif /* FREECIV_JSON_CONNECTION */
34099 e = 0;
34100
34101 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->transported_by);
34102
34103 if (e) {
34104 log_packet_detailed("'transported_by' field error detected");
34105 }
34106
34107#ifdef FREECIV_JSON_CONNECTION
34108 field_addr.name = "carrying";
34109#endif /* FREECIV_JSON_CONNECTION */
34110 e = 0;
34111
34112 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->carrying);
34113
34114 if (e) {
34115 log_packet_detailed("'carrying' field error detected");
34116 }
34117
34118#ifdef FREECIV_JSON_CONNECTION
34119 field_addr.name = "movesleft";
34120#endif /* FREECIV_JSON_CONNECTION */
34121 e = 0;
34122
34123 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->movesleft);
34124
34125 if (e) {
34126 log_packet_detailed("'movesleft' field error detected");
34127 }
34128
34129#ifdef FREECIV_JSON_CONNECTION
34130 field_addr.name = "hp";
34131#endif /* FREECIV_JSON_CONNECTION */
34132 e = 0;
34133
34134 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
34135
34136 if (e) {
34137 log_packet_detailed("'hp' field error detected");
34138 }
34139
34140#ifdef FREECIV_JSON_CONNECTION
34141 field_addr.name = "fuel";
34142#endif /* FREECIV_JSON_CONNECTION */
34143 e = 0;
34144
34145 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
34146
34147 if (e) {
34148 log_packet_detailed("'fuel' field error detected");
34149 }
34150
34151#ifdef FREECIV_JSON_CONNECTION
34152 field_addr.name = "activity_count";
34153#endif /* FREECIV_JSON_CONNECTION */
34154 e = 0;
34155
34156 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->activity_count);
34157
34158 if (e) {
34159 log_packet_detailed("'activity_count' field error detected");
34160 }
34161
34162#ifdef FREECIV_JSON_CONNECTION
34163 field_addr.name = "changed_from_count";
34164#endif /* FREECIV_JSON_CONNECTION */
34165 e = 0;
34166
34167 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->changed_from_count);
34168
34169 if (e) {
34170 log_packet_detailed("'changed_from_count' field error detected");
34171 }
34172
34173#ifdef FREECIV_JSON_CONNECTION
34174 field_addr.name = "goto_tile";
34175#endif /* FREECIV_JSON_CONNECTION */
34176 e = 0;
34177
34178 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->goto_tile);
34179
34180 if (e) {
34181 log_packet_detailed("'goto_tile' field error detected");
34182 }
34183
34184#ifdef FREECIV_JSON_CONNECTION
34185 field_addr.name = "activity";
34186#endif /* FREECIV_JSON_CONNECTION */
34187 e = 0;
34188
34189 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
34190
34191 if (e) {
34192 log_packet_detailed("'activity' field error detected");
34193 }
34194
34195#ifdef FREECIV_JSON_CONNECTION
34196 field_addr.name = "activity_tgt";
34197#endif /* FREECIV_JSON_CONNECTION */
34198 e = 0;
34199
34200 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->activity_tgt);
34201
34202 if (e) {
34203 log_packet_detailed("'activity_tgt' field error detected");
34204 }
34205
34206#ifdef FREECIV_JSON_CONNECTION
34207 field_addr.name = "changed_from";
34208#endif /* FREECIV_JSON_CONNECTION */
34209 e = 0;
34210
34211 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->changed_from);
34212
34213 if (e) {
34214 log_packet_detailed("'changed_from' field error detected");
34215 }
34216
34217#ifdef FREECIV_JSON_CONNECTION
34218 field_addr.name = "changed_from_tgt";
34219#endif /* FREECIV_JSON_CONNECTION */
34220 e = 0;
34221
34222 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->changed_from_tgt);
34223
34224 if (e) {
34225 log_packet_detailed("'changed_from_tgt' field error detected");
34226 }
34227
34228#ifdef FREECIV_JSON_CONNECTION
34229 field_addr.name = "battlegroup";
34230#endif /* FREECIV_JSON_CONNECTION */
34231 e = 0;
34232
34233 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->battlegroup);
34234
34235 if (e) {
34236 log_packet_detailed("'battlegroup' field error detected");
34237 }
34238
34239#ifdef FREECIV_JSON_CONNECTION
34240 field_addr.name = "has_orders";
34241#endif /* FREECIV_JSON_CONNECTION */
34242 e = 0;
34243
34244 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->has_orders);
34245
34246 if (e) {
34247 log_packet_detailed("'has_orders' field error detected");
34248 }
34249
34250#ifdef FREECIV_JSON_CONNECTION
34251 field_addr.name = "orders_length";
34252#endif /* FREECIV_JSON_CONNECTION */
34253 e = 0;
34254
34255 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->orders_length);
34256
34257 if (e) {
34258 log_packet_detailed("'orders_length' field error detected");
34259 }
34260
34261#ifdef FREECIV_JSON_CONNECTION
34262 field_addr.name = "orders_index";
34263#endif /* FREECIV_JSON_CONNECTION */
34264 e = 0;
34265
34266 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->orders_index);
34267
34268 if (e) {
34269 log_packet_detailed("'orders_index' field error detected");
34270 }
34271
34272#ifdef FREECIV_JSON_CONNECTION
34273 field_addr.name = "orders_repeat";
34274#endif /* FREECIV_JSON_CONNECTION */
34275 e = 0;
34276
34277 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->orders_repeat);
34278
34279 if (e) {
34280 log_packet_detailed("'orders_repeat' field error detected");
34281 }
34282
34283#ifdef FREECIV_JSON_CONNECTION
34284 field_addr.name = "orders_vigilant";
34285#endif /* FREECIV_JSON_CONNECTION */
34286 e = 0;
34287
34288 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->orders_vigilant);
34289
34290 if (e) {
34291 log_packet_detailed("'orders_vigilant' field error detected");
34292 }
34293
34294#ifdef FREECIV_JSON_CONNECTION
34295 field_addr.name = "orders";
34296#endif /* FREECIV_JSON_CONNECTION */
34297 e = 0;
34298
34299 {
34300 int i;
34301
34302#ifdef FREECIV_JSON_CONNECTION
34303 /* Create the array. */
34304 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->orders_length);
34305
34306 /* Enter array. */
34307 field_addr.sub_location = plocation_elem_new(0);
34308#endif /* FREECIV_JSON_CONNECTION */
34309
34310 for (i = 0; i < real_packet->orders_length; i++) {
34311#ifdef FREECIV_JSON_CONNECTION
34312 /* Next array element. */
34313 field_addr.sub_location->number = i;
34314#endif /* FREECIV_JSON_CONNECTION */
34315
34316 e |= DIO_PUT(unit_order, &dout, &field_addr, &real_packet->orders[i]);
34317 }
34318
34319#ifdef FREECIV_JSON_CONNECTION
34320 /* Exit array. */
34321 FC_FREE(field_addr.sub_location);
34322#endif /* FREECIV_JSON_CONNECTION */
34323 }
34324
34325 if (e) {
34326 log_packet_detailed("'orders' field error detected");
34327 }
34328
34329#ifdef FREECIV_JSON_CONNECTION
34330 field_addr.name = "action_decision_want";
34331#endif /* FREECIV_JSON_CONNECTION */
34332 e = 0;
34333
34334 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_decision_want);
34335
34336 if (e) {
34337 log_packet_detailed("'action_decision_want' field error detected");
34338 }
34339
34340#ifdef FREECIV_JSON_CONNECTION
34341 field_addr.name = "action_decision_tile";
34342#endif /* FREECIV_JSON_CONNECTION */
34343 e = 0;
34344
34345 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->action_decision_tile);
34346
34347 if (e) {
34348 log_packet_detailed("'action_decision_tile' field error detected");
34349 }
34350#endif /* FREECIV_DELTA_PROTOCOL */
34351
34352 SEND_PACKET_END(PACKET_UNIT_INFO);
34353}
34354
34355 int send_packet_unit_info(struct connection *pc, const struct packet_unit_info *packet)
34356{
34357 if (!pc->used) {
34358 log_error("WARNING: trying to send data to the closed connection %s",
34359 conn_description(pc));
34360 return -1;
34361 }
34362 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_INFO].packet != nullptr, -1,
34363 "Handler for PACKET_UNIT_INFO not installed");
34364 return pc->phs.handlers->send[PACKET_UNIT_INFO].packet(pc, packet);
34365}
34366
34367 void lsend_packet_unit_info(struct conn_list *dest, const struct packet_unit_info *packet)
34368{
34369 conn_list_iterate(dest, pconn) {
34370 send_packet_unit_info(pconn, packet);
34371 } conn_list_iterate_end;
34372}
34373
34374 static inline void init_packet_unit_short_info(struct packet_unit_short_info *packet)
34375{
34376 memset(packet, 0, sizeof(*packet));
34377}
34378
34379#define free_packet_unit_short_info(_packet) (void) 0
34380#define destroy_packet_unit_short_info free
34381
34382#ifdef FREECIV_DELTA_PROTOCOL
34383static genhash_val_t hash_packet_unit_short_info_100(const void *vkey)
34384{
34385 const struct packet_unit_short_info *key = (const struct packet_unit_short_info *) vkey;
34386 genhash_val_t result = 0;
34387
34388 result += key->id;
34389
34390 result &= 0xFFFFFFFF;
34391 return result;
34392}
34393
34394static bool cmp_packet_unit_short_info_100(const void *vkey1, const void *vkey2)
34395{
34396 const struct packet_unit_short_info *old = (const struct packet_unit_short_info *) vkey1;
34397 const struct packet_unit_short_info *real_packet = (const struct packet_unit_short_info *) vkey2;
34398 bool differ;
34399
34400 differ = (old->id != real_packet->id);
34401
34402 return !differ;
34403}
34404 BV_DEFINE(packet_unit_short_info_100_fields, 13);
34405#endif /* FREECIV_DELTA_PROTOCOL */
34406
34407 static struct packet_unit_short_info *receive_packet_unit_short_info_100(struct connection *pc)
34408{
34409#define FREE_PACKET_STRUCT(_packet) free_packet_unit_short_info(_packet)
34410 RECEIVE_PACKET_START(packet_unit_short_info, real_packet);
34411
34412#ifdef FREECIV_JSON_CONNECTION
34413 struct plocation field_addr;
34414 {
34415 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
34416 field_addr = *field_addr_tmp;
34417 FC_FREE(field_addr_tmp);
34418 }
34419#endif /* FREECIV_JSON_CONNECTION */
34420
34421#ifdef FREECIV_JSON_CONNECTION
34422 field_addr.name = "id";
34423#endif /* FREECIV_JSON_CONNECTION */
34424
34425 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
34426 RECEIVE_PACKET_FIELD_ERROR(id);
34427 }
34428
34429 log_packet_detailed("packet_unit_short_info_100: got info about (%d)",
34430 real_packet->id);
34431
34432#ifdef FREECIV_DELTA_PROTOCOL
34433 packet_unit_short_info_100_fields fields;
34434 struct packet_unit_short_info *old;
34435 struct genhash **hash = pc->phs.received + PACKET_UNIT_SHORT_INFO;
34436
34437 if (nullptr == *hash) {
34438 *hash = genhash_new_full(hash_packet_unit_short_info_100, cmp_packet_unit_short_info_100,
34439 nullptr, nullptr, nullptr, destroy_packet_unit_short_info);
34440 }
34441
34442 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
34443 *real_packet = *old;
34444 } else {
34445 /* packet is already initialized empty */
34446 log_packet_detailed(" no old info");
34447 }
34448
34449#ifdef FREECIV_JSON_CONNECTION
34450 field_addr.name = "fields";
34451#endif /* FREECIV_JSON_CONNECTION */
34452 DIO_BV_GET(&din, &field_addr, fields);
34453
34454 if (BV_ISSET(fields, 0)) {
34455 log_packet_detailed(" got field 'owner'");
34456
34457#ifdef FREECIV_JSON_CONNECTION
34458 field_addr.name = "owner";
34459#endif /* FREECIV_JSON_CONNECTION */
34460
34461 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
34462 RECEIVE_PACKET_FIELD_ERROR(owner);
34463 }
34464 }
34465
34466 if (BV_ISSET(fields, 1)) {
34467 log_packet_detailed(" got field 'tile'");
34468
34469#ifdef FREECIV_JSON_CONNECTION
34470 field_addr.name = "tile";
34471#endif /* FREECIV_JSON_CONNECTION */
34472
34473 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
34474 RECEIVE_PACKET_FIELD_ERROR(tile);
34475 }
34476 }
34477
34478 if (BV_ISSET(fields, 2)) {
34479 log_packet_detailed(" got field 'facing'");
34480
34481#ifdef FREECIV_JSON_CONNECTION
34482 field_addr.name = "facing";
34483#endif /* FREECIV_JSON_CONNECTION */
34484
34485 {
34486 int readin;
34487
34488 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
34489 RECEIVE_PACKET_FIELD_ERROR(facing);
34490 }
34491 real_packet->facing = readin;
34492 }
34493 }
34494
34495 if (BV_ISSET(fields, 3)) {
34496 log_packet_detailed(" got field 'type'");
34497
34498#ifdef FREECIV_JSON_CONNECTION
34499 field_addr.name = "type";
34500#endif /* FREECIV_JSON_CONNECTION */
34501
34502 {
34503 int readin;
34504
34505 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
34506 RECEIVE_PACKET_FIELD_ERROR(type);
34507 }
34508 real_packet->type = readin;
34509 }
34510 }
34511
34512 if (BV_ISSET(fields, 4)) {
34513 log_packet_detailed(" got field 'veteran'");
34514
34515#ifdef FREECIV_JSON_CONNECTION
34516 field_addr.name = "veteran";
34517#endif /* FREECIV_JSON_CONNECTION */
34518
34519 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran)) {
34520 RECEIVE_PACKET_FIELD_ERROR(veteran);
34521 }
34522 }
34523
34524 real_packet->occupied = BV_ISSET(fields, 5);
34525
34526 real_packet->transported = BV_ISSET(fields, 6);
34527
34528 if (BV_ISSET(fields, 7)) {
34529 log_packet_detailed(" got field 'hp'");
34530
34531#ifdef FREECIV_JSON_CONNECTION
34532 field_addr.name = "hp";
34533#endif /* FREECIV_JSON_CONNECTION */
34534
34535 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
34536 RECEIVE_PACKET_FIELD_ERROR(hp);
34537 }
34538 }
34539
34540 if (BV_ISSET(fields, 8)) {
34541 log_packet_detailed(" got field 'activity'");
34542
34543#ifdef FREECIV_JSON_CONNECTION
34544 field_addr.name = "activity";
34545#endif /* FREECIV_JSON_CONNECTION */
34546
34547 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->activity)) {
34548 RECEIVE_PACKET_FIELD_ERROR(activity);
34549 }
34550 }
34551
34552 if (BV_ISSET(fields, 9)) {
34553 log_packet_detailed(" got field 'activity_tgt'");
34554
34555#ifdef FREECIV_JSON_CONNECTION
34556 field_addr.name = "activity_tgt";
34557#endif /* FREECIV_JSON_CONNECTION */
34558
34559 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->activity_tgt)) {
34560 RECEIVE_PACKET_FIELD_ERROR(activity_tgt);
34561 }
34562 }
34563
34564 if (BV_ISSET(fields, 10)) {
34565 log_packet_detailed(" got field 'transported_by'");
34566
34567#ifdef FREECIV_JSON_CONNECTION
34568 field_addr.name = "transported_by";
34569#endif /* FREECIV_JSON_CONNECTION */
34570
34571 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->transported_by)) {
34572 RECEIVE_PACKET_FIELD_ERROR(transported_by);
34573 }
34574 }
34575
34576 if (BV_ISSET(fields, 11)) {
34577 log_packet_detailed(" got field 'packet_use'");
34578
34579#ifdef FREECIV_JSON_CONNECTION
34580 field_addr.name = "packet_use";
34581#endif /* FREECIV_JSON_CONNECTION */
34582
34583 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->packet_use)) {
34584 RECEIVE_PACKET_FIELD_ERROR(packet_use);
34585 }
34586 }
34587
34588 if (BV_ISSET(fields, 12)) {
34589 log_packet_detailed(" got field 'info_city_id'");
34590
34591#ifdef FREECIV_JSON_CONNECTION
34592 field_addr.name = "info_city_id";
34593#endif /* FREECIV_JSON_CONNECTION */
34594
34595 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->info_city_id)) {
34596 RECEIVE_PACKET_FIELD_ERROR(info_city_id);
34597 }
34598 }
34599
34600 if (nullptr == old) {
34601 old = fc_malloc(sizeof(*old));
34602 init_packet_unit_short_info(old);
34603 *old = *real_packet;
34604 genhash_insert(*hash, old, old);
34605 } else {
34606 *old = *real_packet;
34607 }
34608
34609 hash = pc->phs.received + PACKET_UNIT_INFO;
34610 if (nullptr != *hash) {
34611 genhash_remove(*hash, real_packet);
34612 }
34613
34614#else /* FREECIV_DELTA_PROTOCOL */
34615#ifdef FREECIV_JSON_CONNECTION
34616 field_addr.name = "owner";
34617#endif /* FREECIV_JSON_CONNECTION */
34618
34619 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
34620 RECEIVE_PACKET_FIELD_ERROR(owner);
34621 }
34622
34623#ifdef FREECIV_JSON_CONNECTION
34624 field_addr.name = "tile";
34625#endif /* FREECIV_JSON_CONNECTION */
34626
34627 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
34628 RECEIVE_PACKET_FIELD_ERROR(tile);
34629 }
34630
34631#ifdef FREECIV_JSON_CONNECTION
34632 field_addr.name = "facing";
34633#endif /* FREECIV_JSON_CONNECTION */
34634
34635 {
34636 int readin;
34637
34638 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
34639 RECEIVE_PACKET_FIELD_ERROR(facing);
34640 }
34641 real_packet->facing = readin;
34642 }
34643
34644#ifdef FREECIV_JSON_CONNECTION
34645 field_addr.name = "type";
34646#endif /* FREECIV_JSON_CONNECTION */
34647
34648 {
34649 int readin;
34650
34651 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
34652 RECEIVE_PACKET_FIELD_ERROR(type);
34653 }
34654 real_packet->type = readin;
34655 }
34656
34657#ifdef FREECIV_JSON_CONNECTION
34658 field_addr.name = "veteran";
34659#endif /* FREECIV_JSON_CONNECTION */
34660
34661 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran)) {
34662 RECEIVE_PACKET_FIELD_ERROR(veteran);
34663 }
34664
34665#ifdef FREECIV_JSON_CONNECTION
34666 field_addr.name = "occupied";
34667#endif /* FREECIV_JSON_CONNECTION */
34668
34669 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->occupied)) {
34670 RECEIVE_PACKET_FIELD_ERROR(occupied);
34671 }
34672
34673#ifdef FREECIV_JSON_CONNECTION
34674 field_addr.name = "transported";
34675#endif /* FREECIV_JSON_CONNECTION */
34676
34677 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->transported)) {
34678 RECEIVE_PACKET_FIELD_ERROR(transported);
34679 }
34680
34681#ifdef FREECIV_JSON_CONNECTION
34682 field_addr.name = "hp";
34683#endif /* FREECIV_JSON_CONNECTION */
34684
34685 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
34686 RECEIVE_PACKET_FIELD_ERROR(hp);
34687 }
34688
34689#ifdef FREECIV_JSON_CONNECTION
34690 field_addr.name = "activity";
34691#endif /* FREECIV_JSON_CONNECTION */
34692
34693 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->activity)) {
34694 RECEIVE_PACKET_FIELD_ERROR(activity);
34695 }
34696
34697#ifdef FREECIV_JSON_CONNECTION
34698 field_addr.name = "activity_tgt";
34699#endif /* FREECIV_JSON_CONNECTION */
34700
34701 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->activity_tgt)) {
34702 RECEIVE_PACKET_FIELD_ERROR(activity_tgt);
34703 }
34704
34705#ifdef FREECIV_JSON_CONNECTION
34706 field_addr.name = "transported_by";
34707#endif /* FREECIV_JSON_CONNECTION */
34708
34709 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->transported_by)) {
34710 RECEIVE_PACKET_FIELD_ERROR(transported_by);
34711 }
34712
34713#ifdef FREECIV_JSON_CONNECTION
34714 field_addr.name = "packet_use";
34715#endif /* FREECIV_JSON_CONNECTION */
34716
34717 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->packet_use)) {
34718 RECEIVE_PACKET_FIELD_ERROR(packet_use);
34719 }
34720
34721#ifdef FREECIV_JSON_CONNECTION
34722 field_addr.name = "info_city_id";
34723#endif /* FREECIV_JSON_CONNECTION */
34724
34725 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->info_city_id)) {
34726 RECEIVE_PACKET_FIELD_ERROR(info_city_id);
34727 }
34728#endif /* FREECIV_DELTA_PROTOCOL */
34729
34730 RECEIVE_PACKET_END(real_packet);
34731#undef FREE_PACKET_STRUCT
34732}
34733
34734 static int send_packet_unit_short_info_100(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
34735{
34736 const struct packet_unit_short_info *real_packet = packet;
34737 int e;
34738 SEND_PACKET_START(PACKET_UNIT_SHORT_INFO);
34739
34740 log_packet_detailed("packet_unit_short_info_100: sending info about (%d)",
34741 real_packet->id);
34742
34743#ifdef FREECIV_DELTA_PROTOCOL
34744 packet_unit_short_info_100_fields fields;
34745 struct packet_unit_short_info *old;
34746 bool differ;
34747 int different = force_to_send;
34748 struct genhash **hash = pc->phs.sent + PACKET_UNIT_SHORT_INFO;
34749
34750 if (nullptr == *hash) {
34751 *hash = genhash_new_full(hash_packet_unit_short_info_100, cmp_packet_unit_short_info_100,
34752 nullptr, nullptr, nullptr, destroy_packet_unit_short_info);
34753 }
34754 BV_CLR_ALL(fields);
34755
34756 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
34757 old = fc_malloc(sizeof(*old));
34758 /* temporary bitcopy just to insert correctly */
34759 *old = *real_packet;
34760 genhash_insert(*hash, old, old);
34761 init_packet_unit_short_info(old);
34762 different = 1; /* Force to send. */
34763 }
34764
34765 differ = (old->owner != real_packet->owner);
34766 if (differ) {
34767 different++;
34768 BV_SET(fields, 0);
34769 }
34770
34771 differ = (old->tile != real_packet->tile);
34772 if (differ) {
34773 different++;
34774 BV_SET(fields, 1);
34775 }
34776
34777 differ = (old->facing != real_packet->facing);
34778 if (differ) {
34779 different++;
34780 BV_SET(fields, 2);
34781 }
34782
34783 differ = (old->type != real_packet->type);
34784 if (differ) {
34785 different++;
34786 BV_SET(fields, 3);
34787 }
34788
34789 differ = (old->veteran != real_packet->veteran);
34790 if (differ) {
34791 different++;
34792 BV_SET(fields, 4);
34793 }
34794
34795 differ = (old->occupied != real_packet->occupied);
34796 if (differ) {
34797 different++;
34798 }
34799 /* folded into head */
34800 if (real_packet->occupied) {
34801 BV_SET(fields, 5);
34802 }
34803
34804 differ = (old->transported != real_packet->transported);
34805 if (differ) {
34806 different++;
34807 }
34808 /* folded into head */
34809 if (real_packet->transported) {
34810 BV_SET(fields, 6);
34811 }
34812
34813 differ = (old->hp != real_packet->hp);
34814 if (differ) {
34815 different++;
34816 BV_SET(fields, 7);
34817 }
34818
34819 differ = (old->activity != real_packet->activity);
34820 if (differ) {
34821 different++;
34822 BV_SET(fields, 8);
34823 }
34824
34825 differ = (old->activity_tgt != real_packet->activity_tgt);
34826 if (differ) {
34827 different++;
34828 BV_SET(fields, 9);
34829 }
34830
34831 differ = (old->transported_by != real_packet->transported_by);
34832 if (differ) {
34833 different++;
34834 BV_SET(fields, 10);
34835 }
34836
34837 differ = (old->packet_use != real_packet->packet_use);
34838 if (differ) {
34839 different++;
34840 BV_SET(fields, 11);
34841 }
34842
34843 differ = (old->info_city_id != real_packet->info_city_id);
34844 if (differ) {
34845 different++;
34846 BV_SET(fields, 12);
34847 }
34848
34849 if (different == 0) {
34850 log_packet_detailed(" no change -> discard");
34851 SEND_PACKET_DISCARD();
34852 }
34853#endif /* FREECIV_DELTA_PROTOCOL */
34854
34855#ifdef FREECIV_JSON_CONNECTION
34856 struct plocation field_addr;
34857 {
34858 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
34859 field_addr = *field_addr_tmp;
34860 FC_FREE(field_addr_tmp);
34861 }
34862#endif /* FREECIV_JSON_CONNECTION */
34863
34864#ifdef FREECIV_JSON_CONNECTION
34865 field_addr.name = "id";
34866#endif /* FREECIV_JSON_CONNECTION */
34867 e = 0;
34868
34869 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
34870
34871 if (e) {
34872 log_packet_detailed("'id' field error detected");
34873 }
34874
34875#ifdef FREECIV_DELTA_PROTOCOL
34876#ifdef FREECIV_JSON_CONNECTION
34877 field_addr.name = "fields";
34878#endif /* FREECIV_JSON_CONNECTION */
34879 e = 0;
34880 e |= DIO_BV_PUT(&dout, &field_addr, fields);
34881 if (e) {
34882 log_packet_detailed("fields bitvector error detected");
34883 }
34884
34885 if (BV_ISSET(fields, 0)) {
34886 log_packet_detailed(" field 'owner' has changed");
34887
34888#ifdef FREECIV_JSON_CONNECTION
34889 field_addr.name = "owner";
34890#endif /* FREECIV_JSON_CONNECTION */
34891 e = 0;
34892
34893 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
34894
34895 if (e) {
34896 log_packet_detailed("'owner' field error detected");
34897 }
34898 }
34899
34900 if (BV_ISSET(fields, 1)) {
34901 log_packet_detailed(" field 'tile' has changed");
34902
34903#ifdef FREECIV_JSON_CONNECTION
34904 field_addr.name = "tile";
34905#endif /* FREECIV_JSON_CONNECTION */
34906 e = 0;
34907
34908 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
34909
34910 if (e) {
34911 log_packet_detailed("'tile' field error detected");
34912 }
34913 }
34914
34915 if (BV_ISSET(fields, 2)) {
34916 log_packet_detailed(" field 'facing' has changed");
34917
34918#ifdef FREECIV_JSON_CONNECTION
34919 field_addr.name = "facing";
34920#endif /* FREECIV_JSON_CONNECTION */
34921 e = 0;
34922
34923 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->facing);
34924
34925 if (e) {
34926 log_packet_detailed("'facing' field error detected");
34927 }
34928 }
34929
34930 if (BV_ISSET(fields, 3)) {
34931 log_packet_detailed(" field 'type' has changed");
34932
34933#ifdef FREECIV_JSON_CONNECTION
34934 field_addr.name = "type";
34935#endif /* FREECIV_JSON_CONNECTION */
34936 e = 0;
34937
34938 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
34939
34940 if (e) {
34941 log_packet_detailed("'type' field error detected");
34942 }
34943 }
34944
34945 if (BV_ISSET(fields, 4)) {
34946 log_packet_detailed(" field 'veteran' has changed");
34947
34948#ifdef FREECIV_JSON_CONNECTION
34949 field_addr.name = "veteran";
34950#endif /* FREECIV_JSON_CONNECTION */
34951 e = 0;
34952
34953 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran);
34954
34955 if (e) {
34956 log_packet_detailed("'veteran' field error detected");
34957 }
34958 }
34959
34960 /* field 5 is folded into the header */
34961
34962 /* field 6 is folded into the header */
34963
34964 if (BV_ISSET(fields, 7)) {
34965 log_packet_detailed(" field 'hp' has changed");
34966
34967#ifdef FREECIV_JSON_CONNECTION
34968 field_addr.name = "hp";
34969#endif /* FREECIV_JSON_CONNECTION */
34970 e = 0;
34971
34972 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
34973
34974 if (e) {
34975 log_packet_detailed("'hp' field error detected");
34976 }
34977 }
34978
34979 if (BV_ISSET(fields, 8)) {
34980 log_packet_detailed(" field 'activity' has changed");
34981
34982#ifdef FREECIV_JSON_CONNECTION
34983 field_addr.name = "activity";
34984#endif /* FREECIV_JSON_CONNECTION */
34985 e = 0;
34986
34987 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
34988
34989 if (e) {
34990 log_packet_detailed("'activity' field error detected");
34991 }
34992 }
34993
34994 if (BV_ISSET(fields, 9)) {
34995 log_packet_detailed(" field 'activity_tgt' has changed");
34996
34997#ifdef FREECIV_JSON_CONNECTION
34998 field_addr.name = "activity_tgt";
34999#endif /* FREECIV_JSON_CONNECTION */
35000 e = 0;
35001
35002 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->activity_tgt);
35003
35004 if (e) {
35005 log_packet_detailed("'activity_tgt' field error detected");
35006 }
35007 }
35008
35009 if (BV_ISSET(fields, 10)) {
35010 log_packet_detailed(" field 'transported_by' has changed");
35011
35012#ifdef FREECIV_JSON_CONNECTION
35013 field_addr.name = "transported_by";
35014#endif /* FREECIV_JSON_CONNECTION */
35015 e = 0;
35016
35017 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->transported_by);
35018
35019 if (e) {
35020 log_packet_detailed("'transported_by' field error detected");
35021 }
35022 }
35023
35024 if (BV_ISSET(fields, 11)) {
35025 log_packet_detailed(" field 'packet_use' has changed");
35026
35027#ifdef FREECIV_JSON_CONNECTION
35028 field_addr.name = "packet_use";
35029#endif /* FREECIV_JSON_CONNECTION */
35030 e = 0;
35031
35032 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->packet_use);
35033
35034 if (e) {
35035 log_packet_detailed("'packet_use' field error detected");
35036 }
35037 }
35038
35039 if (BV_ISSET(fields, 12)) {
35040 log_packet_detailed(" field 'info_city_id' has changed");
35041
35042#ifdef FREECIV_JSON_CONNECTION
35043 field_addr.name = "info_city_id";
35044#endif /* FREECIV_JSON_CONNECTION */
35045 e = 0;
35046
35047 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->info_city_id);
35048
35049 if (e) {
35050 log_packet_detailed("'info_city_id' field error detected");
35051 }
35052 }
35053
35054 *old = *real_packet;
35055
35056 hash = pc->phs.sent + PACKET_UNIT_INFO;
35057 if (nullptr != *hash) {
35058 genhash_remove(*hash, real_packet);
35059 }
35060
35061#else /* FREECIV_DELTA_PROTOCOL */
35062#ifdef FREECIV_JSON_CONNECTION
35063 field_addr.name = "owner";
35064#endif /* FREECIV_JSON_CONNECTION */
35065 e = 0;
35066
35067 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
35068
35069 if (e) {
35070 log_packet_detailed("'owner' field error detected");
35071 }
35072
35073#ifdef FREECIV_JSON_CONNECTION
35074 field_addr.name = "tile";
35075#endif /* FREECIV_JSON_CONNECTION */
35076 e = 0;
35077
35078 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
35079
35080 if (e) {
35081 log_packet_detailed("'tile' field error detected");
35082 }
35083
35084#ifdef FREECIV_JSON_CONNECTION
35085 field_addr.name = "facing";
35086#endif /* FREECIV_JSON_CONNECTION */
35087 e = 0;
35088
35089 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->facing);
35090
35091 if (e) {
35092 log_packet_detailed("'facing' field error detected");
35093 }
35094
35095#ifdef FREECIV_JSON_CONNECTION
35096 field_addr.name = "type";
35097#endif /* FREECIV_JSON_CONNECTION */
35098 e = 0;
35099
35100 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
35101
35102 if (e) {
35103 log_packet_detailed("'type' field error detected");
35104 }
35105
35106#ifdef FREECIV_JSON_CONNECTION
35107 field_addr.name = "veteran";
35108#endif /* FREECIV_JSON_CONNECTION */
35109 e = 0;
35110
35111 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran);
35112
35113 if (e) {
35114 log_packet_detailed("'veteran' field error detected");
35115 }
35116
35117#ifdef FREECIV_JSON_CONNECTION
35118 field_addr.name = "occupied";
35119#endif /* FREECIV_JSON_CONNECTION */
35120 e = 0;
35121
35122 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->occupied);
35123
35124 if (e) {
35125 log_packet_detailed("'occupied' field error detected");
35126 }
35127
35128#ifdef FREECIV_JSON_CONNECTION
35129 field_addr.name = "transported";
35130#endif /* FREECIV_JSON_CONNECTION */
35131 e = 0;
35132
35133 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->transported);
35134
35135 if (e) {
35136 log_packet_detailed("'transported' field error detected");
35137 }
35138
35139#ifdef FREECIV_JSON_CONNECTION
35140 field_addr.name = "hp";
35141#endif /* FREECIV_JSON_CONNECTION */
35142 e = 0;
35143
35144 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
35145
35146 if (e) {
35147 log_packet_detailed("'hp' field error detected");
35148 }
35149
35150#ifdef FREECIV_JSON_CONNECTION
35151 field_addr.name = "activity";
35152#endif /* FREECIV_JSON_CONNECTION */
35153 e = 0;
35154
35155 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
35156
35157 if (e) {
35158 log_packet_detailed("'activity' field error detected");
35159 }
35160
35161#ifdef FREECIV_JSON_CONNECTION
35162 field_addr.name = "activity_tgt";
35163#endif /* FREECIV_JSON_CONNECTION */
35164 e = 0;
35165
35166 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->activity_tgt);
35167
35168 if (e) {
35169 log_packet_detailed("'activity_tgt' field error detected");
35170 }
35171
35172#ifdef FREECIV_JSON_CONNECTION
35173 field_addr.name = "transported_by";
35174#endif /* FREECIV_JSON_CONNECTION */
35175 e = 0;
35176
35177 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->transported_by);
35178
35179 if (e) {
35180 log_packet_detailed("'transported_by' field error detected");
35181 }
35182
35183#ifdef FREECIV_JSON_CONNECTION
35184 field_addr.name = "packet_use";
35185#endif /* FREECIV_JSON_CONNECTION */
35186 e = 0;
35187
35188 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->packet_use);
35189
35190 if (e) {
35191 log_packet_detailed("'packet_use' field error detected");
35192 }
35193
35194#ifdef FREECIV_JSON_CONNECTION
35195 field_addr.name = "info_city_id";
35196#endif /* FREECIV_JSON_CONNECTION */
35197 e = 0;
35198
35199 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->info_city_id);
35200
35201 if (e) {
35202 log_packet_detailed("'info_city_id' field error detected");
35203 }
35204#endif /* FREECIV_DELTA_PROTOCOL */
35205
35206 SEND_PACKET_END(PACKET_UNIT_SHORT_INFO);
35207}
35208
35209 int send_packet_unit_short_info(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
35210{
35211 if (!pc->used) {
35212 log_error("WARNING: trying to send data to the closed connection %s",
35213 conn_description(pc));
35214 return -1;
35215 }
35216 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_SHORT_INFO].force_to_send != nullptr, -1,
35217 "Handler for PACKET_UNIT_SHORT_INFO not installed");
35218 return pc->phs.handlers->send[PACKET_UNIT_SHORT_INFO].force_to_send(pc, packet, force_to_send);
35219}
35220
35221 void lsend_packet_unit_short_info(struct conn_list *dest, const struct packet_unit_short_info *packet, bool force_to_send)
35222{
35223 conn_list_iterate(dest, pconn) {
35224 send_packet_unit_short_info(pconn, packet, force_to_send);
35225 } conn_list_iterate_end;
35226}
35227
35228 static inline void init_packet_unit_combat_info(struct packet_unit_combat_info *packet)
35229{
35230 memset(packet, 0, sizeof(*packet));
35231}
35232
35233#define free_packet_unit_combat_info(_packet) (void) 0
35234#define destroy_packet_unit_combat_info free
35235
35236#ifdef FREECIV_DELTA_PROTOCOL
35237#define hash_packet_unit_combat_info_100 hash_const
35238#define cmp_packet_unit_combat_info_100 cmp_const
35239 BV_DEFINE(packet_unit_combat_info_100_fields, 6);
35240#endif /* FREECIV_DELTA_PROTOCOL */
35241
35242 static struct packet_unit_combat_info *receive_packet_unit_combat_info_100(struct connection *pc)
35243{
35244#define FREE_PACKET_STRUCT(_packet) free_packet_unit_combat_info(_packet)
35245 RECEIVE_PACKET_START(packet_unit_combat_info, real_packet);
35246
35247#ifdef FREECIV_JSON_CONNECTION
35248 struct plocation field_addr;
35249 {
35250 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
35251 field_addr = *field_addr_tmp;
35252 FC_FREE(field_addr_tmp);
35253 }
35254#endif /* FREECIV_JSON_CONNECTION */
35255
35256 log_packet_detailed("packet_unit_combat_info_100: got info about ()");
35257
35258#ifdef FREECIV_DELTA_PROTOCOL
35259 packet_unit_combat_info_100_fields fields;
35260 struct packet_unit_combat_info *old;
35261 struct genhash **hash = pc->phs.received + PACKET_UNIT_COMBAT_INFO;
35262
35263 if (nullptr == *hash) {
35264 *hash = genhash_new_full(hash_packet_unit_combat_info_100, cmp_packet_unit_combat_info_100,
35265 nullptr, nullptr, nullptr, destroy_packet_unit_combat_info);
35266 }
35267
35268 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35269 *real_packet = *old;
35270 } else {
35271 /* packet is already initialized empty */
35272 log_packet_detailed(" no old info");
35273 }
35274
35275#ifdef FREECIV_JSON_CONNECTION
35276 field_addr.name = "fields";
35277#endif /* FREECIV_JSON_CONNECTION */
35278 DIO_BV_GET(&din, &field_addr, fields);
35279
35280 if (BV_ISSET(fields, 0)) {
35281 log_packet_detailed(" got field 'attacker_unit_id'");
35282
35283#ifdef FREECIV_JSON_CONNECTION
35284 field_addr.name = "attacker_unit_id";
35285#endif /* FREECIV_JSON_CONNECTION */
35286
35287 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->attacker_unit_id)) {
35288 RECEIVE_PACKET_FIELD_ERROR(attacker_unit_id);
35289 }
35290 }
35291
35292 if (BV_ISSET(fields, 1)) {
35293 log_packet_detailed(" got field 'defender_unit_id'");
35294
35295#ifdef FREECIV_JSON_CONNECTION
35296 field_addr.name = "defender_unit_id";
35297#endif /* FREECIV_JSON_CONNECTION */
35298
35299 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->defender_unit_id)) {
35300 RECEIVE_PACKET_FIELD_ERROR(defender_unit_id);
35301 }
35302 }
35303
35304 if (BV_ISSET(fields, 2)) {
35305 log_packet_detailed(" got field 'attacker_hp'");
35306
35307#ifdef FREECIV_JSON_CONNECTION
35308 field_addr.name = "attacker_hp";
35309#endif /* FREECIV_JSON_CONNECTION */
35310
35311 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->attacker_hp)) {
35312 RECEIVE_PACKET_FIELD_ERROR(attacker_hp);
35313 }
35314 }
35315
35316 if (BV_ISSET(fields, 3)) {
35317 log_packet_detailed(" got field 'defender_hp'");
35318
35319#ifdef FREECIV_JSON_CONNECTION
35320 field_addr.name = "defender_hp";
35321#endif /* FREECIV_JSON_CONNECTION */
35322
35323 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->defender_hp)) {
35324 RECEIVE_PACKET_FIELD_ERROR(defender_hp);
35325 }
35326 }
35327
35328 real_packet->make_att_veteran = BV_ISSET(fields, 4);
35329
35330 real_packet->make_def_veteran = BV_ISSET(fields, 5);
35331
35332 if (nullptr == old) {
35333 old = fc_malloc(sizeof(*old));
35334 init_packet_unit_combat_info(old);
35335 *old = *real_packet;
35336 genhash_insert(*hash, old, old);
35337 } else {
35338 *old = *real_packet;
35339 }
35340
35341#else /* FREECIV_DELTA_PROTOCOL */
35342#ifdef FREECIV_JSON_CONNECTION
35343 field_addr.name = "attacker_unit_id";
35344#endif /* FREECIV_JSON_CONNECTION */
35345
35346 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->attacker_unit_id)) {
35347 RECEIVE_PACKET_FIELD_ERROR(attacker_unit_id);
35348 }
35349
35350#ifdef FREECIV_JSON_CONNECTION
35351 field_addr.name = "defender_unit_id";
35352#endif /* FREECIV_JSON_CONNECTION */
35353
35354 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->defender_unit_id)) {
35355 RECEIVE_PACKET_FIELD_ERROR(defender_unit_id);
35356 }
35357
35358#ifdef FREECIV_JSON_CONNECTION
35359 field_addr.name = "attacker_hp";
35360#endif /* FREECIV_JSON_CONNECTION */
35361
35362 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->attacker_hp)) {
35363 RECEIVE_PACKET_FIELD_ERROR(attacker_hp);
35364 }
35365
35366#ifdef FREECIV_JSON_CONNECTION
35367 field_addr.name = "defender_hp";
35368#endif /* FREECIV_JSON_CONNECTION */
35369
35370 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->defender_hp)) {
35371 RECEIVE_PACKET_FIELD_ERROR(defender_hp);
35372 }
35373
35374#ifdef FREECIV_JSON_CONNECTION
35375 field_addr.name = "make_att_veteran";
35376#endif /* FREECIV_JSON_CONNECTION */
35377
35378 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->make_att_veteran)) {
35379 RECEIVE_PACKET_FIELD_ERROR(make_att_veteran);
35380 }
35381
35382#ifdef FREECIV_JSON_CONNECTION
35383 field_addr.name = "make_def_veteran";
35384#endif /* FREECIV_JSON_CONNECTION */
35385
35386 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->make_def_veteran)) {
35387 RECEIVE_PACKET_FIELD_ERROR(make_def_veteran);
35388 }
35389#endif /* FREECIV_DELTA_PROTOCOL */
35390
35391 RECEIVE_PACKET_END(real_packet);
35392#undef FREE_PACKET_STRUCT
35393}
35394
35395 static int send_packet_unit_combat_info_100(struct connection *pc, const struct packet_unit_combat_info *packet)
35396{
35397 const struct packet_unit_combat_info *real_packet = packet;
35398 int e;
35399 SEND_PACKET_START(PACKET_UNIT_COMBAT_INFO);
35400
35401 log_packet_detailed("packet_unit_combat_info_100: sending info about ()");
35402
35403#ifdef FREECIV_DELTA_PROTOCOL
35404 packet_unit_combat_info_100_fields fields;
35405 struct packet_unit_combat_info *old;
35406 bool differ;
35407 struct genhash **hash = pc->phs.sent + PACKET_UNIT_COMBAT_INFO;
35408
35409 if (nullptr == *hash) {
35410 *hash = genhash_new_full(hash_packet_unit_combat_info_100, cmp_packet_unit_combat_info_100,
35411 nullptr, nullptr, nullptr, destroy_packet_unit_combat_info);
35412 }
35413 BV_CLR_ALL(fields);
35414
35415 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35416 old = fc_malloc(sizeof(*old));
35417 /* temporary bitcopy just to insert correctly */
35418 *old = *real_packet;
35419 genhash_insert(*hash, old, old);
35420 init_packet_unit_combat_info(old);
35421 }
35422
35423 differ = (old->attacker_unit_id != real_packet->attacker_unit_id);
35424 if (differ) {
35425 BV_SET(fields, 0);
35426 }
35427
35428 differ = (old->defender_unit_id != real_packet->defender_unit_id);
35429 if (differ) {
35430 BV_SET(fields, 1);
35431 }
35432
35433 differ = (old->attacker_hp != real_packet->attacker_hp);
35434 if (differ) {
35435 BV_SET(fields, 2);
35436 }
35437
35438 differ = (old->defender_hp != real_packet->defender_hp);
35439 if (differ) {
35440 BV_SET(fields, 3);
35441 }
35442
35443 /* folded into head */
35444 if (real_packet->make_att_veteran) {
35445 BV_SET(fields, 4);
35446 }
35447
35448 /* folded into head */
35449 if (real_packet->make_def_veteran) {
35450 BV_SET(fields, 5);
35451 }
35452#endif /* FREECIV_DELTA_PROTOCOL */
35453
35454#ifdef FREECIV_JSON_CONNECTION
35455 struct plocation field_addr;
35456 {
35457 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
35458 field_addr = *field_addr_tmp;
35459 FC_FREE(field_addr_tmp);
35460 }
35461#endif /* FREECIV_JSON_CONNECTION */
35462
35463#ifdef FREECIV_DELTA_PROTOCOL
35464#ifdef FREECIV_JSON_CONNECTION
35465 field_addr.name = "fields";
35466#endif /* FREECIV_JSON_CONNECTION */
35467 e = 0;
35468 e |= DIO_BV_PUT(&dout, &field_addr, fields);
35469 if (e) {
35470 log_packet_detailed("fields bitvector error detected");
35471 }
35472
35473 if (BV_ISSET(fields, 0)) {
35474 log_packet_detailed(" field 'attacker_unit_id' has changed");
35475
35476#ifdef FREECIV_JSON_CONNECTION
35477 field_addr.name = "attacker_unit_id";
35478#endif /* FREECIV_JSON_CONNECTION */
35479 e = 0;
35480
35481 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->attacker_unit_id);
35482
35483 if (e) {
35484 log_packet_detailed("'attacker_unit_id' field error detected");
35485 }
35486 }
35487
35488 if (BV_ISSET(fields, 1)) {
35489 log_packet_detailed(" field 'defender_unit_id' has changed");
35490
35491#ifdef FREECIV_JSON_CONNECTION
35492 field_addr.name = "defender_unit_id";
35493#endif /* FREECIV_JSON_CONNECTION */
35494 e = 0;
35495
35496 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->defender_unit_id);
35497
35498 if (e) {
35499 log_packet_detailed("'defender_unit_id' field error detected");
35500 }
35501 }
35502
35503 if (BV_ISSET(fields, 2)) {
35504 log_packet_detailed(" field 'attacker_hp' has changed");
35505
35506#ifdef FREECIV_JSON_CONNECTION
35507 field_addr.name = "attacker_hp";
35508#endif /* FREECIV_JSON_CONNECTION */
35509 e = 0;
35510
35511 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->attacker_hp);
35512
35513 if (e) {
35514 log_packet_detailed("'attacker_hp' field error detected");
35515 }
35516 }
35517
35518 if (BV_ISSET(fields, 3)) {
35519 log_packet_detailed(" field 'defender_hp' has changed");
35520
35521#ifdef FREECIV_JSON_CONNECTION
35522 field_addr.name = "defender_hp";
35523#endif /* FREECIV_JSON_CONNECTION */
35524 e = 0;
35525
35526 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->defender_hp);
35527
35528 if (e) {
35529 log_packet_detailed("'defender_hp' field error detected");
35530 }
35531 }
35532
35533 /* field 4 is folded into the header */
35534
35535 /* field 5 is folded into the header */
35536
35537 *old = *real_packet;
35538
35539#else /* FREECIV_DELTA_PROTOCOL */
35540#ifdef FREECIV_JSON_CONNECTION
35541 field_addr.name = "attacker_unit_id";
35542#endif /* FREECIV_JSON_CONNECTION */
35543 e = 0;
35544
35545 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->attacker_unit_id);
35546
35547 if (e) {
35548 log_packet_detailed("'attacker_unit_id' field error detected");
35549 }
35550
35551#ifdef FREECIV_JSON_CONNECTION
35552 field_addr.name = "defender_unit_id";
35553#endif /* FREECIV_JSON_CONNECTION */
35554 e = 0;
35555
35556 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->defender_unit_id);
35557
35558 if (e) {
35559 log_packet_detailed("'defender_unit_id' field error detected");
35560 }
35561
35562#ifdef FREECIV_JSON_CONNECTION
35563 field_addr.name = "attacker_hp";
35564#endif /* FREECIV_JSON_CONNECTION */
35565 e = 0;
35566
35567 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->attacker_hp);
35568
35569 if (e) {
35570 log_packet_detailed("'attacker_hp' field error detected");
35571 }
35572
35573#ifdef FREECIV_JSON_CONNECTION
35574 field_addr.name = "defender_hp";
35575#endif /* FREECIV_JSON_CONNECTION */
35576 e = 0;
35577
35578 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->defender_hp);
35579
35580 if (e) {
35581 log_packet_detailed("'defender_hp' field error detected");
35582 }
35583
35584#ifdef FREECIV_JSON_CONNECTION
35585 field_addr.name = "make_att_veteran";
35586#endif /* FREECIV_JSON_CONNECTION */
35587 e = 0;
35588
35589 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->make_att_veteran);
35590
35591 if (e) {
35592 log_packet_detailed("'make_att_veteran' field error detected");
35593 }
35594
35595#ifdef FREECIV_JSON_CONNECTION
35596 field_addr.name = "make_def_veteran";
35597#endif /* FREECIV_JSON_CONNECTION */
35598 e = 0;
35599
35600 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->make_def_veteran);
35601
35602 if (e) {
35603 log_packet_detailed("'make_def_veteran' field error detected");
35604 }
35605#endif /* FREECIV_DELTA_PROTOCOL */
35606
35607 SEND_PACKET_END(PACKET_UNIT_COMBAT_INFO);
35608}
35609
35610 int send_packet_unit_combat_info(struct connection *pc, const struct packet_unit_combat_info *packet)
35611{
35612 if (!pc->used) {
35613 log_error("WARNING: trying to send data to the closed connection %s",
35614 conn_description(pc));
35615 return -1;
35616 }
35617 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_COMBAT_INFO].packet != nullptr, -1,
35618 "Handler for PACKET_UNIT_COMBAT_INFO not installed");
35619 return pc->phs.handlers->send[PACKET_UNIT_COMBAT_INFO].packet(pc, packet);
35620}
35621
35622 void lsend_packet_unit_combat_info(struct conn_list *dest, const struct packet_unit_combat_info *packet)
35623{
35624 conn_list_iterate(dest, pconn) {
35625 send_packet_unit_combat_info(pconn, packet);
35626 } conn_list_iterate_end;
35627}
35628
35629 static inline void init_packet_unit_sscs_set(struct packet_unit_sscs_set *packet)
35630{
35631 memset(packet, 0, sizeof(*packet));
35632}
35633
35634#define free_packet_unit_sscs_set(_packet) (void) 0
35635#define destroy_packet_unit_sscs_set free
35636
35637#ifdef FREECIV_DELTA_PROTOCOL
35638#define hash_packet_unit_sscs_set_100 hash_const
35639#define cmp_packet_unit_sscs_set_100 cmp_const
35640 BV_DEFINE(packet_unit_sscs_set_100_fields, 3);
35641#endif /* FREECIV_DELTA_PROTOCOL */
35642
35643 static struct packet_unit_sscs_set *receive_packet_unit_sscs_set_100(struct connection *pc)
35644{
35645#define FREE_PACKET_STRUCT(_packet) free_packet_unit_sscs_set(_packet)
35646 RECEIVE_PACKET_START(packet_unit_sscs_set, real_packet);
35647
35648#ifdef FREECIV_JSON_CONNECTION
35649 struct plocation field_addr;
35650 {
35651 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
35652 field_addr = *field_addr_tmp;
35653 FC_FREE(field_addr_tmp);
35654 }
35655#endif /* FREECIV_JSON_CONNECTION */
35656
35657 log_packet_detailed("packet_unit_sscs_set_100: got info about ()");
35658
35659#ifdef FREECIV_DELTA_PROTOCOL
35660 packet_unit_sscs_set_100_fields fields;
35661 struct packet_unit_sscs_set *old;
35662 struct genhash **hash = pc->phs.received + PACKET_UNIT_SSCS_SET;
35663
35664 if (nullptr == *hash) {
35665 *hash = genhash_new_full(hash_packet_unit_sscs_set_100, cmp_packet_unit_sscs_set_100,
35666 nullptr, nullptr, nullptr, destroy_packet_unit_sscs_set);
35667 }
35668
35669 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35670 *real_packet = *old;
35671 } else {
35672 /* packet is already initialized empty */
35673 log_packet_detailed(" no old info");
35674 }
35675
35676#ifdef FREECIV_JSON_CONNECTION
35677 field_addr.name = "fields";
35678#endif /* FREECIV_JSON_CONNECTION */
35679 DIO_BV_GET(&din, &field_addr, fields);
35680
35681 if (BV_ISSET(fields, 0)) {
35682 log_packet_detailed(" got field 'unit_id'");
35683
35684#ifdef FREECIV_JSON_CONNECTION
35685 field_addr.name = "unit_id";
35686#endif /* FREECIV_JSON_CONNECTION */
35687
35688 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
35689 RECEIVE_PACKET_FIELD_ERROR(unit_id);
35690 }
35691 }
35692
35693 if (BV_ISSET(fields, 1)) {
35694 log_packet_detailed(" got field 'type'");
35695
35696#ifdef FREECIV_JSON_CONNECTION
35697 field_addr.name = "type";
35698#endif /* FREECIV_JSON_CONNECTION */
35699
35700 {
35701 int readin;
35702
35703 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
35704 RECEIVE_PACKET_FIELD_ERROR(type);
35705 }
35706 real_packet->type = readin;
35707 }
35708 }
35709
35710 if (BV_ISSET(fields, 2)) {
35711 log_packet_detailed(" got field 'value'");
35712
35713#ifdef FREECIV_JSON_CONNECTION
35714 field_addr.name = "value";
35715#endif /* FREECIV_JSON_CONNECTION */
35716
35717 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->value)) {
35718 RECEIVE_PACKET_FIELD_ERROR(value);
35719 }
35720 }
35721
35722 if (nullptr == old) {
35723 old = fc_malloc(sizeof(*old));
35724 init_packet_unit_sscs_set(old);
35725 *old = *real_packet;
35726 genhash_insert(*hash, old, old);
35727 } else {
35728 *old = *real_packet;
35729 }
35730
35731#else /* FREECIV_DELTA_PROTOCOL */
35732#ifdef FREECIV_JSON_CONNECTION
35733 field_addr.name = "unit_id";
35734#endif /* FREECIV_JSON_CONNECTION */
35735
35736 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
35737 RECEIVE_PACKET_FIELD_ERROR(unit_id);
35738 }
35739
35740#ifdef FREECIV_JSON_CONNECTION
35741 field_addr.name = "type";
35742#endif /* FREECIV_JSON_CONNECTION */
35743
35744 {
35745 int readin;
35746
35747 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
35748 RECEIVE_PACKET_FIELD_ERROR(type);
35749 }
35750 real_packet->type = readin;
35751 }
35752
35753#ifdef FREECIV_JSON_CONNECTION
35754 field_addr.name = "value";
35755#endif /* FREECIV_JSON_CONNECTION */
35756
35757 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->value)) {
35758 RECEIVE_PACKET_FIELD_ERROR(value);
35759 }
35760#endif /* FREECIV_DELTA_PROTOCOL */
35761
35762 RECEIVE_PACKET_END(real_packet);
35763#undef FREE_PACKET_STRUCT
35764}
35765
35766 static int send_packet_unit_sscs_set_100(struct connection *pc, const struct packet_unit_sscs_set *packet)
35767{
35768 const struct packet_unit_sscs_set *real_packet = packet;
35769 int e;
35770 SEND_PACKET_START(PACKET_UNIT_SSCS_SET);
35771
35772 log_packet_detailed("packet_unit_sscs_set_100: sending info about ()");
35773
35774#ifdef FREECIV_DELTA_PROTOCOL
35775 packet_unit_sscs_set_100_fields fields;
35776 struct packet_unit_sscs_set *old;
35777 bool differ;
35778 struct genhash **hash = pc->phs.sent + PACKET_UNIT_SSCS_SET;
35779
35780 if (nullptr == *hash) {
35781 *hash = genhash_new_full(hash_packet_unit_sscs_set_100, cmp_packet_unit_sscs_set_100,
35782 nullptr, nullptr, nullptr, destroy_packet_unit_sscs_set);
35783 }
35784 BV_CLR_ALL(fields);
35785
35786 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
35787 old = fc_malloc(sizeof(*old));
35788 /* temporary bitcopy just to insert correctly */
35789 *old = *real_packet;
35790 genhash_insert(*hash, old, old);
35791 init_packet_unit_sscs_set(old);
35792 }
35793
35794 differ = (old->unit_id != real_packet->unit_id);
35795 if (differ) {
35796 BV_SET(fields, 0);
35797 }
35798
35799 differ = (old->type != real_packet->type);
35800 if (differ) {
35801 BV_SET(fields, 1);
35802 }
35803
35804 differ = (old->value != real_packet->value);
35805 if (differ) {
35806 BV_SET(fields, 2);
35807 }
35808#endif /* FREECIV_DELTA_PROTOCOL */
35809
35810#ifdef FREECIV_JSON_CONNECTION
35811 struct plocation field_addr;
35812 {
35813 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
35814 field_addr = *field_addr_tmp;
35815 FC_FREE(field_addr_tmp);
35816 }
35817#endif /* FREECIV_JSON_CONNECTION */
35818
35819#ifdef FREECIV_DELTA_PROTOCOL
35820#ifdef FREECIV_JSON_CONNECTION
35821 field_addr.name = "fields";
35822#endif /* FREECIV_JSON_CONNECTION */
35823 e = 0;
35824 e |= DIO_BV_PUT(&dout, &field_addr, fields);
35825 if (e) {
35826 log_packet_detailed("fields bitvector error detected");
35827 }
35828
35829 if (BV_ISSET(fields, 0)) {
35830 log_packet_detailed(" field 'unit_id' has changed");
35831
35832#ifdef FREECIV_JSON_CONNECTION
35833 field_addr.name = "unit_id";
35834#endif /* FREECIV_JSON_CONNECTION */
35835 e = 0;
35836
35837 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
35838
35839 if (e) {
35840 log_packet_detailed("'unit_id' field error detected");
35841 }
35842 }
35843
35844 if (BV_ISSET(fields, 1)) {
35845 log_packet_detailed(" field 'type' has changed");
35846
35847#ifdef FREECIV_JSON_CONNECTION
35848 field_addr.name = "type";
35849#endif /* FREECIV_JSON_CONNECTION */
35850 e = 0;
35851
35852 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
35853
35854 if (e) {
35855 log_packet_detailed("'type' field error detected");
35856 }
35857 }
35858
35859 if (BV_ISSET(fields, 2)) {
35860 log_packet_detailed(" field 'value' has changed");
35861
35862#ifdef FREECIV_JSON_CONNECTION
35863 field_addr.name = "value";
35864#endif /* FREECIV_JSON_CONNECTION */
35865 e = 0;
35866
35867 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->value);
35868
35869 if (e) {
35870 log_packet_detailed("'value' field error detected");
35871 }
35872 }
35873
35874 *old = *real_packet;
35875
35876#else /* FREECIV_DELTA_PROTOCOL */
35877#ifdef FREECIV_JSON_CONNECTION
35878 field_addr.name = "unit_id";
35879#endif /* FREECIV_JSON_CONNECTION */
35880 e = 0;
35881
35882 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
35883
35884 if (e) {
35885 log_packet_detailed("'unit_id' field error detected");
35886 }
35887
35888#ifdef FREECIV_JSON_CONNECTION
35889 field_addr.name = "type";
35890#endif /* FREECIV_JSON_CONNECTION */
35891 e = 0;
35892
35893 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
35894
35895 if (e) {
35896 log_packet_detailed("'type' field error detected");
35897 }
35898
35899#ifdef FREECIV_JSON_CONNECTION
35900 field_addr.name = "value";
35901#endif /* FREECIV_JSON_CONNECTION */
35902 e = 0;
35903
35904 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->value);
35905
35906 if (e) {
35907 log_packet_detailed("'value' field error detected");
35908 }
35909#endif /* FREECIV_DELTA_PROTOCOL */
35910
35911 SEND_PACKET_END(PACKET_UNIT_SSCS_SET);
35912}
35913
35914 int send_packet_unit_sscs_set(struct connection *pc, const struct packet_unit_sscs_set *packet)
35915{
35916 if (!pc->used) {
35917 log_error("WARNING: trying to send data to the closed connection %s",
35918 conn_description(pc));
35919 return -1;
35920 }
35921 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_SSCS_SET].packet != nullptr, -1,
35922 "Handler for PACKET_UNIT_SSCS_SET not installed");
35923 return pc->phs.handlers->send[PACKET_UNIT_SSCS_SET].packet(pc, packet);
35924}
35925
35926 int dsend_packet_unit_sscs_set(struct connection *pc, int unit_id, enum unit_ss_data_type type, int value)
35927{
35928 struct packet_unit_sscs_set packet, *real_packet = &packet;
35929
35930 real_packet->unit_id = unit_id;
35931 real_packet->type = type;
35932 real_packet->value = value;
35933
35934 return send_packet_unit_sscs_set(pc, real_packet);
35935}
35936
35937 static inline void init_packet_unit_orders(struct packet_unit_orders *packet)
35938{
35939 memset(packet, 0, sizeof(*packet));
35940}
35941
35942#define free_packet_unit_orders(_packet) (void) 0
35943#define destroy_packet_unit_orders free
35944
35945#ifdef FREECIV_DELTA_PROTOCOL
35946#define hash_packet_unit_orders_100 hash_const
35947#define cmp_packet_unit_orders_100 cmp_const
35948 BV_DEFINE(packet_unit_orders_100_fields, 7);
35949#endif /* FREECIV_DELTA_PROTOCOL */
35950
35951 static struct packet_unit_orders *receive_packet_unit_orders_100(struct connection *pc)
35952{
35953#define FREE_PACKET_STRUCT(_packet) free_packet_unit_orders(_packet)
35954 RECEIVE_PACKET_START(packet_unit_orders, real_packet);
35955
35956#ifdef FREECIV_JSON_CONNECTION
35957 struct plocation field_addr;
35958 {
35959 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
35960 field_addr = *field_addr_tmp;
35961 FC_FREE(field_addr_tmp);
35962 }
35963#endif /* FREECIV_JSON_CONNECTION */
35964
35965 log_packet_detailed("packet_unit_orders_100: got info about ()");
35966
35967#ifdef FREECIV_DELTA_PROTOCOL
35968 packet_unit_orders_100_fields fields;
35969 struct packet_unit_orders *old;
35970 struct genhash **hash = pc->phs.received + PACKET_UNIT_ORDERS;
35971
35972 if (nullptr == *hash) {
35973 *hash = genhash_new_full(hash_packet_unit_orders_100, cmp_packet_unit_orders_100,
35974 nullptr, nullptr, nullptr, destroy_packet_unit_orders);
35975 }
35976
35977 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
35978 *real_packet = *old;
35979 } else {
35980 /* packet is already initialized empty */
35981 log_packet_detailed(" no old info");
35982 }
35983
35984#ifdef FREECIV_JSON_CONNECTION
35985 field_addr.name = "fields";
35986#endif /* FREECIV_JSON_CONNECTION */
35987 DIO_BV_GET(&din, &field_addr, fields);
35988
35989 if (BV_ISSET(fields, 0)) {
35990 log_packet_detailed(" got field 'unit_id'");
35991
35992#ifdef FREECIV_JSON_CONNECTION
35993 field_addr.name = "unit_id";
35994#endif /* FREECIV_JSON_CONNECTION */
35995
35996 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
35997 RECEIVE_PACKET_FIELD_ERROR(unit_id);
35998 }
35999 }
36000
36001 if (BV_ISSET(fields, 1)) {
36002 log_packet_detailed(" got field 'src_tile'");
36003
36004#ifdef FREECIV_JSON_CONNECTION
36005 field_addr.name = "src_tile";
36006#endif /* FREECIV_JSON_CONNECTION */
36007
36008 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->src_tile)) {
36009 RECEIVE_PACKET_FIELD_ERROR(src_tile);
36010 }
36011 }
36012
36013 if (BV_ISSET(fields, 2)) {
36014 log_packet_detailed(" got field 'length'");
36015
36016#ifdef FREECIV_JSON_CONNECTION
36017 field_addr.name = "length";
36018#endif /* FREECIV_JSON_CONNECTION */
36019
36020 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->length)) {
36021 RECEIVE_PACKET_FIELD_ERROR(length);
36022 }
36023 }
36024
36025 real_packet->repeat = BV_ISSET(fields, 3);
36026
36027 real_packet->vigilant = BV_ISSET(fields, 4);
36028
36029 if (BV_ISSET(fields, 5)) {
36030 log_packet_detailed(" got field 'orders'");
36031
36032#ifdef FREECIV_JSON_CONNECTION
36033 field_addr.name = "orders";
36034#endif /* FREECIV_JSON_CONNECTION */
36035
36036 {
36037 int i;
36038
36039 if (real_packet->length > MAX_LEN_ROUTE) {
36040 RECEIVE_PACKET_FIELD_ERROR(orders, ": array truncated");
36041 }
36042
36043#ifdef FREECIV_JSON_CONNECTION
36044 /* Enter array. */
36045 field_addr.sub_location = plocation_elem_new(0);
36046#endif /* FREECIV_JSON_CONNECTION */
36047
36048 for (i = 0; i < real_packet->length; i++) {
36049#ifdef FREECIV_JSON_CONNECTION
36050 /* Next array element */
36051 field_addr.sub_location->number = i;
36052#endif /* FREECIV_JSON_CONNECTION */
36053
36054 if (!DIO_GET(unit_order, &din, &field_addr, &real_packet->orders[i])) {
36055 RECEIVE_PACKET_FIELD_ERROR(orders);
36056 }
36057 }
36058
36059#ifdef FREECIV_JSON_CONNECTION
36060 /* Exit array. */
36061 FC_FREE(field_addr.sub_location);
36062#endif /* FREECIV_JSON_CONNECTION */
36063 }
36064 }
36065
36066 if (BV_ISSET(fields, 6)) {
36067 log_packet_detailed(" got field 'dest_tile'");
36068
36069#ifdef FREECIV_JSON_CONNECTION
36070 field_addr.name = "dest_tile";
36071#endif /* FREECIV_JSON_CONNECTION */
36072
36073 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->dest_tile)) {
36074 RECEIVE_PACKET_FIELD_ERROR(dest_tile);
36075 }
36076 }
36077
36078 if (nullptr == old) {
36079 old = fc_malloc(sizeof(*old));
36080 init_packet_unit_orders(old);
36081 *old = *real_packet;
36082 genhash_insert(*hash, old, old);
36083 } else {
36084 *old = *real_packet;
36085 }
36086
36087#else /* FREECIV_DELTA_PROTOCOL */
36088#ifdef FREECIV_JSON_CONNECTION
36089 field_addr.name = "unit_id";
36090#endif /* FREECIV_JSON_CONNECTION */
36091
36092 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
36093 RECEIVE_PACKET_FIELD_ERROR(unit_id);
36094 }
36095
36096#ifdef FREECIV_JSON_CONNECTION
36097 field_addr.name = "src_tile";
36098#endif /* FREECIV_JSON_CONNECTION */
36099
36100 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->src_tile)) {
36101 RECEIVE_PACKET_FIELD_ERROR(src_tile);
36102 }
36103
36104#ifdef FREECIV_JSON_CONNECTION
36105 field_addr.name = "length";
36106#endif /* FREECIV_JSON_CONNECTION */
36107
36108 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->length)) {
36109 RECEIVE_PACKET_FIELD_ERROR(length);
36110 }
36111
36112#ifdef FREECIV_JSON_CONNECTION
36113 field_addr.name = "repeat";
36114#endif /* FREECIV_JSON_CONNECTION */
36115
36116 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->repeat)) {
36117 RECEIVE_PACKET_FIELD_ERROR(repeat);
36118 }
36119
36120#ifdef FREECIV_JSON_CONNECTION
36121 field_addr.name = "vigilant";
36122#endif /* FREECIV_JSON_CONNECTION */
36123
36124 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->vigilant)) {
36125 RECEIVE_PACKET_FIELD_ERROR(vigilant);
36126 }
36127
36128#ifdef FREECIV_JSON_CONNECTION
36129 field_addr.name = "orders";
36130#endif /* FREECIV_JSON_CONNECTION */
36131
36132 {
36133 int i;
36134
36135 if (real_packet->length > MAX_LEN_ROUTE) {
36136 RECEIVE_PACKET_FIELD_ERROR(orders, ": array truncated");
36137 }
36138
36139#ifdef FREECIV_JSON_CONNECTION
36140 /* Enter array. */
36141 field_addr.sub_location = plocation_elem_new(0);
36142#endif /* FREECIV_JSON_CONNECTION */
36143
36144 for (i = 0; i < real_packet->length; i++) {
36145#ifdef FREECIV_JSON_CONNECTION
36146 /* Next array element */
36147 field_addr.sub_location->number = i;
36148#endif /* FREECIV_JSON_CONNECTION */
36149
36150 if (!DIO_GET(unit_order, &din, &field_addr, &real_packet->orders[i])) {
36151 RECEIVE_PACKET_FIELD_ERROR(orders);
36152 }
36153 }
36154
36155#ifdef FREECIV_JSON_CONNECTION
36156 /* Exit array. */
36157 FC_FREE(field_addr.sub_location);
36158#endif /* FREECIV_JSON_CONNECTION */
36159 }
36160
36161#ifdef FREECIV_JSON_CONNECTION
36162 field_addr.name = "dest_tile";
36163#endif /* FREECIV_JSON_CONNECTION */
36164
36165 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->dest_tile)) {
36166 RECEIVE_PACKET_FIELD_ERROR(dest_tile);
36167 }
36168#endif /* FREECIV_DELTA_PROTOCOL */
36169
36170 RECEIVE_PACKET_END(real_packet);
36171#undef FREE_PACKET_STRUCT
36172}
36173
36174 static int send_packet_unit_orders_100(struct connection *pc, const struct packet_unit_orders *packet)
36175{
36176 const struct packet_unit_orders *real_packet = packet;
36177 int e;
36178 SEND_PACKET_START(PACKET_UNIT_ORDERS);
36179
36180 log_packet_detailed("packet_unit_orders_100: sending info about ()");
36181
36182#ifdef FREECIV_DELTA_PROTOCOL
36183 packet_unit_orders_100_fields fields;
36184 struct packet_unit_orders *old;
36185 bool differ;
36186 struct genhash **hash = pc->phs.sent + PACKET_UNIT_ORDERS;
36187
36188 if (nullptr == *hash) {
36189 *hash = genhash_new_full(hash_packet_unit_orders_100, cmp_packet_unit_orders_100,
36190 nullptr, nullptr, nullptr, destroy_packet_unit_orders);
36191 }
36192 BV_CLR_ALL(fields);
36193
36194 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36195 old = fc_malloc(sizeof(*old));
36196 /* temporary bitcopy just to insert correctly */
36197 *old = *real_packet;
36198 genhash_insert(*hash, old, old);
36199 init_packet_unit_orders(old);
36200 }
36201
36202 differ = (old->unit_id != real_packet->unit_id);
36203 if (differ) {
36204 BV_SET(fields, 0);
36205 }
36206
36207 differ = (old->src_tile != real_packet->src_tile);
36208 if (differ) {
36209 BV_SET(fields, 1);
36210 }
36211
36212 differ = (old->length != real_packet->length);
36213 if (differ) {
36214 BV_SET(fields, 2);
36215 }
36216
36217 /* folded into head */
36218 if (real_packet->repeat) {
36219 BV_SET(fields, 3);
36220 }
36221
36222 /* folded into head */
36223 if (real_packet->vigilant) {
36224 BV_SET(fields, 4);
36225 }
36226
36227 differ = (old->length != real_packet->length);
36228 if (!differ) {
36229 int i;
36230
36231 for (i = 0; i < old->length; i++) {
36232 differ = !are_unit_orders_equal(&old->orders[i], &real_packet->orders[i]);
36233 if (differ) {
36234 break;
36235 }
36236 }
36237 }
36238 if (differ) {
36239 BV_SET(fields, 5);
36240 }
36241
36242 differ = (old->dest_tile != real_packet->dest_tile);
36243 if (differ) {
36244 BV_SET(fields, 6);
36245 }
36246#endif /* FREECIV_DELTA_PROTOCOL */
36247
36248#ifdef FREECIV_JSON_CONNECTION
36249 struct plocation field_addr;
36250 {
36251 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
36252 field_addr = *field_addr_tmp;
36253 FC_FREE(field_addr_tmp);
36254 }
36255#endif /* FREECIV_JSON_CONNECTION */
36256
36257#ifdef FREECIV_DELTA_PROTOCOL
36258#ifdef FREECIV_JSON_CONNECTION
36259 field_addr.name = "fields";
36260#endif /* FREECIV_JSON_CONNECTION */
36261 e = 0;
36262 e |= DIO_BV_PUT(&dout, &field_addr, fields);
36263 if (e) {
36264 log_packet_detailed("fields bitvector error detected");
36265 }
36266
36267 if (BV_ISSET(fields, 0)) {
36268 log_packet_detailed(" field 'unit_id' has changed");
36269
36270#ifdef FREECIV_JSON_CONNECTION
36271 field_addr.name = "unit_id";
36272#endif /* FREECIV_JSON_CONNECTION */
36273 e = 0;
36274
36275 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
36276
36277 if (e) {
36278 log_packet_detailed("'unit_id' field error detected");
36279 }
36280 }
36281
36282 if (BV_ISSET(fields, 1)) {
36283 log_packet_detailed(" field 'src_tile' has changed");
36284
36285#ifdef FREECIV_JSON_CONNECTION
36286 field_addr.name = "src_tile";
36287#endif /* FREECIV_JSON_CONNECTION */
36288 e = 0;
36289
36290 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->src_tile);
36291
36292 if (e) {
36293 log_packet_detailed("'src_tile' field error detected");
36294 }
36295 }
36296
36297 if (BV_ISSET(fields, 2)) {
36298 log_packet_detailed(" field 'length' has changed");
36299
36300#ifdef FREECIV_JSON_CONNECTION
36301 field_addr.name = "length";
36302#endif /* FREECIV_JSON_CONNECTION */
36303 e = 0;
36304
36305 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->length);
36306
36307 if (e) {
36308 log_packet_detailed("'length' field error detected");
36309 }
36310 }
36311
36312 /* field 3 is folded into the header */
36313
36314 /* field 4 is folded into the header */
36315
36316 if (BV_ISSET(fields, 5)) {
36317 log_packet_detailed(" field 'orders' has changed");
36318
36319#ifdef FREECIV_JSON_CONNECTION
36320 field_addr.name = "orders";
36321#endif /* FREECIV_JSON_CONNECTION */
36322 e = 0;
36323
36324 {
36325 int i;
36326
36327#ifdef FREECIV_JSON_CONNECTION
36328 /* Create the array. */
36329 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->length);
36330
36331 /* Enter array. */
36332 field_addr.sub_location = plocation_elem_new(0);
36333#endif /* FREECIV_JSON_CONNECTION */
36334
36335 for (i = 0; i < real_packet->length; i++) {
36336#ifdef FREECIV_JSON_CONNECTION
36337 /* Next array element. */
36338 field_addr.sub_location->number = i;
36339#endif /* FREECIV_JSON_CONNECTION */
36340
36341 e |= DIO_PUT(unit_order, &dout, &field_addr, &real_packet->orders[i]);
36342 }
36343
36344#ifdef FREECIV_JSON_CONNECTION
36345 /* Exit array. */
36346 FC_FREE(field_addr.sub_location);
36347#endif /* FREECIV_JSON_CONNECTION */
36348 }
36349
36350 if (e) {
36351 log_packet_detailed("'orders' field error detected");
36352 }
36353 }
36354
36355 if (BV_ISSET(fields, 6)) {
36356 log_packet_detailed(" field 'dest_tile' has changed");
36357
36358#ifdef FREECIV_JSON_CONNECTION
36359 field_addr.name = "dest_tile";
36360#endif /* FREECIV_JSON_CONNECTION */
36361 e = 0;
36362
36363 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->dest_tile);
36364
36365 if (e) {
36366 log_packet_detailed("'dest_tile' field error detected");
36367 }
36368 }
36369
36370 *old = *real_packet;
36371
36372#else /* FREECIV_DELTA_PROTOCOL */
36373#ifdef FREECIV_JSON_CONNECTION
36374 field_addr.name = "unit_id";
36375#endif /* FREECIV_JSON_CONNECTION */
36376 e = 0;
36377
36378 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
36379
36380 if (e) {
36381 log_packet_detailed("'unit_id' field error detected");
36382 }
36383
36384#ifdef FREECIV_JSON_CONNECTION
36385 field_addr.name = "src_tile";
36386#endif /* FREECIV_JSON_CONNECTION */
36387 e = 0;
36388
36389 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->src_tile);
36390
36391 if (e) {
36392 log_packet_detailed("'src_tile' field error detected");
36393 }
36394
36395#ifdef FREECIV_JSON_CONNECTION
36396 field_addr.name = "length";
36397#endif /* FREECIV_JSON_CONNECTION */
36398 e = 0;
36399
36400 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->length);
36401
36402 if (e) {
36403 log_packet_detailed("'length' field error detected");
36404 }
36405
36406#ifdef FREECIV_JSON_CONNECTION
36407 field_addr.name = "repeat";
36408#endif /* FREECIV_JSON_CONNECTION */
36409 e = 0;
36410
36411 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->repeat);
36412
36413 if (e) {
36414 log_packet_detailed("'repeat' field error detected");
36415 }
36416
36417#ifdef FREECIV_JSON_CONNECTION
36418 field_addr.name = "vigilant";
36419#endif /* FREECIV_JSON_CONNECTION */
36420 e = 0;
36421
36422 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->vigilant);
36423
36424 if (e) {
36425 log_packet_detailed("'vigilant' field error detected");
36426 }
36427
36428#ifdef FREECIV_JSON_CONNECTION
36429 field_addr.name = "orders";
36430#endif /* FREECIV_JSON_CONNECTION */
36431 e = 0;
36432
36433 {
36434 int i;
36435
36436#ifdef FREECIV_JSON_CONNECTION
36437 /* Create the array. */
36438 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->length);
36439
36440 /* Enter array. */
36441 field_addr.sub_location = plocation_elem_new(0);
36442#endif /* FREECIV_JSON_CONNECTION */
36443
36444 for (i = 0; i < real_packet->length; i++) {
36445#ifdef FREECIV_JSON_CONNECTION
36446 /* Next array element. */
36447 field_addr.sub_location->number = i;
36448#endif /* FREECIV_JSON_CONNECTION */
36449
36450 e |= DIO_PUT(unit_order, &dout, &field_addr, &real_packet->orders[i]);
36451 }
36452
36453#ifdef FREECIV_JSON_CONNECTION
36454 /* Exit array. */
36455 FC_FREE(field_addr.sub_location);
36456#endif /* FREECIV_JSON_CONNECTION */
36457 }
36458
36459 if (e) {
36460 log_packet_detailed("'orders' field error detected");
36461 }
36462
36463#ifdef FREECIV_JSON_CONNECTION
36464 field_addr.name = "dest_tile";
36465#endif /* FREECIV_JSON_CONNECTION */
36466 e = 0;
36467
36468 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->dest_tile);
36469
36470 if (e) {
36471 log_packet_detailed("'dest_tile' field error detected");
36472 }
36473#endif /* FREECIV_DELTA_PROTOCOL */
36474
36475 SEND_PACKET_END(PACKET_UNIT_ORDERS);
36476}
36477
36478 int send_packet_unit_orders(struct connection *pc, const struct packet_unit_orders *packet)
36479{
36480 if (!pc->used) {
36481 log_error("WARNING: trying to send data to the closed connection %s",
36482 conn_description(pc));
36483 return -1;
36484 }
36485 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ORDERS].packet != nullptr, -1,
36486 "Handler for PACKET_UNIT_ORDERS not installed");
36487 return pc->phs.handlers->send[PACKET_UNIT_ORDERS].packet(pc, packet);
36488}
36489
36490 static inline void init_packet_unit_server_side_agent_set(struct packet_unit_server_side_agent_set *packet)
36491{
36492 memset(packet, 0, sizeof(*packet));
36493}
36494
36495#define free_packet_unit_server_side_agent_set(_packet) (void) 0
36496#define destroy_packet_unit_server_side_agent_set free
36497
36498#ifdef FREECIV_DELTA_PROTOCOL
36499#define hash_packet_unit_server_side_agent_set_100 hash_const
36500#define cmp_packet_unit_server_side_agent_set_100 cmp_const
36501 BV_DEFINE(packet_unit_server_side_agent_set_100_fields, 2);
36502#endif /* FREECIV_DELTA_PROTOCOL */
36503
36504 static struct packet_unit_server_side_agent_set *receive_packet_unit_server_side_agent_set_100(struct connection *pc)
36505{
36506#define FREE_PACKET_STRUCT(_packet) free_packet_unit_server_side_agent_set(_packet)
36507 RECEIVE_PACKET_START(packet_unit_server_side_agent_set, real_packet);
36508
36509#ifdef FREECIV_JSON_CONNECTION
36510 struct plocation field_addr;
36511 {
36512 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
36513 field_addr = *field_addr_tmp;
36514 FC_FREE(field_addr_tmp);
36515 }
36516#endif /* FREECIV_JSON_CONNECTION */
36517
36518 log_packet_detailed("packet_unit_server_side_agent_set_100: got info about ()");
36519
36520#ifdef FREECIV_DELTA_PROTOCOL
36521 packet_unit_server_side_agent_set_100_fields fields;
36522 struct packet_unit_server_side_agent_set *old;
36523 struct genhash **hash = pc->phs.received + PACKET_UNIT_SERVER_SIDE_AGENT_SET;
36524
36525 if (nullptr == *hash) {
36526 *hash = genhash_new_full(hash_packet_unit_server_side_agent_set_100, cmp_packet_unit_server_side_agent_set_100,
36527 nullptr, nullptr, nullptr, destroy_packet_unit_server_side_agent_set);
36528 }
36529
36530 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36531 *real_packet = *old;
36532 } else {
36533 /* packet is already initialized empty */
36534 log_packet_detailed(" no old info");
36535 }
36536
36537#ifdef FREECIV_JSON_CONNECTION
36538 field_addr.name = "fields";
36539#endif /* FREECIV_JSON_CONNECTION */
36540 DIO_BV_GET(&din, &field_addr, fields);
36541
36542 if (BV_ISSET(fields, 0)) {
36543 log_packet_detailed(" got field 'unit_id'");
36544
36545#ifdef FREECIV_JSON_CONNECTION
36546 field_addr.name = "unit_id";
36547#endif /* FREECIV_JSON_CONNECTION */
36548
36549 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
36550 RECEIVE_PACKET_FIELD_ERROR(unit_id);
36551 }
36552 }
36553
36554 if (BV_ISSET(fields, 1)) {
36555 log_packet_detailed(" got field 'agent'");
36556
36557#ifdef FREECIV_JSON_CONNECTION
36558 field_addr.name = "agent";
36559#endif /* FREECIV_JSON_CONNECTION */
36560
36561 {
36562 int readin;
36563
36564 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
36565 RECEIVE_PACKET_FIELD_ERROR(agent);
36566 }
36567 real_packet->agent = readin;
36568 }
36569 }
36570
36571 if (nullptr == old) {
36572 old = fc_malloc(sizeof(*old));
36573 init_packet_unit_server_side_agent_set(old);
36574 *old = *real_packet;
36575 genhash_insert(*hash, old, old);
36576 } else {
36577 *old = *real_packet;
36578 }
36579
36580#else /* FREECIV_DELTA_PROTOCOL */
36581#ifdef FREECIV_JSON_CONNECTION
36582 field_addr.name = "unit_id";
36583#endif /* FREECIV_JSON_CONNECTION */
36584
36585 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
36586 RECEIVE_PACKET_FIELD_ERROR(unit_id);
36587 }
36588
36589#ifdef FREECIV_JSON_CONNECTION
36590 field_addr.name = "agent";
36591#endif /* FREECIV_JSON_CONNECTION */
36592
36593 {
36594 int readin;
36595
36596 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
36597 RECEIVE_PACKET_FIELD_ERROR(agent);
36598 }
36599 real_packet->agent = readin;
36600 }
36601#endif /* FREECIV_DELTA_PROTOCOL */
36602
36603 RECEIVE_PACKET_END(real_packet);
36604#undef FREE_PACKET_STRUCT
36605}
36606
36607 static int send_packet_unit_server_side_agent_set_100(struct connection *pc, const struct packet_unit_server_side_agent_set *packet)
36608{
36609 const struct packet_unit_server_side_agent_set *real_packet = packet;
36610 int e;
36611 SEND_PACKET_START(PACKET_UNIT_SERVER_SIDE_AGENT_SET);
36612
36613 log_packet_detailed("packet_unit_server_side_agent_set_100: sending info about ()");
36614
36615#ifdef FREECIV_DELTA_PROTOCOL
36616 packet_unit_server_side_agent_set_100_fields fields;
36617 struct packet_unit_server_side_agent_set *old;
36618 bool differ;
36619 struct genhash **hash = pc->phs.sent + PACKET_UNIT_SERVER_SIDE_AGENT_SET;
36620
36621 if (nullptr == *hash) {
36622 *hash = genhash_new_full(hash_packet_unit_server_side_agent_set_100, cmp_packet_unit_server_side_agent_set_100,
36623 nullptr, nullptr, nullptr, destroy_packet_unit_server_side_agent_set);
36624 }
36625 BV_CLR_ALL(fields);
36626
36627 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36628 old = fc_malloc(sizeof(*old));
36629 /* temporary bitcopy just to insert correctly */
36630 *old = *real_packet;
36631 genhash_insert(*hash, old, old);
36632 init_packet_unit_server_side_agent_set(old);
36633 }
36634
36635 differ = (old->unit_id != real_packet->unit_id);
36636 if (differ) {
36637 BV_SET(fields, 0);
36638 }
36639
36640 differ = (old->agent != real_packet->agent);
36641 if (differ) {
36642 BV_SET(fields, 1);
36643 }
36644#endif /* FREECIV_DELTA_PROTOCOL */
36645
36646#ifdef FREECIV_JSON_CONNECTION
36647 struct plocation field_addr;
36648 {
36649 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
36650 field_addr = *field_addr_tmp;
36651 FC_FREE(field_addr_tmp);
36652 }
36653#endif /* FREECIV_JSON_CONNECTION */
36654
36655#ifdef FREECIV_DELTA_PROTOCOL
36656#ifdef FREECIV_JSON_CONNECTION
36657 field_addr.name = "fields";
36658#endif /* FREECIV_JSON_CONNECTION */
36659 e = 0;
36660 e |= DIO_BV_PUT(&dout, &field_addr, fields);
36661 if (e) {
36662 log_packet_detailed("fields bitvector error detected");
36663 }
36664
36665 if (BV_ISSET(fields, 0)) {
36666 log_packet_detailed(" field 'unit_id' has changed");
36667
36668#ifdef FREECIV_JSON_CONNECTION
36669 field_addr.name = "unit_id";
36670#endif /* FREECIV_JSON_CONNECTION */
36671 e = 0;
36672
36673 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
36674
36675 if (e) {
36676 log_packet_detailed("'unit_id' field error detected");
36677 }
36678 }
36679
36680 if (BV_ISSET(fields, 1)) {
36681 log_packet_detailed(" field 'agent' has changed");
36682
36683#ifdef FREECIV_JSON_CONNECTION
36684 field_addr.name = "agent";
36685#endif /* FREECIV_JSON_CONNECTION */
36686 e = 0;
36687
36688 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->agent);
36689
36690 if (e) {
36691 log_packet_detailed("'agent' field error detected");
36692 }
36693 }
36694
36695 *old = *real_packet;
36696
36697#else /* FREECIV_DELTA_PROTOCOL */
36698#ifdef FREECIV_JSON_CONNECTION
36699 field_addr.name = "unit_id";
36700#endif /* FREECIV_JSON_CONNECTION */
36701 e = 0;
36702
36703 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
36704
36705 if (e) {
36706 log_packet_detailed("'unit_id' field error detected");
36707 }
36708
36709#ifdef FREECIV_JSON_CONNECTION
36710 field_addr.name = "agent";
36711#endif /* FREECIV_JSON_CONNECTION */
36712 e = 0;
36713
36714 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->agent);
36715
36716 if (e) {
36717 log_packet_detailed("'agent' field error detected");
36718 }
36719#endif /* FREECIV_DELTA_PROTOCOL */
36720
36721 SEND_PACKET_END(PACKET_UNIT_SERVER_SIDE_AGENT_SET);
36722}
36723
36724 int send_packet_unit_server_side_agent_set(struct connection *pc, const struct packet_unit_server_side_agent_set *packet)
36725{
36726 if (!pc->used) {
36727 log_error("WARNING: trying to send data to the closed connection %s",
36728 conn_description(pc));
36729 return -1;
36730 }
36731 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_SERVER_SIDE_AGENT_SET].packet != nullptr, -1,
36732 "Handler for PACKET_UNIT_SERVER_SIDE_AGENT_SET not installed");
36733 return pc->phs.handlers->send[PACKET_UNIT_SERVER_SIDE_AGENT_SET].packet(pc, packet);
36734}
36735
36736 int dsend_packet_unit_server_side_agent_set(struct connection *pc, int unit_id, enum server_side_agent agent)
36737{
36738 struct packet_unit_server_side_agent_set packet, *real_packet = &packet;
36739
36740 real_packet->unit_id = unit_id;
36741 real_packet->agent = agent;
36742
36743 return send_packet_unit_server_side_agent_set(pc, real_packet);
36744}
36745
36746 static inline void init_packet_unit_action_query(struct packet_unit_action_query *packet)
36747{
36748 memset(packet, 0, sizeof(*packet));
36749}
36750
36751#define free_packet_unit_action_query(_packet) (void) 0
36752#define destroy_packet_unit_action_query free
36753
36754#ifdef FREECIV_DELTA_PROTOCOL
36755#define hash_packet_unit_action_query_100 hash_const
36756#define cmp_packet_unit_action_query_100 cmp_const
36757 BV_DEFINE(packet_unit_action_query_100_fields, 4);
36758#endif /* FREECIV_DELTA_PROTOCOL */
36759
36760 static struct packet_unit_action_query *receive_packet_unit_action_query_100(struct connection *pc)
36761{
36762#define FREE_PACKET_STRUCT(_packet) free_packet_unit_action_query(_packet)
36763 RECEIVE_PACKET_START(packet_unit_action_query, real_packet);
36764
36765#ifdef FREECIV_JSON_CONNECTION
36766 struct plocation field_addr;
36767 {
36768 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
36769 field_addr = *field_addr_tmp;
36770 FC_FREE(field_addr_tmp);
36771 }
36772#endif /* FREECIV_JSON_CONNECTION */
36773
36774 log_packet_detailed("packet_unit_action_query_100: got info about ()");
36775
36776#ifdef FREECIV_DELTA_PROTOCOL
36777 packet_unit_action_query_100_fields fields;
36778 struct packet_unit_action_query *old;
36779 struct genhash **hash = pc->phs.received + PACKET_UNIT_ACTION_QUERY;
36780
36781 if (nullptr == *hash) {
36782 *hash = genhash_new_full(hash_packet_unit_action_query_100, cmp_packet_unit_action_query_100,
36783 nullptr, nullptr, nullptr, destroy_packet_unit_action_query);
36784 }
36785
36786 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
36787 *real_packet = *old;
36788 } else {
36789 /* packet is already initialized empty */
36790 log_packet_detailed(" no old info");
36791 }
36792
36793#ifdef FREECIV_JSON_CONNECTION
36794 field_addr.name = "fields";
36795#endif /* FREECIV_JSON_CONNECTION */
36796 DIO_BV_GET(&din, &field_addr, fields);
36797
36798 if (BV_ISSET(fields, 0)) {
36799 log_packet_detailed(" got field 'actor_id'");
36800
36801#ifdef FREECIV_JSON_CONNECTION
36802 field_addr.name = "actor_id";
36803#endif /* FREECIV_JSON_CONNECTION */
36804
36805 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
36806 RECEIVE_PACKET_FIELD_ERROR(actor_id);
36807 }
36808 }
36809
36810 if (BV_ISSET(fields, 1)) {
36811 log_packet_detailed(" got field 'target_id'");
36812
36813#ifdef FREECIV_JSON_CONNECTION
36814 field_addr.name = "target_id";
36815#endif /* FREECIV_JSON_CONNECTION */
36816
36817 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_id)) {
36818 RECEIVE_PACKET_FIELD_ERROR(target_id);
36819 }
36820 }
36821
36822 if (BV_ISSET(fields, 2)) {
36823 log_packet_detailed(" got field 'action_type'");
36824
36825#ifdef FREECIV_JSON_CONNECTION
36826 field_addr.name = "action_type";
36827#endif /* FREECIV_JSON_CONNECTION */
36828
36829 {
36830 int readin;
36831
36832 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
36833 RECEIVE_PACKET_FIELD_ERROR(action_type);
36834 }
36835 real_packet->action_type = readin;
36836 }
36837 }
36838
36839 if (BV_ISSET(fields, 3)) {
36840 log_packet_detailed(" got field 'request_kind'");
36841
36842#ifdef FREECIV_JSON_CONNECTION
36843 field_addr.name = "request_kind";
36844#endif /* FREECIV_JSON_CONNECTION */
36845
36846 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
36847 RECEIVE_PACKET_FIELD_ERROR(request_kind);
36848 }
36849 }
36850
36851 if (nullptr == old) {
36852 old = fc_malloc(sizeof(*old));
36853 init_packet_unit_action_query(old);
36854 *old = *real_packet;
36855 genhash_insert(*hash, old, old);
36856 } else {
36857 *old = *real_packet;
36858 }
36859
36860#else /* FREECIV_DELTA_PROTOCOL */
36861#ifdef FREECIV_JSON_CONNECTION
36862 field_addr.name = "actor_id";
36863#endif /* FREECIV_JSON_CONNECTION */
36864
36865 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
36866 RECEIVE_PACKET_FIELD_ERROR(actor_id);
36867 }
36868
36869#ifdef FREECIV_JSON_CONNECTION
36870 field_addr.name = "target_id";
36871#endif /* FREECIV_JSON_CONNECTION */
36872
36873 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_id)) {
36874 RECEIVE_PACKET_FIELD_ERROR(target_id);
36875 }
36876
36877#ifdef FREECIV_JSON_CONNECTION
36878 field_addr.name = "action_type";
36879#endif /* FREECIV_JSON_CONNECTION */
36880
36881 {
36882 int readin;
36883
36884 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
36885 RECEIVE_PACKET_FIELD_ERROR(action_type);
36886 }
36887 real_packet->action_type = readin;
36888 }
36889
36890#ifdef FREECIV_JSON_CONNECTION
36891 field_addr.name = "request_kind";
36892#endif /* FREECIV_JSON_CONNECTION */
36893
36894 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
36895 RECEIVE_PACKET_FIELD_ERROR(request_kind);
36896 }
36897#endif /* FREECIV_DELTA_PROTOCOL */
36898
36899 RECEIVE_PACKET_END(real_packet);
36900#undef FREE_PACKET_STRUCT
36901}
36902
36903 static int send_packet_unit_action_query_100(struct connection *pc, const struct packet_unit_action_query *packet)
36904{
36905 const struct packet_unit_action_query *real_packet = packet;
36906 int e;
36907 SEND_PACKET_START(PACKET_UNIT_ACTION_QUERY);
36908
36909 log_packet_detailed("packet_unit_action_query_100: sending info about ()");
36910
36911#ifdef FREECIV_DELTA_PROTOCOL
36912 packet_unit_action_query_100_fields fields;
36913 struct packet_unit_action_query *old;
36914 bool differ;
36915 struct genhash **hash = pc->phs.sent + PACKET_UNIT_ACTION_QUERY;
36916
36917 if (nullptr == *hash) {
36918 *hash = genhash_new_full(hash_packet_unit_action_query_100, cmp_packet_unit_action_query_100,
36919 nullptr, nullptr, nullptr, destroy_packet_unit_action_query);
36920 }
36921 BV_CLR_ALL(fields);
36922
36923 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
36924 old = fc_malloc(sizeof(*old));
36925 /* temporary bitcopy just to insert correctly */
36926 *old = *real_packet;
36927 genhash_insert(*hash, old, old);
36928 init_packet_unit_action_query(old);
36929 }
36930
36931 differ = (old->actor_id != real_packet->actor_id);
36932 if (differ) {
36933 BV_SET(fields, 0);
36934 }
36935
36936 differ = (old->target_id != real_packet->target_id);
36937 if (differ) {
36938 BV_SET(fields, 1);
36939 }
36940
36941 differ = (old->action_type != real_packet->action_type);
36942 if (differ) {
36943 BV_SET(fields, 2);
36944 }
36945
36946 differ = (old->request_kind != real_packet->request_kind);
36947 if (differ) {
36948 BV_SET(fields, 3);
36949 }
36950#endif /* FREECIV_DELTA_PROTOCOL */
36951
36952#ifdef FREECIV_JSON_CONNECTION
36953 struct plocation field_addr;
36954 {
36955 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
36956 field_addr = *field_addr_tmp;
36957 FC_FREE(field_addr_tmp);
36958 }
36959#endif /* FREECIV_JSON_CONNECTION */
36960
36961#ifdef FREECIV_DELTA_PROTOCOL
36962#ifdef FREECIV_JSON_CONNECTION
36963 field_addr.name = "fields";
36964#endif /* FREECIV_JSON_CONNECTION */
36965 e = 0;
36966 e |= DIO_BV_PUT(&dout, &field_addr, fields);
36967 if (e) {
36968 log_packet_detailed("fields bitvector error detected");
36969 }
36970
36971 if (BV_ISSET(fields, 0)) {
36972 log_packet_detailed(" field 'actor_id' has changed");
36973
36974#ifdef FREECIV_JSON_CONNECTION
36975 field_addr.name = "actor_id";
36976#endif /* FREECIV_JSON_CONNECTION */
36977 e = 0;
36978
36979 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
36980
36981 if (e) {
36982 log_packet_detailed("'actor_id' field error detected");
36983 }
36984 }
36985
36986 if (BV_ISSET(fields, 1)) {
36987 log_packet_detailed(" field 'target_id' has changed");
36988
36989#ifdef FREECIV_JSON_CONNECTION
36990 field_addr.name = "target_id";
36991#endif /* FREECIV_JSON_CONNECTION */
36992 e = 0;
36993
36994 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_id);
36995
36996 if (e) {
36997 log_packet_detailed("'target_id' field error detected");
36998 }
36999 }
37000
37001 if (BV_ISSET(fields, 2)) {
37002 log_packet_detailed(" field 'action_type' has changed");
37003
37004#ifdef FREECIV_JSON_CONNECTION
37005 field_addr.name = "action_type";
37006#endif /* FREECIV_JSON_CONNECTION */
37007 e = 0;
37008
37009 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_type);
37010
37011 if (e) {
37012 log_packet_detailed("'action_type' field error detected");
37013 }
37014 }
37015
37016 if (BV_ISSET(fields, 3)) {
37017 log_packet_detailed(" field 'request_kind' has changed");
37018
37019#ifdef FREECIV_JSON_CONNECTION
37020 field_addr.name = "request_kind";
37021#endif /* FREECIV_JSON_CONNECTION */
37022 e = 0;
37023
37024 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
37025
37026 if (e) {
37027 log_packet_detailed("'request_kind' field error detected");
37028 }
37029 }
37030
37031 *old = *real_packet;
37032
37033#else /* FREECIV_DELTA_PROTOCOL */
37034#ifdef FREECIV_JSON_CONNECTION
37035 field_addr.name = "actor_id";
37036#endif /* FREECIV_JSON_CONNECTION */
37037 e = 0;
37038
37039 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
37040
37041 if (e) {
37042 log_packet_detailed("'actor_id' field error detected");
37043 }
37044
37045#ifdef FREECIV_JSON_CONNECTION
37046 field_addr.name = "target_id";
37047#endif /* FREECIV_JSON_CONNECTION */
37048 e = 0;
37049
37050 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_id);
37051
37052 if (e) {
37053 log_packet_detailed("'target_id' field error detected");
37054 }
37055
37056#ifdef FREECIV_JSON_CONNECTION
37057 field_addr.name = "action_type";
37058#endif /* FREECIV_JSON_CONNECTION */
37059 e = 0;
37060
37061 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_type);
37062
37063 if (e) {
37064 log_packet_detailed("'action_type' field error detected");
37065 }
37066
37067#ifdef FREECIV_JSON_CONNECTION
37068 field_addr.name = "request_kind";
37069#endif /* FREECIV_JSON_CONNECTION */
37070 e = 0;
37071
37072 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
37073
37074 if (e) {
37075 log_packet_detailed("'request_kind' field error detected");
37076 }
37077#endif /* FREECIV_DELTA_PROTOCOL */
37078
37079 SEND_PACKET_END(PACKET_UNIT_ACTION_QUERY);
37080}
37081
37082 int send_packet_unit_action_query(struct connection *pc, const struct packet_unit_action_query *packet)
37083{
37084 if (!pc->used) {
37085 log_error("WARNING: trying to send data to the closed connection %s",
37086 conn_description(pc));
37087 return -1;
37088 }
37089 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ACTION_QUERY].packet != nullptr, -1,
37090 "Handler for PACKET_UNIT_ACTION_QUERY not installed");
37091 return pc->phs.handlers->send[PACKET_UNIT_ACTION_QUERY].packet(pc, packet);
37092}
37093
37094 int dsend_packet_unit_action_query(struct connection *pc, int actor_id, int target_id, action_id action_type, int request_kind)
37095{
37096 struct packet_unit_action_query packet, *real_packet = &packet;
37097
37098 real_packet->actor_id = actor_id;
37099 real_packet->target_id = target_id;
37100 real_packet->action_type = action_type;
37101 real_packet->request_kind = request_kind;
37102
37103 return send_packet_unit_action_query(pc, real_packet);
37104}
37105
37106 static inline void init_packet_unit_type_upgrade(struct packet_unit_type_upgrade *packet)
37107{
37108 memset(packet, 0, sizeof(*packet));
37109}
37110
37111#define free_packet_unit_type_upgrade(_packet) (void) 0
37112#define destroy_packet_unit_type_upgrade free
37113
37114#ifdef FREECIV_DELTA_PROTOCOL
37115#define hash_packet_unit_type_upgrade_100 hash_const
37116#define cmp_packet_unit_type_upgrade_100 cmp_const
37117 BV_DEFINE(packet_unit_type_upgrade_100_fields, 1);
37118#endif /* FREECIV_DELTA_PROTOCOL */
37119
37120 static struct packet_unit_type_upgrade *receive_packet_unit_type_upgrade_100(struct connection *pc)
37121{
37122#define FREE_PACKET_STRUCT(_packet) free_packet_unit_type_upgrade(_packet)
37123 RECEIVE_PACKET_START(packet_unit_type_upgrade, real_packet);
37124
37125#ifdef FREECIV_JSON_CONNECTION
37126 struct plocation field_addr;
37127 {
37128 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
37129 field_addr = *field_addr_tmp;
37130 FC_FREE(field_addr_tmp);
37131 }
37132#endif /* FREECIV_JSON_CONNECTION */
37133
37134 log_packet_detailed("packet_unit_type_upgrade_100: got info about ()");
37135
37136#ifdef FREECIV_DELTA_PROTOCOL
37137 packet_unit_type_upgrade_100_fields fields;
37138 struct packet_unit_type_upgrade *old;
37139 struct genhash **hash = pc->phs.received + PACKET_UNIT_TYPE_UPGRADE;
37140
37141 if (nullptr == *hash) {
37142 *hash = genhash_new_full(hash_packet_unit_type_upgrade_100, cmp_packet_unit_type_upgrade_100,
37143 nullptr, nullptr, nullptr, destroy_packet_unit_type_upgrade);
37144 }
37145
37146 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37147 *real_packet = *old;
37148 } else {
37149 /* packet is already initialized empty */
37150 log_packet_detailed(" no old info");
37151 }
37152
37153#ifdef FREECIV_JSON_CONNECTION
37154 field_addr.name = "fields";
37155#endif /* FREECIV_JSON_CONNECTION */
37156 DIO_BV_GET(&din, &field_addr, fields);
37157
37158 if (BV_ISSET(fields, 0)) {
37159 log_packet_detailed(" got field 'type'");
37160
37161#ifdef FREECIV_JSON_CONNECTION
37162 field_addr.name = "type";
37163#endif /* FREECIV_JSON_CONNECTION */
37164
37165 {
37166 int readin;
37167
37168 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
37169 RECEIVE_PACKET_FIELD_ERROR(type);
37170 }
37171 real_packet->type = readin;
37172 }
37173 }
37174
37175 if (nullptr == old) {
37176 old = fc_malloc(sizeof(*old));
37177 init_packet_unit_type_upgrade(old);
37178 *old = *real_packet;
37179 genhash_insert(*hash, old, old);
37180 } else {
37181 *old = *real_packet;
37182 }
37183
37184#else /* FREECIV_DELTA_PROTOCOL */
37185#ifdef FREECIV_JSON_CONNECTION
37186 field_addr.name = "type";
37187#endif /* FREECIV_JSON_CONNECTION */
37188
37189 {
37190 int readin;
37191
37192 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
37193 RECEIVE_PACKET_FIELD_ERROR(type);
37194 }
37195 real_packet->type = readin;
37196 }
37197#endif /* FREECIV_DELTA_PROTOCOL */
37198
37199 RECEIVE_PACKET_END(real_packet);
37200#undef FREE_PACKET_STRUCT
37201}
37202
37203 static int send_packet_unit_type_upgrade_100(struct connection *pc, const struct packet_unit_type_upgrade *packet)
37204{
37205 const struct packet_unit_type_upgrade *real_packet = packet;
37206 int e;
37207 SEND_PACKET_START(PACKET_UNIT_TYPE_UPGRADE);
37208
37209 log_packet_detailed("packet_unit_type_upgrade_100: sending info about ()");
37210
37211#ifdef FREECIV_DELTA_PROTOCOL
37212 packet_unit_type_upgrade_100_fields fields;
37213 struct packet_unit_type_upgrade *old;
37214 bool differ;
37215 struct genhash **hash = pc->phs.sent + PACKET_UNIT_TYPE_UPGRADE;
37216
37217 if (nullptr == *hash) {
37218 *hash = genhash_new_full(hash_packet_unit_type_upgrade_100, cmp_packet_unit_type_upgrade_100,
37219 nullptr, nullptr, nullptr, destroy_packet_unit_type_upgrade);
37220 }
37221 BV_CLR_ALL(fields);
37222
37223 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37224 old = fc_malloc(sizeof(*old));
37225 /* temporary bitcopy just to insert correctly */
37226 *old = *real_packet;
37227 genhash_insert(*hash, old, old);
37228 init_packet_unit_type_upgrade(old);
37229 }
37230
37231 differ = (old->type != real_packet->type);
37232 if (differ) {
37233 BV_SET(fields, 0);
37234 }
37235#endif /* FREECIV_DELTA_PROTOCOL */
37236
37237#ifdef FREECIV_JSON_CONNECTION
37238 struct plocation field_addr;
37239 {
37240 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
37241 field_addr = *field_addr_tmp;
37242 FC_FREE(field_addr_tmp);
37243 }
37244#endif /* FREECIV_JSON_CONNECTION */
37245
37246#ifdef FREECIV_DELTA_PROTOCOL
37247#ifdef FREECIV_JSON_CONNECTION
37248 field_addr.name = "fields";
37249#endif /* FREECIV_JSON_CONNECTION */
37250 e = 0;
37251 e |= DIO_BV_PUT(&dout, &field_addr, fields);
37252 if (e) {
37253 log_packet_detailed("fields bitvector error detected");
37254 }
37255
37256 if (BV_ISSET(fields, 0)) {
37257 log_packet_detailed(" field 'type' has changed");
37258
37259#ifdef FREECIV_JSON_CONNECTION
37260 field_addr.name = "type";
37261#endif /* FREECIV_JSON_CONNECTION */
37262 e = 0;
37263
37264 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
37265
37266 if (e) {
37267 log_packet_detailed("'type' field error detected");
37268 }
37269 }
37270
37271 *old = *real_packet;
37272
37273#else /* FREECIV_DELTA_PROTOCOL */
37274#ifdef FREECIV_JSON_CONNECTION
37275 field_addr.name = "type";
37276#endif /* FREECIV_JSON_CONNECTION */
37277 e = 0;
37278
37279 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
37280
37281 if (e) {
37282 log_packet_detailed("'type' field error detected");
37283 }
37284#endif /* FREECIV_DELTA_PROTOCOL */
37285
37286 SEND_PACKET_END(PACKET_UNIT_TYPE_UPGRADE);
37287}
37288
37289 int send_packet_unit_type_upgrade(struct connection *pc, const struct packet_unit_type_upgrade *packet)
37290{
37291 if (!pc->used) {
37292 log_error("WARNING: trying to send data to the closed connection %s",
37293 conn_description(pc));
37294 return -1;
37295 }
37296 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_TYPE_UPGRADE].packet != nullptr, -1,
37297 "Handler for PACKET_UNIT_TYPE_UPGRADE not installed");
37298 return pc->phs.handlers->send[PACKET_UNIT_TYPE_UPGRADE].packet(pc, packet);
37299}
37300
37301 int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
37302{
37303 struct packet_unit_type_upgrade packet, *real_packet = &packet;
37304
37305 real_packet->type = type;
37306
37307 return send_packet_unit_type_upgrade(pc, real_packet);
37308}
37309
37310 static inline void init_packet_unit_do_action(struct packet_unit_do_action *packet)
37311{
37312 memset(packet, 0, sizeof(*packet));
37313}
37314
37315#define free_packet_unit_do_action(_packet) (void) 0
37316#define destroy_packet_unit_do_action free
37317
37318#ifdef FREECIV_DELTA_PROTOCOL
37319#define hash_packet_unit_do_action_100 hash_const
37320#define cmp_packet_unit_do_action_100 cmp_const
37321 BV_DEFINE(packet_unit_do_action_100_fields, 5);
37322#endif /* FREECIV_DELTA_PROTOCOL */
37323
37324 static struct packet_unit_do_action *receive_packet_unit_do_action_100(struct connection *pc)
37325{
37326#define FREE_PACKET_STRUCT(_packet) free_packet_unit_do_action(_packet)
37327 RECEIVE_PACKET_START(packet_unit_do_action, real_packet);
37328
37329#ifdef FREECIV_JSON_CONNECTION
37330 struct plocation field_addr;
37331 {
37332 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
37333 field_addr = *field_addr_tmp;
37334 FC_FREE(field_addr_tmp);
37335 }
37336#endif /* FREECIV_JSON_CONNECTION */
37337
37338 log_packet_detailed("packet_unit_do_action_100: got info about ()");
37339
37340#ifdef FREECIV_DELTA_PROTOCOL
37341 packet_unit_do_action_100_fields fields;
37342 struct packet_unit_do_action *old;
37343 struct genhash **hash = pc->phs.received + PACKET_UNIT_DO_ACTION;
37344
37345 if (nullptr == *hash) {
37346 *hash = genhash_new_full(hash_packet_unit_do_action_100, cmp_packet_unit_do_action_100,
37347 nullptr, nullptr, nullptr, destroy_packet_unit_do_action);
37348 }
37349
37350 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37351 *real_packet = *old;
37352 } else {
37353 /* packet is already initialized empty */
37354 log_packet_detailed(" no old info");
37355 }
37356
37357#ifdef FREECIV_JSON_CONNECTION
37358 field_addr.name = "fields";
37359#endif /* FREECIV_JSON_CONNECTION */
37360 DIO_BV_GET(&din, &field_addr, fields);
37361
37362 if (BV_ISSET(fields, 0)) {
37363 log_packet_detailed(" got field 'actor_id'");
37364
37365#ifdef FREECIV_JSON_CONNECTION
37366 field_addr.name = "actor_id";
37367#endif /* FREECIV_JSON_CONNECTION */
37368
37369 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
37370 RECEIVE_PACKET_FIELD_ERROR(actor_id);
37371 }
37372 }
37373
37374 if (BV_ISSET(fields, 1)) {
37375 log_packet_detailed(" got field 'target_id'");
37376
37377#ifdef FREECIV_JSON_CONNECTION
37378 field_addr.name = "target_id";
37379#endif /* FREECIV_JSON_CONNECTION */
37380
37381 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_id)) {
37382 RECEIVE_PACKET_FIELD_ERROR(target_id);
37383 }
37384 }
37385
37386 if (BV_ISSET(fields, 2)) {
37387 log_packet_detailed(" got field 'sub_tgt_id'");
37388
37389#ifdef FREECIV_JSON_CONNECTION
37390 field_addr.name = "sub_tgt_id";
37391#endif /* FREECIV_JSON_CONNECTION */
37392
37393 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->sub_tgt_id)) {
37394 RECEIVE_PACKET_FIELD_ERROR(sub_tgt_id);
37395 }
37396 }
37397
37398 if (BV_ISSET(fields, 3)) {
37399 log_packet_detailed(" got field 'name'");
37400
37401#ifdef FREECIV_JSON_CONNECTION
37402 field_addr.name = "name";
37403#endif /* FREECIV_JSON_CONNECTION */
37404
37405 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
37406 RECEIVE_PACKET_FIELD_ERROR(name);
37407 }
37408 }
37409
37410 if (BV_ISSET(fields, 4)) {
37411 log_packet_detailed(" got field 'action_type'");
37412
37413#ifdef FREECIV_JSON_CONNECTION
37414 field_addr.name = "action_type";
37415#endif /* FREECIV_JSON_CONNECTION */
37416
37417 {
37418 int readin;
37419
37420 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
37421 RECEIVE_PACKET_FIELD_ERROR(action_type);
37422 }
37423 real_packet->action_type = readin;
37424 }
37425 }
37426
37427 if (nullptr == old) {
37428 old = fc_malloc(sizeof(*old));
37429 init_packet_unit_do_action(old);
37430 *old = *real_packet;
37431 genhash_insert(*hash, old, old);
37432 } else {
37433 *old = *real_packet;
37434 }
37435
37436#else /* FREECIV_DELTA_PROTOCOL */
37437#ifdef FREECIV_JSON_CONNECTION
37438 field_addr.name = "actor_id";
37439#endif /* FREECIV_JSON_CONNECTION */
37440
37441 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
37442 RECEIVE_PACKET_FIELD_ERROR(actor_id);
37443 }
37444
37445#ifdef FREECIV_JSON_CONNECTION
37446 field_addr.name = "target_id";
37447#endif /* FREECIV_JSON_CONNECTION */
37448
37449 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_id)) {
37450 RECEIVE_PACKET_FIELD_ERROR(target_id);
37451 }
37452
37453#ifdef FREECIV_JSON_CONNECTION
37454 field_addr.name = "sub_tgt_id";
37455#endif /* FREECIV_JSON_CONNECTION */
37456
37457 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->sub_tgt_id)) {
37458 RECEIVE_PACKET_FIELD_ERROR(sub_tgt_id);
37459 }
37460
37461#ifdef FREECIV_JSON_CONNECTION
37462 field_addr.name = "name";
37463#endif /* FREECIV_JSON_CONNECTION */
37464
37465 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
37466 RECEIVE_PACKET_FIELD_ERROR(name);
37467 }
37468
37469#ifdef FREECIV_JSON_CONNECTION
37470 field_addr.name = "action_type";
37471#endif /* FREECIV_JSON_CONNECTION */
37472
37473 {
37474 int readin;
37475
37476 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
37477 RECEIVE_PACKET_FIELD_ERROR(action_type);
37478 }
37479 real_packet->action_type = readin;
37480 }
37481#endif /* FREECIV_DELTA_PROTOCOL */
37482
37483 RECEIVE_PACKET_END(real_packet);
37484#undef FREE_PACKET_STRUCT
37485}
37486
37487 static int send_packet_unit_do_action_100(struct connection *pc, const struct packet_unit_do_action *packet)
37488{
37489 const struct packet_unit_do_action *real_packet = packet;
37490 int e;
37491 SEND_PACKET_START(PACKET_UNIT_DO_ACTION);
37492
37493 log_packet_detailed("packet_unit_do_action_100: sending info about ()");
37494
37495#ifdef FREECIV_DELTA_PROTOCOL
37496 packet_unit_do_action_100_fields fields;
37497 struct packet_unit_do_action *old;
37498 bool differ;
37499 struct genhash **hash = pc->phs.sent + PACKET_UNIT_DO_ACTION;
37500
37501 if (nullptr == *hash) {
37502 *hash = genhash_new_full(hash_packet_unit_do_action_100, cmp_packet_unit_do_action_100,
37503 nullptr, nullptr, nullptr, destroy_packet_unit_do_action);
37504 }
37505 BV_CLR_ALL(fields);
37506
37507 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37508 old = fc_malloc(sizeof(*old));
37509 /* temporary bitcopy just to insert correctly */
37510 *old = *real_packet;
37511 genhash_insert(*hash, old, old);
37512 init_packet_unit_do_action(old);
37513 }
37514
37515 differ = (old->actor_id != real_packet->actor_id);
37516 if (differ) {
37517 BV_SET(fields, 0);
37518 }
37519
37520 differ = (old->target_id != real_packet->target_id);
37521 if (differ) {
37522 BV_SET(fields, 1);
37523 }
37524
37525 differ = (old->sub_tgt_id != real_packet->sub_tgt_id);
37526 if (differ) {
37527 BV_SET(fields, 2);
37528 }
37529
37530 differ = (strcmp(old->name, real_packet->name) != 0);
37531 if (differ) {
37532 BV_SET(fields, 3);
37533 }
37534
37535 differ = (old->action_type != real_packet->action_type);
37536 if (differ) {
37537 BV_SET(fields, 4);
37538 }
37539#endif /* FREECIV_DELTA_PROTOCOL */
37540
37541#ifdef FREECIV_JSON_CONNECTION
37542 struct plocation field_addr;
37543 {
37544 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
37545 field_addr = *field_addr_tmp;
37546 FC_FREE(field_addr_tmp);
37547 }
37548#endif /* FREECIV_JSON_CONNECTION */
37549
37550#ifdef FREECIV_DELTA_PROTOCOL
37551#ifdef FREECIV_JSON_CONNECTION
37552 field_addr.name = "fields";
37553#endif /* FREECIV_JSON_CONNECTION */
37554 e = 0;
37555 e |= DIO_BV_PUT(&dout, &field_addr, fields);
37556 if (e) {
37557 log_packet_detailed("fields bitvector error detected");
37558 }
37559
37560 if (BV_ISSET(fields, 0)) {
37561 log_packet_detailed(" field 'actor_id' has changed");
37562
37563#ifdef FREECIV_JSON_CONNECTION
37564 field_addr.name = "actor_id";
37565#endif /* FREECIV_JSON_CONNECTION */
37566 e = 0;
37567
37568 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
37569
37570 if (e) {
37571 log_packet_detailed("'actor_id' field error detected");
37572 }
37573 }
37574
37575 if (BV_ISSET(fields, 1)) {
37576 log_packet_detailed(" field 'target_id' has changed");
37577
37578#ifdef FREECIV_JSON_CONNECTION
37579 field_addr.name = "target_id";
37580#endif /* FREECIV_JSON_CONNECTION */
37581 e = 0;
37582
37583 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_id);
37584
37585 if (e) {
37586 log_packet_detailed("'target_id' field error detected");
37587 }
37588 }
37589
37590 if (BV_ISSET(fields, 2)) {
37591 log_packet_detailed(" field 'sub_tgt_id' has changed");
37592
37593#ifdef FREECIV_JSON_CONNECTION
37594 field_addr.name = "sub_tgt_id";
37595#endif /* FREECIV_JSON_CONNECTION */
37596 e = 0;
37597
37598 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->sub_tgt_id);
37599
37600 if (e) {
37601 log_packet_detailed("'sub_tgt_id' field error detected");
37602 }
37603 }
37604
37605 if (BV_ISSET(fields, 3)) {
37606 log_packet_detailed(" field 'name' has changed");
37607
37608#ifdef FREECIV_JSON_CONNECTION
37609 field_addr.name = "name";
37610#endif /* FREECIV_JSON_CONNECTION */
37611 e = 0;
37612
37613 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
37614
37615 if (e) {
37616 log_packet_detailed("'name' field error detected");
37617 }
37618 }
37619
37620 if (BV_ISSET(fields, 4)) {
37621 log_packet_detailed(" field 'action_type' has changed");
37622
37623#ifdef FREECIV_JSON_CONNECTION
37624 field_addr.name = "action_type";
37625#endif /* FREECIV_JSON_CONNECTION */
37626 e = 0;
37627
37628 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_type);
37629
37630 if (e) {
37631 log_packet_detailed("'action_type' field error detected");
37632 }
37633 }
37634
37635 *old = *real_packet;
37636
37637#else /* FREECIV_DELTA_PROTOCOL */
37638#ifdef FREECIV_JSON_CONNECTION
37639 field_addr.name = "actor_id";
37640#endif /* FREECIV_JSON_CONNECTION */
37641 e = 0;
37642
37643 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
37644
37645 if (e) {
37646 log_packet_detailed("'actor_id' field error detected");
37647 }
37648
37649#ifdef FREECIV_JSON_CONNECTION
37650 field_addr.name = "target_id";
37651#endif /* FREECIV_JSON_CONNECTION */
37652 e = 0;
37653
37654 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_id);
37655
37656 if (e) {
37657 log_packet_detailed("'target_id' field error detected");
37658 }
37659
37660#ifdef FREECIV_JSON_CONNECTION
37661 field_addr.name = "sub_tgt_id";
37662#endif /* FREECIV_JSON_CONNECTION */
37663 e = 0;
37664
37665 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->sub_tgt_id);
37666
37667 if (e) {
37668 log_packet_detailed("'sub_tgt_id' field error detected");
37669 }
37670
37671#ifdef FREECIV_JSON_CONNECTION
37672 field_addr.name = "name";
37673#endif /* FREECIV_JSON_CONNECTION */
37674 e = 0;
37675
37676 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
37677
37678 if (e) {
37679 log_packet_detailed("'name' field error detected");
37680 }
37681
37682#ifdef FREECIV_JSON_CONNECTION
37683 field_addr.name = "action_type";
37684#endif /* FREECIV_JSON_CONNECTION */
37685 e = 0;
37686
37687 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_type);
37688
37689 if (e) {
37690 log_packet_detailed("'action_type' field error detected");
37691 }
37692#endif /* FREECIV_DELTA_PROTOCOL */
37693
37694 SEND_PACKET_END(PACKET_UNIT_DO_ACTION);
37695}
37696
37697 int send_packet_unit_do_action(struct connection *pc, const struct packet_unit_do_action *packet)
37698{
37699 if (!pc->used) {
37700 log_error("WARNING: trying to send data to the closed connection %s",
37701 conn_description(pc));
37702 return -1;
37703 }
37704 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_DO_ACTION].packet != nullptr, -1,
37705 "Handler for PACKET_UNIT_DO_ACTION not installed");
37706 return pc->phs.handlers->send[PACKET_UNIT_DO_ACTION].packet(pc, packet);
37707}
37708
37709 int dsend_packet_unit_do_action(struct connection *pc, int actor_id, int target_id, int sub_tgt_id, const char *name, action_id action_type)
37710{
37711 struct packet_unit_do_action packet, *real_packet = &packet;
37712
37713 real_packet->actor_id = actor_id;
37714 real_packet->target_id = target_id;
37715 real_packet->sub_tgt_id = sub_tgt_id;
37716 sz_strlcpy(real_packet->name, name);
37717 real_packet->action_type = action_type;
37718
37719 return send_packet_unit_do_action(pc, real_packet);
37720}
37721
37722 static inline void init_packet_unit_action_answer(struct packet_unit_action_answer *packet)
37723{
37724 memset(packet, 0, sizeof(*packet));
37725}
37726
37727#define free_packet_unit_action_answer(_packet) (void) 0
37728#define destroy_packet_unit_action_answer free
37729
37730#ifdef FREECIV_DELTA_PROTOCOL
37731#define hash_packet_unit_action_answer_100 hash_const
37732#define cmp_packet_unit_action_answer_100 cmp_const
37733 BV_DEFINE(packet_unit_action_answer_100_fields, 5);
37734#endif /* FREECIV_DELTA_PROTOCOL */
37735
37736 static struct packet_unit_action_answer *receive_packet_unit_action_answer_100(struct connection *pc)
37737{
37738#define FREE_PACKET_STRUCT(_packet) free_packet_unit_action_answer(_packet)
37739 RECEIVE_PACKET_START(packet_unit_action_answer, real_packet);
37740
37741#ifdef FREECIV_JSON_CONNECTION
37742 struct plocation field_addr;
37743 {
37744 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
37745 field_addr = *field_addr_tmp;
37746 FC_FREE(field_addr_tmp);
37747 }
37748#endif /* FREECIV_JSON_CONNECTION */
37749
37750 log_packet_detailed("packet_unit_action_answer_100: got info about ()");
37751
37752#ifdef FREECIV_DELTA_PROTOCOL
37753 packet_unit_action_answer_100_fields fields;
37754 struct packet_unit_action_answer *old;
37755 struct genhash **hash = pc->phs.received + PACKET_UNIT_ACTION_ANSWER;
37756
37757 if (nullptr == *hash) {
37758 *hash = genhash_new_full(hash_packet_unit_action_answer_100, cmp_packet_unit_action_answer_100,
37759 nullptr, nullptr, nullptr, destroy_packet_unit_action_answer);
37760 }
37761
37762 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
37763 *real_packet = *old;
37764 } else {
37765 /* packet is already initialized empty */
37766 log_packet_detailed(" no old info");
37767 }
37768
37769#ifdef FREECIV_JSON_CONNECTION
37770 field_addr.name = "fields";
37771#endif /* FREECIV_JSON_CONNECTION */
37772 DIO_BV_GET(&din, &field_addr, fields);
37773
37774 if (BV_ISSET(fields, 0)) {
37775 log_packet_detailed(" got field 'actor_id'");
37776
37777#ifdef FREECIV_JSON_CONNECTION
37778 field_addr.name = "actor_id";
37779#endif /* FREECIV_JSON_CONNECTION */
37780
37781 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
37782 RECEIVE_PACKET_FIELD_ERROR(actor_id);
37783 }
37784 }
37785
37786 if (BV_ISSET(fields, 1)) {
37787 log_packet_detailed(" got field 'target_id'");
37788
37789#ifdef FREECIV_JSON_CONNECTION
37790 field_addr.name = "target_id";
37791#endif /* FREECIV_JSON_CONNECTION */
37792
37793 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_id)) {
37794 RECEIVE_PACKET_FIELD_ERROR(target_id);
37795 }
37796 }
37797
37798 if (BV_ISSET(fields, 2)) {
37799 log_packet_detailed(" got field 'cost'");
37800
37801#ifdef FREECIV_JSON_CONNECTION
37802 field_addr.name = "cost";
37803#endif /* FREECIV_JSON_CONNECTION */
37804
37805 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->cost)) {
37806 RECEIVE_PACKET_FIELD_ERROR(cost);
37807 }
37808 }
37809
37810 if (BV_ISSET(fields, 3)) {
37811 log_packet_detailed(" got field 'action_type'");
37812
37813#ifdef FREECIV_JSON_CONNECTION
37814 field_addr.name = "action_type";
37815#endif /* FREECIV_JSON_CONNECTION */
37816
37817 {
37818 int readin;
37819
37820 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
37821 RECEIVE_PACKET_FIELD_ERROR(action_type);
37822 }
37823 real_packet->action_type = readin;
37824 }
37825 }
37826
37827 if (BV_ISSET(fields, 4)) {
37828 log_packet_detailed(" got field 'request_kind'");
37829
37830#ifdef FREECIV_JSON_CONNECTION
37831 field_addr.name = "request_kind";
37832#endif /* FREECIV_JSON_CONNECTION */
37833
37834 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
37835 RECEIVE_PACKET_FIELD_ERROR(request_kind);
37836 }
37837 }
37838
37839 if (nullptr == old) {
37840 old = fc_malloc(sizeof(*old));
37841 init_packet_unit_action_answer(old);
37842 *old = *real_packet;
37843 genhash_insert(*hash, old, old);
37844 } else {
37845 *old = *real_packet;
37846 }
37847
37848#else /* FREECIV_DELTA_PROTOCOL */
37849#ifdef FREECIV_JSON_CONNECTION
37850 field_addr.name = "actor_id";
37851#endif /* FREECIV_JSON_CONNECTION */
37852
37853 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_id)) {
37854 RECEIVE_PACKET_FIELD_ERROR(actor_id);
37855 }
37856
37857#ifdef FREECIV_JSON_CONNECTION
37858 field_addr.name = "target_id";
37859#endif /* FREECIV_JSON_CONNECTION */
37860
37861 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_id)) {
37862 RECEIVE_PACKET_FIELD_ERROR(target_id);
37863 }
37864
37865#ifdef FREECIV_JSON_CONNECTION
37866 field_addr.name = "cost";
37867#endif /* FREECIV_JSON_CONNECTION */
37868
37869 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->cost)) {
37870 RECEIVE_PACKET_FIELD_ERROR(cost);
37871 }
37872
37873#ifdef FREECIV_JSON_CONNECTION
37874 field_addr.name = "action_type";
37875#endif /* FREECIV_JSON_CONNECTION */
37876
37877 {
37878 int readin;
37879
37880 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
37881 RECEIVE_PACKET_FIELD_ERROR(action_type);
37882 }
37883 real_packet->action_type = readin;
37884 }
37885
37886#ifdef FREECIV_JSON_CONNECTION
37887 field_addr.name = "request_kind";
37888#endif /* FREECIV_JSON_CONNECTION */
37889
37890 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
37891 RECEIVE_PACKET_FIELD_ERROR(request_kind);
37892 }
37893#endif /* FREECIV_DELTA_PROTOCOL */
37894
37895 RECEIVE_PACKET_END(real_packet);
37896#undef FREE_PACKET_STRUCT
37897}
37898
37899 static int send_packet_unit_action_answer_100(struct connection *pc, const struct packet_unit_action_answer *packet)
37900{
37901 const struct packet_unit_action_answer *real_packet = packet;
37902 int e;
37903 SEND_PACKET_START(PACKET_UNIT_ACTION_ANSWER);
37904
37905 log_packet_detailed("packet_unit_action_answer_100: sending info about ()");
37906
37907#ifdef FREECIV_DELTA_PROTOCOL
37908 packet_unit_action_answer_100_fields fields;
37909 struct packet_unit_action_answer *old;
37910 bool differ;
37911 struct genhash **hash = pc->phs.sent + PACKET_UNIT_ACTION_ANSWER;
37912
37913 if (nullptr == *hash) {
37914 *hash = genhash_new_full(hash_packet_unit_action_answer_100, cmp_packet_unit_action_answer_100,
37915 nullptr, nullptr, nullptr, destroy_packet_unit_action_answer);
37916 }
37917 BV_CLR_ALL(fields);
37918
37919 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
37920 old = fc_malloc(sizeof(*old));
37921 /* temporary bitcopy just to insert correctly */
37922 *old = *real_packet;
37923 genhash_insert(*hash, old, old);
37924 init_packet_unit_action_answer(old);
37925 }
37926
37927 differ = (old->actor_id != real_packet->actor_id);
37928 if (differ) {
37929 BV_SET(fields, 0);
37930 }
37931
37932 differ = (old->target_id != real_packet->target_id);
37933 if (differ) {
37934 BV_SET(fields, 1);
37935 }
37936
37937 differ = (old->cost != real_packet->cost);
37938 if (differ) {
37939 BV_SET(fields, 2);
37940 }
37941
37942 differ = (old->action_type != real_packet->action_type);
37943 if (differ) {
37944 BV_SET(fields, 3);
37945 }
37946
37947 differ = (old->request_kind != real_packet->request_kind);
37948 if (differ) {
37949 BV_SET(fields, 4);
37950 }
37951#endif /* FREECIV_DELTA_PROTOCOL */
37952
37953#ifdef FREECIV_JSON_CONNECTION
37954 struct plocation field_addr;
37955 {
37956 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
37957 field_addr = *field_addr_tmp;
37958 FC_FREE(field_addr_tmp);
37959 }
37960#endif /* FREECIV_JSON_CONNECTION */
37961
37962#ifdef FREECIV_DELTA_PROTOCOL
37963#ifdef FREECIV_JSON_CONNECTION
37964 field_addr.name = "fields";
37965#endif /* FREECIV_JSON_CONNECTION */
37966 e = 0;
37967 e |= DIO_BV_PUT(&dout, &field_addr, fields);
37968 if (e) {
37969 log_packet_detailed("fields bitvector error detected");
37970 }
37971
37972 if (BV_ISSET(fields, 0)) {
37973 log_packet_detailed(" field 'actor_id' has changed");
37974
37975#ifdef FREECIV_JSON_CONNECTION
37976 field_addr.name = "actor_id";
37977#endif /* FREECIV_JSON_CONNECTION */
37978 e = 0;
37979
37980 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
37981
37982 if (e) {
37983 log_packet_detailed("'actor_id' field error detected");
37984 }
37985 }
37986
37987 if (BV_ISSET(fields, 1)) {
37988 log_packet_detailed(" field 'target_id' has changed");
37989
37990#ifdef FREECIV_JSON_CONNECTION
37991 field_addr.name = "target_id";
37992#endif /* FREECIV_JSON_CONNECTION */
37993 e = 0;
37994
37995 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_id);
37996
37997 if (e) {
37998 log_packet_detailed("'target_id' field error detected");
37999 }
38000 }
38001
38002 if (BV_ISSET(fields, 2)) {
38003 log_packet_detailed(" field 'cost' has changed");
38004
38005#ifdef FREECIV_JSON_CONNECTION
38006 field_addr.name = "cost";
38007#endif /* FREECIV_JSON_CONNECTION */
38008 e = 0;
38009
38010 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->cost);
38011
38012 if (e) {
38013 log_packet_detailed("'cost' field error detected");
38014 }
38015 }
38016
38017 if (BV_ISSET(fields, 3)) {
38018 log_packet_detailed(" field 'action_type' has changed");
38019
38020#ifdef FREECIV_JSON_CONNECTION
38021 field_addr.name = "action_type";
38022#endif /* FREECIV_JSON_CONNECTION */
38023 e = 0;
38024
38025 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_type);
38026
38027 if (e) {
38028 log_packet_detailed("'action_type' field error detected");
38029 }
38030 }
38031
38032 if (BV_ISSET(fields, 4)) {
38033 log_packet_detailed(" field 'request_kind' has changed");
38034
38035#ifdef FREECIV_JSON_CONNECTION
38036 field_addr.name = "request_kind";
38037#endif /* FREECIV_JSON_CONNECTION */
38038 e = 0;
38039
38040 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
38041
38042 if (e) {
38043 log_packet_detailed("'request_kind' field error detected");
38044 }
38045 }
38046
38047 *old = *real_packet;
38048
38049#else /* FREECIV_DELTA_PROTOCOL */
38050#ifdef FREECIV_JSON_CONNECTION
38051 field_addr.name = "actor_id";
38052#endif /* FREECIV_JSON_CONNECTION */
38053 e = 0;
38054
38055 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_id);
38056
38057 if (e) {
38058 log_packet_detailed("'actor_id' field error detected");
38059 }
38060
38061#ifdef FREECIV_JSON_CONNECTION
38062 field_addr.name = "target_id";
38063#endif /* FREECIV_JSON_CONNECTION */
38064 e = 0;
38065
38066 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_id);
38067
38068 if (e) {
38069 log_packet_detailed("'target_id' field error detected");
38070 }
38071
38072#ifdef FREECIV_JSON_CONNECTION
38073 field_addr.name = "cost";
38074#endif /* FREECIV_JSON_CONNECTION */
38075 e = 0;
38076
38077 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->cost);
38078
38079 if (e) {
38080 log_packet_detailed("'cost' field error detected");
38081 }
38082
38083#ifdef FREECIV_JSON_CONNECTION
38084 field_addr.name = "action_type";
38085#endif /* FREECIV_JSON_CONNECTION */
38086 e = 0;
38087
38088 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->action_type);
38089
38090 if (e) {
38091 log_packet_detailed("'action_type' field error detected");
38092 }
38093
38094#ifdef FREECIV_JSON_CONNECTION
38095 field_addr.name = "request_kind";
38096#endif /* FREECIV_JSON_CONNECTION */
38097 e = 0;
38098
38099 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
38100
38101 if (e) {
38102 log_packet_detailed("'request_kind' field error detected");
38103 }
38104#endif /* FREECIV_DELTA_PROTOCOL */
38105
38106 SEND_PACKET_END(PACKET_UNIT_ACTION_ANSWER);
38107}
38108
38109 int send_packet_unit_action_answer(struct connection *pc, const struct packet_unit_action_answer *packet)
38110{
38111 if (!pc->used) {
38112 log_error("WARNING: trying to send data to the closed connection %s",
38113 conn_description(pc));
38114 return -1;
38115 }
38116 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ACTION_ANSWER].packet != nullptr, -1,
38117 "Handler for PACKET_UNIT_ACTION_ANSWER not installed");
38118 return pc->phs.handlers->send[PACKET_UNIT_ACTION_ANSWER].packet(pc, packet);
38119}
38120
38121 int dsend_packet_unit_action_answer(struct connection *pc, int actor_id, int target_id, int cost, action_id action_type, int request_kind)
38122{
38123 struct packet_unit_action_answer packet, *real_packet = &packet;
38124
38125 real_packet->actor_id = actor_id;
38126 real_packet->target_id = target_id;
38127 real_packet->cost = cost;
38128 real_packet->action_type = action_type;
38129 real_packet->request_kind = request_kind;
38130
38131 return send_packet_unit_action_answer(pc, real_packet);
38132}
38133
38134 static inline void init_packet_unit_get_actions(struct packet_unit_get_actions *packet)
38135{
38136 memset(packet, 0, sizeof(*packet));
38137}
38138
38139#define free_packet_unit_get_actions(_packet) (void) 0
38140#define destroy_packet_unit_get_actions free
38141
38142#ifdef FREECIV_DELTA_PROTOCOL
38143#define hash_packet_unit_get_actions_100 hash_const
38144#define cmp_packet_unit_get_actions_100 cmp_const
38145 BV_DEFINE(packet_unit_get_actions_100_fields, 5);
38146#endif /* FREECIV_DELTA_PROTOCOL */
38147
38148 static struct packet_unit_get_actions *receive_packet_unit_get_actions_100(struct connection *pc)
38149{
38150#define FREE_PACKET_STRUCT(_packet) free_packet_unit_get_actions(_packet)
38151 RECEIVE_PACKET_START(packet_unit_get_actions, real_packet);
38152
38153#ifdef FREECIV_JSON_CONNECTION
38154 struct plocation field_addr;
38155 {
38156 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
38157 field_addr = *field_addr_tmp;
38158 FC_FREE(field_addr_tmp);
38159 }
38160#endif /* FREECIV_JSON_CONNECTION */
38161
38162 log_packet_detailed("packet_unit_get_actions_100: got info about ()");
38163
38164#ifdef FREECIV_DELTA_PROTOCOL
38165 packet_unit_get_actions_100_fields fields;
38166 struct packet_unit_get_actions *old;
38167 struct genhash **hash = pc->phs.received + PACKET_UNIT_GET_ACTIONS;
38168
38169 if (nullptr == *hash) {
38170 *hash = genhash_new_full(hash_packet_unit_get_actions_100, cmp_packet_unit_get_actions_100,
38171 nullptr, nullptr, nullptr, destroy_packet_unit_get_actions);
38172 }
38173
38174 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38175 *real_packet = *old;
38176 } else {
38177 /* packet is already initialized empty */
38178 log_packet_detailed(" no old info");
38179 }
38180
38181#ifdef FREECIV_JSON_CONNECTION
38182 field_addr.name = "fields";
38183#endif /* FREECIV_JSON_CONNECTION */
38184 DIO_BV_GET(&din, &field_addr, fields);
38185
38186 if (BV_ISSET(fields, 0)) {
38187 log_packet_detailed(" got field 'actor_unit_id'");
38188
38189#ifdef FREECIV_JSON_CONNECTION
38190 field_addr.name = "actor_unit_id";
38191#endif /* FREECIV_JSON_CONNECTION */
38192
38193 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_unit_id)) {
38194 RECEIVE_PACKET_FIELD_ERROR(actor_unit_id);
38195 }
38196 }
38197
38198 if (BV_ISSET(fields, 1)) {
38199 log_packet_detailed(" got field 'target_unit_id'");
38200
38201#ifdef FREECIV_JSON_CONNECTION
38202 field_addr.name = "target_unit_id";
38203#endif /* FREECIV_JSON_CONNECTION */
38204
38205 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->target_unit_id)) {
38206 RECEIVE_PACKET_FIELD_ERROR(target_unit_id);
38207 }
38208 }
38209
38210 if (BV_ISSET(fields, 2)) {
38211 log_packet_detailed(" got field 'target_tile_id'");
38212
38213#ifdef FREECIV_JSON_CONNECTION
38214 field_addr.name = "target_tile_id";
38215#endif /* FREECIV_JSON_CONNECTION */
38216
38217 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_tile_id)) {
38218 RECEIVE_PACKET_FIELD_ERROR(target_tile_id);
38219 }
38220 }
38221
38222 if (BV_ISSET(fields, 3)) {
38223 log_packet_detailed(" got field 'target_extra_id'");
38224
38225#ifdef FREECIV_JSON_CONNECTION
38226 field_addr.name = "target_extra_id";
38227#endif /* FREECIV_JSON_CONNECTION */
38228
38229 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->target_extra_id)) {
38230 RECEIVE_PACKET_FIELD_ERROR(target_extra_id);
38231 }
38232 }
38233
38234 if (BV_ISSET(fields, 4)) {
38235 log_packet_detailed(" got field 'request_kind'");
38236
38237#ifdef FREECIV_JSON_CONNECTION
38238 field_addr.name = "request_kind";
38239#endif /* FREECIV_JSON_CONNECTION */
38240
38241 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
38242 RECEIVE_PACKET_FIELD_ERROR(request_kind);
38243 }
38244 }
38245
38246 if (nullptr == old) {
38247 old = fc_malloc(sizeof(*old));
38248 init_packet_unit_get_actions(old);
38249 *old = *real_packet;
38250 genhash_insert(*hash, old, old);
38251 } else {
38252 *old = *real_packet;
38253 }
38254
38255#else /* FREECIV_DELTA_PROTOCOL */
38256#ifdef FREECIV_JSON_CONNECTION
38257 field_addr.name = "actor_unit_id";
38258#endif /* FREECIV_JSON_CONNECTION */
38259
38260 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_unit_id)) {
38261 RECEIVE_PACKET_FIELD_ERROR(actor_unit_id);
38262 }
38263
38264#ifdef FREECIV_JSON_CONNECTION
38265 field_addr.name = "target_unit_id";
38266#endif /* FREECIV_JSON_CONNECTION */
38267
38268 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->target_unit_id)) {
38269 RECEIVE_PACKET_FIELD_ERROR(target_unit_id);
38270 }
38271
38272#ifdef FREECIV_JSON_CONNECTION
38273 field_addr.name = "target_tile_id";
38274#endif /* FREECIV_JSON_CONNECTION */
38275
38276 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_tile_id)) {
38277 RECEIVE_PACKET_FIELD_ERROR(target_tile_id);
38278 }
38279
38280#ifdef FREECIV_JSON_CONNECTION
38281 field_addr.name = "target_extra_id";
38282#endif /* FREECIV_JSON_CONNECTION */
38283
38284 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->target_extra_id)) {
38285 RECEIVE_PACKET_FIELD_ERROR(target_extra_id);
38286 }
38287
38288#ifdef FREECIV_JSON_CONNECTION
38289 field_addr.name = "request_kind";
38290#endif /* FREECIV_JSON_CONNECTION */
38291
38292 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
38293 RECEIVE_PACKET_FIELD_ERROR(request_kind);
38294 }
38295#endif /* FREECIV_DELTA_PROTOCOL */
38296
38297 RECEIVE_PACKET_END(real_packet);
38298#undef FREE_PACKET_STRUCT
38299}
38300
38301 static int send_packet_unit_get_actions_100(struct connection *pc, const struct packet_unit_get_actions *packet)
38302{
38303 const struct packet_unit_get_actions *real_packet = packet;
38304 int e;
38305 SEND_PACKET_START(PACKET_UNIT_GET_ACTIONS);
38306
38307 log_packet_detailed("packet_unit_get_actions_100: sending info about ()");
38308
38309#ifdef FREECIV_DELTA_PROTOCOL
38310 packet_unit_get_actions_100_fields fields;
38311 struct packet_unit_get_actions *old;
38312 bool differ;
38313 struct genhash **hash = pc->phs.sent + PACKET_UNIT_GET_ACTIONS;
38314
38315 if (nullptr == *hash) {
38316 *hash = genhash_new_full(hash_packet_unit_get_actions_100, cmp_packet_unit_get_actions_100,
38317 nullptr, nullptr, nullptr, destroy_packet_unit_get_actions);
38318 }
38319 BV_CLR_ALL(fields);
38320
38321 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38322 old = fc_malloc(sizeof(*old));
38323 /* temporary bitcopy just to insert correctly */
38324 *old = *real_packet;
38325 genhash_insert(*hash, old, old);
38326 init_packet_unit_get_actions(old);
38327 }
38328
38329 differ = (old->actor_unit_id != real_packet->actor_unit_id);
38330 if (differ) {
38331 BV_SET(fields, 0);
38332 }
38333
38334 differ = (old->target_unit_id != real_packet->target_unit_id);
38335 if (differ) {
38336 BV_SET(fields, 1);
38337 }
38338
38339 differ = (old->target_tile_id != real_packet->target_tile_id);
38340 if (differ) {
38341 BV_SET(fields, 2);
38342 }
38343
38344 differ = (old->target_extra_id != real_packet->target_extra_id);
38345 if (differ) {
38346 BV_SET(fields, 3);
38347 }
38348
38349 differ = (old->request_kind != real_packet->request_kind);
38350 if (differ) {
38351 BV_SET(fields, 4);
38352 }
38353#endif /* FREECIV_DELTA_PROTOCOL */
38354
38355#ifdef FREECIV_JSON_CONNECTION
38356 struct plocation field_addr;
38357 {
38358 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
38359 field_addr = *field_addr_tmp;
38360 FC_FREE(field_addr_tmp);
38361 }
38362#endif /* FREECIV_JSON_CONNECTION */
38363
38364#ifdef FREECIV_DELTA_PROTOCOL
38365#ifdef FREECIV_JSON_CONNECTION
38366 field_addr.name = "fields";
38367#endif /* FREECIV_JSON_CONNECTION */
38368 e = 0;
38369 e |= DIO_BV_PUT(&dout, &field_addr, fields);
38370 if (e) {
38371 log_packet_detailed("fields bitvector error detected");
38372 }
38373
38374 if (BV_ISSET(fields, 0)) {
38375 log_packet_detailed(" field 'actor_unit_id' has changed");
38376
38377#ifdef FREECIV_JSON_CONNECTION
38378 field_addr.name = "actor_unit_id";
38379#endif /* FREECIV_JSON_CONNECTION */
38380 e = 0;
38381
38382 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_unit_id);
38383
38384 if (e) {
38385 log_packet_detailed("'actor_unit_id' field error detected");
38386 }
38387 }
38388
38389 if (BV_ISSET(fields, 1)) {
38390 log_packet_detailed(" field 'target_unit_id' has changed");
38391
38392#ifdef FREECIV_JSON_CONNECTION
38393 field_addr.name = "target_unit_id";
38394#endif /* FREECIV_JSON_CONNECTION */
38395 e = 0;
38396
38397 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->target_unit_id);
38398
38399 if (e) {
38400 log_packet_detailed("'target_unit_id' field error detected");
38401 }
38402 }
38403
38404 if (BV_ISSET(fields, 2)) {
38405 log_packet_detailed(" field 'target_tile_id' has changed");
38406
38407#ifdef FREECIV_JSON_CONNECTION
38408 field_addr.name = "target_tile_id";
38409#endif /* FREECIV_JSON_CONNECTION */
38410 e = 0;
38411
38412 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_tile_id);
38413
38414 if (e) {
38415 log_packet_detailed("'target_tile_id' field error detected");
38416 }
38417 }
38418
38419 if (BV_ISSET(fields, 3)) {
38420 log_packet_detailed(" field 'target_extra_id' has changed");
38421
38422#ifdef FREECIV_JSON_CONNECTION
38423 field_addr.name = "target_extra_id";
38424#endif /* FREECIV_JSON_CONNECTION */
38425 e = 0;
38426
38427 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_extra_id);
38428
38429 if (e) {
38430 log_packet_detailed("'target_extra_id' field error detected");
38431 }
38432 }
38433
38434 if (BV_ISSET(fields, 4)) {
38435 log_packet_detailed(" field 'request_kind' has changed");
38436
38437#ifdef FREECIV_JSON_CONNECTION
38438 field_addr.name = "request_kind";
38439#endif /* FREECIV_JSON_CONNECTION */
38440 e = 0;
38441
38442 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
38443
38444 if (e) {
38445 log_packet_detailed("'request_kind' field error detected");
38446 }
38447 }
38448
38449 *old = *real_packet;
38450
38451#else /* FREECIV_DELTA_PROTOCOL */
38452#ifdef FREECIV_JSON_CONNECTION
38453 field_addr.name = "actor_unit_id";
38454#endif /* FREECIV_JSON_CONNECTION */
38455 e = 0;
38456
38457 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_unit_id);
38458
38459 if (e) {
38460 log_packet_detailed("'actor_unit_id' field error detected");
38461 }
38462
38463#ifdef FREECIV_JSON_CONNECTION
38464 field_addr.name = "target_unit_id";
38465#endif /* FREECIV_JSON_CONNECTION */
38466 e = 0;
38467
38468 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->target_unit_id);
38469
38470 if (e) {
38471 log_packet_detailed("'target_unit_id' field error detected");
38472 }
38473
38474#ifdef FREECIV_JSON_CONNECTION
38475 field_addr.name = "target_tile_id";
38476#endif /* FREECIV_JSON_CONNECTION */
38477 e = 0;
38478
38479 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_tile_id);
38480
38481 if (e) {
38482 log_packet_detailed("'target_tile_id' field error detected");
38483 }
38484
38485#ifdef FREECIV_JSON_CONNECTION
38486 field_addr.name = "target_extra_id";
38487#endif /* FREECIV_JSON_CONNECTION */
38488 e = 0;
38489
38490 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_extra_id);
38491
38492 if (e) {
38493 log_packet_detailed("'target_extra_id' field error detected");
38494 }
38495
38496#ifdef FREECIV_JSON_CONNECTION
38497 field_addr.name = "request_kind";
38498#endif /* FREECIV_JSON_CONNECTION */
38499 e = 0;
38500
38501 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
38502
38503 if (e) {
38504 log_packet_detailed("'request_kind' field error detected");
38505 }
38506#endif /* FREECIV_DELTA_PROTOCOL */
38507
38508 SEND_PACKET_END(PACKET_UNIT_GET_ACTIONS);
38509}
38510
38511 int send_packet_unit_get_actions(struct connection *pc, const struct packet_unit_get_actions *packet)
38512{
38513 if (!pc->used) {
38514 log_error("WARNING: trying to send data to the closed connection %s",
38515 conn_description(pc));
38516 return -1;
38517 }
38518 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_GET_ACTIONS].packet != nullptr, -1,
38519 "Handler for PACKET_UNIT_GET_ACTIONS not installed");
38520 return pc->phs.handlers->send[PACKET_UNIT_GET_ACTIONS].packet(pc, packet);
38521}
38522
38523 int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
38524{
38525 struct packet_unit_get_actions packet, *real_packet = &packet;
38526
38527 real_packet->actor_unit_id = actor_unit_id;
38528 real_packet->target_unit_id = target_unit_id;
38529 real_packet->target_tile_id = target_tile_id;
38530 real_packet->target_extra_id = target_extra_id;
38531 real_packet->request_kind = request_kind;
38532
38533 return send_packet_unit_get_actions(pc, real_packet);
38534}
38535
38536 static inline void init_packet_unit_actions(struct packet_unit_actions *packet)
38537{
38538 memset(packet, 0, sizeof(*packet));
38539}
38540
38541#define free_packet_unit_actions(_packet) (void) 0
38542#define destroy_packet_unit_actions free
38543
38544#ifdef FREECIV_DELTA_PROTOCOL
38545#define hash_packet_unit_actions_100 hash_const
38546#define cmp_packet_unit_actions_100 cmp_const
38547 BV_DEFINE(packet_unit_actions_100_fields, 7);
38548#endif /* FREECIV_DELTA_PROTOCOL */
38549
38550 static struct packet_unit_actions *receive_packet_unit_actions_100(struct connection *pc)
38551{
38552#define FREE_PACKET_STRUCT(_packet) free_packet_unit_actions(_packet)
38553 RECEIVE_PACKET_START(packet_unit_actions, real_packet);
38554
38555#ifdef FREECIV_JSON_CONNECTION
38556 struct plocation field_addr;
38557 {
38558 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
38559 field_addr = *field_addr_tmp;
38560 FC_FREE(field_addr_tmp);
38561 }
38562#endif /* FREECIV_JSON_CONNECTION */
38563
38564 log_packet_detailed("packet_unit_actions_100: got info about ()");
38565
38566#ifdef FREECIV_DELTA_PROTOCOL
38567 packet_unit_actions_100_fields fields;
38568 struct packet_unit_actions *old;
38569 struct genhash **hash = pc->phs.received + PACKET_UNIT_ACTIONS;
38570
38571 if (nullptr == *hash) {
38572 *hash = genhash_new_full(hash_packet_unit_actions_100, cmp_packet_unit_actions_100,
38573 nullptr, nullptr, nullptr, destroy_packet_unit_actions);
38574 }
38575
38576 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
38577 *real_packet = *old;
38578 } else {
38579 /* packet is already initialized empty */
38580 log_packet_detailed(" no old info");
38581 }
38582
38583#ifdef FREECIV_JSON_CONNECTION
38584 field_addr.name = "fields";
38585#endif /* FREECIV_JSON_CONNECTION */
38586 DIO_BV_GET(&din, &field_addr, fields);
38587
38588 if (BV_ISSET(fields, 0)) {
38589 log_packet_detailed(" got field 'actor_unit_id'");
38590
38591#ifdef FREECIV_JSON_CONNECTION
38592 field_addr.name = "actor_unit_id";
38593#endif /* FREECIV_JSON_CONNECTION */
38594
38595 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_unit_id)) {
38596 RECEIVE_PACKET_FIELD_ERROR(actor_unit_id);
38597 }
38598 }
38599
38600 if (BV_ISSET(fields, 1)) {
38601 log_packet_detailed(" got field 'target_unit_id'");
38602
38603#ifdef FREECIV_JSON_CONNECTION
38604 field_addr.name = "target_unit_id";
38605#endif /* FREECIV_JSON_CONNECTION */
38606
38607 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->target_unit_id)) {
38608 RECEIVE_PACKET_FIELD_ERROR(target_unit_id);
38609 }
38610 }
38611
38612 if (BV_ISSET(fields, 2)) {
38613 log_packet_detailed(" got field 'target_city_id'");
38614
38615#ifdef FREECIV_JSON_CONNECTION
38616 field_addr.name = "target_city_id";
38617#endif /* FREECIV_JSON_CONNECTION */
38618
38619 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->target_city_id)) {
38620 RECEIVE_PACKET_FIELD_ERROR(target_city_id);
38621 }
38622 }
38623
38624 if (BV_ISSET(fields, 3)) {
38625 log_packet_detailed(" got field 'target_tile_id'");
38626
38627#ifdef FREECIV_JSON_CONNECTION
38628 field_addr.name = "target_tile_id";
38629#endif /* FREECIV_JSON_CONNECTION */
38630
38631 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_tile_id)) {
38632 RECEIVE_PACKET_FIELD_ERROR(target_tile_id);
38633 }
38634 }
38635
38636 if (BV_ISSET(fields, 4)) {
38637 log_packet_detailed(" got field 'target_extra_id'");
38638
38639#ifdef FREECIV_JSON_CONNECTION
38640 field_addr.name = "target_extra_id";
38641#endif /* FREECIV_JSON_CONNECTION */
38642
38643 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->target_extra_id)) {
38644 RECEIVE_PACKET_FIELD_ERROR(target_extra_id);
38645 }
38646 }
38647
38648 if (BV_ISSET(fields, 5)) {
38649 log_packet_detailed(" got field 'request_kind'");
38650
38651#ifdef FREECIV_JSON_CONNECTION
38652 field_addr.name = "request_kind";
38653#endif /* FREECIV_JSON_CONNECTION */
38654
38655 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
38656 RECEIVE_PACKET_FIELD_ERROR(request_kind);
38657 }
38658 }
38659
38660 if (BV_ISSET(fields, 6)) {
38661 log_packet_detailed(" got field 'action_probabilities'");
38662
38663#ifdef FREECIV_JSON_CONNECTION
38664 field_addr.name = "action_probabilities";
38665#endif /* FREECIV_JSON_CONNECTION */
38666
38667 {
38668 int i;
38669
38670
38671#ifdef FREECIV_JSON_CONNECTION
38672 /* Enter array. */
38673 field_addr.sub_location = plocation_elem_new(0);
38674#endif /* FREECIV_JSON_CONNECTION */
38675
38676 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
38677#ifdef FREECIV_JSON_CONNECTION
38678 /* Next array element */
38679 field_addr.sub_location->number = i;
38680#endif /* FREECIV_JSON_CONNECTION */
38681
38682 if (!DIO_GET(action_probability, &din, &field_addr, &real_packet->action_probabilities[i])) {
38683 RECEIVE_PACKET_FIELD_ERROR(action_probabilities);
38684 }
38685 }
38686
38687#ifdef FREECIV_JSON_CONNECTION
38688 /* Exit array. */
38689 FC_FREE(field_addr.sub_location);
38690#endif /* FREECIV_JSON_CONNECTION */
38691 }
38692 }
38693
38694 if (nullptr == old) {
38695 old = fc_malloc(sizeof(*old));
38696 init_packet_unit_actions(old);
38697 *old = *real_packet;
38698 genhash_insert(*hash, old, old);
38699 } else {
38700 *old = *real_packet;
38701 }
38702
38703#else /* FREECIV_DELTA_PROTOCOL */
38704#ifdef FREECIV_JSON_CONNECTION
38705 field_addr.name = "actor_unit_id";
38706#endif /* FREECIV_JSON_CONNECTION */
38707
38708 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->actor_unit_id)) {
38709 RECEIVE_PACKET_FIELD_ERROR(actor_unit_id);
38710 }
38711
38712#ifdef FREECIV_JSON_CONNECTION
38713 field_addr.name = "target_unit_id";
38714#endif /* FREECIV_JSON_CONNECTION */
38715
38716 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->target_unit_id)) {
38717 RECEIVE_PACKET_FIELD_ERROR(target_unit_id);
38718 }
38719
38720#ifdef FREECIV_JSON_CONNECTION
38721 field_addr.name = "target_city_id";
38722#endif /* FREECIV_JSON_CONNECTION */
38723
38724 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->target_city_id)) {
38725 RECEIVE_PACKET_FIELD_ERROR(target_city_id);
38726 }
38727
38728#ifdef FREECIV_JSON_CONNECTION
38729 field_addr.name = "target_tile_id";
38730#endif /* FREECIV_JSON_CONNECTION */
38731
38732 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->target_tile_id)) {
38733 RECEIVE_PACKET_FIELD_ERROR(target_tile_id);
38734 }
38735
38736#ifdef FREECIV_JSON_CONNECTION
38737 field_addr.name = "target_extra_id";
38738#endif /* FREECIV_JSON_CONNECTION */
38739
38740 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->target_extra_id)) {
38741 RECEIVE_PACKET_FIELD_ERROR(target_extra_id);
38742 }
38743
38744#ifdef FREECIV_JSON_CONNECTION
38745 field_addr.name = "request_kind";
38746#endif /* FREECIV_JSON_CONNECTION */
38747
38748 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->request_kind)) {
38749 RECEIVE_PACKET_FIELD_ERROR(request_kind);
38750 }
38751
38752#ifdef FREECIV_JSON_CONNECTION
38753 field_addr.name = "action_probabilities";
38754#endif /* FREECIV_JSON_CONNECTION */
38755
38756 {
38757 int i;
38758
38759
38760#ifdef FREECIV_JSON_CONNECTION
38761 /* Enter array. */
38762 field_addr.sub_location = plocation_elem_new(0);
38763#endif /* FREECIV_JSON_CONNECTION */
38764
38765 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
38766#ifdef FREECIV_JSON_CONNECTION
38767 /* Next array element */
38768 field_addr.sub_location->number = i;
38769#endif /* FREECIV_JSON_CONNECTION */
38770
38771 if (!DIO_GET(action_probability, &din, &field_addr, &real_packet->action_probabilities[i])) {
38772 RECEIVE_PACKET_FIELD_ERROR(action_probabilities);
38773 }
38774 }
38775
38776#ifdef FREECIV_JSON_CONNECTION
38777 /* Exit array. */
38778 FC_FREE(field_addr.sub_location);
38779#endif /* FREECIV_JSON_CONNECTION */
38780 }
38781#endif /* FREECIV_DELTA_PROTOCOL */
38782
38783 RECEIVE_PACKET_END(real_packet);
38784#undef FREE_PACKET_STRUCT
38785}
38786
38787 static int send_packet_unit_actions_100(struct connection *pc, const struct packet_unit_actions *packet)
38788{
38789 const struct packet_unit_actions *real_packet = packet;
38790 int e;
38791 SEND_PACKET_START(PACKET_UNIT_ACTIONS);
38792
38793 log_packet_detailed("packet_unit_actions_100: sending info about ()");
38794
38795#ifdef FREECIV_DELTA_PROTOCOL
38796 packet_unit_actions_100_fields fields;
38797 struct packet_unit_actions *old;
38798 bool differ;
38799 struct genhash **hash = pc->phs.sent + PACKET_UNIT_ACTIONS;
38800
38801 if (nullptr == *hash) {
38802 *hash = genhash_new_full(hash_packet_unit_actions_100, cmp_packet_unit_actions_100,
38803 nullptr, nullptr, nullptr, destroy_packet_unit_actions);
38804 }
38805 BV_CLR_ALL(fields);
38806
38807 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
38808 old = fc_malloc(sizeof(*old));
38809 /* temporary bitcopy just to insert correctly */
38810 *old = *real_packet;
38811 genhash_insert(*hash, old, old);
38812 init_packet_unit_actions(old);
38813 }
38814
38815 differ = (old->actor_unit_id != real_packet->actor_unit_id);
38816 if (differ) {
38817 BV_SET(fields, 0);
38818 }
38819
38820 differ = (old->target_unit_id != real_packet->target_unit_id);
38821 if (differ) {
38822 BV_SET(fields, 1);
38823 }
38824
38825 differ = (old->target_city_id != real_packet->target_city_id);
38826 if (differ) {
38827 BV_SET(fields, 2);
38828 }
38829
38830 differ = (old->target_tile_id != real_packet->target_tile_id);
38831 if (differ) {
38832 BV_SET(fields, 3);
38833 }
38834
38835 differ = (old->target_extra_id != real_packet->target_extra_id);
38836 if (differ) {
38837 BV_SET(fields, 4);
38838 }
38839
38840 differ = (old->request_kind != real_packet->request_kind);
38841 if (differ) {
38842 BV_SET(fields, 5);
38843 }
38844
38845 differ = FALSE;
38846 {
38847 int i;
38848
38849 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
38850 differ = !are_action_probabilitys_equal(&old->action_probabilities[i], &real_packet->action_probabilities[i]);
38851 if (differ) {
38852 break;
38853 }
38854 }
38855 }
38856 if (differ) {
38857 BV_SET(fields, 6);
38858 }
38859#endif /* FREECIV_DELTA_PROTOCOL */
38860
38861#ifdef FREECIV_JSON_CONNECTION
38862 struct plocation field_addr;
38863 {
38864 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
38865 field_addr = *field_addr_tmp;
38866 FC_FREE(field_addr_tmp);
38867 }
38868#endif /* FREECIV_JSON_CONNECTION */
38869
38870#ifdef FREECIV_DELTA_PROTOCOL
38871#ifdef FREECIV_JSON_CONNECTION
38872 field_addr.name = "fields";
38873#endif /* FREECIV_JSON_CONNECTION */
38874 e = 0;
38875 e |= DIO_BV_PUT(&dout, &field_addr, fields);
38876 if (e) {
38877 log_packet_detailed("fields bitvector error detected");
38878 }
38879
38880 if (BV_ISSET(fields, 0)) {
38881 log_packet_detailed(" field 'actor_unit_id' has changed");
38882
38883#ifdef FREECIV_JSON_CONNECTION
38884 field_addr.name = "actor_unit_id";
38885#endif /* FREECIV_JSON_CONNECTION */
38886 e = 0;
38887
38888 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_unit_id);
38889
38890 if (e) {
38891 log_packet_detailed("'actor_unit_id' field error detected");
38892 }
38893 }
38894
38895 if (BV_ISSET(fields, 1)) {
38896 log_packet_detailed(" field 'target_unit_id' has changed");
38897
38898#ifdef FREECIV_JSON_CONNECTION
38899 field_addr.name = "target_unit_id";
38900#endif /* FREECIV_JSON_CONNECTION */
38901 e = 0;
38902
38903 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->target_unit_id);
38904
38905 if (e) {
38906 log_packet_detailed("'target_unit_id' field error detected");
38907 }
38908 }
38909
38910 if (BV_ISSET(fields, 2)) {
38911 log_packet_detailed(" field 'target_city_id' has changed");
38912
38913#ifdef FREECIV_JSON_CONNECTION
38914 field_addr.name = "target_city_id";
38915#endif /* FREECIV_JSON_CONNECTION */
38916 e = 0;
38917
38918 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->target_city_id);
38919
38920 if (e) {
38921 log_packet_detailed("'target_city_id' field error detected");
38922 }
38923 }
38924
38925 if (BV_ISSET(fields, 3)) {
38926 log_packet_detailed(" field 'target_tile_id' has changed");
38927
38928#ifdef FREECIV_JSON_CONNECTION
38929 field_addr.name = "target_tile_id";
38930#endif /* FREECIV_JSON_CONNECTION */
38931 e = 0;
38932
38933 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_tile_id);
38934
38935 if (e) {
38936 log_packet_detailed("'target_tile_id' field error detected");
38937 }
38938 }
38939
38940 if (BV_ISSET(fields, 4)) {
38941 log_packet_detailed(" field 'target_extra_id' has changed");
38942
38943#ifdef FREECIV_JSON_CONNECTION
38944 field_addr.name = "target_extra_id";
38945#endif /* FREECIV_JSON_CONNECTION */
38946 e = 0;
38947
38948 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_extra_id);
38949
38950 if (e) {
38951 log_packet_detailed("'target_extra_id' field error detected");
38952 }
38953 }
38954
38955 if (BV_ISSET(fields, 5)) {
38956 log_packet_detailed(" field 'request_kind' has changed");
38957
38958#ifdef FREECIV_JSON_CONNECTION
38959 field_addr.name = "request_kind";
38960#endif /* FREECIV_JSON_CONNECTION */
38961 e = 0;
38962
38963 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
38964
38965 if (e) {
38966 log_packet_detailed("'request_kind' field error detected");
38967 }
38968 }
38969
38970 if (BV_ISSET(fields, 6)) {
38971 log_packet_detailed(" field 'action_probabilities' has changed");
38972
38973#ifdef FREECIV_JSON_CONNECTION
38974 field_addr.name = "action_probabilities";
38975#endif /* FREECIV_JSON_CONNECTION */
38976 e = 0;
38977
38978 {
38979 int i;
38980
38981#ifdef FREECIV_JSON_CONNECTION
38982 /* Create the array. */
38983 e |= DIO_PUT(farray, &dout, &field_addr, MAX_NUM_ACTIONS);
38984
38985 /* Enter array. */
38986 field_addr.sub_location = plocation_elem_new(0);
38987#endif /* FREECIV_JSON_CONNECTION */
38988
38989 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
38990#ifdef FREECIV_JSON_CONNECTION
38991 /* Next array element. */
38992 field_addr.sub_location->number = i;
38993#endif /* FREECIV_JSON_CONNECTION */
38994
38995 e |= DIO_PUT(action_probability, &dout, &field_addr, &real_packet->action_probabilities[i]);
38996 }
38997
38998#ifdef FREECIV_JSON_CONNECTION
38999 /* Exit array. */
39000 FC_FREE(field_addr.sub_location);
39001#endif /* FREECIV_JSON_CONNECTION */
39002 }
39003
39004 if (e) {
39005 log_packet_detailed("'action_probabilities' field error detected");
39006 }
39007 }
39008
39009 *old = *real_packet;
39010
39011#else /* FREECIV_DELTA_PROTOCOL */
39012#ifdef FREECIV_JSON_CONNECTION
39013 field_addr.name = "actor_unit_id";
39014#endif /* FREECIV_JSON_CONNECTION */
39015 e = 0;
39016
39017 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->actor_unit_id);
39018
39019 if (e) {
39020 log_packet_detailed("'actor_unit_id' field error detected");
39021 }
39022
39023#ifdef FREECIV_JSON_CONNECTION
39024 field_addr.name = "target_unit_id";
39025#endif /* FREECIV_JSON_CONNECTION */
39026 e = 0;
39027
39028 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->target_unit_id);
39029
39030 if (e) {
39031 log_packet_detailed("'target_unit_id' field error detected");
39032 }
39033
39034#ifdef FREECIV_JSON_CONNECTION
39035 field_addr.name = "target_city_id";
39036#endif /* FREECIV_JSON_CONNECTION */
39037 e = 0;
39038
39039 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->target_city_id);
39040
39041 if (e) {
39042 log_packet_detailed("'target_city_id' field error detected");
39043 }
39044
39045#ifdef FREECIV_JSON_CONNECTION
39046 field_addr.name = "target_tile_id";
39047#endif /* FREECIV_JSON_CONNECTION */
39048 e = 0;
39049
39050 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->target_tile_id);
39051
39052 if (e) {
39053 log_packet_detailed("'target_tile_id' field error detected");
39054 }
39055
39056#ifdef FREECIV_JSON_CONNECTION
39057 field_addr.name = "target_extra_id";
39058#endif /* FREECIV_JSON_CONNECTION */
39059 e = 0;
39060
39061 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_extra_id);
39062
39063 if (e) {
39064 log_packet_detailed("'target_extra_id' field error detected");
39065 }
39066
39067#ifdef FREECIV_JSON_CONNECTION
39068 field_addr.name = "request_kind";
39069#endif /* FREECIV_JSON_CONNECTION */
39070 e = 0;
39071
39072 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->request_kind);
39073
39074 if (e) {
39075 log_packet_detailed("'request_kind' field error detected");
39076 }
39077
39078#ifdef FREECIV_JSON_CONNECTION
39079 field_addr.name = "action_probabilities";
39080#endif /* FREECIV_JSON_CONNECTION */
39081 e = 0;
39082
39083 {
39084 int i;
39085
39086#ifdef FREECIV_JSON_CONNECTION
39087 /* Create the array. */
39088 e |= DIO_PUT(farray, &dout, &field_addr, MAX_NUM_ACTIONS);
39089
39090 /* Enter array. */
39091 field_addr.sub_location = plocation_elem_new(0);
39092#endif /* FREECIV_JSON_CONNECTION */
39093
39094 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
39095#ifdef FREECIV_JSON_CONNECTION
39096 /* Next array element. */
39097 field_addr.sub_location->number = i;
39098#endif /* FREECIV_JSON_CONNECTION */
39099
39100 e |= DIO_PUT(action_probability, &dout, &field_addr, &real_packet->action_probabilities[i]);
39101 }
39102
39103#ifdef FREECIV_JSON_CONNECTION
39104 /* Exit array. */
39105 FC_FREE(field_addr.sub_location);
39106#endif /* FREECIV_JSON_CONNECTION */
39107 }
39108
39109 if (e) {
39110 log_packet_detailed("'action_probabilities' field error detected");
39111 }
39112#endif /* FREECIV_DELTA_PROTOCOL */
39113
39114 SEND_PACKET_END(PACKET_UNIT_ACTIONS);
39115}
39116
39117 int send_packet_unit_actions(struct connection *pc, const struct packet_unit_actions *packet)
39118{
39119 if (!pc->used) {
39120 log_error("WARNING: trying to send data to the closed connection %s",
39121 conn_description(pc));
39122 return -1;
39123 }
39124 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_ACTIONS].packet != nullptr, -1,
39125 "Handler for PACKET_UNIT_ACTIONS not installed");
39126 return pc->phs.handlers->send[PACKET_UNIT_ACTIONS].packet(pc, packet);
39127}
39128
39129 int dsend_packet_unit_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_city_id, int target_tile_id, int target_extra_id, int request_kind, const struct act_prob *action_probabilities)
39130{
39131 struct packet_unit_actions packet, *real_packet = &packet;
39132
39133 real_packet->actor_unit_id = actor_unit_id;
39134 real_packet->target_unit_id = target_unit_id;
39135 real_packet->target_city_id = target_city_id;
39136 real_packet->target_tile_id = target_tile_id;
39137 real_packet->target_extra_id = target_extra_id;
39138 real_packet->request_kind = request_kind;
39139 {
39140 int i;
39141
39142 for (i = 0; i < MAX_NUM_ACTIONS; i++) {
39143 real_packet->action_probabilities[i] = action_probabilities[i];
39144 }
39145 }
39146
39147 return send_packet_unit_actions(pc, real_packet);
39148}
39149
39150 static inline void init_packet_unit_change_activity(struct packet_unit_change_activity *packet)
39151{
39152 memset(packet, 0, sizeof(*packet));
39153}
39154
39155#define free_packet_unit_change_activity(_packet) (void) 0
39156#define destroy_packet_unit_change_activity free
39157
39158#ifdef FREECIV_DELTA_PROTOCOL
39159#define hash_packet_unit_change_activity_100 hash_const
39160#define cmp_packet_unit_change_activity_100 cmp_const
39161 BV_DEFINE(packet_unit_change_activity_100_fields, 3);
39162#endif /* FREECIV_DELTA_PROTOCOL */
39163
39164 static struct packet_unit_change_activity *receive_packet_unit_change_activity_100(struct connection *pc)
39165{
39166#define FREE_PACKET_STRUCT(_packet) free_packet_unit_change_activity(_packet)
39167 RECEIVE_PACKET_START(packet_unit_change_activity, real_packet);
39168
39169#ifdef FREECIV_JSON_CONNECTION
39170 struct plocation field_addr;
39171 {
39172 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39173 field_addr = *field_addr_tmp;
39174 FC_FREE(field_addr_tmp);
39175 }
39176#endif /* FREECIV_JSON_CONNECTION */
39177
39178 log_packet_detailed("packet_unit_change_activity_100: got info about ()");
39179
39180#ifdef FREECIV_DELTA_PROTOCOL
39181 packet_unit_change_activity_100_fields fields;
39182 struct packet_unit_change_activity *old;
39183 struct genhash **hash = pc->phs.received + PACKET_UNIT_CHANGE_ACTIVITY;
39184
39185 if (nullptr == *hash) {
39186 *hash = genhash_new_full(hash_packet_unit_change_activity_100, cmp_packet_unit_change_activity_100,
39187 nullptr, nullptr, nullptr, destroy_packet_unit_change_activity);
39188 }
39189
39190 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39191 *real_packet = *old;
39192 } else {
39193 /* packet is already initialized empty */
39194 log_packet_detailed(" no old info");
39195 }
39196
39197#ifdef FREECIV_JSON_CONNECTION
39198 field_addr.name = "fields";
39199#endif /* FREECIV_JSON_CONNECTION */
39200 DIO_BV_GET(&din, &field_addr, fields);
39201
39202 if (BV_ISSET(fields, 0)) {
39203 log_packet_detailed(" got field 'unit_id'");
39204
39205#ifdef FREECIV_JSON_CONNECTION
39206 field_addr.name = "unit_id";
39207#endif /* FREECIV_JSON_CONNECTION */
39208
39209 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
39210 RECEIVE_PACKET_FIELD_ERROR(unit_id);
39211 }
39212 }
39213
39214 if (BV_ISSET(fields, 1)) {
39215 log_packet_detailed(" got field 'activity'");
39216
39217#ifdef FREECIV_JSON_CONNECTION
39218 field_addr.name = "activity";
39219#endif /* FREECIV_JSON_CONNECTION */
39220
39221 {
39222 int readin;
39223
39224 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
39225 RECEIVE_PACKET_FIELD_ERROR(activity);
39226 }
39227 real_packet->activity = readin;
39228 }
39229 }
39230
39231 if (BV_ISSET(fields, 2)) {
39232 log_packet_detailed(" got field 'target'");
39233
39234#ifdef FREECIV_JSON_CONNECTION
39235 field_addr.name = "target";
39236#endif /* FREECIV_JSON_CONNECTION */
39237
39238 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->target)) {
39239 RECEIVE_PACKET_FIELD_ERROR(target);
39240 }
39241 }
39242
39243 if (nullptr == old) {
39244 old = fc_malloc(sizeof(*old));
39245 init_packet_unit_change_activity(old);
39246 *old = *real_packet;
39247 genhash_insert(*hash, old, old);
39248 } else {
39249 *old = *real_packet;
39250 }
39251
39252#else /* FREECIV_DELTA_PROTOCOL */
39253#ifdef FREECIV_JSON_CONNECTION
39254 field_addr.name = "unit_id";
39255#endif /* FREECIV_JSON_CONNECTION */
39256
39257 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->unit_id)) {
39258 RECEIVE_PACKET_FIELD_ERROR(unit_id);
39259 }
39260
39261#ifdef FREECIV_JSON_CONNECTION
39262 field_addr.name = "activity";
39263#endif /* FREECIV_JSON_CONNECTION */
39264
39265 {
39266 int readin;
39267
39268 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
39269 RECEIVE_PACKET_FIELD_ERROR(activity);
39270 }
39271 real_packet->activity = readin;
39272 }
39273
39274#ifdef FREECIV_JSON_CONNECTION
39275 field_addr.name = "target";
39276#endif /* FREECIV_JSON_CONNECTION */
39277
39278 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->target)) {
39279 RECEIVE_PACKET_FIELD_ERROR(target);
39280 }
39281#endif /* FREECIV_DELTA_PROTOCOL */
39282
39283 RECEIVE_PACKET_END(real_packet);
39284#undef FREE_PACKET_STRUCT
39285}
39286
39287 static int send_packet_unit_change_activity_100(struct connection *pc, const struct packet_unit_change_activity *packet)
39288{
39289 const struct packet_unit_change_activity *real_packet = packet;
39290 int e;
39291 SEND_PACKET_START(PACKET_UNIT_CHANGE_ACTIVITY);
39292
39293 log_packet_detailed("packet_unit_change_activity_100: sending info about ()");
39294
39295#ifdef FREECIV_DELTA_PROTOCOL
39296 packet_unit_change_activity_100_fields fields;
39297 struct packet_unit_change_activity *old;
39298 bool differ;
39299 struct genhash **hash = pc->phs.sent + PACKET_UNIT_CHANGE_ACTIVITY;
39300
39301 if (nullptr == *hash) {
39302 *hash = genhash_new_full(hash_packet_unit_change_activity_100, cmp_packet_unit_change_activity_100,
39303 nullptr, nullptr, nullptr, destroy_packet_unit_change_activity);
39304 }
39305 BV_CLR_ALL(fields);
39306
39307 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39308 old = fc_malloc(sizeof(*old));
39309 /* temporary bitcopy just to insert correctly */
39310 *old = *real_packet;
39311 genhash_insert(*hash, old, old);
39312 init_packet_unit_change_activity(old);
39313 }
39314
39315 differ = (old->unit_id != real_packet->unit_id);
39316 if (differ) {
39317 BV_SET(fields, 0);
39318 }
39319
39320 differ = (old->activity != real_packet->activity);
39321 if (differ) {
39322 BV_SET(fields, 1);
39323 }
39324
39325 differ = (old->target != real_packet->target);
39326 if (differ) {
39327 BV_SET(fields, 2);
39328 }
39329#endif /* FREECIV_DELTA_PROTOCOL */
39330
39331#ifdef FREECIV_JSON_CONNECTION
39332 struct plocation field_addr;
39333 {
39334 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39335 field_addr = *field_addr_tmp;
39336 FC_FREE(field_addr_tmp);
39337 }
39338#endif /* FREECIV_JSON_CONNECTION */
39339
39340#ifdef FREECIV_DELTA_PROTOCOL
39341#ifdef FREECIV_JSON_CONNECTION
39342 field_addr.name = "fields";
39343#endif /* FREECIV_JSON_CONNECTION */
39344 e = 0;
39345 e |= DIO_BV_PUT(&dout, &field_addr, fields);
39346 if (e) {
39347 log_packet_detailed("fields bitvector error detected");
39348 }
39349
39350 if (BV_ISSET(fields, 0)) {
39351 log_packet_detailed(" field 'unit_id' has changed");
39352
39353#ifdef FREECIV_JSON_CONNECTION
39354 field_addr.name = "unit_id";
39355#endif /* FREECIV_JSON_CONNECTION */
39356 e = 0;
39357
39358 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
39359
39360 if (e) {
39361 log_packet_detailed("'unit_id' field error detected");
39362 }
39363 }
39364
39365 if (BV_ISSET(fields, 1)) {
39366 log_packet_detailed(" field 'activity' has changed");
39367
39368#ifdef FREECIV_JSON_CONNECTION
39369 field_addr.name = "activity";
39370#endif /* FREECIV_JSON_CONNECTION */
39371 e = 0;
39372
39373 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
39374
39375 if (e) {
39376 log_packet_detailed("'activity' field error detected");
39377 }
39378 }
39379
39380 if (BV_ISSET(fields, 2)) {
39381 log_packet_detailed(" field 'target' has changed");
39382
39383#ifdef FREECIV_JSON_CONNECTION
39384 field_addr.name = "target";
39385#endif /* FREECIV_JSON_CONNECTION */
39386 e = 0;
39387
39388 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target);
39389
39390 if (e) {
39391 log_packet_detailed("'target' field error detected");
39392 }
39393 }
39394
39395 *old = *real_packet;
39396
39397#else /* FREECIV_DELTA_PROTOCOL */
39398#ifdef FREECIV_JSON_CONNECTION
39399 field_addr.name = "unit_id";
39400#endif /* FREECIV_JSON_CONNECTION */
39401 e = 0;
39402
39403 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->unit_id);
39404
39405 if (e) {
39406 log_packet_detailed("'unit_id' field error detected");
39407 }
39408
39409#ifdef FREECIV_JSON_CONNECTION
39410 field_addr.name = "activity";
39411#endif /* FREECIV_JSON_CONNECTION */
39412 e = 0;
39413
39414 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
39415
39416 if (e) {
39417 log_packet_detailed("'activity' field error detected");
39418 }
39419
39420#ifdef FREECIV_JSON_CONNECTION
39421 field_addr.name = "target";
39422#endif /* FREECIV_JSON_CONNECTION */
39423 e = 0;
39424
39425 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target);
39426
39427 if (e) {
39428 log_packet_detailed("'target' field error detected");
39429 }
39430#endif /* FREECIV_DELTA_PROTOCOL */
39431
39432 SEND_PACKET_END(PACKET_UNIT_CHANGE_ACTIVITY);
39433}
39434
39435 int send_packet_unit_change_activity(struct connection *pc, const struct packet_unit_change_activity *packet)
39436{
39437 if (!pc->used) {
39438 log_error("WARNING: trying to send data to the closed connection %s",
39439 conn_description(pc));
39440 return -1;
39441 }
39442 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_UNIT_CHANGE_ACTIVITY].packet != nullptr, -1,
39443 "Handler for PACKET_UNIT_CHANGE_ACTIVITY not installed");
39444 return pc->phs.handlers->send[PACKET_UNIT_CHANGE_ACTIVITY].packet(pc, packet);
39445}
39446
39447 int dsend_packet_unit_change_activity(struct connection *pc, int unit_id, enum unit_activity activity, int target)
39448{
39449 struct packet_unit_change_activity packet, *real_packet = &packet;
39450
39451 real_packet->unit_id = unit_id;
39452 real_packet->activity = activity;
39453 real_packet->target = target;
39454
39455 return send_packet_unit_change_activity(pc, real_packet);
39456}
39457
39458 static inline void init_packet_diplomacy_init_meeting_req(struct packet_diplomacy_init_meeting_req *packet)
39459{
39460 memset(packet, 0, sizeof(*packet));
39461}
39462
39463#define free_packet_diplomacy_init_meeting_req(_packet) (void) 0
39464#define destroy_packet_diplomacy_init_meeting_req free
39465
39466#ifdef FREECIV_DELTA_PROTOCOL
39467#define hash_packet_diplomacy_init_meeting_req_100 hash_const
39468#define cmp_packet_diplomacy_init_meeting_req_100 cmp_const
39469 BV_DEFINE(packet_diplomacy_init_meeting_req_100_fields, 1);
39470#endif /* FREECIV_DELTA_PROTOCOL */
39471
39472 static struct packet_diplomacy_init_meeting_req *receive_packet_diplomacy_init_meeting_req_100(struct connection *pc)
39473{
39474#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_init_meeting_req(_packet)
39475 RECEIVE_PACKET_START(packet_diplomacy_init_meeting_req, real_packet);
39476
39477#ifdef FREECIV_JSON_CONNECTION
39478 struct plocation field_addr;
39479 {
39480 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39481 field_addr = *field_addr_tmp;
39482 FC_FREE(field_addr_tmp);
39483 }
39484#endif /* FREECIV_JSON_CONNECTION */
39485
39486 log_packet_detailed("packet_diplomacy_init_meeting_req_100: got info about ()");
39487
39488#ifdef FREECIV_DELTA_PROTOCOL
39489 packet_diplomacy_init_meeting_req_100_fields fields;
39490 struct packet_diplomacy_init_meeting_req *old;
39491 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_INIT_MEETING_REQ;
39492
39493 if (nullptr == *hash) {
39494 *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_req_100, cmp_packet_diplomacy_init_meeting_req_100,
39495 nullptr, nullptr, nullptr, destroy_packet_diplomacy_init_meeting_req);
39496 }
39497
39498 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39499 *real_packet = *old;
39500 } else {
39501 /* packet is already initialized empty */
39502 log_packet_detailed(" no old info");
39503 }
39504
39505#ifdef FREECIV_JSON_CONNECTION
39506 field_addr.name = "fields";
39507#endif /* FREECIV_JSON_CONNECTION */
39508 DIO_BV_GET(&din, &field_addr, fields);
39509
39510 if (BV_ISSET(fields, 0)) {
39511 log_packet_detailed(" got field 'counterpart'");
39512
39513#ifdef FREECIV_JSON_CONNECTION
39514 field_addr.name = "counterpart";
39515#endif /* FREECIV_JSON_CONNECTION */
39516
39517 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
39518 RECEIVE_PACKET_FIELD_ERROR(counterpart);
39519 }
39520 }
39521
39522 if (nullptr == old) {
39523 old = fc_malloc(sizeof(*old));
39524 init_packet_diplomacy_init_meeting_req(old);
39525 *old = *real_packet;
39526 genhash_insert(*hash, old, old);
39527 } else {
39528 *old = *real_packet;
39529 }
39530
39531#else /* FREECIV_DELTA_PROTOCOL */
39532#ifdef FREECIV_JSON_CONNECTION
39533 field_addr.name = "counterpart";
39534#endif /* FREECIV_JSON_CONNECTION */
39535
39536 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
39537 RECEIVE_PACKET_FIELD_ERROR(counterpart);
39538 }
39539#endif /* FREECIV_DELTA_PROTOCOL */
39540
39541 RECEIVE_PACKET_END(real_packet);
39542#undef FREE_PACKET_STRUCT
39543}
39544
39545 static int send_packet_diplomacy_init_meeting_req_100(struct connection *pc, const struct packet_diplomacy_init_meeting_req *packet)
39546{
39547 const struct packet_diplomacy_init_meeting_req *real_packet = packet;
39548 int e;
39549 SEND_PACKET_START(PACKET_DIPLOMACY_INIT_MEETING_REQ);
39550
39551 log_packet_detailed("packet_diplomacy_init_meeting_req_100: sending info about ()");
39552
39553#ifdef FREECIV_DELTA_PROTOCOL
39554 packet_diplomacy_init_meeting_req_100_fields fields;
39555 struct packet_diplomacy_init_meeting_req *old;
39556 bool differ;
39557 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_INIT_MEETING_REQ;
39558
39559 if (nullptr == *hash) {
39560 *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_req_100, cmp_packet_diplomacy_init_meeting_req_100,
39561 nullptr, nullptr, nullptr, destroy_packet_diplomacy_init_meeting_req);
39562 }
39563 BV_CLR_ALL(fields);
39564
39565 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39566 old = fc_malloc(sizeof(*old));
39567 /* temporary bitcopy just to insert correctly */
39568 *old = *real_packet;
39569 genhash_insert(*hash, old, old);
39570 init_packet_diplomacy_init_meeting_req(old);
39571 }
39572
39573 differ = (old->counterpart != real_packet->counterpart);
39574 if (differ) {
39575 BV_SET(fields, 0);
39576 }
39577#endif /* FREECIV_DELTA_PROTOCOL */
39578
39579#ifdef FREECIV_JSON_CONNECTION
39580 struct plocation field_addr;
39581 {
39582 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39583 field_addr = *field_addr_tmp;
39584 FC_FREE(field_addr_tmp);
39585 }
39586#endif /* FREECIV_JSON_CONNECTION */
39587
39588#ifdef FREECIV_DELTA_PROTOCOL
39589#ifdef FREECIV_JSON_CONNECTION
39590 field_addr.name = "fields";
39591#endif /* FREECIV_JSON_CONNECTION */
39592 e = 0;
39593 e |= DIO_BV_PUT(&dout, &field_addr, fields);
39594 if (e) {
39595 log_packet_detailed("fields bitvector error detected");
39596 }
39597
39598 if (BV_ISSET(fields, 0)) {
39599 log_packet_detailed(" field 'counterpart' has changed");
39600
39601#ifdef FREECIV_JSON_CONNECTION
39602 field_addr.name = "counterpart";
39603#endif /* FREECIV_JSON_CONNECTION */
39604 e = 0;
39605
39606 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
39607
39608 if (e) {
39609 log_packet_detailed("'counterpart' field error detected");
39610 }
39611 }
39612
39613 *old = *real_packet;
39614
39615#else /* FREECIV_DELTA_PROTOCOL */
39616#ifdef FREECIV_JSON_CONNECTION
39617 field_addr.name = "counterpart";
39618#endif /* FREECIV_JSON_CONNECTION */
39619 e = 0;
39620
39621 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
39622
39623 if (e) {
39624 log_packet_detailed("'counterpart' field error detected");
39625 }
39626#endif /* FREECIV_DELTA_PROTOCOL */
39627
39628 SEND_PACKET_END(PACKET_DIPLOMACY_INIT_MEETING_REQ);
39629}
39630
39631 int send_packet_diplomacy_init_meeting_req(struct connection *pc, const struct packet_diplomacy_init_meeting_req *packet)
39632{
39633 if (!pc->used) {
39634 log_error("WARNING: trying to send data to the closed connection %s",
39635 conn_description(pc));
39636 return -1;
39637 }
39638 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING_REQ].packet != nullptr, -1,
39639 "Handler for PACKET_DIPLOMACY_INIT_MEETING_REQ not installed");
39640 return pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING_REQ].packet(pc, packet);
39641}
39642
39643 int dsend_packet_diplomacy_init_meeting_req(struct connection *pc, int counterpart)
39644{
39645 struct packet_diplomacy_init_meeting_req packet, *real_packet = &packet;
39646
39647 real_packet->counterpart = counterpart;
39648
39649 return send_packet_diplomacy_init_meeting_req(pc, real_packet);
39650}
39651
39652 static inline void init_packet_diplomacy_init_meeting(struct packet_diplomacy_init_meeting *packet)
39653{
39654 memset(packet, 0, sizeof(*packet));
39655}
39656
39657#define free_packet_diplomacy_init_meeting(_packet) (void) 0
39658#define destroy_packet_diplomacy_init_meeting free
39659
39660#ifdef FREECIV_DELTA_PROTOCOL
39661#define hash_packet_diplomacy_init_meeting_100 hash_const
39662#define cmp_packet_diplomacy_init_meeting_100 cmp_const
39663 BV_DEFINE(packet_diplomacy_init_meeting_100_fields, 2);
39664#endif /* FREECIV_DELTA_PROTOCOL */
39665
39666 static struct packet_diplomacy_init_meeting *receive_packet_diplomacy_init_meeting_100(struct connection *pc)
39667{
39668#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_init_meeting(_packet)
39669 RECEIVE_PACKET_START(packet_diplomacy_init_meeting, real_packet);
39670
39671#ifdef FREECIV_JSON_CONNECTION
39672 struct plocation field_addr;
39673 {
39674 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39675 field_addr = *field_addr_tmp;
39676 FC_FREE(field_addr_tmp);
39677 }
39678#endif /* FREECIV_JSON_CONNECTION */
39679
39680 log_packet_detailed("packet_diplomacy_init_meeting_100: got info about ()");
39681
39682#ifdef FREECIV_DELTA_PROTOCOL
39683 packet_diplomacy_init_meeting_100_fields fields;
39684 struct packet_diplomacy_init_meeting *old;
39685 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_INIT_MEETING;
39686
39687 if (nullptr == *hash) {
39688 *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_100, cmp_packet_diplomacy_init_meeting_100,
39689 nullptr, nullptr, nullptr, destroy_packet_diplomacy_init_meeting);
39690 }
39691
39692 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39693 *real_packet = *old;
39694 } else {
39695 /* packet is already initialized empty */
39696 log_packet_detailed(" no old info");
39697 }
39698
39699#ifdef FREECIV_JSON_CONNECTION
39700 field_addr.name = "fields";
39701#endif /* FREECIV_JSON_CONNECTION */
39702 DIO_BV_GET(&din, &field_addr, fields);
39703
39704 if (BV_ISSET(fields, 0)) {
39705 log_packet_detailed(" got field 'counterpart'");
39706
39707#ifdef FREECIV_JSON_CONNECTION
39708 field_addr.name = "counterpart";
39709#endif /* FREECIV_JSON_CONNECTION */
39710
39711 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
39712 RECEIVE_PACKET_FIELD_ERROR(counterpart);
39713 }
39714 }
39715
39716 if (BV_ISSET(fields, 1)) {
39717 log_packet_detailed(" got field 'initiated_from'");
39718
39719#ifdef FREECIV_JSON_CONNECTION
39720 field_addr.name = "initiated_from";
39721#endif /* FREECIV_JSON_CONNECTION */
39722
39723 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->initiated_from)) {
39724 RECEIVE_PACKET_FIELD_ERROR(initiated_from);
39725 }
39726 }
39727
39728 if (nullptr == old) {
39729 old = fc_malloc(sizeof(*old));
39730 init_packet_diplomacy_init_meeting(old);
39731 *old = *real_packet;
39732 genhash_insert(*hash, old, old);
39733 } else {
39734 *old = *real_packet;
39735 }
39736
39737#else /* FREECIV_DELTA_PROTOCOL */
39738#ifdef FREECIV_JSON_CONNECTION
39739 field_addr.name = "counterpart";
39740#endif /* FREECIV_JSON_CONNECTION */
39741
39742 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
39743 RECEIVE_PACKET_FIELD_ERROR(counterpart);
39744 }
39745
39746#ifdef FREECIV_JSON_CONNECTION
39747 field_addr.name = "initiated_from";
39748#endif /* FREECIV_JSON_CONNECTION */
39749
39750 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->initiated_from)) {
39751 RECEIVE_PACKET_FIELD_ERROR(initiated_from);
39752 }
39753#endif /* FREECIV_DELTA_PROTOCOL */
39754
39755 RECEIVE_PACKET_END(real_packet);
39756#undef FREE_PACKET_STRUCT
39757}
39758
39759 static int send_packet_diplomacy_init_meeting_100(struct connection *pc, const struct packet_diplomacy_init_meeting *packet)
39760{
39761 const struct packet_diplomacy_init_meeting *real_packet = packet;
39762 int e;
39763 SEND_PACKET_START(PACKET_DIPLOMACY_INIT_MEETING);
39764
39765 log_packet_detailed("packet_diplomacy_init_meeting_100: sending info about ()");
39766
39767#ifdef FREECIV_DELTA_PROTOCOL
39768 packet_diplomacy_init_meeting_100_fields fields;
39769 struct packet_diplomacy_init_meeting *old;
39770 bool differ;
39771 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_INIT_MEETING;
39772
39773 if (nullptr == *hash) {
39774 *hash = genhash_new_full(hash_packet_diplomacy_init_meeting_100, cmp_packet_diplomacy_init_meeting_100,
39775 nullptr, nullptr, nullptr, destroy_packet_diplomacy_init_meeting);
39776 }
39777 BV_CLR_ALL(fields);
39778
39779 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
39780 old = fc_malloc(sizeof(*old));
39781 /* temporary bitcopy just to insert correctly */
39782 *old = *real_packet;
39783 genhash_insert(*hash, old, old);
39784 init_packet_diplomacy_init_meeting(old);
39785 }
39786
39787 differ = (old->counterpart != real_packet->counterpart);
39788 if (differ) {
39789 BV_SET(fields, 0);
39790 }
39791
39792 differ = (old->initiated_from != real_packet->initiated_from);
39793 if (differ) {
39794 BV_SET(fields, 1);
39795 }
39796#endif /* FREECIV_DELTA_PROTOCOL */
39797
39798#ifdef FREECIV_JSON_CONNECTION
39799 struct plocation field_addr;
39800 {
39801 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39802 field_addr = *field_addr_tmp;
39803 FC_FREE(field_addr_tmp);
39804 }
39805#endif /* FREECIV_JSON_CONNECTION */
39806
39807#ifdef FREECIV_DELTA_PROTOCOL
39808#ifdef FREECIV_JSON_CONNECTION
39809 field_addr.name = "fields";
39810#endif /* FREECIV_JSON_CONNECTION */
39811 e = 0;
39812 e |= DIO_BV_PUT(&dout, &field_addr, fields);
39813 if (e) {
39814 log_packet_detailed("fields bitvector error detected");
39815 }
39816
39817 if (BV_ISSET(fields, 0)) {
39818 log_packet_detailed(" field 'counterpart' has changed");
39819
39820#ifdef FREECIV_JSON_CONNECTION
39821 field_addr.name = "counterpart";
39822#endif /* FREECIV_JSON_CONNECTION */
39823 e = 0;
39824
39825 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
39826
39827 if (e) {
39828 log_packet_detailed("'counterpart' field error detected");
39829 }
39830 }
39831
39832 if (BV_ISSET(fields, 1)) {
39833 log_packet_detailed(" field 'initiated_from' has changed");
39834
39835#ifdef FREECIV_JSON_CONNECTION
39836 field_addr.name = "initiated_from";
39837#endif /* FREECIV_JSON_CONNECTION */
39838 e = 0;
39839
39840 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->initiated_from);
39841
39842 if (e) {
39843 log_packet_detailed("'initiated_from' field error detected");
39844 }
39845 }
39846
39847 *old = *real_packet;
39848
39849#else /* FREECIV_DELTA_PROTOCOL */
39850#ifdef FREECIV_JSON_CONNECTION
39851 field_addr.name = "counterpart";
39852#endif /* FREECIV_JSON_CONNECTION */
39853 e = 0;
39854
39855 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
39856
39857 if (e) {
39858 log_packet_detailed("'counterpart' field error detected");
39859 }
39860
39861#ifdef FREECIV_JSON_CONNECTION
39862 field_addr.name = "initiated_from";
39863#endif /* FREECIV_JSON_CONNECTION */
39864 e = 0;
39865
39866 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->initiated_from);
39867
39868 if (e) {
39869 log_packet_detailed("'initiated_from' field error detected");
39870 }
39871#endif /* FREECIV_DELTA_PROTOCOL */
39872
39873 SEND_PACKET_END(PACKET_DIPLOMACY_INIT_MEETING);
39874}
39875
39876 int send_packet_diplomacy_init_meeting(struct connection *pc, const struct packet_diplomacy_init_meeting *packet)
39877{
39878 if (!pc->used) {
39879 log_error("WARNING: trying to send data to the closed connection %s",
39880 conn_description(pc));
39881 return -1;
39882 }
39883 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING].packet != nullptr, -1,
39884 "Handler for PACKET_DIPLOMACY_INIT_MEETING not installed");
39885 return pc->phs.handlers->send[PACKET_DIPLOMACY_INIT_MEETING].packet(pc, packet);
39886}
39887
39888 void lsend_packet_diplomacy_init_meeting(struct conn_list *dest, const struct packet_diplomacy_init_meeting *packet)
39889{
39890 conn_list_iterate(dest, pconn) {
39891 send_packet_diplomacy_init_meeting(pconn, packet);
39892 } conn_list_iterate_end;
39893}
39894
39895 int dsend_packet_diplomacy_init_meeting(struct connection *pc, int counterpart, int initiated_from)
39896{
39897 struct packet_diplomacy_init_meeting packet, *real_packet = &packet;
39898
39899 real_packet->counterpart = counterpart;
39900 real_packet->initiated_from = initiated_from;
39901
39902 return send_packet_diplomacy_init_meeting(pc, real_packet);
39903}
39904
39905 void dlsend_packet_diplomacy_init_meeting(struct conn_list *dest, int counterpart, int initiated_from)
39906{
39907 struct packet_diplomacy_init_meeting packet, *real_packet = &packet;
39908
39909 real_packet->counterpart = counterpart;
39910 real_packet->initiated_from = initiated_from;
39911
39912 lsend_packet_diplomacy_init_meeting(dest, real_packet);
39913}
39914
39915 static inline void init_packet_diplomacy_cancel_meeting_req(struct packet_diplomacy_cancel_meeting_req *packet)
39916{
39917 memset(packet, 0, sizeof(*packet));
39918}
39919
39920#define free_packet_diplomacy_cancel_meeting_req(_packet) (void) 0
39921#define destroy_packet_diplomacy_cancel_meeting_req free
39922
39923#ifdef FREECIV_DELTA_PROTOCOL
39924#define hash_packet_diplomacy_cancel_meeting_req_100 hash_const
39925#define cmp_packet_diplomacy_cancel_meeting_req_100 cmp_const
39926 BV_DEFINE(packet_diplomacy_cancel_meeting_req_100_fields, 1);
39927#endif /* FREECIV_DELTA_PROTOCOL */
39928
39929 static struct packet_diplomacy_cancel_meeting_req *receive_packet_diplomacy_cancel_meeting_req_100(struct connection *pc)
39930{
39931#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_cancel_meeting_req(_packet)
39932 RECEIVE_PACKET_START(packet_diplomacy_cancel_meeting_req, real_packet);
39933
39934#ifdef FREECIV_JSON_CONNECTION
39935 struct plocation field_addr;
39936 {
39937 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
39938 field_addr = *field_addr_tmp;
39939 FC_FREE(field_addr_tmp);
39940 }
39941#endif /* FREECIV_JSON_CONNECTION */
39942
39943 log_packet_detailed("packet_diplomacy_cancel_meeting_req_100: got info about ()");
39944
39945#ifdef FREECIV_DELTA_PROTOCOL
39946 packet_diplomacy_cancel_meeting_req_100_fields fields;
39947 struct packet_diplomacy_cancel_meeting_req *old;
39948 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CANCEL_MEETING_REQ;
39949
39950 if (nullptr == *hash) {
39951 *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_req_100, cmp_packet_diplomacy_cancel_meeting_req_100,
39952 nullptr, nullptr, nullptr, destroy_packet_diplomacy_cancel_meeting_req);
39953 }
39954
39955 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
39956 *real_packet = *old;
39957 } else {
39958 /* packet is already initialized empty */
39959 log_packet_detailed(" no old info");
39960 }
39961
39962#ifdef FREECIV_JSON_CONNECTION
39963 field_addr.name = "fields";
39964#endif /* FREECIV_JSON_CONNECTION */
39965 DIO_BV_GET(&din, &field_addr, fields);
39966
39967 if (BV_ISSET(fields, 0)) {
39968 log_packet_detailed(" got field 'counterpart'");
39969
39970#ifdef FREECIV_JSON_CONNECTION
39971 field_addr.name = "counterpart";
39972#endif /* FREECIV_JSON_CONNECTION */
39973
39974 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
39975 RECEIVE_PACKET_FIELD_ERROR(counterpart);
39976 }
39977 }
39978
39979 if (nullptr == old) {
39980 old = fc_malloc(sizeof(*old));
39981 init_packet_diplomacy_cancel_meeting_req(old);
39982 *old = *real_packet;
39983 genhash_insert(*hash, old, old);
39984 } else {
39985 *old = *real_packet;
39986 }
39987
39988#else /* FREECIV_DELTA_PROTOCOL */
39989#ifdef FREECIV_JSON_CONNECTION
39990 field_addr.name = "counterpart";
39991#endif /* FREECIV_JSON_CONNECTION */
39992
39993 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
39994 RECEIVE_PACKET_FIELD_ERROR(counterpart);
39995 }
39996#endif /* FREECIV_DELTA_PROTOCOL */
39997
39998 RECEIVE_PACKET_END(real_packet);
39999#undef FREE_PACKET_STRUCT
40000}
40001
40002 static int send_packet_diplomacy_cancel_meeting_req_100(struct connection *pc, const struct packet_diplomacy_cancel_meeting_req *packet)
40003{
40004 const struct packet_diplomacy_cancel_meeting_req *real_packet = packet;
40005 int e;
40006 SEND_PACKET_START(PACKET_DIPLOMACY_CANCEL_MEETING_REQ);
40007
40008 log_packet_detailed("packet_diplomacy_cancel_meeting_req_100: sending info about ()");
40009
40010#ifdef FREECIV_DELTA_PROTOCOL
40011 packet_diplomacy_cancel_meeting_req_100_fields fields;
40012 struct packet_diplomacy_cancel_meeting_req *old;
40013 bool differ;
40014 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CANCEL_MEETING_REQ;
40015
40016 if (nullptr == *hash) {
40017 *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_req_100, cmp_packet_diplomacy_cancel_meeting_req_100,
40018 nullptr, nullptr, nullptr, destroy_packet_diplomacy_cancel_meeting_req);
40019 }
40020 BV_CLR_ALL(fields);
40021
40022 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40023 old = fc_malloc(sizeof(*old));
40024 /* temporary bitcopy just to insert correctly */
40025 *old = *real_packet;
40026 genhash_insert(*hash, old, old);
40027 init_packet_diplomacy_cancel_meeting_req(old);
40028 }
40029
40030 differ = (old->counterpart != real_packet->counterpart);
40031 if (differ) {
40032 BV_SET(fields, 0);
40033 }
40034#endif /* FREECIV_DELTA_PROTOCOL */
40035
40036#ifdef FREECIV_JSON_CONNECTION
40037 struct plocation field_addr;
40038 {
40039 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40040 field_addr = *field_addr_tmp;
40041 FC_FREE(field_addr_tmp);
40042 }
40043#endif /* FREECIV_JSON_CONNECTION */
40044
40045#ifdef FREECIV_DELTA_PROTOCOL
40046#ifdef FREECIV_JSON_CONNECTION
40047 field_addr.name = "fields";
40048#endif /* FREECIV_JSON_CONNECTION */
40049 e = 0;
40050 e |= DIO_BV_PUT(&dout, &field_addr, fields);
40051 if (e) {
40052 log_packet_detailed("fields bitvector error detected");
40053 }
40054
40055 if (BV_ISSET(fields, 0)) {
40056 log_packet_detailed(" field 'counterpart' has changed");
40057
40058#ifdef FREECIV_JSON_CONNECTION
40059 field_addr.name = "counterpart";
40060#endif /* FREECIV_JSON_CONNECTION */
40061 e = 0;
40062
40063 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40064
40065 if (e) {
40066 log_packet_detailed("'counterpart' field error detected");
40067 }
40068 }
40069
40070 *old = *real_packet;
40071
40072#else /* FREECIV_DELTA_PROTOCOL */
40073#ifdef FREECIV_JSON_CONNECTION
40074 field_addr.name = "counterpart";
40075#endif /* FREECIV_JSON_CONNECTION */
40076 e = 0;
40077
40078 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40079
40080 if (e) {
40081 log_packet_detailed("'counterpart' field error detected");
40082 }
40083#endif /* FREECIV_DELTA_PROTOCOL */
40084
40085 SEND_PACKET_END(PACKET_DIPLOMACY_CANCEL_MEETING_REQ);
40086}
40087
40088 int send_packet_diplomacy_cancel_meeting_req(struct connection *pc, const struct packet_diplomacy_cancel_meeting_req *packet)
40089{
40090 if (!pc->used) {
40091 log_error("WARNING: trying to send data to the closed connection %s",
40092 conn_description(pc));
40093 return -1;
40094 }
40095 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING_REQ].packet != nullptr, -1,
40096 "Handler for PACKET_DIPLOMACY_CANCEL_MEETING_REQ not installed");
40097 return pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING_REQ].packet(pc, packet);
40098}
40099
40100 int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
40101{
40102 struct packet_diplomacy_cancel_meeting_req packet, *real_packet = &packet;
40103
40104 real_packet->counterpart = counterpart;
40105
40106 return send_packet_diplomacy_cancel_meeting_req(pc, real_packet);
40107}
40108
40109 static inline void init_packet_diplomacy_cancel_meeting(struct packet_diplomacy_cancel_meeting *packet)
40110{
40111 memset(packet, 0, sizeof(*packet));
40112}
40113
40114#define free_packet_diplomacy_cancel_meeting(_packet) (void) 0
40115#define destroy_packet_diplomacy_cancel_meeting free
40116
40117#ifdef FREECIV_DELTA_PROTOCOL
40118#define hash_packet_diplomacy_cancel_meeting_100 hash_const
40119#define cmp_packet_diplomacy_cancel_meeting_100 cmp_const
40120 BV_DEFINE(packet_diplomacy_cancel_meeting_100_fields, 2);
40121#endif /* FREECIV_DELTA_PROTOCOL */
40122
40123 static struct packet_diplomacy_cancel_meeting *receive_packet_diplomacy_cancel_meeting_100(struct connection *pc)
40124{
40125#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_cancel_meeting(_packet)
40126 RECEIVE_PACKET_START(packet_diplomacy_cancel_meeting, real_packet);
40127
40128#ifdef FREECIV_JSON_CONNECTION
40129 struct plocation field_addr;
40130 {
40131 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40132 field_addr = *field_addr_tmp;
40133 FC_FREE(field_addr_tmp);
40134 }
40135#endif /* FREECIV_JSON_CONNECTION */
40136
40137 log_packet_detailed("packet_diplomacy_cancel_meeting_100: got info about ()");
40138
40139#ifdef FREECIV_DELTA_PROTOCOL
40140 packet_diplomacy_cancel_meeting_100_fields fields;
40141 struct packet_diplomacy_cancel_meeting *old;
40142 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CANCEL_MEETING;
40143
40144 if (nullptr == *hash) {
40145 *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_100, cmp_packet_diplomacy_cancel_meeting_100,
40146 nullptr, nullptr, nullptr, destroy_packet_diplomacy_cancel_meeting);
40147 }
40148
40149 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
40150 *real_packet = *old;
40151 } else {
40152 /* packet is already initialized empty */
40153 log_packet_detailed(" no old info");
40154 }
40155
40156#ifdef FREECIV_JSON_CONNECTION
40157 field_addr.name = "fields";
40158#endif /* FREECIV_JSON_CONNECTION */
40159 DIO_BV_GET(&din, &field_addr, fields);
40160
40161 if (BV_ISSET(fields, 0)) {
40162 log_packet_detailed(" got field 'counterpart'");
40163
40164#ifdef FREECIV_JSON_CONNECTION
40165 field_addr.name = "counterpart";
40166#endif /* FREECIV_JSON_CONNECTION */
40167
40168 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
40169 RECEIVE_PACKET_FIELD_ERROR(counterpart);
40170 }
40171 }
40172
40173 if (BV_ISSET(fields, 1)) {
40174 log_packet_detailed(" got field 'initiated_from'");
40175
40176#ifdef FREECIV_JSON_CONNECTION
40177 field_addr.name = "initiated_from";
40178#endif /* FREECIV_JSON_CONNECTION */
40179
40180 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->initiated_from)) {
40181 RECEIVE_PACKET_FIELD_ERROR(initiated_from);
40182 }
40183 }
40184
40185 if (nullptr == old) {
40186 old = fc_malloc(sizeof(*old));
40187 init_packet_diplomacy_cancel_meeting(old);
40188 *old = *real_packet;
40189 genhash_insert(*hash, old, old);
40190 } else {
40191 *old = *real_packet;
40192 }
40193
40194#else /* FREECIV_DELTA_PROTOCOL */
40195#ifdef FREECIV_JSON_CONNECTION
40196 field_addr.name = "counterpart";
40197#endif /* FREECIV_JSON_CONNECTION */
40198
40199 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
40200 RECEIVE_PACKET_FIELD_ERROR(counterpart);
40201 }
40202
40203#ifdef FREECIV_JSON_CONNECTION
40204 field_addr.name = "initiated_from";
40205#endif /* FREECIV_JSON_CONNECTION */
40206
40207 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->initiated_from)) {
40208 RECEIVE_PACKET_FIELD_ERROR(initiated_from);
40209 }
40210#endif /* FREECIV_DELTA_PROTOCOL */
40211
40212 RECEIVE_PACKET_END(real_packet);
40213#undef FREE_PACKET_STRUCT
40214}
40215
40216 static int send_packet_diplomacy_cancel_meeting_100(struct connection *pc, const struct packet_diplomacy_cancel_meeting *packet)
40217{
40218 const struct packet_diplomacy_cancel_meeting *real_packet = packet;
40219 int e;
40220 SEND_PACKET_START(PACKET_DIPLOMACY_CANCEL_MEETING);
40221
40222 log_packet_detailed("packet_diplomacy_cancel_meeting_100: sending info about ()");
40223
40224#ifdef FREECIV_DELTA_PROTOCOL
40225 packet_diplomacy_cancel_meeting_100_fields fields;
40226 struct packet_diplomacy_cancel_meeting *old;
40227 bool differ;
40228 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CANCEL_MEETING;
40229
40230 if (nullptr == *hash) {
40231 *hash = genhash_new_full(hash_packet_diplomacy_cancel_meeting_100, cmp_packet_diplomacy_cancel_meeting_100,
40232 nullptr, nullptr, nullptr, destroy_packet_diplomacy_cancel_meeting);
40233 }
40234 BV_CLR_ALL(fields);
40235
40236 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40237 old = fc_malloc(sizeof(*old));
40238 /* temporary bitcopy just to insert correctly */
40239 *old = *real_packet;
40240 genhash_insert(*hash, old, old);
40241 init_packet_diplomacy_cancel_meeting(old);
40242 }
40243
40244 differ = (old->counterpart != real_packet->counterpart);
40245 if (differ) {
40246 BV_SET(fields, 0);
40247 }
40248
40249 differ = (old->initiated_from != real_packet->initiated_from);
40250 if (differ) {
40251 BV_SET(fields, 1);
40252 }
40253#endif /* FREECIV_DELTA_PROTOCOL */
40254
40255#ifdef FREECIV_JSON_CONNECTION
40256 struct plocation field_addr;
40257 {
40258 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40259 field_addr = *field_addr_tmp;
40260 FC_FREE(field_addr_tmp);
40261 }
40262#endif /* FREECIV_JSON_CONNECTION */
40263
40264#ifdef FREECIV_DELTA_PROTOCOL
40265#ifdef FREECIV_JSON_CONNECTION
40266 field_addr.name = "fields";
40267#endif /* FREECIV_JSON_CONNECTION */
40268 e = 0;
40269 e |= DIO_BV_PUT(&dout, &field_addr, fields);
40270 if (e) {
40271 log_packet_detailed("fields bitvector error detected");
40272 }
40273
40274 if (BV_ISSET(fields, 0)) {
40275 log_packet_detailed(" field 'counterpart' has changed");
40276
40277#ifdef FREECIV_JSON_CONNECTION
40278 field_addr.name = "counterpart";
40279#endif /* FREECIV_JSON_CONNECTION */
40280 e = 0;
40281
40282 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40283
40284 if (e) {
40285 log_packet_detailed("'counterpart' field error detected");
40286 }
40287 }
40288
40289 if (BV_ISSET(fields, 1)) {
40290 log_packet_detailed(" field 'initiated_from' has changed");
40291
40292#ifdef FREECIV_JSON_CONNECTION
40293 field_addr.name = "initiated_from";
40294#endif /* FREECIV_JSON_CONNECTION */
40295 e = 0;
40296
40297 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->initiated_from);
40298
40299 if (e) {
40300 log_packet_detailed("'initiated_from' field error detected");
40301 }
40302 }
40303
40304 *old = *real_packet;
40305
40306#else /* FREECIV_DELTA_PROTOCOL */
40307#ifdef FREECIV_JSON_CONNECTION
40308 field_addr.name = "counterpart";
40309#endif /* FREECIV_JSON_CONNECTION */
40310 e = 0;
40311
40312 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40313
40314 if (e) {
40315 log_packet_detailed("'counterpart' field error detected");
40316 }
40317
40318#ifdef FREECIV_JSON_CONNECTION
40319 field_addr.name = "initiated_from";
40320#endif /* FREECIV_JSON_CONNECTION */
40321 e = 0;
40322
40323 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->initiated_from);
40324
40325 if (e) {
40326 log_packet_detailed("'initiated_from' field error detected");
40327 }
40328#endif /* FREECIV_DELTA_PROTOCOL */
40329
40330 SEND_PACKET_END(PACKET_DIPLOMACY_CANCEL_MEETING);
40331}
40332
40333 int send_packet_diplomacy_cancel_meeting(struct connection *pc, const struct packet_diplomacy_cancel_meeting *packet)
40334{
40335 if (!pc->used) {
40336 log_error("WARNING: trying to send data to the closed connection %s",
40337 conn_description(pc));
40338 return -1;
40339 }
40340 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING].packet != nullptr, -1,
40341 "Handler for PACKET_DIPLOMACY_CANCEL_MEETING not installed");
40342 return pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_MEETING].packet(pc, packet);
40343}
40344
40345 void lsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, const struct packet_diplomacy_cancel_meeting *packet)
40346{
40347 conn_list_iterate(dest, pconn) {
40348 send_packet_diplomacy_cancel_meeting(pconn, packet);
40349 } conn_list_iterate_end;
40350}
40351
40352 int dsend_packet_diplomacy_cancel_meeting(struct connection *pc, int counterpart, int initiated_from)
40353{
40354 struct packet_diplomacy_cancel_meeting packet, *real_packet = &packet;
40355
40356 real_packet->counterpart = counterpart;
40357 real_packet->initiated_from = initiated_from;
40358
40359 return send_packet_diplomacy_cancel_meeting(pc, real_packet);
40360}
40361
40362 void dlsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, int counterpart, int initiated_from)
40363{
40364 struct packet_diplomacy_cancel_meeting packet, *real_packet = &packet;
40365
40366 real_packet->counterpart = counterpart;
40367 real_packet->initiated_from = initiated_from;
40368
40369 lsend_packet_diplomacy_cancel_meeting(dest, real_packet);
40370}
40371
40372 static inline void init_packet_diplomacy_create_clause_req(struct packet_diplomacy_create_clause_req *packet)
40373{
40374 memset(packet, 0, sizeof(*packet));
40375}
40376
40377#define free_packet_diplomacy_create_clause_req(_packet) (void) 0
40378#define destroy_packet_diplomacy_create_clause_req free
40379
40380#ifdef FREECIV_DELTA_PROTOCOL
40381#define hash_packet_diplomacy_create_clause_req_100 hash_const
40382#define cmp_packet_diplomacy_create_clause_req_100 cmp_const
40383 BV_DEFINE(packet_diplomacy_create_clause_req_100_fields, 4);
40384#endif /* FREECIV_DELTA_PROTOCOL */
40385
40386 static struct packet_diplomacy_create_clause_req *receive_packet_diplomacy_create_clause_req_100(struct connection *pc)
40387{
40388#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_create_clause_req(_packet)
40389 RECEIVE_PACKET_START(packet_diplomacy_create_clause_req, real_packet);
40390
40391#ifdef FREECIV_JSON_CONNECTION
40392 struct plocation field_addr;
40393 {
40394 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40395 field_addr = *field_addr_tmp;
40396 FC_FREE(field_addr_tmp);
40397 }
40398#endif /* FREECIV_JSON_CONNECTION */
40399
40400 log_packet_detailed("packet_diplomacy_create_clause_req_100: got info about ()");
40401
40402#ifdef FREECIV_DELTA_PROTOCOL
40403 packet_diplomacy_create_clause_req_100_fields fields;
40404 struct packet_diplomacy_create_clause_req *old;
40405 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CREATE_CLAUSE_REQ;
40406
40407 if (nullptr == *hash) {
40408 *hash = genhash_new_full(hash_packet_diplomacy_create_clause_req_100, cmp_packet_diplomacy_create_clause_req_100,
40409 nullptr, nullptr, nullptr, destroy_packet_diplomacy_create_clause_req);
40410 }
40411
40412 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
40413 *real_packet = *old;
40414 } else {
40415 /* packet is already initialized empty */
40416 log_packet_detailed(" no old info");
40417 }
40418
40419#ifdef FREECIV_JSON_CONNECTION
40420 field_addr.name = "fields";
40421#endif /* FREECIV_JSON_CONNECTION */
40422 DIO_BV_GET(&din, &field_addr, fields);
40423
40424 if (BV_ISSET(fields, 0)) {
40425 log_packet_detailed(" got field 'counterpart'");
40426
40427#ifdef FREECIV_JSON_CONNECTION
40428 field_addr.name = "counterpart";
40429#endif /* FREECIV_JSON_CONNECTION */
40430
40431 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
40432 RECEIVE_PACKET_FIELD_ERROR(counterpart);
40433 }
40434 }
40435
40436 if (BV_ISSET(fields, 1)) {
40437 log_packet_detailed(" got field 'giver'");
40438
40439#ifdef FREECIV_JSON_CONNECTION
40440 field_addr.name = "giver";
40441#endif /* FREECIV_JSON_CONNECTION */
40442
40443 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
40444 RECEIVE_PACKET_FIELD_ERROR(giver);
40445 }
40446 }
40447
40448 if (BV_ISSET(fields, 2)) {
40449 log_packet_detailed(" got field 'type'");
40450
40451#ifdef FREECIV_JSON_CONNECTION
40452 field_addr.name = "type";
40453#endif /* FREECIV_JSON_CONNECTION */
40454
40455 {
40456 int readin;
40457
40458 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
40459 RECEIVE_PACKET_FIELD_ERROR(type);
40460 }
40461 real_packet->type = readin;
40462 }
40463 }
40464
40465 if (BV_ISSET(fields, 3)) {
40466 log_packet_detailed(" got field 'value'");
40467
40468#ifdef FREECIV_JSON_CONNECTION
40469 field_addr.name = "value";
40470#endif /* FREECIV_JSON_CONNECTION */
40471
40472 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
40473 RECEIVE_PACKET_FIELD_ERROR(value);
40474 }
40475 }
40476
40477 if (nullptr == old) {
40478 old = fc_malloc(sizeof(*old));
40479 init_packet_diplomacy_create_clause_req(old);
40480 *old = *real_packet;
40481 genhash_insert(*hash, old, old);
40482 } else {
40483 *old = *real_packet;
40484 }
40485
40486#else /* FREECIV_DELTA_PROTOCOL */
40487#ifdef FREECIV_JSON_CONNECTION
40488 field_addr.name = "counterpart";
40489#endif /* FREECIV_JSON_CONNECTION */
40490
40491 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
40492 RECEIVE_PACKET_FIELD_ERROR(counterpart);
40493 }
40494
40495#ifdef FREECIV_JSON_CONNECTION
40496 field_addr.name = "giver";
40497#endif /* FREECIV_JSON_CONNECTION */
40498
40499 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
40500 RECEIVE_PACKET_FIELD_ERROR(giver);
40501 }
40502
40503#ifdef FREECIV_JSON_CONNECTION
40504 field_addr.name = "type";
40505#endif /* FREECIV_JSON_CONNECTION */
40506
40507 {
40508 int readin;
40509
40510 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
40511 RECEIVE_PACKET_FIELD_ERROR(type);
40512 }
40513 real_packet->type = readin;
40514 }
40515
40516#ifdef FREECIV_JSON_CONNECTION
40517 field_addr.name = "value";
40518#endif /* FREECIV_JSON_CONNECTION */
40519
40520 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
40521 RECEIVE_PACKET_FIELD_ERROR(value);
40522 }
40523#endif /* FREECIV_DELTA_PROTOCOL */
40524
40525 RECEIVE_PACKET_END(real_packet);
40526#undef FREE_PACKET_STRUCT
40527}
40528
40529 static int send_packet_diplomacy_create_clause_req_100(struct connection *pc, const struct packet_diplomacy_create_clause_req *packet)
40530{
40531 const struct packet_diplomacy_create_clause_req *real_packet = packet;
40532 int e;
40533 SEND_PACKET_START(PACKET_DIPLOMACY_CREATE_CLAUSE_REQ);
40534
40535 log_packet_detailed("packet_diplomacy_create_clause_req_100: sending info about ()");
40536
40537#ifdef FREECIV_DELTA_PROTOCOL
40538 packet_diplomacy_create_clause_req_100_fields fields;
40539 struct packet_diplomacy_create_clause_req *old;
40540 bool differ;
40541 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CREATE_CLAUSE_REQ;
40542
40543 if (nullptr == *hash) {
40544 *hash = genhash_new_full(hash_packet_diplomacy_create_clause_req_100, cmp_packet_diplomacy_create_clause_req_100,
40545 nullptr, nullptr, nullptr, destroy_packet_diplomacy_create_clause_req);
40546 }
40547 BV_CLR_ALL(fields);
40548
40549 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40550 old = fc_malloc(sizeof(*old));
40551 /* temporary bitcopy just to insert correctly */
40552 *old = *real_packet;
40553 genhash_insert(*hash, old, old);
40554 init_packet_diplomacy_create_clause_req(old);
40555 }
40556
40557 differ = (old->counterpart != real_packet->counterpart);
40558 if (differ) {
40559 BV_SET(fields, 0);
40560 }
40561
40562 differ = (old->giver != real_packet->giver);
40563 if (differ) {
40564 BV_SET(fields, 1);
40565 }
40566
40567 differ = (old->type != real_packet->type);
40568 if (differ) {
40569 BV_SET(fields, 2);
40570 }
40571
40572 differ = (old->value != real_packet->value);
40573 if (differ) {
40574 BV_SET(fields, 3);
40575 }
40576#endif /* FREECIV_DELTA_PROTOCOL */
40577
40578#ifdef FREECIV_JSON_CONNECTION
40579 struct plocation field_addr;
40580 {
40581 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40582 field_addr = *field_addr_tmp;
40583 FC_FREE(field_addr_tmp);
40584 }
40585#endif /* FREECIV_JSON_CONNECTION */
40586
40587#ifdef FREECIV_DELTA_PROTOCOL
40588#ifdef FREECIV_JSON_CONNECTION
40589 field_addr.name = "fields";
40590#endif /* FREECIV_JSON_CONNECTION */
40591 e = 0;
40592 e |= DIO_BV_PUT(&dout, &field_addr, fields);
40593 if (e) {
40594 log_packet_detailed("fields bitvector error detected");
40595 }
40596
40597 if (BV_ISSET(fields, 0)) {
40598 log_packet_detailed(" field 'counterpart' has changed");
40599
40600#ifdef FREECIV_JSON_CONNECTION
40601 field_addr.name = "counterpart";
40602#endif /* FREECIV_JSON_CONNECTION */
40603 e = 0;
40604
40605 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40606
40607 if (e) {
40608 log_packet_detailed("'counterpart' field error detected");
40609 }
40610 }
40611
40612 if (BV_ISSET(fields, 1)) {
40613 log_packet_detailed(" field 'giver' has changed");
40614
40615#ifdef FREECIV_JSON_CONNECTION
40616 field_addr.name = "giver";
40617#endif /* FREECIV_JSON_CONNECTION */
40618 e = 0;
40619
40620 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
40621
40622 if (e) {
40623 log_packet_detailed("'giver' field error detected");
40624 }
40625 }
40626
40627 if (BV_ISSET(fields, 2)) {
40628 log_packet_detailed(" field 'type' has changed");
40629
40630#ifdef FREECIV_JSON_CONNECTION
40631 field_addr.name = "type";
40632#endif /* FREECIV_JSON_CONNECTION */
40633 e = 0;
40634
40635 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
40636
40637 if (e) {
40638 log_packet_detailed("'type' field error detected");
40639 }
40640 }
40641
40642 if (BV_ISSET(fields, 3)) {
40643 log_packet_detailed(" field 'value' has changed");
40644
40645#ifdef FREECIV_JSON_CONNECTION
40646 field_addr.name = "value";
40647#endif /* FREECIV_JSON_CONNECTION */
40648 e = 0;
40649
40650 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
40651
40652 if (e) {
40653 log_packet_detailed("'value' field error detected");
40654 }
40655 }
40656
40657 *old = *real_packet;
40658
40659#else /* FREECIV_DELTA_PROTOCOL */
40660#ifdef FREECIV_JSON_CONNECTION
40661 field_addr.name = "counterpart";
40662#endif /* FREECIV_JSON_CONNECTION */
40663 e = 0;
40664
40665 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40666
40667 if (e) {
40668 log_packet_detailed("'counterpart' field error detected");
40669 }
40670
40671#ifdef FREECIV_JSON_CONNECTION
40672 field_addr.name = "giver";
40673#endif /* FREECIV_JSON_CONNECTION */
40674 e = 0;
40675
40676 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
40677
40678 if (e) {
40679 log_packet_detailed("'giver' field error detected");
40680 }
40681
40682#ifdef FREECIV_JSON_CONNECTION
40683 field_addr.name = "type";
40684#endif /* FREECIV_JSON_CONNECTION */
40685 e = 0;
40686
40687 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
40688
40689 if (e) {
40690 log_packet_detailed("'type' field error detected");
40691 }
40692
40693#ifdef FREECIV_JSON_CONNECTION
40694 field_addr.name = "value";
40695#endif /* FREECIV_JSON_CONNECTION */
40696 e = 0;
40697
40698 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
40699
40700 if (e) {
40701 log_packet_detailed("'value' field error detected");
40702 }
40703#endif /* FREECIV_DELTA_PROTOCOL */
40704
40705 SEND_PACKET_END(PACKET_DIPLOMACY_CREATE_CLAUSE_REQ);
40706}
40707
40708 int send_packet_diplomacy_create_clause_req(struct connection *pc, const struct packet_diplomacy_create_clause_req *packet)
40709{
40710 if (!pc->used) {
40711 log_error("WARNING: trying to send data to the closed connection %s",
40712 conn_description(pc));
40713 return -1;
40714 }
40715 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ].packet != nullptr, -1,
40716 "Handler for PACKET_DIPLOMACY_CREATE_CLAUSE_REQ not installed");
40717 return pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ].packet(pc, packet);
40718}
40719
40720 int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
40721{
40722 struct packet_diplomacy_create_clause_req packet, *real_packet = &packet;
40723
40724 real_packet->counterpart = counterpart;
40725 real_packet->giver = giver;
40726 real_packet->type = type;
40727 real_packet->value = value;
40728
40729 return send_packet_diplomacy_create_clause_req(pc, real_packet);
40730}
40731
40732 static inline void init_packet_diplomacy_create_clause(struct packet_diplomacy_create_clause *packet)
40733{
40734 memset(packet, 0, sizeof(*packet));
40735}
40736
40737#define free_packet_diplomacy_create_clause(_packet) (void) 0
40738#define destroy_packet_diplomacy_create_clause free
40739
40740#ifdef FREECIV_DELTA_PROTOCOL
40741#define hash_packet_diplomacy_create_clause_100 hash_const
40742#define cmp_packet_diplomacy_create_clause_100 cmp_const
40743 BV_DEFINE(packet_diplomacy_create_clause_100_fields, 4);
40744#endif /* FREECIV_DELTA_PROTOCOL */
40745
40746 static struct packet_diplomacy_create_clause *receive_packet_diplomacy_create_clause_100(struct connection *pc)
40747{
40748#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_create_clause(_packet)
40749 RECEIVE_PACKET_START(packet_diplomacy_create_clause, real_packet);
40750
40751#ifdef FREECIV_JSON_CONNECTION
40752 struct plocation field_addr;
40753 {
40754 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40755 field_addr = *field_addr_tmp;
40756 FC_FREE(field_addr_tmp);
40757 }
40758#endif /* FREECIV_JSON_CONNECTION */
40759
40760 log_packet_detailed("packet_diplomacy_create_clause_100: got info about ()");
40761
40762#ifdef FREECIV_DELTA_PROTOCOL
40763 packet_diplomacy_create_clause_100_fields fields;
40764 struct packet_diplomacy_create_clause *old;
40765 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CREATE_CLAUSE;
40766
40767 if (nullptr == *hash) {
40768 *hash = genhash_new_full(hash_packet_diplomacy_create_clause_100, cmp_packet_diplomacy_create_clause_100,
40769 nullptr, nullptr, nullptr, destroy_packet_diplomacy_create_clause);
40770 }
40771
40772 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
40773 *real_packet = *old;
40774 } else {
40775 /* packet is already initialized empty */
40776 log_packet_detailed(" no old info");
40777 }
40778
40779#ifdef FREECIV_JSON_CONNECTION
40780 field_addr.name = "fields";
40781#endif /* FREECIV_JSON_CONNECTION */
40782 DIO_BV_GET(&din, &field_addr, fields);
40783
40784 if (BV_ISSET(fields, 0)) {
40785 log_packet_detailed(" got field 'counterpart'");
40786
40787#ifdef FREECIV_JSON_CONNECTION
40788 field_addr.name = "counterpart";
40789#endif /* FREECIV_JSON_CONNECTION */
40790
40791 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
40792 RECEIVE_PACKET_FIELD_ERROR(counterpart);
40793 }
40794 }
40795
40796 if (BV_ISSET(fields, 1)) {
40797 log_packet_detailed(" got field 'giver'");
40798
40799#ifdef FREECIV_JSON_CONNECTION
40800 field_addr.name = "giver";
40801#endif /* FREECIV_JSON_CONNECTION */
40802
40803 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
40804 RECEIVE_PACKET_FIELD_ERROR(giver);
40805 }
40806 }
40807
40808 if (BV_ISSET(fields, 2)) {
40809 log_packet_detailed(" got field 'type'");
40810
40811#ifdef FREECIV_JSON_CONNECTION
40812 field_addr.name = "type";
40813#endif /* FREECIV_JSON_CONNECTION */
40814
40815 {
40816 int readin;
40817
40818 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
40819 RECEIVE_PACKET_FIELD_ERROR(type);
40820 }
40821 real_packet->type = readin;
40822 }
40823 }
40824
40825 if (BV_ISSET(fields, 3)) {
40826 log_packet_detailed(" got field 'value'");
40827
40828#ifdef FREECIV_JSON_CONNECTION
40829 field_addr.name = "value";
40830#endif /* FREECIV_JSON_CONNECTION */
40831
40832 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
40833 RECEIVE_PACKET_FIELD_ERROR(value);
40834 }
40835 }
40836
40837 if (nullptr == old) {
40838 old = fc_malloc(sizeof(*old));
40839 init_packet_diplomacy_create_clause(old);
40840 *old = *real_packet;
40841 genhash_insert(*hash, old, old);
40842 } else {
40843 *old = *real_packet;
40844 }
40845
40846#else /* FREECIV_DELTA_PROTOCOL */
40847#ifdef FREECIV_JSON_CONNECTION
40848 field_addr.name = "counterpart";
40849#endif /* FREECIV_JSON_CONNECTION */
40850
40851 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
40852 RECEIVE_PACKET_FIELD_ERROR(counterpart);
40853 }
40854
40855#ifdef FREECIV_JSON_CONNECTION
40856 field_addr.name = "giver";
40857#endif /* FREECIV_JSON_CONNECTION */
40858
40859 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
40860 RECEIVE_PACKET_FIELD_ERROR(giver);
40861 }
40862
40863#ifdef FREECIV_JSON_CONNECTION
40864 field_addr.name = "type";
40865#endif /* FREECIV_JSON_CONNECTION */
40866
40867 {
40868 int readin;
40869
40870 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
40871 RECEIVE_PACKET_FIELD_ERROR(type);
40872 }
40873 real_packet->type = readin;
40874 }
40875
40876#ifdef FREECIV_JSON_CONNECTION
40877 field_addr.name = "value";
40878#endif /* FREECIV_JSON_CONNECTION */
40879
40880 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
40881 RECEIVE_PACKET_FIELD_ERROR(value);
40882 }
40883#endif /* FREECIV_DELTA_PROTOCOL */
40884
40885 RECEIVE_PACKET_END(real_packet);
40886#undef FREE_PACKET_STRUCT
40887}
40888
40889 static int send_packet_diplomacy_create_clause_100(struct connection *pc, const struct packet_diplomacy_create_clause *packet)
40890{
40891 const struct packet_diplomacy_create_clause *real_packet = packet;
40892 int e;
40893 SEND_PACKET_START(PACKET_DIPLOMACY_CREATE_CLAUSE);
40894
40895 log_packet_detailed("packet_diplomacy_create_clause_100: sending info about ()");
40896
40897#ifdef FREECIV_DELTA_PROTOCOL
40898 packet_diplomacy_create_clause_100_fields fields;
40899 struct packet_diplomacy_create_clause *old;
40900 bool differ;
40901 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CREATE_CLAUSE;
40902
40903 if (nullptr == *hash) {
40904 *hash = genhash_new_full(hash_packet_diplomacy_create_clause_100, cmp_packet_diplomacy_create_clause_100,
40905 nullptr, nullptr, nullptr, destroy_packet_diplomacy_create_clause);
40906 }
40907 BV_CLR_ALL(fields);
40908
40909 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
40910 old = fc_malloc(sizeof(*old));
40911 /* temporary bitcopy just to insert correctly */
40912 *old = *real_packet;
40913 genhash_insert(*hash, old, old);
40914 init_packet_diplomacy_create_clause(old);
40915 }
40916
40917 differ = (old->counterpart != real_packet->counterpart);
40918 if (differ) {
40919 BV_SET(fields, 0);
40920 }
40921
40922 differ = (old->giver != real_packet->giver);
40923 if (differ) {
40924 BV_SET(fields, 1);
40925 }
40926
40927 differ = (old->type != real_packet->type);
40928 if (differ) {
40929 BV_SET(fields, 2);
40930 }
40931
40932 differ = (old->value != real_packet->value);
40933 if (differ) {
40934 BV_SET(fields, 3);
40935 }
40936#endif /* FREECIV_DELTA_PROTOCOL */
40937
40938#ifdef FREECIV_JSON_CONNECTION
40939 struct plocation field_addr;
40940 {
40941 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
40942 field_addr = *field_addr_tmp;
40943 FC_FREE(field_addr_tmp);
40944 }
40945#endif /* FREECIV_JSON_CONNECTION */
40946
40947#ifdef FREECIV_DELTA_PROTOCOL
40948#ifdef FREECIV_JSON_CONNECTION
40949 field_addr.name = "fields";
40950#endif /* FREECIV_JSON_CONNECTION */
40951 e = 0;
40952 e |= DIO_BV_PUT(&dout, &field_addr, fields);
40953 if (e) {
40954 log_packet_detailed("fields bitvector error detected");
40955 }
40956
40957 if (BV_ISSET(fields, 0)) {
40958 log_packet_detailed(" field 'counterpart' has changed");
40959
40960#ifdef FREECIV_JSON_CONNECTION
40961 field_addr.name = "counterpart";
40962#endif /* FREECIV_JSON_CONNECTION */
40963 e = 0;
40964
40965 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
40966
40967 if (e) {
40968 log_packet_detailed("'counterpart' field error detected");
40969 }
40970 }
40971
40972 if (BV_ISSET(fields, 1)) {
40973 log_packet_detailed(" field 'giver' has changed");
40974
40975#ifdef FREECIV_JSON_CONNECTION
40976 field_addr.name = "giver";
40977#endif /* FREECIV_JSON_CONNECTION */
40978 e = 0;
40979
40980 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
40981
40982 if (e) {
40983 log_packet_detailed("'giver' field error detected");
40984 }
40985 }
40986
40987 if (BV_ISSET(fields, 2)) {
40988 log_packet_detailed(" field 'type' has changed");
40989
40990#ifdef FREECIV_JSON_CONNECTION
40991 field_addr.name = "type";
40992#endif /* FREECIV_JSON_CONNECTION */
40993 e = 0;
40994
40995 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
40996
40997 if (e) {
40998 log_packet_detailed("'type' field error detected");
40999 }
41000 }
41001
41002 if (BV_ISSET(fields, 3)) {
41003 log_packet_detailed(" field 'value' has changed");
41004
41005#ifdef FREECIV_JSON_CONNECTION
41006 field_addr.name = "value";
41007#endif /* FREECIV_JSON_CONNECTION */
41008 e = 0;
41009
41010 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
41011
41012 if (e) {
41013 log_packet_detailed("'value' field error detected");
41014 }
41015 }
41016
41017 *old = *real_packet;
41018
41019#else /* FREECIV_DELTA_PROTOCOL */
41020#ifdef FREECIV_JSON_CONNECTION
41021 field_addr.name = "counterpart";
41022#endif /* FREECIV_JSON_CONNECTION */
41023 e = 0;
41024
41025 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
41026
41027 if (e) {
41028 log_packet_detailed("'counterpart' field error detected");
41029 }
41030
41031#ifdef FREECIV_JSON_CONNECTION
41032 field_addr.name = "giver";
41033#endif /* FREECIV_JSON_CONNECTION */
41034 e = 0;
41035
41036 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
41037
41038 if (e) {
41039 log_packet_detailed("'giver' field error detected");
41040 }
41041
41042#ifdef FREECIV_JSON_CONNECTION
41043 field_addr.name = "type";
41044#endif /* FREECIV_JSON_CONNECTION */
41045 e = 0;
41046
41047 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
41048
41049 if (e) {
41050 log_packet_detailed("'type' field error detected");
41051 }
41052
41053#ifdef FREECIV_JSON_CONNECTION
41054 field_addr.name = "value";
41055#endif /* FREECIV_JSON_CONNECTION */
41056 e = 0;
41057
41058 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
41059
41060 if (e) {
41061 log_packet_detailed("'value' field error detected");
41062 }
41063#endif /* FREECIV_DELTA_PROTOCOL */
41064
41065 SEND_PACKET_END(PACKET_DIPLOMACY_CREATE_CLAUSE);
41066}
41067
41068 int send_packet_diplomacy_create_clause(struct connection *pc, const struct packet_diplomacy_create_clause *packet)
41069{
41070 if (!pc->used) {
41071 log_error("WARNING: trying to send data to the closed connection %s",
41072 conn_description(pc));
41073 return -1;
41074 }
41075 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE].packet != nullptr, -1,
41076 "Handler for PACKET_DIPLOMACY_CREATE_CLAUSE not installed");
41077 return pc->phs.handlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE].packet(pc, packet);
41078}
41079
41080 void lsend_packet_diplomacy_create_clause(struct conn_list *dest, const struct packet_diplomacy_create_clause *packet)
41081{
41082 conn_list_iterate(dest, pconn) {
41083 send_packet_diplomacy_create_clause(pconn, packet);
41084 } conn_list_iterate_end;
41085}
41086
41087 int dsend_packet_diplomacy_create_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
41088{
41089 struct packet_diplomacy_create_clause packet, *real_packet = &packet;
41090
41091 real_packet->counterpart = counterpart;
41092 real_packet->giver = giver;
41093 real_packet->type = type;
41094 real_packet->value = value;
41095
41096 return send_packet_diplomacy_create_clause(pc, real_packet);
41097}
41098
41099 void dlsend_packet_diplomacy_create_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
41100{
41101 struct packet_diplomacy_create_clause packet, *real_packet = &packet;
41102
41103 real_packet->counterpart = counterpart;
41104 real_packet->giver = giver;
41105 real_packet->type = type;
41106 real_packet->value = value;
41107
41108 lsend_packet_diplomacy_create_clause(dest, real_packet);
41109}
41110
41111 static inline void init_packet_diplomacy_remove_clause_req(struct packet_diplomacy_remove_clause_req *packet)
41112{
41113 memset(packet, 0, sizeof(*packet));
41114}
41115
41116#define free_packet_diplomacy_remove_clause_req(_packet) (void) 0
41117#define destroy_packet_diplomacy_remove_clause_req free
41118
41119#ifdef FREECIV_DELTA_PROTOCOL
41120#define hash_packet_diplomacy_remove_clause_req_100 hash_const
41121#define cmp_packet_diplomacy_remove_clause_req_100 cmp_const
41122 BV_DEFINE(packet_diplomacy_remove_clause_req_100_fields, 4);
41123#endif /* FREECIV_DELTA_PROTOCOL */
41124
41125 static struct packet_diplomacy_remove_clause_req *receive_packet_diplomacy_remove_clause_req_100(struct connection *pc)
41126{
41127#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_remove_clause_req(_packet)
41128 RECEIVE_PACKET_START(packet_diplomacy_remove_clause_req, real_packet);
41129
41130#ifdef FREECIV_JSON_CONNECTION
41131 struct plocation field_addr;
41132 {
41133 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
41134 field_addr = *field_addr_tmp;
41135 FC_FREE(field_addr_tmp);
41136 }
41137#endif /* FREECIV_JSON_CONNECTION */
41138
41139 log_packet_detailed("packet_diplomacy_remove_clause_req_100: got info about ()");
41140
41141#ifdef FREECIV_DELTA_PROTOCOL
41142 packet_diplomacy_remove_clause_req_100_fields fields;
41143 struct packet_diplomacy_remove_clause_req *old;
41144 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ;
41145
41146 if (nullptr == *hash) {
41147 *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_req_100, cmp_packet_diplomacy_remove_clause_req_100,
41148 nullptr, nullptr, nullptr, destroy_packet_diplomacy_remove_clause_req);
41149 }
41150
41151 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41152 *real_packet = *old;
41153 } else {
41154 /* packet is already initialized empty */
41155 log_packet_detailed(" no old info");
41156 }
41157
41158#ifdef FREECIV_JSON_CONNECTION
41159 field_addr.name = "fields";
41160#endif /* FREECIV_JSON_CONNECTION */
41161 DIO_BV_GET(&din, &field_addr, fields);
41162
41163 if (BV_ISSET(fields, 0)) {
41164 log_packet_detailed(" got field 'counterpart'");
41165
41166#ifdef FREECIV_JSON_CONNECTION
41167 field_addr.name = "counterpart";
41168#endif /* FREECIV_JSON_CONNECTION */
41169
41170 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
41171 RECEIVE_PACKET_FIELD_ERROR(counterpart);
41172 }
41173 }
41174
41175 if (BV_ISSET(fields, 1)) {
41176 log_packet_detailed(" got field 'giver'");
41177
41178#ifdef FREECIV_JSON_CONNECTION
41179 field_addr.name = "giver";
41180#endif /* FREECIV_JSON_CONNECTION */
41181
41182 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
41183 RECEIVE_PACKET_FIELD_ERROR(giver);
41184 }
41185 }
41186
41187 if (BV_ISSET(fields, 2)) {
41188 log_packet_detailed(" got field 'type'");
41189
41190#ifdef FREECIV_JSON_CONNECTION
41191 field_addr.name = "type";
41192#endif /* FREECIV_JSON_CONNECTION */
41193
41194 {
41195 int readin;
41196
41197 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
41198 RECEIVE_PACKET_FIELD_ERROR(type);
41199 }
41200 real_packet->type = readin;
41201 }
41202 }
41203
41204 if (BV_ISSET(fields, 3)) {
41205 log_packet_detailed(" got field 'value'");
41206
41207#ifdef FREECIV_JSON_CONNECTION
41208 field_addr.name = "value";
41209#endif /* FREECIV_JSON_CONNECTION */
41210
41211 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
41212 RECEIVE_PACKET_FIELD_ERROR(value);
41213 }
41214 }
41215
41216 if (nullptr == old) {
41217 old = fc_malloc(sizeof(*old));
41218 init_packet_diplomacy_remove_clause_req(old);
41219 *old = *real_packet;
41220 genhash_insert(*hash, old, old);
41221 } else {
41222 *old = *real_packet;
41223 }
41224
41225#else /* FREECIV_DELTA_PROTOCOL */
41226#ifdef FREECIV_JSON_CONNECTION
41227 field_addr.name = "counterpart";
41228#endif /* FREECIV_JSON_CONNECTION */
41229
41230 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
41231 RECEIVE_PACKET_FIELD_ERROR(counterpart);
41232 }
41233
41234#ifdef FREECIV_JSON_CONNECTION
41235 field_addr.name = "giver";
41236#endif /* FREECIV_JSON_CONNECTION */
41237
41238 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
41239 RECEIVE_PACKET_FIELD_ERROR(giver);
41240 }
41241
41242#ifdef FREECIV_JSON_CONNECTION
41243 field_addr.name = "type";
41244#endif /* FREECIV_JSON_CONNECTION */
41245
41246 {
41247 int readin;
41248
41249 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
41250 RECEIVE_PACKET_FIELD_ERROR(type);
41251 }
41252 real_packet->type = readin;
41253 }
41254
41255#ifdef FREECIV_JSON_CONNECTION
41256 field_addr.name = "value";
41257#endif /* FREECIV_JSON_CONNECTION */
41258
41259 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
41260 RECEIVE_PACKET_FIELD_ERROR(value);
41261 }
41262#endif /* FREECIV_DELTA_PROTOCOL */
41263
41264 RECEIVE_PACKET_END(real_packet);
41265#undef FREE_PACKET_STRUCT
41266}
41267
41268 static int send_packet_diplomacy_remove_clause_req_100(struct connection *pc, const struct packet_diplomacy_remove_clause_req *packet)
41269{
41270 const struct packet_diplomacy_remove_clause_req *real_packet = packet;
41271 int e;
41272 SEND_PACKET_START(PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ);
41273
41274 log_packet_detailed("packet_diplomacy_remove_clause_req_100: sending info about ()");
41275
41276#ifdef FREECIV_DELTA_PROTOCOL
41277 packet_diplomacy_remove_clause_req_100_fields fields;
41278 struct packet_diplomacy_remove_clause_req *old;
41279 bool differ;
41280 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ;
41281
41282 if (nullptr == *hash) {
41283 *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_req_100, cmp_packet_diplomacy_remove_clause_req_100,
41284 nullptr, nullptr, nullptr, destroy_packet_diplomacy_remove_clause_req);
41285 }
41286 BV_CLR_ALL(fields);
41287
41288 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41289 old = fc_malloc(sizeof(*old));
41290 /* temporary bitcopy just to insert correctly */
41291 *old = *real_packet;
41292 genhash_insert(*hash, old, old);
41293 init_packet_diplomacy_remove_clause_req(old);
41294 }
41295
41296 differ = (old->counterpart != real_packet->counterpart);
41297 if (differ) {
41298 BV_SET(fields, 0);
41299 }
41300
41301 differ = (old->giver != real_packet->giver);
41302 if (differ) {
41303 BV_SET(fields, 1);
41304 }
41305
41306 differ = (old->type != real_packet->type);
41307 if (differ) {
41308 BV_SET(fields, 2);
41309 }
41310
41311 differ = (old->value != real_packet->value);
41312 if (differ) {
41313 BV_SET(fields, 3);
41314 }
41315#endif /* FREECIV_DELTA_PROTOCOL */
41316
41317#ifdef FREECIV_JSON_CONNECTION
41318 struct plocation field_addr;
41319 {
41320 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
41321 field_addr = *field_addr_tmp;
41322 FC_FREE(field_addr_tmp);
41323 }
41324#endif /* FREECIV_JSON_CONNECTION */
41325
41326#ifdef FREECIV_DELTA_PROTOCOL
41327#ifdef FREECIV_JSON_CONNECTION
41328 field_addr.name = "fields";
41329#endif /* FREECIV_JSON_CONNECTION */
41330 e = 0;
41331 e |= DIO_BV_PUT(&dout, &field_addr, fields);
41332 if (e) {
41333 log_packet_detailed("fields bitvector error detected");
41334 }
41335
41336 if (BV_ISSET(fields, 0)) {
41337 log_packet_detailed(" field 'counterpart' has changed");
41338
41339#ifdef FREECIV_JSON_CONNECTION
41340 field_addr.name = "counterpart";
41341#endif /* FREECIV_JSON_CONNECTION */
41342 e = 0;
41343
41344 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
41345
41346 if (e) {
41347 log_packet_detailed("'counterpart' field error detected");
41348 }
41349 }
41350
41351 if (BV_ISSET(fields, 1)) {
41352 log_packet_detailed(" field 'giver' has changed");
41353
41354#ifdef FREECIV_JSON_CONNECTION
41355 field_addr.name = "giver";
41356#endif /* FREECIV_JSON_CONNECTION */
41357 e = 0;
41358
41359 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
41360
41361 if (e) {
41362 log_packet_detailed("'giver' field error detected");
41363 }
41364 }
41365
41366 if (BV_ISSET(fields, 2)) {
41367 log_packet_detailed(" field 'type' has changed");
41368
41369#ifdef FREECIV_JSON_CONNECTION
41370 field_addr.name = "type";
41371#endif /* FREECIV_JSON_CONNECTION */
41372 e = 0;
41373
41374 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
41375
41376 if (e) {
41377 log_packet_detailed("'type' field error detected");
41378 }
41379 }
41380
41381 if (BV_ISSET(fields, 3)) {
41382 log_packet_detailed(" field 'value' has changed");
41383
41384#ifdef FREECIV_JSON_CONNECTION
41385 field_addr.name = "value";
41386#endif /* FREECIV_JSON_CONNECTION */
41387 e = 0;
41388
41389 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
41390
41391 if (e) {
41392 log_packet_detailed("'value' field error detected");
41393 }
41394 }
41395
41396 *old = *real_packet;
41397
41398#else /* FREECIV_DELTA_PROTOCOL */
41399#ifdef FREECIV_JSON_CONNECTION
41400 field_addr.name = "counterpart";
41401#endif /* FREECIV_JSON_CONNECTION */
41402 e = 0;
41403
41404 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
41405
41406 if (e) {
41407 log_packet_detailed("'counterpart' field error detected");
41408 }
41409
41410#ifdef FREECIV_JSON_CONNECTION
41411 field_addr.name = "giver";
41412#endif /* FREECIV_JSON_CONNECTION */
41413 e = 0;
41414
41415 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
41416
41417 if (e) {
41418 log_packet_detailed("'giver' field error detected");
41419 }
41420
41421#ifdef FREECIV_JSON_CONNECTION
41422 field_addr.name = "type";
41423#endif /* FREECIV_JSON_CONNECTION */
41424 e = 0;
41425
41426 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
41427
41428 if (e) {
41429 log_packet_detailed("'type' field error detected");
41430 }
41431
41432#ifdef FREECIV_JSON_CONNECTION
41433 field_addr.name = "value";
41434#endif /* FREECIV_JSON_CONNECTION */
41435 e = 0;
41436
41437 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
41438
41439 if (e) {
41440 log_packet_detailed("'value' field error detected");
41441 }
41442#endif /* FREECIV_DELTA_PROTOCOL */
41443
41444 SEND_PACKET_END(PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ);
41445}
41446
41447 int send_packet_diplomacy_remove_clause_req(struct connection *pc, const struct packet_diplomacy_remove_clause_req *packet)
41448{
41449 if (!pc->used) {
41450 log_error("WARNING: trying to send data to the closed connection %s",
41451 conn_description(pc));
41452 return -1;
41453 }
41454 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ].packet != nullptr, -1,
41455 "Handler for PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ not installed");
41456 return pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ].packet(pc, packet);
41457}
41458
41459 int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
41460{
41461 struct packet_diplomacy_remove_clause_req packet, *real_packet = &packet;
41462
41463 real_packet->counterpart = counterpart;
41464 real_packet->giver = giver;
41465 real_packet->type = type;
41466 real_packet->value = value;
41467
41468 return send_packet_diplomacy_remove_clause_req(pc, real_packet);
41469}
41470
41471 static inline void init_packet_diplomacy_remove_clause(struct packet_diplomacy_remove_clause *packet)
41472{
41473 memset(packet, 0, sizeof(*packet));
41474}
41475
41476#define free_packet_diplomacy_remove_clause(_packet) (void) 0
41477#define destroy_packet_diplomacy_remove_clause free
41478
41479#ifdef FREECIV_DELTA_PROTOCOL
41480#define hash_packet_diplomacy_remove_clause_100 hash_const
41481#define cmp_packet_diplomacy_remove_clause_100 cmp_const
41482 BV_DEFINE(packet_diplomacy_remove_clause_100_fields, 4);
41483#endif /* FREECIV_DELTA_PROTOCOL */
41484
41485 static struct packet_diplomacy_remove_clause *receive_packet_diplomacy_remove_clause_100(struct connection *pc)
41486{
41487#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_remove_clause(_packet)
41488 RECEIVE_PACKET_START(packet_diplomacy_remove_clause, real_packet);
41489
41490#ifdef FREECIV_JSON_CONNECTION
41491 struct plocation field_addr;
41492 {
41493 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
41494 field_addr = *field_addr_tmp;
41495 FC_FREE(field_addr_tmp);
41496 }
41497#endif /* FREECIV_JSON_CONNECTION */
41498
41499 log_packet_detailed("packet_diplomacy_remove_clause_100: got info about ()");
41500
41501#ifdef FREECIV_DELTA_PROTOCOL
41502 packet_diplomacy_remove_clause_100_fields fields;
41503 struct packet_diplomacy_remove_clause *old;
41504 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_REMOVE_CLAUSE;
41505
41506 if (nullptr == *hash) {
41507 *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_100, cmp_packet_diplomacy_remove_clause_100,
41508 nullptr, nullptr, nullptr, destroy_packet_diplomacy_remove_clause);
41509 }
41510
41511 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41512 *real_packet = *old;
41513 } else {
41514 /* packet is already initialized empty */
41515 log_packet_detailed(" no old info");
41516 }
41517
41518#ifdef FREECIV_JSON_CONNECTION
41519 field_addr.name = "fields";
41520#endif /* FREECIV_JSON_CONNECTION */
41521 DIO_BV_GET(&din, &field_addr, fields);
41522
41523 if (BV_ISSET(fields, 0)) {
41524 log_packet_detailed(" got field 'counterpart'");
41525
41526#ifdef FREECIV_JSON_CONNECTION
41527 field_addr.name = "counterpart";
41528#endif /* FREECIV_JSON_CONNECTION */
41529
41530 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
41531 RECEIVE_PACKET_FIELD_ERROR(counterpart);
41532 }
41533 }
41534
41535 if (BV_ISSET(fields, 1)) {
41536 log_packet_detailed(" got field 'giver'");
41537
41538#ifdef FREECIV_JSON_CONNECTION
41539 field_addr.name = "giver";
41540#endif /* FREECIV_JSON_CONNECTION */
41541
41542 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
41543 RECEIVE_PACKET_FIELD_ERROR(giver);
41544 }
41545 }
41546
41547 if (BV_ISSET(fields, 2)) {
41548 log_packet_detailed(" got field 'type'");
41549
41550#ifdef FREECIV_JSON_CONNECTION
41551 field_addr.name = "type";
41552#endif /* FREECIV_JSON_CONNECTION */
41553
41554 {
41555 int readin;
41556
41557 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
41558 RECEIVE_PACKET_FIELD_ERROR(type);
41559 }
41560 real_packet->type = readin;
41561 }
41562 }
41563
41564 if (BV_ISSET(fields, 3)) {
41565 log_packet_detailed(" got field 'value'");
41566
41567#ifdef FREECIV_JSON_CONNECTION
41568 field_addr.name = "value";
41569#endif /* FREECIV_JSON_CONNECTION */
41570
41571 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
41572 RECEIVE_PACKET_FIELD_ERROR(value);
41573 }
41574 }
41575
41576 if (nullptr == old) {
41577 old = fc_malloc(sizeof(*old));
41578 init_packet_diplomacy_remove_clause(old);
41579 *old = *real_packet;
41580 genhash_insert(*hash, old, old);
41581 } else {
41582 *old = *real_packet;
41583 }
41584
41585#else /* FREECIV_DELTA_PROTOCOL */
41586#ifdef FREECIV_JSON_CONNECTION
41587 field_addr.name = "counterpart";
41588#endif /* FREECIV_JSON_CONNECTION */
41589
41590 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
41591 RECEIVE_PACKET_FIELD_ERROR(counterpart);
41592 }
41593
41594#ifdef FREECIV_JSON_CONNECTION
41595 field_addr.name = "giver";
41596#endif /* FREECIV_JSON_CONNECTION */
41597
41598 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->giver)) {
41599 RECEIVE_PACKET_FIELD_ERROR(giver);
41600 }
41601
41602#ifdef FREECIV_JSON_CONNECTION
41603 field_addr.name = "type";
41604#endif /* FREECIV_JSON_CONNECTION */
41605
41606 {
41607 int readin;
41608
41609 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
41610 RECEIVE_PACKET_FIELD_ERROR(type);
41611 }
41612 real_packet->type = readin;
41613 }
41614
41615#ifdef FREECIV_JSON_CONNECTION
41616 field_addr.name = "value";
41617#endif /* FREECIV_JSON_CONNECTION */
41618
41619 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->value)) {
41620 RECEIVE_PACKET_FIELD_ERROR(value);
41621 }
41622#endif /* FREECIV_DELTA_PROTOCOL */
41623
41624 RECEIVE_PACKET_END(real_packet);
41625#undef FREE_PACKET_STRUCT
41626}
41627
41628 static int send_packet_diplomacy_remove_clause_100(struct connection *pc, const struct packet_diplomacy_remove_clause *packet)
41629{
41630 const struct packet_diplomacy_remove_clause *real_packet = packet;
41631 int e;
41632 SEND_PACKET_START(PACKET_DIPLOMACY_REMOVE_CLAUSE);
41633
41634 log_packet_detailed("packet_diplomacy_remove_clause_100: sending info about ()");
41635
41636#ifdef FREECIV_DELTA_PROTOCOL
41637 packet_diplomacy_remove_clause_100_fields fields;
41638 struct packet_diplomacy_remove_clause *old;
41639 bool differ;
41640 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_REMOVE_CLAUSE;
41641
41642 if (nullptr == *hash) {
41643 *hash = genhash_new_full(hash_packet_diplomacy_remove_clause_100, cmp_packet_diplomacy_remove_clause_100,
41644 nullptr, nullptr, nullptr, destroy_packet_diplomacy_remove_clause);
41645 }
41646 BV_CLR_ALL(fields);
41647
41648 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41649 old = fc_malloc(sizeof(*old));
41650 /* temporary bitcopy just to insert correctly */
41651 *old = *real_packet;
41652 genhash_insert(*hash, old, old);
41653 init_packet_diplomacy_remove_clause(old);
41654 }
41655
41656 differ = (old->counterpart != real_packet->counterpart);
41657 if (differ) {
41658 BV_SET(fields, 0);
41659 }
41660
41661 differ = (old->giver != real_packet->giver);
41662 if (differ) {
41663 BV_SET(fields, 1);
41664 }
41665
41666 differ = (old->type != real_packet->type);
41667 if (differ) {
41668 BV_SET(fields, 2);
41669 }
41670
41671 differ = (old->value != real_packet->value);
41672 if (differ) {
41673 BV_SET(fields, 3);
41674 }
41675#endif /* FREECIV_DELTA_PROTOCOL */
41676
41677#ifdef FREECIV_JSON_CONNECTION
41678 struct plocation field_addr;
41679 {
41680 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
41681 field_addr = *field_addr_tmp;
41682 FC_FREE(field_addr_tmp);
41683 }
41684#endif /* FREECIV_JSON_CONNECTION */
41685
41686#ifdef FREECIV_DELTA_PROTOCOL
41687#ifdef FREECIV_JSON_CONNECTION
41688 field_addr.name = "fields";
41689#endif /* FREECIV_JSON_CONNECTION */
41690 e = 0;
41691 e |= DIO_BV_PUT(&dout, &field_addr, fields);
41692 if (e) {
41693 log_packet_detailed("fields bitvector error detected");
41694 }
41695
41696 if (BV_ISSET(fields, 0)) {
41697 log_packet_detailed(" field 'counterpart' has changed");
41698
41699#ifdef FREECIV_JSON_CONNECTION
41700 field_addr.name = "counterpart";
41701#endif /* FREECIV_JSON_CONNECTION */
41702 e = 0;
41703
41704 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
41705
41706 if (e) {
41707 log_packet_detailed("'counterpart' field error detected");
41708 }
41709 }
41710
41711 if (BV_ISSET(fields, 1)) {
41712 log_packet_detailed(" field 'giver' has changed");
41713
41714#ifdef FREECIV_JSON_CONNECTION
41715 field_addr.name = "giver";
41716#endif /* FREECIV_JSON_CONNECTION */
41717 e = 0;
41718
41719 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
41720
41721 if (e) {
41722 log_packet_detailed("'giver' field error detected");
41723 }
41724 }
41725
41726 if (BV_ISSET(fields, 2)) {
41727 log_packet_detailed(" field 'type' has changed");
41728
41729#ifdef FREECIV_JSON_CONNECTION
41730 field_addr.name = "type";
41731#endif /* FREECIV_JSON_CONNECTION */
41732 e = 0;
41733
41734 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
41735
41736 if (e) {
41737 log_packet_detailed("'type' field error detected");
41738 }
41739 }
41740
41741 if (BV_ISSET(fields, 3)) {
41742 log_packet_detailed(" field 'value' has changed");
41743
41744#ifdef FREECIV_JSON_CONNECTION
41745 field_addr.name = "value";
41746#endif /* FREECIV_JSON_CONNECTION */
41747 e = 0;
41748
41749 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
41750
41751 if (e) {
41752 log_packet_detailed("'value' field error detected");
41753 }
41754 }
41755
41756 *old = *real_packet;
41757
41758#else /* FREECIV_DELTA_PROTOCOL */
41759#ifdef FREECIV_JSON_CONNECTION
41760 field_addr.name = "counterpart";
41761#endif /* FREECIV_JSON_CONNECTION */
41762 e = 0;
41763
41764 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
41765
41766 if (e) {
41767 log_packet_detailed("'counterpart' field error detected");
41768 }
41769
41770#ifdef FREECIV_JSON_CONNECTION
41771 field_addr.name = "giver";
41772#endif /* FREECIV_JSON_CONNECTION */
41773 e = 0;
41774
41775 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->giver);
41776
41777 if (e) {
41778 log_packet_detailed("'giver' field error detected");
41779 }
41780
41781#ifdef FREECIV_JSON_CONNECTION
41782 field_addr.name = "type";
41783#endif /* FREECIV_JSON_CONNECTION */
41784 e = 0;
41785
41786 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
41787
41788 if (e) {
41789 log_packet_detailed("'type' field error detected");
41790 }
41791
41792#ifdef FREECIV_JSON_CONNECTION
41793 field_addr.name = "value";
41794#endif /* FREECIV_JSON_CONNECTION */
41795 e = 0;
41796
41797 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->value);
41798
41799 if (e) {
41800 log_packet_detailed("'value' field error detected");
41801 }
41802#endif /* FREECIV_DELTA_PROTOCOL */
41803
41804 SEND_PACKET_END(PACKET_DIPLOMACY_REMOVE_CLAUSE);
41805}
41806
41807 int send_packet_diplomacy_remove_clause(struct connection *pc, const struct packet_diplomacy_remove_clause *packet)
41808{
41809 if (!pc->used) {
41810 log_error("WARNING: trying to send data to the closed connection %s",
41811 conn_description(pc));
41812 return -1;
41813 }
41814 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE].packet != nullptr, -1,
41815 "Handler for PACKET_DIPLOMACY_REMOVE_CLAUSE not installed");
41816 return pc->phs.handlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE].packet(pc, packet);
41817}
41818
41819 void lsend_packet_diplomacy_remove_clause(struct conn_list *dest, const struct packet_diplomacy_remove_clause *packet)
41820{
41821 conn_list_iterate(dest, pconn) {
41822 send_packet_diplomacy_remove_clause(pconn, packet);
41823 } conn_list_iterate_end;
41824}
41825
41826 int dsend_packet_diplomacy_remove_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
41827{
41828 struct packet_diplomacy_remove_clause packet, *real_packet = &packet;
41829
41830 real_packet->counterpart = counterpart;
41831 real_packet->giver = giver;
41832 real_packet->type = type;
41833 real_packet->value = value;
41834
41835 return send_packet_diplomacy_remove_clause(pc, real_packet);
41836}
41837
41838 void dlsend_packet_diplomacy_remove_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
41839{
41840 struct packet_diplomacy_remove_clause packet, *real_packet = &packet;
41841
41842 real_packet->counterpart = counterpart;
41843 real_packet->giver = giver;
41844 real_packet->type = type;
41845 real_packet->value = value;
41846
41847 lsend_packet_diplomacy_remove_clause(dest, real_packet);
41848}
41849
41850 static inline void init_packet_diplomacy_accept_treaty_req(struct packet_diplomacy_accept_treaty_req *packet)
41851{
41852 memset(packet, 0, sizeof(*packet));
41853}
41854
41855#define free_packet_diplomacy_accept_treaty_req(_packet) (void) 0
41856#define destroy_packet_diplomacy_accept_treaty_req free
41857
41858#ifdef FREECIV_DELTA_PROTOCOL
41859#define hash_packet_diplomacy_accept_treaty_req_100 hash_const
41860#define cmp_packet_diplomacy_accept_treaty_req_100 cmp_const
41861 BV_DEFINE(packet_diplomacy_accept_treaty_req_100_fields, 1);
41862#endif /* FREECIV_DELTA_PROTOCOL */
41863
41864 static struct packet_diplomacy_accept_treaty_req *receive_packet_diplomacy_accept_treaty_req_100(struct connection *pc)
41865{
41866#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_accept_treaty_req(_packet)
41867 RECEIVE_PACKET_START(packet_diplomacy_accept_treaty_req, real_packet);
41868
41869#ifdef FREECIV_JSON_CONNECTION
41870 struct plocation field_addr;
41871 {
41872 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
41873 field_addr = *field_addr_tmp;
41874 FC_FREE(field_addr_tmp);
41875 }
41876#endif /* FREECIV_JSON_CONNECTION */
41877
41878 log_packet_detailed("packet_diplomacy_accept_treaty_req_100: got info about ()");
41879
41880#ifdef FREECIV_DELTA_PROTOCOL
41881 packet_diplomacy_accept_treaty_req_100_fields fields;
41882 struct packet_diplomacy_accept_treaty_req *old;
41883 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_ACCEPT_TREATY_REQ;
41884
41885 if (nullptr == *hash) {
41886 *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_req_100, cmp_packet_diplomacy_accept_treaty_req_100,
41887 nullptr, nullptr, nullptr, destroy_packet_diplomacy_accept_treaty_req);
41888 }
41889
41890 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
41891 *real_packet = *old;
41892 } else {
41893 /* packet is already initialized empty */
41894 log_packet_detailed(" no old info");
41895 }
41896
41897#ifdef FREECIV_JSON_CONNECTION
41898 field_addr.name = "fields";
41899#endif /* FREECIV_JSON_CONNECTION */
41900 DIO_BV_GET(&din, &field_addr, fields);
41901
41902 if (BV_ISSET(fields, 0)) {
41903 log_packet_detailed(" got field 'counterpart'");
41904
41905#ifdef FREECIV_JSON_CONNECTION
41906 field_addr.name = "counterpart";
41907#endif /* FREECIV_JSON_CONNECTION */
41908
41909 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
41910 RECEIVE_PACKET_FIELD_ERROR(counterpart);
41911 }
41912 }
41913
41914 if (nullptr == old) {
41915 old = fc_malloc(sizeof(*old));
41916 init_packet_diplomacy_accept_treaty_req(old);
41917 *old = *real_packet;
41918 genhash_insert(*hash, old, old);
41919 } else {
41920 *old = *real_packet;
41921 }
41922
41923#else /* FREECIV_DELTA_PROTOCOL */
41924#ifdef FREECIV_JSON_CONNECTION
41925 field_addr.name = "counterpart";
41926#endif /* FREECIV_JSON_CONNECTION */
41927
41928 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
41929 RECEIVE_PACKET_FIELD_ERROR(counterpart);
41930 }
41931#endif /* FREECIV_DELTA_PROTOCOL */
41932
41933 RECEIVE_PACKET_END(real_packet);
41934#undef FREE_PACKET_STRUCT
41935}
41936
41937 static int send_packet_diplomacy_accept_treaty_req_100(struct connection *pc, const struct packet_diplomacy_accept_treaty_req *packet)
41938{
41939 const struct packet_diplomacy_accept_treaty_req *real_packet = packet;
41940 int e;
41941 SEND_PACKET_START(PACKET_DIPLOMACY_ACCEPT_TREATY_REQ);
41942
41943 log_packet_detailed("packet_diplomacy_accept_treaty_req_100: sending info about ()");
41944
41945#ifdef FREECIV_DELTA_PROTOCOL
41946 packet_diplomacy_accept_treaty_req_100_fields fields;
41947 struct packet_diplomacy_accept_treaty_req *old;
41948 bool differ;
41949 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_ACCEPT_TREATY_REQ;
41950
41951 if (nullptr == *hash) {
41952 *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_req_100, cmp_packet_diplomacy_accept_treaty_req_100,
41953 nullptr, nullptr, nullptr, destroy_packet_diplomacy_accept_treaty_req);
41954 }
41955 BV_CLR_ALL(fields);
41956
41957 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
41958 old = fc_malloc(sizeof(*old));
41959 /* temporary bitcopy just to insert correctly */
41960 *old = *real_packet;
41961 genhash_insert(*hash, old, old);
41962 init_packet_diplomacy_accept_treaty_req(old);
41963 }
41964
41965 differ = (old->counterpart != real_packet->counterpart);
41966 if (differ) {
41967 BV_SET(fields, 0);
41968 }
41969#endif /* FREECIV_DELTA_PROTOCOL */
41970
41971#ifdef FREECIV_JSON_CONNECTION
41972 struct plocation field_addr;
41973 {
41974 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
41975 field_addr = *field_addr_tmp;
41976 FC_FREE(field_addr_tmp);
41977 }
41978#endif /* FREECIV_JSON_CONNECTION */
41979
41980#ifdef FREECIV_DELTA_PROTOCOL
41981#ifdef FREECIV_JSON_CONNECTION
41982 field_addr.name = "fields";
41983#endif /* FREECIV_JSON_CONNECTION */
41984 e = 0;
41985 e |= DIO_BV_PUT(&dout, &field_addr, fields);
41986 if (e) {
41987 log_packet_detailed("fields bitvector error detected");
41988 }
41989
41990 if (BV_ISSET(fields, 0)) {
41991 log_packet_detailed(" field 'counterpart' has changed");
41992
41993#ifdef FREECIV_JSON_CONNECTION
41994 field_addr.name = "counterpart";
41995#endif /* FREECIV_JSON_CONNECTION */
41996 e = 0;
41997
41998 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
41999
42000 if (e) {
42001 log_packet_detailed("'counterpart' field error detected");
42002 }
42003 }
42004
42005 *old = *real_packet;
42006
42007#else /* FREECIV_DELTA_PROTOCOL */
42008#ifdef FREECIV_JSON_CONNECTION
42009 field_addr.name = "counterpart";
42010#endif /* FREECIV_JSON_CONNECTION */
42011 e = 0;
42012
42013 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
42014
42015 if (e) {
42016 log_packet_detailed("'counterpart' field error detected");
42017 }
42018#endif /* FREECIV_DELTA_PROTOCOL */
42019
42020 SEND_PACKET_END(PACKET_DIPLOMACY_ACCEPT_TREATY_REQ);
42021}
42022
42023 int send_packet_diplomacy_accept_treaty_req(struct connection *pc, const struct packet_diplomacy_accept_treaty_req *packet)
42024{
42025 if (!pc->used) {
42026 log_error("WARNING: trying to send data to the closed connection %s",
42027 conn_description(pc));
42028 return -1;
42029 }
42030 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ].packet != nullptr, -1,
42031 "Handler for PACKET_DIPLOMACY_ACCEPT_TREATY_REQ not installed");
42032 return pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ].packet(pc, packet);
42033}
42034
42035 int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
42036{
42037 struct packet_diplomacy_accept_treaty_req packet, *real_packet = &packet;
42038
42039 real_packet->counterpart = counterpart;
42040
42041 return send_packet_diplomacy_accept_treaty_req(pc, real_packet);
42042}
42043
42044 static inline void init_packet_diplomacy_accept_treaty(struct packet_diplomacy_accept_treaty *packet)
42045{
42046 memset(packet, 0, sizeof(*packet));
42047}
42048
42049#define free_packet_diplomacy_accept_treaty(_packet) (void) 0
42050#define destroy_packet_diplomacy_accept_treaty free
42051
42052#ifdef FREECIV_DELTA_PROTOCOL
42053#define hash_packet_diplomacy_accept_treaty_100 hash_const
42054#define cmp_packet_diplomacy_accept_treaty_100 cmp_const
42055 BV_DEFINE(packet_diplomacy_accept_treaty_100_fields, 3);
42056#endif /* FREECIV_DELTA_PROTOCOL */
42057
42058 static struct packet_diplomacy_accept_treaty *receive_packet_diplomacy_accept_treaty_100(struct connection *pc)
42059{
42060#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_accept_treaty(_packet)
42061 RECEIVE_PACKET_START(packet_diplomacy_accept_treaty, real_packet);
42062
42063#ifdef FREECIV_JSON_CONNECTION
42064 struct plocation field_addr;
42065 {
42066 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42067 field_addr = *field_addr_tmp;
42068 FC_FREE(field_addr_tmp);
42069 }
42070#endif /* FREECIV_JSON_CONNECTION */
42071
42072 log_packet_detailed("packet_diplomacy_accept_treaty_100: got info about ()");
42073
42074#ifdef FREECIV_DELTA_PROTOCOL
42075 packet_diplomacy_accept_treaty_100_fields fields;
42076 struct packet_diplomacy_accept_treaty *old;
42077 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_ACCEPT_TREATY;
42078
42079 if (nullptr == *hash) {
42080 *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_100, cmp_packet_diplomacy_accept_treaty_100,
42081 nullptr, nullptr, nullptr, destroy_packet_diplomacy_accept_treaty);
42082 }
42083
42084 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42085 *real_packet = *old;
42086 } else {
42087 /* packet is already initialized empty */
42088 log_packet_detailed(" no old info");
42089 }
42090
42091#ifdef FREECIV_JSON_CONNECTION
42092 field_addr.name = "fields";
42093#endif /* FREECIV_JSON_CONNECTION */
42094 DIO_BV_GET(&din, &field_addr, fields);
42095
42096 if (BV_ISSET(fields, 0)) {
42097 log_packet_detailed(" got field 'counterpart'");
42098
42099#ifdef FREECIV_JSON_CONNECTION
42100 field_addr.name = "counterpart";
42101#endif /* FREECIV_JSON_CONNECTION */
42102
42103 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
42104 RECEIVE_PACKET_FIELD_ERROR(counterpart);
42105 }
42106 }
42107
42108 real_packet->I_accepted = BV_ISSET(fields, 1);
42109
42110 real_packet->other_accepted = BV_ISSET(fields, 2);
42111
42112 if (nullptr == old) {
42113 old = fc_malloc(sizeof(*old));
42114 init_packet_diplomacy_accept_treaty(old);
42115 *old = *real_packet;
42116 genhash_insert(*hash, old, old);
42117 } else {
42118 *old = *real_packet;
42119 }
42120
42121#else /* FREECIV_DELTA_PROTOCOL */
42122#ifdef FREECIV_JSON_CONNECTION
42123 field_addr.name = "counterpart";
42124#endif /* FREECIV_JSON_CONNECTION */
42125
42126 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->counterpart)) {
42127 RECEIVE_PACKET_FIELD_ERROR(counterpart);
42128 }
42129
42130#ifdef FREECIV_JSON_CONNECTION
42131 field_addr.name = "I_accepted";
42132#endif /* FREECIV_JSON_CONNECTION */
42133
42134 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->I_accepted)) {
42135 RECEIVE_PACKET_FIELD_ERROR(I_accepted);
42136 }
42137
42138#ifdef FREECIV_JSON_CONNECTION
42139 field_addr.name = "other_accepted";
42140#endif /* FREECIV_JSON_CONNECTION */
42141
42142 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->other_accepted)) {
42143 RECEIVE_PACKET_FIELD_ERROR(other_accepted);
42144 }
42145#endif /* FREECIV_DELTA_PROTOCOL */
42146
42147 RECEIVE_PACKET_END(real_packet);
42148#undef FREE_PACKET_STRUCT
42149}
42150
42151 static int send_packet_diplomacy_accept_treaty_100(struct connection *pc, const struct packet_diplomacy_accept_treaty *packet)
42152{
42153 const struct packet_diplomacy_accept_treaty *real_packet = packet;
42154 int e;
42155 SEND_PACKET_START(PACKET_DIPLOMACY_ACCEPT_TREATY);
42156
42157 log_packet_detailed("packet_diplomacy_accept_treaty_100: sending info about ()");
42158
42159#ifdef FREECIV_DELTA_PROTOCOL
42160 packet_diplomacy_accept_treaty_100_fields fields;
42161 struct packet_diplomacy_accept_treaty *old;
42162 bool differ;
42163 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_ACCEPT_TREATY;
42164
42165 if (nullptr == *hash) {
42166 *hash = genhash_new_full(hash_packet_diplomacy_accept_treaty_100, cmp_packet_diplomacy_accept_treaty_100,
42167 nullptr, nullptr, nullptr, destroy_packet_diplomacy_accept_treaty);
42168 }
42169 BV_CLR_ALL(fields);
42170
42171 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42172 old = fc_malloc(sizeof(*old));
42173 /* temporary bitcopy just to insert correctly */
42174 *old = *real_packet;
42175 genhash_insert(*hash, old, old);
42176 init_packet_diplomacy_accept_treaty(old);
42177 }
42178
42179 differ = (old->counterpart != real_packet->counterpart);
42180 if (differ) {
42181 BV_SET(fields, 0);
42182 }
42183
42184 /* folded into head */
42185 if (real_packet->I_accepted) {
42186 BV_SET(fields, 1);
42187 }
42188
42189 /* folded into head */
42190 if (real_packet->other_accepted) {
42191 BV_SET(fields, 2);
42192 }
42193#endif /* FREECIV_DELTA_PROTOCOL */
42194
42195#ifdef FREECIV_JSON_CONNECTION
42196 struct plocation field_addr;
42197 {
42198 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42199 field_addr = *field_addr_tmp;
42200 FC_FREE(field_addr_tmp);
42201 }
42202#endif /* FREECIV_JSON_CONNECTION */
42203
42204#ifdef FREECIV_DELTA_PROTOCOL
42205#ifdef FREECIV_JSON_CONNECTION
42206 field_addr.name = "fields";
42207#endif /* FREECIV_JSON_CONNECTION */
42208 e = 0;
42209 e |= DIO_BV_PUT(&dout, &field_addr, fields);
42210 if (e) {
42211 log_packet_detailed("fields bitvector error detected");
42212 }
42213
42214 if (BV_ISSET(fields, 0)) {
42215 log_packet_detailed(" field 'counterpart' has changed");
42216
42217#ifdef FREECIV_JSON_CONNECTION
42218 field_addr.name = "counterpart";
42219#endif /* FREECIV_JSON_CONNECTION */
42220 e = 0;
42221
42222 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
42223
42224 if (e) {
42225 log_packet_detailed("'counterpart' field error detected");
42226 }
42227 }
42228
42229 /* field 1 is folded into the header */
42230
42231 /* field 2 is folded into the header */
42232
42233 *old = *real_packet;
42234
42235#else /* FREECIV_DELTA_PROTOCOL */
42236#ifdef FREECIV_JSON_CONNECTION
42237 field_addr.name = "counterpart";
42238#endif /* FREECIV_JSON_CONNECTION */
42239 e = 0;
42240
42241 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->counterpart);
42242
42243 if (e) {
42244 log_packet_detailed("'counterpart' field error detected");
42245 }
42246
42247#ifdef FREECIV_JSON_CONNECTION
42248 field_addr.name = "I_accepted";
42249#endif /* FREECIV_JSON_CONNECTION */
42250 e = 0;
42251
42252 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->I_accepted);
42253
42254 if (e) {
42255 log_packet_detailed("'I_accepted' field error detected");
42256 }
42257
42258#ifdef FREECIV_JSON_CONNECTION
42259 field_addr.name = "other_accepted";
42260#endif /* FREECIV_JSON_CONNECTION */
42261 e = 0;
42262
42263 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->other_accepted);
42264
42265 if (e) {
42266 log_packet_detailed("'other_accepted' field error detected");
42267 }
42268#endif /* FREECIV_DELTA_PROTOCOL */
42269
42270 SEND_PACKET_END(PACKET_DIPLOMACY_ACCEPT_TREATY);
42271}
42272
42273 int send_packet_diplomacy_accept_treaty(struct connection *pc, const struct packet_diplomacy_accept_treaty *packet)
42274{
42275 if (!pc->used) {
42276 log_error("WARNING: trying to send data to the closed connection %s",
42277 conn_description(pc));
42278 return -1;
42279 }
42280 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY].packet != nullptr, -1,
42281 "Handler for PACKET_DIPLOMACY_ACCEPT_TREATY not installed");
42282 return pc->phs.handlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY].packet(pc, packet);
42283}
42284
42285 void lsend_packet_diplomacy_accept_treaty(struct conn_list *dest, const struct packet_diplomacy_accept_treaty *packet)
42286{
42287 conn_list_iterate(dest, pconn) {
42288 send_packet_diplomacy_accept_treaty(pconn, packet);
42289 } conn_list_iterate_end;
42290}
42291
42292 int dsend_packet_diplomacy_accept_treaty(struct connection *pc, int counterpart, bool I_accepted, bool other_accepted)
42293{
42294 struct packet_diplomacy_accept_treaty packet, *real_packet = &packet;
42295
42296 real_packet->counterpart = counterpart;
42297 real_packet->I_accepted = I_accepted;
42298 real_packet->other_accepted = other_accepted;
42299
42300 return send_packet_diplomacy_accept_treaty(pc, real_packet);
42301}
42302
42303 void dlsend_packet_diplomacy_accept_treaty(struct conn_list *dest, int counterpart, bool I_accepted, bool other_accepted)
42304{
42305 struct packet_diplomacy_accept_treaty packet, *real_packet = &packet;
42306
42307 real_packet->counterpart = counterpart;
42308 real_packet->I_accepted = I_accepted;
42309 real_packet->other_accepted = other_accepted;
42310
42311 lsend_packet_diplomacy_accept_treaty(dest, real_packet);
42312}
42313
42314 static inline void init_packet_diplomacy_cancel_pact(struct packet_diplomacy_cancel_pact *packet)
42315{
42316 memset(packet, 0, sizeof(*packet));
42317}
42318
42319#define free_packet_diplomacy_cancel_pact(_packet) (void) 0
42320#define destroy_packet_diplomacy_cancel_pact free
42321
42322#ifdef FREECIV_DELTA_PROTOCOL
42323#define hash_packet_diplomacy_cancel_pact_100 hash_const
42324#define cmp_packet_diplomacy_cancel_pact_100 cmp_const
42325 BV_DEFINE(packet_diplomacy_cancel_pact_100_fields, 2);
42326#endif /* FREECIV_DELTA_PROTOCOL */
42327
42328 static struct packet_diplomacy_cancel_pact *receive_packet_diplomacy_cancel_pact_100(struct connection *pc)
42329{
42330#define FREE_PACKET_STRUCT(_packet) free_packet_diplomacy_cancel_pact(_packet)
42331 RECEIVE_PACKET_START(packet_diplomacy_cancel_pact, real_packet);
42332
42333#ifdef FREECIV_JSON_CONNECTION
42334 struct plocation field_addr;
42335 {
42336 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42337 field_addr = *field_addr_tmp;
42338 FC_FREE(field_addr_tmp);
42339 }
42340#endif /* FREECIV_JSON_CONNECTION */
42341
42342 log_packet_detailed("packet_diplomacy_cancel_pact_100: got info about ()");
42343
42344#ifdef FREECIV_DELTA_PROTOCOL
42345 packet_diplomacy_cancel_pact_100_fields fields;
42346 struct packet_diplomacy_cancel_pact *old;
42347 struct genhash **hash = pc->phs.received + PACKET_DIPLOMACY_CANCEL_PACT;
42348
42349 if (nullptr == *hash) {
42350 *hash = genhash_new_full(hash_packet_diplomacy_cancel_pact_100, cmp_packet_diplomacy_cancel_pact_100,
42351 nullptr, nullptr, nullptr, destroy_packet_diplomacy_cancel_pact);
42352 }
42353
42354 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42355 *real_packet = *old;
42356 } else {
42357 /* packet is already initialized empty */
42358 log_packet_detailed(" no old info");
42359 }
42360
42361#ifdef FREECIV_JSON_CONNECTION
42362 field_addr.name = "fields";
42363#endif /* FREECIV_JSON_CONNECTION */
42364 DIO_BV_GET(&din, &field_addr, fields);
42365
42366 if (BV_ISSET(fields, 0)) {
42367 log_packet_detailed(" got field 'other_player_id'");
42368
42369#ifdef FREECIV_JSON_CONNECTION
42370 field_addr.name = "other_player_id";
42371#endif /* FREECIV_JSON_CONNECTION */
42372
42373 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->other_player_id)) {
42374 RECEIVE_PACKET_FIELD_ERROR(other_player_id);
42375 }
42376 }
42377
42378 if (BV_ISSET(fields, 1)) {
42379 log_packet_detailed(" got field 'clause'");
42380
42381#ifdef FREECIV_JSON_CONNECTION
42382 field_addr.name = "clause";
42383#endif /* FREECIV_JSON_CONNECTION */
42384
42385 {
42386 int readin;
42387
42388 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
42389 RECEIVE_PACKET_FIELD_ERROR(clause);
42390 }
42391 real_packet->clause = readin;
42392 }
42393 }
42394
42395 if (nullptr == old) {
42396 old = fc_malloc(sizeof(*old));
42397 init_packet_diplomacy_cancel_pact(old);
42398 *old = *real_packet;
42399 genhash_insert(*hash, old, old);
42400 } else {
42401 *old = *real_packet;
42402 }
42403
42404#else /* FREECIV_DELTA_PROTOCOL */
42405#ifdef FREECIV_JSON_CONNECTION
42406 field_addr.name = "other_player_id";
42407#endif /* FREECIV_JSON_CONNECTION */
42408
42409 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->other_player_id)) {
42410 RECEIVE_PACKET_FIELD_ERROR(other_player_id);
42411 }
42412
42413#ifdef FREECIV_JSON_CONNECTION
42414 field_addr.name = "clause";
42415#endif /* FREECIV_JSON_CONNECTION */
42416
42417 {
42418 int readin;
42419
42420 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
42421 RECEIVE_PACKET_FIELD_ERROR(clause);
42422 }
42423 real_packet->clause = readin;
42424 }
42425#endif /* FREECIV_DELTA_PROTOCOL */
42426
42427 RECEIVE_PACKET_END(real_packet);
42428#undef FREE_PACKET_STRUCT
42429}
42430
42431 static int send_packet_diplomacy_cancel_pact_100(struct connection *pc, const struct packet_diplomacy_cancel_pact *packet)
42432{
42433 const struct packet_diplomacy_cancel_pact *real_packet = packet;
42434 int e;
42435 SEND_PACKET_START(PACKET_DIPLOMACY_CANCEL_PACT);
42436
42437 log_packet_detailed("packet_diplomacy_cancel_pact_100: sending info about ()");
42438
42439#ifdef FREECIV_DELTA_PROTOCOL
42440 packet_diplomacy_cancel_pact_100_fields fields;
42441 struct packet_diplomacy_cancel_pact *old;
42442 bool differ;
42443 struct genhash **hash = pc->phs.sent + PACKET_DIPLOMACY_CANCEL_PACT;
42444
42445 if (nullptr == *hash) {
42446 *hash = genhash_new_full(hash_packet_diplomacy_cancel_pact_100, cmp_packet_diplomacy_cancel_pact_100,
42447 nullptr, nullptr, nullptr, destroy_packet_diplomacy_cancel_pact);
42448 }
42449 BV_CLR_ALL(fields);
42450
42451 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42452 old = fc_malloc(sizeof(*old));
42453 /* temporary bitcopy just to insert correctly */
42454 *old = *real_packet;
42455 genhash_insert(*hash, old, old);
42456 init_packet_diplomacy_cancel_pact(old);
42457 }
42458
42459 differ = (old->other_player_id != real_packet->other_player_id);
42460 if (differ) {
42461 BV_SET(fields, 0);
42462 }
42463
42464 differ = (old->clause != real_packet->clause);
42465 if (differ) {
42466 BV_SET(fields, 1);
42467 }
42468#endif /* FREECIV_DELTA_PROTOCOL */
42469
42470#ifdef FREECIV_JSON_CONNECTION
42471 struct plocation field_addr;
42472 {
42473 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42474 field_addr = *field_addr_tmp;
42475 FC_FREE(field_addr_tmp);
42476 }
42477#endif /* FREECIV_JSON_CONNECTION */
42478
42479#ifdef FREECIV_DELTA_PROTOCOL
42480#ifdef FREECIV_JSON_CONNECTION
42481 field_addr.name = "fields";
42482#endif /* FREECIV_JSON_CONNECTION */
42483 e = 0;
42484 e |= DIO_BV_PUT(&dout, &field_addr, fields);
42485 if (e) {
42486 log_packet_detailed("fields bitvector error detected");
42487 }
42488
42489 if (BV_ISSET(fields, 0)) {
42490 log_packet_detailed(" field 'other_player_id' has changed");
42491
42492#ifdef FREECIV_JSON_CONNECTION
42493 field_addr.name = "other_player_id";
42494#endif /* FREECIV_JSON_CONNECTION */
42495 e = 0;
42496
42497 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->other_player_id);
42498
42499 if (e) {
42500 log_packet_detailed("'other_player_id' field error detected");
42501 }
42502 }
42503
42504 if (BV_ISSET(fields, 1)) {
42505 log_packet_detailed(" field 'clause' has changed");
42506
42507#ifdef FREECIV_JSON_CONNECTION
42508 field_addr.name = "clause";
42509#endif /* FREECIV_JSON_CONNECTION */
42510 e = 0;
42511
42512 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->clause);
42513
42514 if (e) {
42515 log_packet_detailed("'clause' field error detected");
42516 }
42517 }
42518
42519 *old = *real_packet;
42520
42521#else /* FREECIV_DELTA_PROTOCOL */
42522#ifdef FREECIV_JSON_CONNECTION
42523 field_addr.name = "other_player_id";
42524#endif /* FREECIV_JSON_CONNECTION */
42525 e = 0;
42526
42527 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->other_player_id);
42528
42529 if (e) {
42530 log_packet_detailed("'other_player_id' field error detected");
42531 }
42532
42533#ifdef FREECIV_JSON_CONNECTION
42534 field_addr.name = "clause";
42535#endif /* FREECIV_JSON_CONNECTION */
42536 e = 0;
42537
42538 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->clause);
42539
42540 if (e) {
42541 log_packet_detailed("'clause' field error detected");
42542 }
42543#endif /* FREECIV_DELTA_PROTOCOL */
42544
42545 SEND_PACKET_END(PACKET_DIPLOMACY_CANCEL_PACT);
42546}
42547
42548 int send_packet_diplomacy_cancel_pact(struct connection *pc, const struct packet_diplomacy_cancel_pact *packet)
42549{
42550 if (!pc->used) {
42551 log_error("WARNING: trying to send data to the closed connection %s",
42552 conn_description(pc));
42553 return -1;
42554 }
42555 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_PACT].packet != nullptr, -1,
42556 "Handler for PACKET_DIPLOMACY_CANCEL_PACT not installed");
42557 return pc->phs.handlers->send[PACKET_DIPLOMACY_CANCEL_PACT].packet(pc, packet);
42558}
42559
42560 int dsend_packet_diplomacy_cancel_pact(struct connection *pc, int other_player_id, enum clause_type clause)
42561{
42562 struct packet_diplomacy_cancel_pact packet, *real_packet = &packet;
42563
42564 real_packet->other_player_id = other_player_id;
42565 real_packet->clause = clause;
42566
42567 return send_packet_diplomacy_cancel_pact(pc, real_packet);
42568}
42569
42570 static inline void init_packet_page_msg(struct packet_page_msg *packet)
42571{
42572 memset(packet, 0, sizeof(*packet));
42573}
42574
42575#define free_packet_page_msg(_packet) (void) 0
42576#define destroy_packet_page_msg free
42577
42578#ifdef FREECIV_DELTA_PROTOCOL
42579#define hash_packet_page_msg_100 hash_const
42580#define cmp_packet_page_msg_100 cmp_const
42581 BV_DEFINE(packet_page_msg_100_fields, 5);
42582#endif /* FREECIV_DELTA_PROTOCOL */
42583
42584 static struct packet_page_msg *receive_packet_page_msg_100(struct connection *pc)
42585{
42586#define FREE_PACKET_STRUCT(_packet) free_packet_page_msg(_packet)
42587 RECEIVE_PACKET_START(packet_page_msg, real_packet);
42588
42589#ifdef FREECIV_JSON_CONNECTION
42590 struct plocation field_addr;
42591 {
42592 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42593 field_addr = *field_addr_tmp;
42594 FC_FREE(field_addr_tmp);
42595 }
42596#endif /* FREECIV_JSON_CONNECTION */
42597
42598 log_packet_detailed("packet_page_msg_100: got info about ()");
42599
42600#ifdef FREECIV_DELTA_PROTOCOL
42601 packet_page_msg_100_fields fields;
42602 struct packet_page_msg *old;
42603 struct genhash **hash = pc->phs.received + PACKET_PAGE_MSG;
42604
42605 if (nullptr == *hash) {
42606 *hash = genhash_new_full(hash_packet_page_msg_100, cmp_packet_page_msg_100,
42607 nullptr, nullptr, nullptr, destroy_packet_page_msg);
42608 }
42609
42610 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
42611 *real_packet = *old;
42612 } else {
42613 /* packet is already initialized empty */
42614 log_packet_detailed(" no old info");
42615 }
42616
42617#ifdef FREECIV_JSON_CONNECTION
42618 field_addr.name = "fields";
42619#endif /* FREECIV_JSON_CONNECTION */
42620 DIO_BV_GET(&din, &field_addr, fields);
42621
42622 if (BV_ISSET(fields, 0)) {
42623 log_packet_detailed(" got field 'caption'");
42624
42625#ifdef FREECIV_JSON_CONNECTION
42626 field_addr.name = "caption";
42627#endif /* FREECIV_JSON_CONNECTION */
42628
42629 if (!DIO_GET(string, &din, &field_addr, real_packet->caption, sizeof(real_packet->caption))) {
42630 RECEIVE_PACKET_FIELD_ERROR(caption);
42631 }
42632 }
42633
42634 if (BV_ISSET(fields, 1)) {
42635 log_packet_detailed(" got field 'headline'");
42636
42637#ifdef FREECIV_JSON_CONNECTION
42638 field_addr.name = "headline";
42639#endif /* FREECIV_JSON_CONNECTION */
42640
42641 if (!DIO_GET(string, &din, &field_addr, real_packet->headline, sizeof(real_packet->headline))) {
42642 RECEIVE_PACKET_FIELD_ERROR(headline);
42643 }
42644 }
42645
42646 if (BV_ISSET(fields, 2)) {
42647 log_packet_detailed(" got field 'event'");
42648
42649#ifdef FREECIV_JSON_CONNECTION
42650 field_addr.name = "event";
42651#endif /* FREECIV_JSON_CONNECTION */
42652
42653 {
42654 int readin;
42655
42656 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
42657 RECEIVE_PACKET_FIELD_ERROR(event);
42658 }
42659 real_packet->event = readin;
42660 }
42661 }
42662
42663 if (BV_ISSET(fields, 3)) {
42664 log_packet_detailed(" got field 'len'");
42665
42666#ifdef FREECIV_JSON_CONNECTION
42667 field_addr.name = "len";
42668#endif /* FREECIV_JSON_CONNECTION */
42669
42670 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->len)) {
42671 RECEIVE_PACKET_FIELD_ERROR(len);
42672 }
42673 }
42674
42675 if (BV_ISSET(fields, 4)) {
42676 log_packet_detailed(" got field 'parts'");
42677
42678#ifdef FREECIV_JSON_CONNECTION
42679 field_addr.name = "parts";
42680#endif /* FREECIV_JSON_CONNECTION */
42681
42682 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->parts)) {
42683 RECEIVE_PACKET_FIELD_ERROR(parts);
42684 }
42685 }
42686
42687 if (nullptr == old) {
42688 old = fc_malloc(sizeof(*old));
42689 init_packet_page_msg(old);
42690 *old = *real_packet;
42691 genhash_insert(*hash, old, old);
42692 } else {
42693 *old = *real_packet;
42694 }
42695
42696#else /* FREECIV_DELTA_PROTOCOL */
42697#ifdef FREECIV_JSON_CONNECTION
42698 field_addr.name = "caption";
42699#endif /* FREECIV_JSON_CONNECTION */
42700
42701 if (!DIO_GET(string, &din, &field_addr, real_packet->caption, sizeof(real_packet->caption))) {
42702 RECEIVE_PACKET_FIELD_ERROR(caption);
42703 }
42704
42705#ifdef FREECIV_JSON_CONNECTION
42706 field_addr.name = "headline";
42707#endif /* FREECIV_JSON_CONNECTION */
42708
42709 if (!DIO_GET(string, &din, &field_addr, real_packet->headline, sizeof(real_packet->headline))) {
42710 RECEIVE_PACKET_FIELD_ERROR(headline);
42711 }
42712
42713#ifdef FREECIV_JSON_CONNECTION
42714 field_addr.name = "event";
42715#endif /* FREECIV_JSON_CONNECTION */
42716
42717 {
42718 int readin;
42719
42720 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
42721 RECEIVE_PACKET_FIELD_ERROR(event);
42722 }
42723 real_packet->event = readin;
42724 }
42725
42726#ifdef FREECIV_JSON_CONNECTION
42727 field_addr.name = "len";
42728#endif /* FREECIV_JSON_CONNECTION */
42729
42730 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->len)) {
42731 RECEIVE_PACKET_FIELD_ERROR(len);
42732 }
42733
42734#ifdef FREECIV_JSON_CONNECTION
42735 field_addr.name = "parts";
42736#endif /* FREECIV_JSON_CONNECTION */
42737
42738 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->parts)) {
42739 RECEIVE_PACKET_FIELD_ERROR(parts);
42740 }
42741#endif /* FREECIV_DELTA_PROTOCOL */
42742
42743 RECEIVE_PACKET_END(real_packet);
42744#undef FREE_PACKET_STRUCT
42745}
42746
42747 static int send_packet_page_msg_100(struct connection *pc, const struct packet_page_msg *packet)
42748{
42749 const struct packet_page_msg *real_packet = packet;
42750 int e;
42751 SEND_PACKET_START(PACKET_PAGE_MSG);
42752
42753 log_packet_detailed("packet_page_msg_100: sending info about ()");
42754
42755#ifdef FREECIV_DELTA_PROTOCOL
42756 packet_page_msg_100_fields fields;
42757 struct packet_page_msg *old;
42758 bool differ;
42759 struct genhash **hash = pc->phs.sent + PACKET_PAGE_MSG;
42760
42761 if (nullptr == *hash) {
42762 *hash = genhash_new_full(hash_packet_page_msg_100, cmp_packet_page_msg_100,
42763 nullptr, nullptr, nullptr, destroy_packet_page_msg);
42764 }
42765 BV_CLR_ALL(fields);
42766
42767 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
42768 old = fc_malloc(sizeof(*old));
42769 /* temporary bitcopy just to insert correctly */
42770 *old = *real_packet;
42771 genhash_insert(*hash, old, old);
42772 init_packet_page_msg(old);
42773 }
42774
42775 differ = (strcmp(old->caption, real_packet->caption) != 0);
42776 if (differ) {
42777 BV_SET(fields, 0);
42778 }
42779
42780 differ = (strcmp(old->headline, real_packet->headline) != 0);
42781 if (differ) {
42782 BV_SET(fields, 1);
42783 }
42784
42785 differ = (old->event != real_packet->event);
42786 if (differ) {
42787 BV_SET(fields, 2);
42788 }
42789
42790 differ = (old->len != real_packet->len);
42791 if (differ) {
42792 BV_SET(fields, 3);
42793 }
42794
42795 differ = (old->parts != real_packet->parts);
42796 if (differ) {
42797 BV_SET(fields, 4);
42798 }
42799#endif /* FREECIV_DELTA_PROTOCOL */
42800
42801#ifdef FREECIV_JSON_CONNECTION
42802 struct plocation field_addr;
42803 {
42804 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42805 field_addr = *field_addr_tmp;
42806 FC_FREE(field_addr_tmp);
42807 }
42808#endif /* FREECIV_JSON_CONNECTION */
42809
42810#ifdef FREECIV_DELTA_PROTOCOL
42811#ifdef FREECIV_JSON_CONNECTION
42812 field_addr.name = "fields";
42813#endif /* FREECIV_JSON_CONNECTION */
42814 e = 0;
42815 e |= DIO_BV_PUT(&dout, &field_addr, fields);
42816 if (e) {
42817 log_packet_detailed("fields bitvector error detected");
42818 }
42819
42820 if (BV_ISSET(fields, 0)) {
42821 log_packet_detailed(" field 'caption' has changed");
42822
42823#ifdef FREECIV_JSON_CONNECTION
42824 field_addr.name = "caption";
42825#endif /* FREECIV_JSON_CONNECTION */
42826 e = 0;
42827
42828 e |= DIO_PUT(string, &dout, &field_addr, real_packet->caption);
42829
42830 if (e) {
42831 log_packet_detailed("'caption' field error detected");
42832 }
42833 }
42834
42835 if (BV_ISSET(fields, 1)) {
42836 log_packet_detailed(" field 'headline' has changed");
42837
42838#ifdef FREECIV_JSON_CONNECTION
42839 field_addr.name = "headline";
42840#endif /* FREECIV_JSON_CONNECTION */
42841 e = 0;
42842
42843 e |= DIO_PUT(string, &dout, &field_addr, real_packet->headline);
42844
42845 if (e) {
42846 log_packet_detailed("'headline' field error detected");
42847 }
42848 }
42849
42850 if (BV_ISSET(fields, 2)) {
42851 log_packet_detailed(" field 'event' has changed");
42852
42853#ifdef FREECIV_JSON_CONNECTION
42854 field_addr.name = "event";
42855#endif /* FREECIV_JSON_CONNECTION */
42856 e = 0;
42857
42858 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->event);
42859
42860 if (e) {
42861 log_packet_detailed("'event' field error detected");
42862 }
42863 }
42864
42865 if (BV_ISSET(fields, 3)) {
42866 log_packet_detailed(" field 'len' has changed");
42867
42868#ifdef FREECIV_JSON_CONNECTION
42869 field_addr.name = "len";
42870#endif /* FREECIV_JSON_CONNECTION */
42871 e = 0;
42872
42873 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->len);
42874
42875 if (e) {
42876 log_packet_detailed("'len' field error detected");
42877 }
42878 }
42879
42880 if (BV_ISSET(fields, 4)) {
42881 log_packet_detailed(" field 'parts' has changed");
42882
42883#ifdef FREECIV_JSON_CONNECTION
42884 field_addr.name = "parts";
42885#endif /* FREECIV_JSON_CONNECTION */
42886 e = 0;
42887
42888 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->parts);
42889
42890 if (e) {
42891 log_packet_detailed("'parts' field error detected");
42892 }
42893 }
42894
42895 *old = *real_packet;
42896
42897#else /* FREECIV_DELTA_PROTOCOL */
42898#ifdef FREECIV_JSON_CONNECTION
42899 field_addr.name = "caption";
42900#endif /* FREECIV_JSON_CONNECTION */
42901 e = 0;
42902
42903 e |= DIO_PUT(string, &dout, &field_addr, real_packet->caption);
42904
42905 if (e) {
42906 log_packet_detailed("'caption' field error detected");
42907 }
42908
42909#ifdef FREECIV_JSON_CONNECTION
42910 field_addr.name = "headline";
42911#endif /* FREECIV_JSON_CONNECTION */
42912 e = 0;
42913
42914 e |= DIO_PUT(string, &dout, &field_addr, real_packet->headline);
42915
42916 if (e) {
42917 log_packet_detailed("'headline' field error detected");
42918 }
42919
42920#ifdef FREECIV_JSON_CONNECTION
42921 field_addr.name = "event";
42922#endif /* FREECIV_JSON_CONNECTION */
42923 e = 0;
42924
42925 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->event);
42926
42927 if (e) {
42928 log_packet_detailed("'event' field error detected");
42929 }
42930
42931#ifdef FREECIV_JSON_CONNECTION
42932 field_addr.name = "len";
42933#endif /* FREECIV_JSON_CONNECTION */
42934 e = 0;
42935
42936 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->len);
42937
42938 if (e) {
42939 log_packet_detailed("'len' field error detected");
42940 }
42941
42942#ifdef FREECIV_JSON_CONNECTION
42943 field_addr.name = "parts";
42944#endif /* FREECIV_JSON_CONNECTION */
42945 e = 0;
42946
42947 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->parts);
42948
42949 if (e) {
42950 log_packet_detailed("'parts' field error detected");
42951 }
42952#endif /* FREECIV_DELTA_PROTOCOL */
42953
42954 SEND_PACKET_END(PACKET_PAGE_MSG);
42955}
42956
42957 int send_packet_page_msg(struct connection *pc, const struct packet_page_msg *packet)
42958{
42959 if (!pc->used) {
42960 log_error("WARNING: trying to send data to the closed connection %s",
42961 conn_description(pc));
42962 return -1;
42963 }
42964 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PAGE_MSG].packet != nullptr, -1,
42965 "Handler for PACKET_PAGE_MSG not installed");
42966 return pc->phs.handlers->send[PACKET_PAGE_MSG].packet(pc, packet);
42967}
42968
42969 void lsend_packet_page_msg(struct conn_list *dest, const struct packet_page_msg *packet)
42970{
42971 conn_list_iterate(dest, pconn) {
42972 send_packet_page_msg(pconn, packet);
42973 } conn_list_iterate_end;
42974}
42975
42976 static inline void init_packet_page_msg_part(struct packet_page_msg_part *packet)
42977{
42978 memset(packet, 0, sizeof(*packet));
42979}
42980
42981#define free_packet_page_msg_part(_packet) (void) 0
42982#define destroy_packet_page_msg_part free
42983
42984#ifdef FREECIV_DELTA_PROTOCOL
42985#define hash_packet_page_msg_part_100 hash_const
42986#define cmp_packet_page_msg_part_100 cmp_const
42987 BV_DEFINE(packet_page_msg_part_100_fields, 1);
42988#endif /* FREECIV_DELTA_PROTOCOL */
42989
42990 static struct packet_page_msg_part *receive_packet_page_msg_part_100(struct connection *pc)
42991{
42992#define FREE_PACKET_STRUCT(_packet) free_packet_page_msg_part(_packet)
42993 RECEIVE_PACKET_START(packet_page_msg_part, real_packet);
42994
42995#ifdef FREECIV_JSON_CONNECTION
42996 struct plocation field_addr;
42997 {
42998 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
42999 field_addr = *field_addr_tmp;
43000 FC_FREE(field_addr_tmp);
43001 }
43002#endif /* FREECIV_JSON_CONNECTION */
43003
43004 log_packet_detailed("packet_page_msg_part_100: got info about ()");
43005
43006#ifdef FREECIV_DELTA_PROTOCOL
43007 packet_page_msg_part_100_fields fields;
43008 struct packet_page_msg_part *old;
43009 struct genhash **hash = pc->phs.received + PACKET_PAGE_MSG_PART;
43010
43011 if (nullptr == *hash) {
43012 *hash = genhash_new_full(hash_packet_page_msg_part_100, cmp_packet_page_msg_part_100,
43013 nullptr, nullptr, nullptr, destroy_packet_page_msg_part);
43014 }
43015
43016 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
43017 *real_packet = *old;
43018 } else {
43019 /* packet is already initialized empty */
43020 log_packet_detailed(" no old info");
43021 }
43022
43023#ifdef FREECIV_JSON_CONNECTION
43024 field_addr.name = "fields";
43025#endif /* FREECIV_JSON_CONNECTION */
43026 DIO_BV_GET(&din, &field_addr, fields);
43027
43028 if (BV_ISSET(fields, 0)) {
43029 log_packet_detailed(" got field 'lines'");
43030
43031#ifdef FREECIV_JSON_CONNECTION
43032 field_addr.name = "lines";
43033#endif /* FREECIV_JSON_CONNECTION */
43034
43035 if (!DIO_GET(string, &din, &field_addr, real_packet->lines, sizeof(real_packet->lines))) {
43036 RECEIVE_PACKET_FIELD_ERROR(lines);
43037 }
43038 }
43039
43040 if (nullptr == old) {
43041 old = fc_malloc(sizeof(*old));
43042 init_packet_page_msg_part(old);
43043 *old = *real_packet;
43044 genhash_insert(*hash, old, old);
43045 } else {
43046 *old = *real_packet;
43047 }
43048
43049#else /* FREECIV_DELTA_PROTOCOL */
43050#ifdef FREECIV_JSON_CONNECTION
43051 field_addr.name = "lines";
43052#endif /* FREECIV_JSON_CONNECTION */
43053
43054 if (!DIO_GET(string, &din, &field_addr, real_packet->lines, sizeof(real_packet->lines))) {
43055 RECEIVE_PACKET_FIELD_ERROR(lines);
43056 }
43057#endif /* FREECIV_DELTA_PROTOCOL */
43058
43059 RECEIVE_PACKET_END(real_packet);
43060#undef FREE_PACKET_STRUCT
43061}
43062
43063 static int send_packet_page_msg_part_100(struct connection *pc, const struct packet_page_msg_part *packet)
43064{
43065 const struct packet_page_msg_part *real_packet = packet;
43066 int e;
43067 SEND_PACKET_START(PACKET_PAGE_MSG_PART);
43068
43069 log_packet_detailed("packet_page_msg_part_100: sending info about ()");
43070
43071#ifdef FREECIV_DELTA_PROTOCOL
43072 packet_page_msg_part_100_fields fields;
43073 struct packet_page_msg_part *old;
43074 bool differ;
43075 struct genhash **hash = pc->phs.sent + PACKET_PAGE_MSG_PART;
43076
43077 if (nullptr == *hash) {
43078 *hash = genhash_new_full(hash_packet_page_msg_part_100, cmp_packet_page_msg_part_100,
43079 nullptr, nullptr, nullptr, destroy_packet_page_msg_part);
43080 }
43081 BV_CLR_ALL(fields);
43082
43083 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
43084 old = fc_malloc(sizeof(*old));
43085 /* temporary bitcopy just to insert correctly */
43086 *old = *real_packet;
43087 genhash_insert(*hash, old, old);
43088 init_packet_page_msg_part(old);
43089 }
43090
43091 differ = (strcmp(old->lines, real_packet->lines) != 0);
43092 if (differ) {
43093 BV_SET(fields, 0);
43094 }
43095#endif /* FREECIV_DELTA_PROTOCOL */
43096
43097#ifdef FREECIV_JSON_CONNECTION
43098 struct plocation field_addr;
43099 {
43100 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
43101 field_addr = *field_addr_tmp;
43102 FC_FREE(field_addr_tmp);
43103 }
43104#endif /* FREECIV_JSON_CONNECTION */
43105
43106#ifdef FREECIV_DELTA_PROTOCOL
43107#ifdef FREECIV_JSON_CONNECTION
43108 field_addr.name = "fields";
43109#endif /* FREECIV_JSON_CONNECTION */
43110 e = 0;
43111 e |= DIO_BV_PUT(&dout, &field_addr, fields);
43112 if (e) {
43113 log_packet_detailed("fields bitvector error detected");
43114 }
43115
43116 if (BV_ISSET(fields, 0)) {
43117 log_packet_detailed(" field 'lines' has changed");
43118
43119#ifdef FREECIV_JSON_CONNECTION
43120 field_addr.name = "lines";
43121#endif /* FREECIV_JSON_CONNECTION */
43122 e = 0;
43123
43124 e |= DIO_PUT(string, &dout, &field_addr, real_packet->lines);
43125
43126 if (e) {
43127 log_packet_detailed("'lines' field error detected");
43128 }
43129 }
43130
43131 *old = *real_packet;
43132
43133#else /* FREECIV_DELTA_PROTOCOL */
43134#ifdef FREECIV_JSON_CONNECTION
43135 field_addr.name = "lines";
43136#endif /* FREECIV_JSON_CONNECTION */
43137 e = 0;
43138
43139 e |= DIO_PUT(string, &dout, &field_addr, real_packet->lines);
43140
43141 if (e) {
43142 log_packet_detailed("'lines' field error detected");
43143 }
43144#endif /* FREECIV_DELTA_PROTOCOL */
43145
43146 SEND_PACKET_END(PACKET_PAGE_MSG_PART);
43147}
43148
43149 int send_packet_page_msg_part(struct connection *pc, const struct packet_page_msg_part *packet)
43150{
43151 if (!pc->used) {
43152 log_error("WARNING: trying to send data to the closed connection %s",
43153 conn_description(pc));
43154 return -1;
43155 }
43156 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PAGE_MSG_PART].packet != nullptr, -1,
43157 "Handler for PACKET_PAGE_MSG_PART not installed");
43158 return pc->phs.handlers->send[PACKET_PAGE_MSG_PART].packet(pc, packet);
43159}
43160
43161 void lsend_packet_page_msg_part(struct conn_list *dest, const struct packet_page_msg_part *packet)
43162{
43163 conn_list_iterate(dest, pconn) {
43164 send_packet_page_msg_part(pconn, packet);
43165 } conn_list_iterate_end;
43166}
43167
43168 static inline void init_packet_report_req(struct packet_report_req *packet)
43169{
43170 memset(packet, 0, sizeof(*packet));
43171}
43172
43173#define free_packet_report_req(_packet) (void) 0
43174#define destroy_packet_report_req free
43175
43176#ifdef FREECIV_DELTA_PROTOCOL
43177#define hash_packet_report_req_100 hash_const
43178#define cmp_packet_report_req_100 cmp_const
43179 BV_DEFINE(packet_report_req_100_fields, 1);
43180#endif /* FREECIV_DELTA_PROTOCOL */
43181
43182 static struct packet_report_req *receive_packet_report_req_100(struct connection *pc)
43183{
43184#define FREE_PACKET_STRUCT(_packet) free_packet_report_req(_packet)
43185 RECEIVE_PACKET_START(packet_report_req, real_packet);
43186
43187#ifdef FREECIV_JSON_CONNECTION
43188 struct plocation field_addr;
43189 {
43190 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
43191 field_addr = *field_addr_tmp;
43192 FC_FREE(field_addr_tmp);
43193 }
43194#endif /* FREECIV_JSON_CONNECTION */
43195
43196 log_packet_detailed("packet_report_req_100: got info about ()");
43197
43198#ifdef FREECIV_DELTA_PROTOCOL
43199 packet_report_req_100_fields fields;
43200 struct packet_report_req *old;
43201 struct genhash **hash = pc->phs.received + PACKET_REPORT_REQ;
43202
43203 if (nullptr == *hash) {
43204 *hash = genhash_new_full(hash_packet_report_req_100, cmp_packet_report_req_100,
43205 nullptr, nullptr, nullptr, destroy_packet_report_req);
43206 }
43207
43208 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
43209 *real_packet = *old;
43210 } else {
43211 /* packet is already initialized empty */
43212 log_packet_detailed(" no old info");
43213 }
43214
43215#ifdef FREECIV_JSON_CONNECTION
43216 field_addr.name = "fields";
43217#endif /* FREECIV_JSON_CONNECTION */
43218 DIO_BV_GET(&din, &field_addr, fields);
43219
43220 if (BV_ISSET(fields, 0)) {
43221 log_packet_detailed(" got field 'type'");
43222
43223#ifdef FREECIV_JSON_CONNECTION
43224 field_addr.name = "type";
43225#endif /* FREECIV_JSON_CONNECTION */
43226
43227 {
43228 int readin;
43229
43230 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
43231 RECEIVE_PACKET_FIELD_ERROR(type);
43232 }
43233 real_packet->type = readin;
43234 }
43235 }
43236
43237 if (nullptr == old) {
43238 old = fc_malloc(sizeof(*old));
43239 init_packet_report_req(old);
43240 *old = *real_packet;
43241 genhash_insert(*hash, old, old);
43242 } else {
43243 *old = *real_packet;
43244 }
43245
43246#else /* FREECIV_DELTA_PROTOCOL */
43247#ifdef FREECIV_JSON_CONNECTION
43248 field_addr.name = "type";
43249#endif /* FREECIV_JSON_CONNECTION */
43250
43251 {
43252 int readin;
43253
43254 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
43255 RECEIVE_PACKET_FIELD_ERROR(type);
43256 }
43257 real_packet->type = readin;
43258 }
43259#endif /* FREECIV_DELTA_PROTOCOL */
43260
43261 RECEIVE_PACKET_END(real_packet);
43262#undef FREE_PACKET_STRUCT
43263}
43264
43265 static int send_packet_report_req_100(struct connection *pc, const struct packet_report_req *packet)
43266{
43267 const struct packet_report_req *real_packet = packet;
43268 int e;
43269 SEND_PACKET_START(PACKET_REPORT_REQ);
43270
43271 log_packet_detailed("packet_report_req_100: sending info about ()");
43272
43273#ifdef FREECIV_DELTA_PROTOCOL
43274 packet_report_req_100_fields fields;
43275 struct packet_report_req *old;
43276 bool differ;
43277 struct genhash **hash = pc->phs.sent + PACKET_REPORT_REQ;
43278
43279 if (nullptr == *hash) {
43280 *hash = genhash_new_full(hash_packet_report_req_100, cmp_packet_report_req_100,
43281 nullptr, nullptr, nullptr, destroy_packet_report_req);
43282 }
43283 BV_CLR_ALL(fields);
43284
43285 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
43286 old = fc_malloc(sizeof(*old));
43287 /* temporary bitcopy just to insert correctly */
43288 *old = *real_packet;
43289 genhash_insert(*hash, old, old);
43290 init_packet_report_req(old);
43291 }
43292
43293 differ = (old->type != real_packet->type);
43294 if (differ) {
43295 BV_SET(fields, 0);
43296 }
43297#endif /* FREECIV_DELTA_PROTOCOL */
43298
43299#ifdef FREECIV_JSON_CONNECTION
43300 struct plocation field_addr;
43301 {
43302 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
43303 field_addr = *field_addr_tmp;
43304 FC_FREE(field_addr_tmp);
43305 }
43306#endif /* FREECIV_JSON_CONNECTION */
43307
43308#ifdef FREECIV_DELTA_PROTOCOL
43309#ifdef FREECIV_JSON_CONNECTION
43310 field_addr.name = "fields";
43311#endif /* FREECIV_JSON_CONNECTION */
43312 e = 0;
43313 e |= DIO_BV_PUT(&dout, &field_addr, fields);
43314 if (e) {
43315 log_packet_detailed("fields bitvector error detected");
43316 }
43317
43318 if (BV_ISSET(fields, 0)) {
43319 log_packet_detailed(" field 'type' has changed");
43320
43321#ifdef FREECIV_JSON_CONNECTION
43322 field_addr.name = "type";
43323#endif /* FREECIV_JSON_CONNECTION */
43324 e = 0;
43325
43326 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
43327
43328 if (e) {
43329 log_packet_detailed("'type' field error detected");
43330 }
43331 }
43332
43333 *old = *real_packet;
43334
43335#else /* FREECIV_DELTA_PROTOCOL */
43336#ifdef FREECIV_JSON_CONNECTION
43337 field_addr.name = "type";
43338#endif /* FREECIV_JSON_CONNECTION */
43339 e = 0;
43340
43341 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
43342
43343 if (e) {
43344 log_packet_detailed("'type' field error detected");
43345 }
43346#endif /* FREECIV_DELTA_PROTOCOL */
43347
43348 SEND_PACKET_END(PACKET_REPORT_REQ);
43349}
43350
43351 int send_packet_report_req(struct connection *pc, const struct packet_report_req *packet)
43352{
43353 if (!pc->used) {
43354 log_error("WARNING: trying to send data to the closed connection %s",
43355 conn_description(pc));
43356 return -1;
43357 }
43358 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_REPORT_REQ].packet != nullptr, -1,
43359 "Handler for PACKET_REPORT_REQ not installed");
43360 return pc->phs.handlers->send[PACKET_REPORT_REQ].packet(pc, packet);
43361}
43362
43363 int dsend_packet_report_req(struct connection *pc, enum report_type type)
43364{
43365 struct packet_report_req packet, *real_packet = &packet;
43366
43367 real_packet->type = type;
43368
43369 return send_packet_report_req(pc, real_packet);
43370}
43371
43372 static inline void init_packet_conn_info(struct packet_conn_info *packet)
43373{
43374 memset(packet, 0, sizeof(*packet));
43375}
43376
43377#define free_packet_conn_info(_packet) (void) 0
43378#define destroy_packet_conn_info free
43379
43380#ifdef FREECIV_DELTA_PROTOCOL
43381static genhash_val_t hash_packet_conn_info_100(const void *vkey)
43382{
43383 const struct packet_conn_info *key = (const struct packet_conn_info *) vkey;
43384 genhash_val_t result = 0;
43385
43386 result += key->id;
43387
43388 result &= 0xFFFFFFFF;
43389 return result;
43390}
43391
43392static bool cmp_packet_conn_info_100(const void *vkey1, const void *vkey2)
43393{
43394 const struct packet_conn_info *old = (const struct packet_conn_info *) vkey1;
43395 const struct packet_conn_info *real_packet = (const struct packet_conn_info *) vkey2;
43396 bool differ;
43397
43398 differ = (old->id != real_packet->id);
43399
43400 return !differ;
43401}
43402 BV_DEFINE(packet_conn_info_100_fields, 8);
43403#endif /* FREECIV_DELTA_PROTOCOL */
43404
43405 static struct packet_conn_info *receive_packet_conn_info_100(struct connection *pc)
43406{
43407#define FREE_PACKET_STRUCT(_packet) free_packet_conn_info(_packet)
43408 RECEIVE_PACKET_START(packet_conn_info, real_packet);
43409
43410#ifdef FREECIV_JSON_CONNECTION
43411 struct plocation field_addr;
43412 {
43413 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
43414 field_addr = *field_addr_tmp;
43415 FC_FREE(field_addr_tmp);
43416 }
43417#endif /* FREECIV_JSON_CONNECTION */
43418
43419#ifdef FREECIV_JSON_CONNECTION
43420 field_addr.name = "id";
43421#endif /* FREECIV_JSON_CONNECTION */
43422
43423 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->id)) {
43424 RECEIVE_PACKET_FIELD_ERROR(id);
43425 }
43426
43427 log_packet_detailed("packet_conn_info_100: got info about (%d)",
43428 real_packet->id);
43429
43430#ifdef FREECIV_DELTA_PROTOCOL
43431 packet_conn_info_100_fields fields;
43432 struct packet_conn_info *old;
43433 struct genhash **hash = pc->phs.received + PACKET_CONN_INFO;
43434
43435 if (nullptr == *hash) {
43436 *hash = genhash_new_full(hash_packet_conn_info_100, cmp_packet_conn_info_100,
43437 nullptr, nullptr, nullptr, destroy_packet_conn_info);
43438 }
43439
43440 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
43441 *real_packet = *old;
43442 } else {
43443 /* packet is already initialized empty */
43444 log_packet_detailed(" no old info");
43445 }
43446
43447#ifdef FREECIV_JSON_CONNECTION
43448 field_addr.name = "fields";
43449#endif /* FREECIV_JSON_CONNECTION */
43450 DIO_BV_GET(&din, &field_addr, fields);
43451
43452 real_packet->used = BV_ISSET(fields, 0);
43453
43454 real_packet->established = BV_ISSET(fields, 1);
43455
43456 real_packet->observer = BV_ISSET(fields, 2);
43457
43458 if (BV_ISSET(fields, 3)) {
43459 log_packet_detailed(" got field 'player_num'");
43460
43461#ifdef FREECIV_JSON_CONNECTION
43462 field_addr.name = "player_num";
43463#endif /* FREECIV_JSON_CONNECTION */
43464
43465 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_num)) {
43466 RECEIVE_PACKET_FIELD_ERROR(player_num);
43467 }
43468 }
43469
43470 if (BV_ISSET(fields, 4)) {
43471 log_packet_detailed(" got field 'access_level'");
43472
43473#ifdef FREECIV_JSON_CONNECTION
43474 field_addr.name = "access_level";
43475#endif /* FREECIV_JSON_CONNECTION */
43476
43477 {
43478 int readin;
43479
43480 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
43481 RECEIVE_PACKET_FIELD_ERROR(access_level);
43482 }
43483 real_packet->access_level = readin;
43484 }
43485 }
43486
43487 if (BV_ISSET(fields, 5)) {
43488 log_packet_detailed(" got field 'username'");
43489
43490#ifdef FREECIV_JSON_CONNECTION
43491 field_addr.name = "username";
43492#endif /* FREECIV_JSON_CONNECTION */
43493
43494 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
43495 RECEIVE_PACKET_FIELD_ERROR(username);
43496 }
43497 }
43498
43499 if (BV_ISSET(fields, 6)) {
43500 log_packet_detailed(" got field 'addr'");
43501
43502#ifdef FREECIV_JSON_CONNECTION
43503 field_addr.name = "addr";
43504#endif /* FREECIV_JSON_CONNECTION */
43505
43506 if (!DIO_GET(string, &din, &field_addr, real_packet->addr, sizeof(real_packet->addr))) {
43507 RECEIVE_PACKET_FIELD_ERROR(addr);
43508 }
43509 }
43510
43511 if (BV_ISSET(fields, 7)) {
43512 log_packet_detailed(" got field 'capability'");
43513
43514#ifdef FREECIV_JSON_CONNECTION
43515 field_addr.name = "capability";
43516#endif /* FREECIV_JSON_CONNECTION */
43517
43518 if (!DIO_GET(string, &din, &field_addr, real_packet->capability, sizeof(real_packet->capability))) {
43519 RECEIVE_PACKET_FIELD_ERROR(capability);
43520 }
43521 }
43522
43523 if (nullptr == old) {
43524 old = fc_malloc(sizeof(*old));
43525 init_packet_conn_info(old);
43526 *old = *real_packet;
43527 genhash_insert(*hash, old, old);
43528 } else {
43529 *old = *real_packet;
43530 }
43531
43532#else /* FREECIV_DELTA_PROTOCOL */
43533#ifdef FREECIV_JSON_CONNECTION
43534 field_addr.name = "used";
43535#endif /* FREECIV_JSON_CONNECTION */
43536
43537 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->used)) {
43538 RECEIVE_PACKET_FIELD_ERROR(used);
43539 }
43540
43541#ifdef FREECIV_JSON_CONNECTION
43542 field_addr.name = "established";
43543#endif /* FREECIV_JSON_CONNECTION */
43544
43545 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->established)) {
43546 RECEIVE_PACKET_FIELD_ERROR(established);
43547 }
43548
43549#ifdef FREECIV_JSON_CONNECTION
43550 field_addr.name = "observer";
43551#endif /* FREECIV_JSON_CONNECTION */
43552
43553 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->observer)) {
43554 RECEIVE_PACKET_FIELD_ERROR(observer);
43555 }
43556
43557#ifdef FREECIV_JSON_CONNECTION
43558 field_addr.name = "player_num";
43559#endif /* FREECIV_JSON_CONNECTION */
43560
43561 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_num)) {
43562 RECEIVE_PACKET_FIELD_ERROR(player_num);
43563 }
43564
43565#ifdef FREECIV_JSON_CONNECTION
43566 field_addr.name = "access_level";
43567#endif /* FREECIV_JSON_CONNECTION */
43568
43569 {
43570 int readin;
43571
43572 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
43573 RECEIVE_PACKET_FIELD_ERROR(access_level);
43574 }
43575 real_packet->access_level = readin;
43576 }
43577
43578#ifdef FREECIV_JSON_CONNECTION
43579 field_addr.name = "username";
43580#endif /* FREECIV_JSON_CONNECTION */
43581
43582 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
43583 RECEIVE_PACKET_FIELD_ERROR(username);
43584 }
43585
43586#ifdef FREECIV_JSON_CONNECTION
43587 field_addr.name = "addr";
43588#endif /* FREECIV_JSON_CONNECTION */
43589
43590 if (!DIO_GET(string, &din, &field_addr, real_packet->addr, sizeof(real_packet->addr))) {
43591 RECEIVE_PACKET_FIELD_ERROR(addr);
43592 }
43593
43594#ifdef FREECIV_JSON_CONNECTION
43595 field_addr.name = "capability";
43596#endif /* FREECIV_JSON_CONNECTION */
43597
43598 if (!DIO_GET(string, &din, &field_addr, real_packet->capability, sizeof(real_packet->capability))) {
43599 RECEIVE_PACKET_FIELD_ERROR(capability);
43600 }
43601#endif /* FREECIV_DELTA_PROTOCOL */
43602
43603 RECEIVE_PACKET_END(real_packet);
43604#undef FREE_PACKET_STRUCT
43605}
43606
43607 static int send_packet_conn_info_100(struct connection *pc, const struct packet_conn_info *packet)
43608{
43609 const struct packet_conn_info *real_packet = packet;
43610 int e;
43611 SEND_PACKET_START(PACKET_CONN_INFO);
43612
43613 log_packet_detailed("packet_conn_info_100: sending info about (%d)",
43614 real_packet->id);
43615
43616#ifdef FREECIV_DELTA_PROTOCOL
43617 packet_conn_info_100_fields fields;
43618 struct packet_conn_info *old;
43619 bool differ;
43620 int different = 0;
43621 struct genhash **hash = pc->phs.sent + PACKET_CONN_INFO;
43622
43623 if (nullptr == *hash) {
43624 *hash = genhash_new_full(hash_packet_conn_info_100, cmp_packet_conn_info_100,
43625 nullptr, nullptr, nullptr, destroy_packet_conn_info);
43626 }
43627 BV_CLR_ALL(fields);
43628
43629 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
43630 old = fc_malloc(sizeof(*old));
43631 /* temporary bitcopy just to insert correctly */
43632 *old = *real_packet;
43633 genhash_insert(*hash, old, old);
43634 init_packet_conn_info(old);
43635 different = 1; /* Force to send. */
43636 }
43637
43638 differ = (old->used != real_packet->used);
43639 if (differ) {
43640 different++;
43641 }
43642 /* folded into head */
43643 if (real_packet->used) {
43644 BV_SET(fields, 0);
43645 }
43646
43647 differ = (old->established != real_packet->established);
43648 if (differ) {
43649 different++;
43650 }
43651 /* folded into head */
43652 if (real_packet->established) {
43653 BV_SET(fields, 1);
43654 }
43655
43656 differ = (old->observer != real_packet->observer);
43657 if (differ) {
43658 different++;
43659 }
43660 /* folded into head */
43661 if (real_packet->observer) {
43662 BV_SET(fields, 2);
43663 }
43664
43665 differ = (old->player_num != real_packet->player_num);
43666 if (differ) {
43667 different++;
43668 BV_SET(fields, 3);
43669 }
43670
43671 differ = (old->access_level != real_packet->access_level);
43672 if (differ) {
43673 different++;
43674 BV_SET(fields, 4);
43675 }
43676
43677 differ = (strcmp(old->username, real_packet->username) != 0);
43678 if (differ) {
43679 different++;
43680 BV_SET(fields, 5);
43681 }
43682
43683 differ = (strcmp(old->addr, real_packet->addr) != 0);
43684 if (differ) {
43685 different++;
43686 BV_SET(fields, 6);
43687 }
43688
43689 differ = (strcmp(old->capability, real_packet->capability) != 0);
43690 if (differ) {
43691 different++;
43692 BV_SET(fields, 7);
43693 }
43694
43695 if (different == 0) {
43696 log_packet_detailed(" no change -> discard");
43697 SEND_PACKET_DISCARD();
43698 }
43699#endif /* FREECIV_DELTA_PROTOCOL */
43700
43701#ifdef FREECIV_JSON_CONNECTION
43702 struct plocation field_addr;
43703 {
43704 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
43705 field_addr = *field_addr_tmp;
43706 FC_FREE(field_addr_tmp);
43707 }
43708#endif /* FREECIV_JSON_CONNECTION */
43709
43710#ifdef FREECIV_JSON_CONNECTION
43711 field_addr.name = "id";
43712#endif /* FREECIV_JSON_CONNECTION */
43713 e = 0;
43714
43715 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->id);
43716
43717 if (e) {
43718 log_packet_detailed("'id' field error detected");
43719 }
43720
43721#ifdef FREECIV_DELTA_PROTOCOL
43722#ifdef FREECIV_JSON_CONNECTION
43723 field_addr.name = "fields";
43724#endif /* FREECIV_JSON_CONNECTION */
43725 e = 0;
43726 e |= DIO_BV_PUT(&dout, &field_addr, fields);
43727 if (e) {
43728 log_packet_detailed("fields bitvector error detected");
43729 }
43730
43731 /* field 0 is folded into the header */
43732
43733 /* field 1 is folded into the header */
43734
43735 /* field 2 is folded into the header */
43736
43737 if (BV_ISSET(fields, 3)) {
43738 log_packet_detailed(" field 'player_num' has changed");
43739
43740#ifdef FREECIV_JSON_CONNECTION
43741 field_addr.name = "player_num";
43742#endif /* FREECIV_JSON_CONNECTION */
43743 e = 0;
43744
43745 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_num);
43746
43747 if (e) {
43748 log_packet_detailed("'player_num' field error detected");
43749 }
43750 }
43751
43752 if (BV_ISSET(fields, 4)) {
43753 log_packet_detailed(" field 'access_level' has changed");
43754
43755#ifdef FREECIV_JSON_CONNECTION
43756 field_addr.name = "access_level";
43757#endif /* FREECIV_JSON_CONNECTION */
43758 e = 0;
43759
43760 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->access_level);
43761
43762 if (e) {
43763 log_packet_detailed("'access_level' field error detected");
43764 }
43765 }
43766
43767 if (BV_ISSET(fields, 5)) {
43768 log_packet_detailed(" field 'username' has changed");
43769
43770#ifdef FREECIV_JSON_CONNECTION
43771 field_addr.name = "username";
43772#endif /* FREECIV_JSON_CONNECTION */
43773 e = 0;
43774
43775 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
43776
43777 if (e) {
43778 log_packet_detailed("'username' field error detected");
43779 }
43780 }
43781
43782 if (BV_ISSET(fields, 6)) {
43783 log_packet_detailed(" field 'addr' has changed");
43784
43785#ifdef FREECIV_JSON_CONNECTION
43786 field_addr.name = "addr";
43787#endif /* FREECIV_JSON_CONNECTION */
43788 e = 0;
43789
43790 e |= DIO_PUT(string, &dout, &field_addr, real_packet->addr);
43791
43792 if (e) {
43793 log_packet_detailed("'addr' field error detected");
43794 }
43795 }
43796
43797 if (BV_ISSET(fields, 7)) {
43798 log_packet_detailed(" field 'capability' has changed");
43799
43800#ifdef FREECIV_JSON_CONNECTION
43801 field_addr.name = "capability";
43802#endif /* FREECIV_JSON_CONNECTION */
43803 e = 0;
43804
43805 e |= DIO_PUT(string, &dout, &field_addr, real_packet->capability);
43806
43807 if (e) {
43808 log_packet_detailed("'capability' field error detected");
43809 }
43810 }
43811
43812 *old = *real_packet;
43813
43814#else /* FREECIV_DELTA_PROTOCOL */
43815#ifdef FREECIV_JSON_CONNECTION
43816 field_addr.name = "used";
43817#endif /* FREECIV_JSON_CONNECTION */
43818 e = 0;
43819
43820 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->used);
43821
43822 if (e) {
43823 log_packet_detailed("'used' field error detected");
43824 }
43825
43826#ifdef FREECIV_JSON_CONNECTION
43827 field_addr.name = "established";
43828#endif /* FREECIV_JSON_CONNECTION */
43829 e = 0;
43830
43831 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->established);
43832
43833 if (e) {
43834 log_packet_detailed("'established' field error detected");
43835 }
43836
43837#ifdef FREECIV_JSON_CONNECTION
43838 field_addr.name = "observer";
43839#endif /* FREECIV_JSON_CONNECTION */
43840 e = 0;
43841
43842 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->observer);
43843
43844 if (e) {
43845 log_packet_detailed("'observer' field error detected");
43846 }
43847
43848#ifdef FREECIV_JSON_CONNECTION
43849 field_addr.name = "player_num";
43850#endif /* FREECIV_JSON_CONNECTION */
43851 e = 0;
43852
43853 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_num);
43854
43855 if (e) {
43856 log_packet_detailed("'player_num' field error detected");
43857 }
43858
43859#ifdef FREECIV_JSON_CONNECTION
43860 field_addr.name = "access_level";
43861#endif /* FREECIV_JSON_CONNECTION */
43862 e = 0;
43863
43864 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->access_level);
43865
43866 if (e) {
43867 log_packet_detailed("'access_level' field error detected");
43868 }
43869
43870#ifdef FREECIV_JSON_CONNECTION
43871 field_addr.name = "username";
43872#endif /* FREECIV_JSON_CONNECTION */
43873 e = 0;
43874
43875 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
43876
43877 if (e) {
43878 log_packet_detailed("'username' field error detected");
43879 }
43880
43881#ifdef FREECIV_JSON_CONNECTION
43882 field_addr.name = "addr";
43883#endif /* FREECIV_JSON_CONNECTION */
43884 e = 0;
43885
43886 e |= DIO_PUT(string, &dout, &field_addr, real_packet->addr);
43887
43888 if (e) {
43889 log_packet_detailed("'addr' field error detected");
43890 }
43891
43892#ifdef FREECIV_JSON_CONNECTION
43893 field_addr.name = "capability";
43894#endif /* FREECIV_JSON_CONNECTION */
43895 e = 0;
43896
43897 e |= DIO_PUT(string, &dout, &field_addr, real_packet->capability);
43898
43899 if (e) {
43900 log_packet_detailed("'capability' field error detected");
43901 }
43902#endif /* FREECIV_DELTA_PROTOCOL */
43903
43904 SEND_PACKET_END(PACKET_CONN_INFO);
43905}
43906
43907 int send_packet_conn_info(struct connection *pc, const struct packet_conn_info *packet)
43908{
43909 if (!pc->used) {
43910 log_error("WARNING: trying to send data to the closed connection %s",
43911 conn_description(pc));
43912 return -1;
43913 }
43914 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_INFO].packet != nullptr, -1,
43915 "Handler for PACKET_CONN_INFO not installed");
43916 return pc->phs.handlers->send[PACKET_CONN_INFO].packet(pc, packet);
43917}
43918
43919 void lsend_packet_conn_info(struct conn_list *dest, const struct packet_conn_info *packet)
43920{
43921 conn_list_iterate(dest, pconn) {
43922 send_packet_conn_info(pconn, packet);
43923 } conn_list_iterate_end;
43924}
43925
43926 static inline void init_packet_conn_ping_info(struct packet_conn_ping_info *packet)
43927{
43928 memset(packet, 0, sizeof(*packet));
43929}
43930
43931#define free_packet_conn_ping_info(_packet) (void) 0
43932#define destroy_packet_conn_ping_info free
43933
43934#ifdef FREECIV_DELTA_PROTOCOL
43935#define hash_packet_conn_ping_info_100 hash_const
43936#define cmp_packet_conn_ping_info_100 cmp_const
43937 BV_DEFINE(packet_conn_ping_info_100_fields, 3);
43938#endif /* FREECIV_DELTA_PROTOCOL */
43939
43940 static struct packet_conn_ping_info *receive_packet_conn_ping_info_100(struct connection *pc)
43941{
43942#define FREE_PACKET_STRUCT(_packet) free_packet_conn_ping_info(_packet)
43943 RECEIVE_PACKET_START(packet_conn_ping_info, real_packet);
43944
43945#ifdef FREECIV_JSON_CONNECTION
43946 struct plocation field_addr;
43947 {
43948 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
43949 field_addr = *field_addr_tmp;
43950 FC_FREE(field_addr_tmp);
43951 }
43952#endif /* FREECIV_JSON_CONNECTION */
43953
43954 log_packet_detailed("packet_conn_ping_info_100: got info about ()");
43955
43956#ifdef FREECIV_DELTA_PROTOCOL
43957 packet_conn_ping_info_100_fields fields;
43958 struct packet_conn_ping_info *old;
43959 struct genhash **hash = pc->phs.received + PACKET_CONN_PING_INFO;
43960
43961 if (nullptr == *hash) {
43962 *hash = genhash_new_full(hash_packet_conn_ping_info_100, cmp_packet_conn_ping_info_100,
43963 nullptr, nullptr, nullptr, destroy_packet_conn_ping_info);
43964 }
43965
43966 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
43967 *real_packet = *old;
43968 } else {
43969 /* packet is already initialized empty */
43970 log_packet_detailed(" no old info");
43971 }
43972
43973#ifdef FREECIV_JSON_CONNECTION
43974 field_addr.name = "fields";
43975#endif /* FREECIV_JSON_CONNECTION */
43976 DIO_BV_GET(&din, &field_addr, fields);
43977
43978 if (BV_ISSET(fields, 0)) {
43979 log_packet_detailed(" got field 'connections'");
43980
43981#ifdef FREECIV_JSON_CONNECTION
43982 field_addr.name = "connections";
43983#endif /* FREECIV_JSON_CONNECTION */
43984
43985 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->connections)) {
43986 RECEIVE_PACKET_FIELD_ERROR(connections);
43987 }
43988 }
43989
43990 if (BV_ISSET(fields, 1)) {
43991 log_packet_detailed(" got field 'conn_id'");
43992
43993#ifdef FREECIV_JSON_CONNECTION
43994 field_addr.name = "conn_id";
43995#endif /* FREECIV_JSON_CONNECTION */
43996
43997 {
43998 int i;
43999
44000 if (real_packet->connections > MAX_NUM_CONNECTIONS) {
44001 RECEIVE_PACKET_FIELD_ERROR(conn_id, ": array truncated");
44002 }
44003
44004#ifdef FREECIV_JSON_CONNECTION
44005 /* Enter array. */
44006 field_addr.sub_location = plocation_elem_new(0);
44007#endif /* FREECIV_JSON_CONNECTION */
44008
44009 for (i = 0; i < real_packet->connections; i++) {
44010#ifdef FREECIV_JSON_CONNECTION
44011 /* Next array element */
44012 field_addr.sub_location->number = i;
44013#endif /* FREECIV_JSON_CONNECTION */
44014
44015 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id[i])) {
44016 RECEIVE_PACKET_FIELD_ERROR(conn_id);
44017 }
44018 }
44019
44020#ifdef FREECIV_JSON_CONNECTION
44021 /* Exit array. */
44022 FC_FREE(field_addr.sub_location);
44023#endif /* FREECIV_JSON_CONNECTION */
44024 }
44025 }
44026
44027 if (BV_ISSET(fields, 2)) {
44028 log_packet_detailed(" got field 'ping_time'");
44029
44030#ifdef FREECIV_JSON_CONNECTION
44031 field_addr.name = "ping_time";
44032#endif /* FREECIV_JSON_CONNECTION */
44033
44034 {
44035 int i;
44036
44037 if (real_packet->connections > MAX_NUM_CONNECTIONS) {
44038 RECEIVE_PACKET_FIELD_ERROR(ping_time, ": array truncated");
44039 }
44040
44041#ifdef FREECIV_JSON_CONNECTION
44042 /* Enter array. */
44043 field_addr.sub_location = plocation_elem_new(0);
44044#endif /* FREECIV_JSON_CONNECTION */
44045
44046 for (i = 0; i < real_packet->connections; i++) {
44047#ifdef FREECIV_JSON_CONNECTION
44048 /* Next array element */
44049 field_addr.sub_location->number = i;
44050#endif /* FREECIV_JSON_CONNECTION */
44051
44052 if (!DIO_GET(sfloat, &din, &field_addr, &real_packet->ping_time[i], 100000)) {
44053 RECEIVE_PACKET_FIELD_ERROR(ping_time);
44054 }
44055 }
44056
44057#ifdef FREECIV_JSON_CONNECTION
44058 /* Exit array. */
44059 FC_FREE(field_addr.sub_location);
44060#endif /* FREECIV_JSON_CONNECTION */
44061 }
44062 }
44063
44064 if (nullptr == old) {
44065 old = fc_malloc(sizeof(*old));
44066 init_packet_conn_ping_info(old);
44067 *old = *real_packet;
44068 genhash_insert(*hash, old, old);
44069 } else {
44070 *old = *real_packet;
44071 }
44072
44073#else /* FREECIV_DELTA_PROTOCOL */
44074#ifdef FREECIV_JSON_CONNECTION
44075 field_addr.name = "connections";
44076#endif /* FREECIV_JSON_CONNECTION */
44077
44078 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->connections)) {
44079 RECEIVE_PACKET_FIELD_ERROR(connections);
44080 }
44081
44082#ifdef FREECIV_JSON_CONNECTION
44083 field_addr.name = "conn_id";
44084#endif /* FREECIV_JSON_CONNECTION */
44085
44086 {
44087 int i;
44088
44089 if (real_packet->connections > MAX_NUM_CONNECTIONS) {
44090 RECEIVE_PACKET_FIELD_ERROR(conn_id, ": array truncated");
44091 }
44092
44093#ifdef FREECIV_JSON_CONNECTION
44094 /* Enter array. */
44095 field_addr.sub_location = plocation_elem_new(0);
44096#endif /* FREECIV_JSON_CONNECTION */
44097
44098 for (i = 0; i < real_packet->connections; i++) {
44099#ifdef FREECIV_JSON_CONNECTION
44100 /* Next array element */
44101 field_addr.sub_location->number = i;
44102#endif /* FREECIV_JSON_CONNECTION */
44103
44104 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->conn_id[i])) {
44105 RECEIVE_PACKET_FIELD_ERROR(conn_id);
44106 }
44107 }
44108
44109#ifdef FREECIV_JSON_CONNECTION
44110 /* Exit array. */
44111 FC_FREE(field_addr.sub_location);
44112#endif /* FREECIV_JSON_CONNECTION */
44113 }
44114
44115#ifdef FREECIV_JSON_CONNECTION
44116 field_addr.name = "ping_time";
44117#endif /* FREECIV_JSON_CONNECTION */
44118
44119 {
44120 int i;
44121
44122 if (real_packet->connections > MAX_NUM_CONNECTIONS) {
44123 RECEIVE_PACKET_FIELD_ERROR(ping_time, ": array truncated");
44124 }
44125
44126#ifdef FREECIV_JSON_CONNECTION
44127 /* Enter array. */
44128 field_addr.sub_location = plocation_elem_new(0);
44129#endif /* FREECIV_JSON_CONNECTION */
44130
44131 for (i = 0; i < real_packet->connections; i++) {
44132#ifdef FREECIV_JSON_CONNECTION
44133 /* Next array element */
44134 field_addr.sub_location->number = i;
44135#endif /* FREECIV_JSON_CONNECTION */
44136
44137 if (!DIO_GET(sfloat, &din, &field_addr, &real_packet->ping_time[i], 100000)) {
44138 RECEIVE_PACKET_FIELD_ERROR(ping_time);
44139 }
44140 }
44141
44142#ifdef FREECIV_JSON_CONNECTION
44143 /* Exit array. */
44144 FC_FREE(field_addr.sub_location);
44145#endif /* FREECIV_JSON_CONNECTION */
44146 }
44147#endif /* FREECIV_DELTA_PROTOCOL */
44148
44149 RECEIVE_PACKET_END(real_packet);
44150#undef FREE_PACKET_STRUCT
44151}
44152
44153 static int send_packet_conn_ping_info_100(struct connection *pc, const struct packet_conn_ping_info *packet)
44154{
44155 const struct packet_conn_ping_info *real_packet = packet;
44156 int e;
44157 SEND_PACKET_START(PACKET_CONN_PING_INFO);
44158
44159 log_packet_detailed("packet_conn_ping_info_100: sending info about ()");
44160
44161#ifdef FREECIV_DELTA_PROTOCOL
44162 packet_conn_ping_info_100_fields fields;
44163 struct packet_conn_ping_info *old;
44164 bool differ;
44165 struct genhash **hash = pc->phs.sent + PACKET_CONN_PING_INFO;
44166
44167 if (nullptr == *hash) {
44168 *hash = genhash_new_full(hash_packet_conn_ping_info_100, cmp_packet_conn_ping_info_100,
44169 nullptr, nullptr, nullptr, destroy_packet_conn_ping_info);
44170 }
44171 BV_CLR_ALL(fields);
44172
44173 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
44174 old = fc_malloc(sizeof(*old));
44175 /* temporary bitcopy just to insert correctly */
44176 *old = *real_packet;
44177 genhash_insert(*hash, old, old);
44178 init_packet_conn_ping_info(old);
44179 }
44180
44181 differ = (old->connections != real_packet->connections);
44182 if (differ) {
44183 BV_SET(fields, 0);
44184 }
44185
44186 differ = (old->connections != real_packet->connections);
44187 if (!differ) {
44188 int i;
44189
44190 for (i = 0; i < old->connections; i++) {
44191 differ = (old->conn_id[i] != real_packet->conn_id[i]);
44192 if (differ) {
44193 break;
44194 }
44195 }
44196 }
44197 if (differ) {
44198 BV_SET(fields, 1);
44199 }
44200
44201 differ = (old->connections != real_packet->connections);
44202 if (!differ) {
44203 int i;
44204
44205 for (i = 0; i < old->connections; i++) {
44206 differ = ((int) (old->ping_time[i] * 100000) != (int) (real_packet->ping_time[i] * 100000));
44207 if (differ) {
44208 break;
44209 }
44210 }
44211 }
44212 if (differ) {
44213 BV_SET(fields, 2);
44214 }
44215#endif /* FREECIV_DELTA_PROTOCOL */
44216
44217#ifdef FREECIV_JSON_CONNECTION
44218 struct plocation field_addr;
44219 {
44220 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
44221 field_addr = *field_addr_tmp;
44222 FC_FREE(field_addr_tmp);
44223 }
44224#endif /* FREECIV_JSON_CONNECTION */
44225
44226#ifdef FREECIV_DELTA_PROTOCOL
44227#ifdef FREECIV_JSON_CONNECTION
44228 field_addr.name = "fields";
44229#endif /* FREECIV_JSON_CONNECTION */
44230 e = 0;
44231 e |= DIO_BV_PUT(&dout, &field_addr, fields);
44232 if (e) {
44233 log_packet_detailed("fields bitvector error detected");
44234 }
44235
44236 if (BV_ISSET(fields, 0)) {
44237 log_packet_detailed(" field 'connections' has changed");
44238
44239#ifdef FREECIV_JSON_CONNECTION
44240 field_addr.name = "connections";
44241#endif /* FREECIV_JSON_CONNECTION */
44242 e = 0;
44243
44244 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->connections);
44245
44246 if (e) {
44247 log_packet_detailed("'connections' field error detected");
44248 }
44249 }
44250
44251 if (BV_ISSET(fields, 1)) {
44252 log_packet_detailed(" field 'conn_id' has changed");
44253
44254#ifdef FREECIV_JSON_CONNECTION
44255 field_addr.name = "conn_id";
44256#endif /* FREECIV_JSON_CONNECTION */
44257 e = 0;
44258
44259 {
44260 int i;
44261
44262#ifdef FREECIV_JSON_CONNECTION
44263 /* Create the array. */
44264 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->connections);
44265
44266 /* Enter array. */
44267 field_addr.sub_location = plocation_elem_new(0);
44268#endif /* FREECIV_JSON_CONNECTION */
44269
44270 for (i = 0; i < real_packet->connections; i++) {
44271#ifdef FREECIV_JSON_CONNECTION
44272 /* Next array element. */
44273 field_addr.sub_location->number = i;
44274#endif /* FREECIV_JSON_CONNECTION */
44275
44276 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id[i]);
44277 }
44278
44279#ifdef FREECIV_JSON_CONNECTION
44280 /* Exit array. */
44281 FC_FREE(field_addr.sub_location);
44282#endif /* FREECIV_JSON_CONNECTION */
44283 }
44284
44285 if (e) {
44286 log_packet_detailed("'conn_id' field error detected");
44287 }
44288 }
44289
44290 if (BV_ISSET(fields, 2)) {
44291 log_packet_detailed(" field 'ping_time' has changed");
44292
44293#ifdef FREECIV_JSON_CONNECTION
44294 field_addr.name = "ping_time";
44295#endif /* FREECIV_JSON_CONNECTION */
44296 e = 0;
44297
44298 {
44299 int i;
44300
44301#ifdef FREECIV_JSON_CONNECTION
44302 /* Create the array. */
44303 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->connections);
44304
44305 /* Enter array. */
44306 field_addr.sub_location = plocation_elem_new(0);
44307#endif /* FREECIV_JSON_CONNECTION */
44308
44309 for (i = 0; i < real_packet->connections; i++) {
44310#ifdef FREECIV_JSON_CONNECTION
44311 /* Next array element. */
44312 field_addr.sub_location->number = i;
44313#endif /* FREECIV_JSON_CONNECTION */
44314
44315 e |= DIO_PUT(sfloat, &dout, &field_addr, real_packet->ping_time[i], 100000);
44316 }
44317
44318#ifdef FREECIV_JSON_CONNECTION
44319 /* Exit array. */
44320 FC_FREE(field_addr.sub_location);
44321#endif /* FREECIV_JSON_CONNECTION */
44322 }
44323
44324 if (e) {
44325 log_packet_detailed("'ping_time' field error detected");
44326 }
44327 }
44328
44329 *old = *real_packet;
44330
44331#else /* FREECIV_DELTA_PROTOCOL */
44332#ifdef FREECIV_JSON_CONNECTION
44333 field_addr.name = "connections";
44334#endif /* FREECIV_JSON_CONNECTION */
44335 e = 0;
44336
44337 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->connections);
44338
44339 if (e) {
44340 log_packet_detailed("'connections' field error detected");
44341 }
44342
44343#ifdef FREECIV_JSON_CONNECTION
44344 field_addr.name = "conn_id";
44345#endif /* FREECIV_JSON_CONNECTION */
44346 e = 0;
44347
44348 {
44349 int i;
44350
44351#ifdef FREECIV_JSON_CONNECTION
44352 /* Create the array. */
44353 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->connections);
44354
44355 /* Enter array. */
44356 field_addr.sub_location = plocation_elem_new(0);
44357#endif /* FREECIV_JSON_CONNECTION */
44358
44359 for (i = 0; i < real_packet->connections; i++) {
44360#ifdef FREECIV_JSON_CONNECTION
44361 /* Next array element. */
44362 field_addr.sub_location->number = i;
44363#endif /* FREECIV_JSON_CONNECTION */
44364
44365 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->conn_id[i]);
44366 }
44367
44368#ifdef FREECIV_JSON_CONNECTION
44369 /* Exit array. */
44370 FC_FREE(field_addr.sub_location);
44371#endif /* FREECIV_JSON_CONNECTION */
44372 }
44373
44374 if (e) {
44375 log_packet_detailed("'conn_id' field error detected");
44376 }
44377
44378#ifdef FREECIV_JSON_CONNECTION
44379 field_addr.name = "ping_time";
44380#endif /* FREECIV_JSON_CONNECTION */
44381 e = 0;
44382
44383 {
44384 int i;
44385
44386#ifdef FREECIV_JSON_CONNECTION
44387 /* Create the array. */
44388 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->connections);
44389
44390 /* Enter array. */
44391 field_addr.sub_location = plocation_elem_new(0);
44392#endif /* FREECIV_JSON_CONNECTION */
44393
44394 for (i = 0; i < real_packet->connections; i++) {
44395#ifdef FREECIV_JSON_CONNECTION
44396 /* Next array element. */
44397 field_addr.sub_location->number = i;
44398#endif /* FREECIV_JSON_CONNECTION */
44399
44400 e |= DIO_PUT(sfloat, &dout, &field_addr, real_packet->ping_time[i], 100000);
44401 }
44402
44403#ifdef FREECIV_JSON_CONNECTION
44404 /* Exit array. */
44405 FC_FREE(field_addr.sub_location);
44406#endif /* FREECIV_JSON_CONNECTION */
44407 }
44408
44409 if (e) {
44410 log_packet_detailed("'ping_time' field error detected");
44411 }
44412#endif /* FREECIV_DELTA_PROTOCOL */
44413
44414 SEND_PACKET_END(PACKET_CONN_PING_INFO);
44415}
44416
44417 int send_packet_conn_ping_info(struct connection *pc, const struct packet_conn_ping_info *packet)
44418{
44419 if (!pc->used) {
44420 log_error("WARNING: trying to send data to the closed connection %s",
44421 conn_description(pc));
44422 return -1;
44423 }
44424 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_PING_INFO].packet != nullptr, -1,
44425 "Handler for PACKET_CONN_PING_INFO not installed");
44426 return pc->phs.handlers->send[PACKET_CONN_PING_INFO].packet(pc, packet);
44427}
44428
44429 void lsend_packet_conn_ping_info(struct conn_list *dest, const struct packet_conn_ping_info *packet)
44430{
44431 conn_list_iterate(dest, pconn) {
44432 send_packet_conn_ping_info(pconn, packet);
44433 } conn_list_iterate_end;
44434}
44435
44436 static inline void init_packet_conn_ping(struct packet_conn_ping *packet)
44437{
44438 memset(packet, 0, sizeof(*packet));
44439}
44440
44441#define free_packet_conn_ping(_packet) (void) 0
44442#define destroy_packet_conn_ping free
44443
44444 static struct packet_conn_ping *receive_packet_conn_ping_100(struct connection *pc)
44445{
44446#define FREE_PACKET_STRUCT(_packet) free_packet_conn_ping(_packet)
44447 RECEIVE_PACKET_START(packet_conn_ping, real_packet);
44448
44449 log_packet_detailed("packet_conn_ping_100: got info about ()");
44450
44451 real_packet->__dummy = 0xff;
44452
44453 RECEIVE_PACKET_END(real_packet);
44454#undef FREE_PACKET_STRUCT
44455}
44456
44457 static int send_packet_conn_ping_100(struct connection *pc)
44458{
44459 SEND_PACKET_START(PACKET_CONN_PING);
44460
44461 log_packet_detailed("packet_conn_ping_100: sending info about ()");
44462
44463 SEND_PACKET_END(PACKET_CONN_PING);
44464}
44465
44466 int send_packet_conn_ping(struct connection *pc)
44467{
44468 if (!pc->used) {
44469 log_error("WARNING: trying to send data to the closed connection %s",
44470 conn_description(pc));
44471 return -1;
44472 }
44473 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_PING].no_packet != nullptr, -1,
44474 "Handler for PACKET_CONN_PING not installed");
44475 return pc->phs.handlers->send[PACKET_CONN_PING].no_packet(pc);
44476}
44477
44478 static inline void init_packet_conn_pong(struct packet_conn_pong *packet)
44479{
44480 memset(packet, 0, sizeof(*packet));
44481}
44482
44483#define free_packet_conn_pong(_packet) (void) 0
44484#define destroy_packet_conn_pong free
44485
44486 static struct packet_conn_pong *receive_packet_conn_pong_100(struct connection *pc)
44487{
44488#define FREE_PACKET_STRUCT(_packet) free_packet_conn_pong(_packet)
44489 RECEIVE_PACKET_START(packet_conn_pong, real_packet);
44490
44491 log_packet_detailed("packet_conn_pong_100: got info about ()");
44492
44493 real_packet->__dummy = 0xff;
44494
44495 RECEIVE_PACKET_END(real_packet);
44496#undef FREE_PACKET_STRUCT
44497}
44498
44499 static int send_packet_conn_pong_100(struct connection *pc)
44500{
44501 SEND_PACKET_START(PACKET_CONN_PONG);
44502
44503 log_packet_detailed("packet_conn_pong_100: sending info about ()");
44504
44505 SEND_PACKET_END(PACKET_CONN_PONG);
44506}
44507
44508 int send_packet_conn_pong(struct connection *pc)
44509{
44510 if (!pc->used) {
44511 log_error("WARNING: trying to send data to the closed connection %s",
44512 conn_description(pc));
44513 return -1;
44514 }
44515 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CONN_PONG].no_packet != nullptr, -1,
44516 "Handler for PACKET_CONN_PONG not installed");
44517 return pc->phs.handlers->send[PACKET_CONN_PONG].no_packet(pc);
44518}
44519
44520 static inline void init_packet_client_heartbeat(struct packet_client_heartbeat *packet)
44521{
44522 memset(packet, 0, sizeof(*packet));
44523}
44524
44525#define free_packet_client_heartbeat(_packet) (void) 0
44526#define destroy_packet_client_heartbeat free
44527
44528 static struct packet_client_heartbeat *receive_packet_client_heartbeat_100(struct connection *pc)
44529{
44530#define FREE_PACKET_STRUCT(_packet) free_packet_client_heartbeat(_packet)
44531 RECEIVE_PACKET_START(packet_client_heartbeat, real_packet);
44532
44533 log_packet_detailed("packet_client_heartbeat_100: got info about ()");
44534
44535 real_packet->__dummy = 0xff;
44536
44537 RECEIVE_PACKET_END(real_packet);
44538#undef FREE_PACKET_STRUCT
44539}
44540
44541 static int send_packet_client_heartbeat_100(struct connection *pc)
44542{
44543 SEND_PACKET_START(PACKET_CLIENT_HEARTBEAT);
44544
44545 log_packet_detailed("packet_client_heartbeat_100: sending info about ()");
44546
44547 SEND_PACKET_END(PACKET_CLIENT_HEARTBEAT);
44548}
44549
44550 int send_packet_client_heartbeat(struct connection *pc)
44551{
44552 if (!pc->used) {
44553 log_error("WARNING: trying to send data to the closed connection %s",
44554 conn_description(pc));
44555 return -1;
44556 }
44557 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CLIENT_HEARTBEAT].no_packet != nullptr, -1,
44558 "Handler for PACKET_CLIENT_HEARTBEAT not installed");
44559 return pc->phs.handlers->send[PACKET_CLIENT_HEARTBEAT].no_packet(pc);
44560}
44561
44562 static inline void init_packet_client_info(struct packet_client_info *packet)
44563{
44564 memset(packet, 0, sizeof(*packet));
44565}
44566
44567#define free_packet_client_info(_packet) (void) 0
44568#define destroy_packet_client_info free
44569
44570#ifdef FREECIV_DELTA_PROTOCOL
44571#define hash_packet_client_info_100 hash_const
44572#define cmp_packet_client_info_100 cmp_const
44573 BV_DEFINE(packet_client_info_100_fields, 3);
44574#endif /* FREECIV_DELTA_PROTOCOL */
44575
44576 static struct packet_client_info *receive_packet_client_info_100(struct connection *pc)
44577{
44578#define FREE_PACKET_STRUCT(_packet) free_packet_client_info(_packet)
44579 RECEIVE_PACKET_START(packet_client_info, real_packet);
44580
44581#ifdef FREECIV_JSON_CONNECTION
44582 struct plocation field_addr;
44583 {
44584 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
44585 field_addr = *field_addr_tmp;
44586 FC_FREE(field_addr_tmp);
44587 }
44588#endif /* FREECIV_JSON_CONNECTION */
44589
44590 log_packet_detailed("packet_client_info_100: got info about ()");
44591
44592#ifdef FREECIV_DELTA_PROTOCOL
44593 packet_client_info_100_fields fields;
44594 struct packet_client_info *old;
44595 struct genhash **hash = pc->phs.received + PACKET_CLIENT_INFO;
44596
44597 if (nullptr == *hash) {
44598 *hash = genhash_new_full(hash_packet_client_info_100, cmp_packet_client_info_100,
44599 nullptr, nullptr, nullptr, destroy_packet_client_info);
44600 }
44601
44602 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
44603 *real_packet = *old;
44604 } else {
44605 /* packet is already initialized empty */
44606 log_packet_detailed(" no old info");
44607 }
44608
44609#ifdef FREECIV_JSON_CONNECTION
44610 field_addr.name = "fields";
44611#endif /* FREECIV_JSON_CONNECTION */
44612 DIO_BV_GET(&din, &field_addr, fields);
44613
44614 if (BV_ISSET(fields, 0)) {
44615 log_packet_detailed(" got field 'gui'");
44616
44617#ifdef FREECIV_JSON_CONNECTION
44618 field_addr.name = "gui";
44619#endif /* FREECIV_JSON_CONNECTION */
44620
44621 {
44622 int readin;
44623
44624 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
44625 RECEIVE_PACKET_FIELD_ERROR(gui);
44626 }
44627 real_packet->gui = readin;
44628 }
44629 }
44630
44631 if (BV_ISSET(fields, 1)) {
44632 log_packet_detailed(" got field 'emerg_version'");
44633
44634#ifdef FREECIV_JSON_CONNECTION
44635 field_addr.name = "emerg_version";
44636#endif /* FREECIV_JSON_CONNECTION */
44637
44638 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->emerg_version)) {
44639 RECEIVE_PACKET_FIELD_ERROR(emerg_version);
44640 }
44641 }
44642
44643 if (BV_ISSET(fields, 2)) {
44644 log_packet_detailed(" got field 'distribution'");
44645
44646#ifdef FREECIV_JSON_CONNECTION
44647 field_addr.name = "distribution";
44648#endif /* FREECIV_JSON_CONNECTION */
44649
44650 if (!DIO_GET(string, &din, &field_addr, real_packet->distribution, sizeof(real_packet->distribution))) {
44651 RECEIVE_PACKET_FIELD_ERROR(distribution);
44652 }
44653 }
44654
44655 if (nullptr == old) {
44656 old = fc_malloc(sizeof(*old));
44657 init_packet_client_info(old);
44658 *old = *real_packet;
44659 genhash_insert(*hash, old, old);
44660 } else {
44661 *old = *real_packet;
44662 }
44663
44664#else /* FREECIV_DELTA_PROTOCOL */
44665#ifdef FREECIV_JSON_CONNECTION
44666 field_addr.name = "gui";
44667#endif /* FREECIV_JSON_CONNECTION */
44668
44669 {
44670 int readin;
44671
44672 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
44673 RECEIVE_PACKET_FIELD_ERROR(gui);
44674 }
44675 real_packet->gui = readin;
44676 }
44677
44678#ifdef FREECIV_JSON_CONNECTION
44679 field_addr.name = "emerg_version";
44680#endif /* FREECIV_JSON_CONNECTION */
44681
44682 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->emerg_version)) {
44683 RECEIVE_PACKET_FIELD_ERROR(emerg_version);
44684 }
44685
44686#ifdef FREECIV_JSON_CONNECTION
44687 field_addr.name = "distribution";
44688#endif /* FREECIV_JSON_CONNECTION */
44689
44690 if (!DIO_GET(string, &din, &field_addr, real_packet->distribution, sizeof(real_packet->distribution))) {
44691 RECEIVE_PACKET_FIELD_ERROR(distribution);
44692 }
44693#endif /* FREECIV_DELTA_PROTOCOL */
44694
44695 RECEIVE_PACKET_END(real_packet);
44696#undef FREE_PACKET_STRUCT
44697}
44698
44699 static int send_packet_client_info_100(struct connection *pc, const struct packet_client_info *packet)
44700{
44701 const struct packet_client_info *real_packet = packet;
44702 int e;
44703 SEND_PACKET_START(PACKET_CLIENT_INFO);
44704
44705 log_packet_detailed("packet_client_info_100: sending info about ()");
44706
44707#ifdef FREECIV_DELTA_PROTOCOL
44708 packet_client_info_100_fields fields;
44709 struct packet_client_info *old;
44710 bool differ;
44711 struct genhash **hash = pc->phs.sent + PACKET_CLIENT_INFO;
44712
44713 if (nullptr == *hash) {
44714 *hash = genhash_new_full(hash_packet_client_info_100, cmp_packet_client_info_100,
44715 nullptr, nullptr, nullptr, destroy_packet_client_info);
44716 }
44717 BV_CLR_ALL(fields);
44718
44719 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
44720 old = fc_malloc(sizeof(*old));
44721 /* temporary bitcopy just to insert correctly */
44722 *old = *real_packet;
44723 genhash_insert(*hash, old, old);
44724 init_packet_client_info(old);
44725 }
44726
44727 differ = (old->gui != real_packet->gui);
44728 if (differ) {
44729 BV_SET(fields, 0);
44730 }
44731
44732 differ = (old->emerg_version != real_packet->emerg_version);
44733 if (differ) {
44734 BV_SET(fields, 1);
44735 }
44736
44737 differ = (strcmp(old->distribution, real_packet->distribution) != 0);
44738 if (differ) {
44739 BV_SET(fields, 2);
44740 }
44741#endif /* FREECIV_DELTA_PROTOCOL */
44742
44743#ifdef FREECIV_JSON_CONNECTION
44744 struct plocation field_addr;
44745 {
44746 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
44747 field_addr = *field_addr_tmp;
44748 FC_FREE(field_addr_tmp);
44749 }
44750#endif /* FREECIV_JSON_CONNECTION */
44751
44752#ifdef FREECIV_DELTA_PROTOCOL
44753#ifdef FREECIV_JSON_CONNECTION
44754 field_addr.name = "fields";
44755#endif /* FREECIV_JSON_CONNECTION */
44756 e = 0;
44757 e |= DIO_BV_PUT(&dout, &field_addr, fields);
44758 if (e) {
44759 log_packet_detailed("fields bitvector error detected");
44760 }
44761
44762 if (BV_ISSET(fields, 0)) {
44763 log_packet_detailed(" field 'gui' has changed");
44764
44765#ifdef FREECIV_JSON_CONNECTION
44766 field_addr.name = "gui";
44767#endif /* FREECIV_JSON_CONNECTION */
44768 e = 0;
44769
44770 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gui);
44771
44772 if (e) {
44773 log_packet_detailed("'gui' field error detected");
44774 }
44775 }
44776
44777 if (BV_ISSET(fields, 1)) {
44778 log_packet_detailed(" field 'emerg_version' has changed");
44779
44780#ifdef FREECIV_JSON_CONNECTION
44781 field_addr.name = "emerg_version";
44782#endif /* FREECIV_JSON_CONNECTION */
44783 e = 0;
44784
44785 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->emerg_version);
44786
44787 if (e) {
44788 log_packet_detailed("'emerg_version' field error detected");
44789 }
44790 }
44791
44792 if (BV_ISSET(fields, 2)) {
44793 log_packet_detailed(" field 'distribution' has changed");
44794
44795#ifdef FREECIV_JSON_CONNECTION
44796 field_addr.name = "distribution";
44797#endif /* FREECIV_JSON_CONNECTION */
44798 e = 0;
44799
44800 e |= DIO_PUT(string, &dout, &field_addr, real_packet->distribution);
44801
44802 if (e) {
44803 log_packet_detailed("'distribution' field error detected");
44804 }
44805 }
44806
44807 *old = *real_packet;
44808
44809#else /* FREECIV_DELTA_PROTOCOL */
44810#ifdef FREECIV_JSON_CONNECTION
44811 field_addr.name = "gui";
44812#endif /* FREECIV_JSON_CONNECTION */
44813 e = 0;
44814
44815 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gui);
44816
44817 if (e) {
44818 log_packet_detailed("'gui' field error detected");
44819 }
44820
44821#ifdef FREECIV_JSON_CONNECTION
44822 field_addr.name = "emerg_version";
44823#endif /* FREECIV_JSON_CONNECTION */
44824 e = 0;
44825
44826 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->emerg_version);
44827
44828 if (e) {
44829 log_packet_detailed("'emerg_version' field error detected");
44830 }
44831
44832#ifdef FREECIV_JSON_CONNECTION
44833 field_addr.name = "distribution";
44834#endif /* FREECIV_JSON_CONNECTION */
44835 e = 0;
44836
44837 e |= DIO_PUT(string, &dout, &field_addr, real_packet->distribution);
44838
44839 if (e) {
44840 log_packet_detailed("'distribution' field error detected");
44841 }
44842#endif /* FREECIV_DELTA_PROTOCOL */
44843
44844 SEND_PACKET_END(PACKET_CLIENT_INFO);
44845}
44846
44847 int send_packet_client_info(struct connection *pc, const struct packet_client_info *packet)
44848{
44849 if (!pc->used) {
44850 log_error("WARNING: trying to send data to the closed connection %s",
44851 conn_description(pc));
44852 return -1;
44853 }
44854 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_CLIENT_INFO].packet != nullptr, -1,
44855 "Handler for PACKET_CLIENT_INFO not installed");
44856 return pc->phs.handlers->send[PACKET_CLIENT_INFO].packet(pc, packet);
44857}
44858
44859 static inline void init_packet_end_phase(struct packet_end_phase *packet)
44860{
44861 memset(packet, 0, sizeof(*packet));
44862}
44863
44864#define free_packet_end_phase(_packet) (void) 0
44865#define destroy_packet_end_phase free
44866
44867 static struct packet_end_phase *receive_packet_end_phase_100(struct connection *pc)
44868{
44869#define FREE_PACKET_STRUCT(_packet) free_packet_end_phase(_packet)
44870 RECEIVE_PACKET_START(packet_end_phase, real_packet);
44871
44872 log_packet_detailed("packet_end_phase_100: got info about ()");
44873
44874 real_packet->__dummy = 0xff;
44875
44876 RECEIVE_PACKET_END(real_packet);
44877#undef FREE_PACKET_STRUCT
44878}
44879
44880 static int send_packet_end_phase_100(struct connection *pc)
44881{
44882 SEND_PACKET_START(PACKET_END_PHASE);
44883
44884 log_packet_detailed("packet_end_phase_100: sending info about ()");
44885
44886 SEND_PACKET_END(PACKET_END_PHASE);
44887}
44888
44889 int send_packet_end_phase(struct connection *pc)
44890{
44891 if (!pc->used) {
44892 log_error("WARNING: trying to send data to the closed connection %s",
44893 conn_description(pc));
44894 return -1;
44895 }
44896 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_END_PHASE].no_packet != nullptr, -1,
44897 "Handler for PACKET_END_PHASE not installed");
44898 return pc->phs.handlers->send[PACKET_END_PHASE].no_packet(pc);
44899}
44900
44901 void lsend_packet_end_phase(struct conn_list *dest)
44902{
44903 conn_list_iterate(dest, pconn) {
44904 send_packet_end_phase(pconn);
44905 } conn_list_iterate_end;
44906}
44907
44908 static inline void init_packet_start_phase(struct packet_start_phase *packet)
44909{
44910 memset(packet, 0, sizeof(*packet));
44911}
44912
44913#define free_packet_start_phase(_packet) (void) 0
44914#define destroy_packet_start_phase free
44915
44916#ifdef FREECIV_DELTA_PROTOCOL
44917#define hash_packet_start_phase_100 hash_const
44918#define cmp_packet_start_phase_100 cmp_const
44919 BV_DEFINE(packet_start_phase_100_fields, 1);
44920#endif /* FREECIV_DELTA_PROTOCOL */
44921
44922 static struct packet_start_phase *receive_packet_start_phase_100(struct connection *pc)
44923{
44924#define FREE_PACKET_STRUCT(_packet) free_packet_start_phase(_packet)
44925 RECEIVE_PACKET_START(packet_start_phase, real_packet);
44926
44927#ifdef FREECIV_JSON_CONNECTION
44928 struct plocation field_addr;
44929 {
44930 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
44931 field_addr = *field_addr_tmp;
44932 FC_FREE(field_addr_tmp);
44933 }
44934#endif /* FREECIV_JSON_CONNECTION */
44935
44936 log_packet_detailed("packet_start_phase_100: got info about ()");
44937
44938#ifdef FREECIV_DELTA_PROTOCOL
44939 packet_start_phase_100_fields fields;
44940 struct packet_start_phase *old;
44941 struct genhash **hash = pc->phs.received + PACKET_START_PHASE;
44942
44943 if (nullptr == *hash) {
44944 *hash = genhash_new_full(hash_packet_start_phase_100, cmp_packet_start_phase_100,
44945 nullptr, nullptr, nullptr, destroy_packet_start_phase);
44946 }
44947
44948 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
44949 *real_packet = *old;
44950 } else {
44951 /* packet is already initialized empty */
44952 log_packet_detailed(" no old info");
44953 }
44954
44955#ifdef FREECIV_JSON_CONNECTION
44956 field_addr.name = "fields";
44957#endif /* FREECIV_JSON_CONNECTION */
44958 DIO_BV_GET(&din, &field_addr, fields);
44959
44960 if (BV_ISSET(fields, 0)) {
44961 log_packet_detailed(" got field 'phase'");
44962
44963#ifdef FREECIV_JSON_CONNECTION
44964 field_addr.name = "phase";
44965#endif /* FREECIV_JSON_CONNECTION */
44966
44967 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
44968 RECEIVE_PACKET_FIELD_ERROR(phase);
44969 }
44970 }
44971
44972 if (nullptr == old) {
44973 old = fc_malloc(sizeof(*old));
44974 init_packet_start_phase(old);
44975 *old = *real_packet;
44976 genhash_insert(*hash, old, old);
44977 } else {
44978 *old = *real_packet;
44979 }
44980
44981#else /* FREECIV_DELTA_PROTOCOL */
44982#ifdef FREECIV_JSON_CONNECTION
44983 field_addr.name = "phase";
44984#endif /* FREECIV_JSON_CONNECTION */
44985
44986 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->phase)) {
44987 RECEIVE_PACKET_FIELD_ERROR(phase);
44988 }
44989#endif /* FREECIV_DELTA_PROTOCOL */
44990
44991 RECEIVE_PACKET_END(real_packet);
44992#undef FREE_PACKET_STRUCT
44993}
44994
44995 static int send_packet_start_phase_100(struct connection *pc, const struct packet_start_phase *packet)
44996{
44997 const struct packet_start_phase *real_packet = packet;
44998 int e;
44999 SEND_PACKET_START(PACKET_START_PHASE);
45000
45001 log_packet_detailed("packet_start_phase_100: sending info about ()");
45002
45003#ifdef FREECIV_DELTA_PROTOCOL
45004 packet_start_phase_100_fields fields;
45005 struct packet_start_phase *old;
45006 bool differ;
45007 struct genhash **hash = pc->phs.sent + PACKET_START_PHASE;
45008
45009 if (nullptr == *hash) {
45010 *hash = genhash_new_full(hash_packet_start_phase_100, cmp_packet_start_phase_100,
45011 nullptr, nullptr, nullptr, destroy_packet_start_phase);
45012 }
45013 BV_CLR_ALL(fields);
45014
45015 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
45016 old = fc_malloc(sizeof(*old));
45017 /* temporary bitcopy just to insert correctly */
45018 *old = *real_packet;
45019 genhash_insert(*hash, old, old);
45020 init_packet_start_phase(old);
45021 }
45022
45023 differ = (old->phase != real_packet->phase);
45024 if (differ) {
45025 BV_SET(fields, 0);
45026 }
45027#endif /* FREECIV_DELTA_PROTOCOL */
45028
45029#ifdef FREECIV_JSON_CONNECTION
45030 struct plocation field_addr;
45031 {
45032 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
45033 field_addr = *field_addr_tmp;
45034 FC_FREE(field_addr_tmp);
45035 }
45036#endif /* FREECIV_JSON_CONNECTION */
45037
45038#ifdef FREECIV_DELTA_PROTOCOL
45039#ifdef FREECIV_JSON_CONNECTION
45040 field_addr.name = "fields";
45041#endif /* FREECIV_JSON_CONNECTION */
45042 e = 0;
45043 e |= DIO_BV_PUT(&dout, &field_addr, fields);
45044 if (e) {
45045 log_packet_detailed("fields bitvector error detected");
45046 }
45047
45048 if (BV_ISSET(fields, 0)) {
45049 log_packet_detailed(" field 'phase' has changed");
45050
45051#ifdef FREECIV_JSON_CONNECTION
45052 field_addr.name = "phase";
45053#endif /* FREECIV_JSON_CONNECTION */
45054 e = 0;
45055
45056 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
45057
45058 if (e) {
45059 log_packet_detailed("'phase' field error detected");
45060 }
45061 }
45062
45063 *old = *real_packet;
45064
45065#else /* FREECIV_DELTA_PROTOCOL */
45066#ifdef FREECIV_JSON_CONNECTION
45067 field_addr.name = "phase";
45068#endif /* FREECIV_JSON_CONNECTION */
45069 e = 0;
45070
45071 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->phase);
45072
45073 if (e) {
45074 log_packet_detailed("'phase' field error detected");
45075 }
45076#endif /* FREECIV_DELTA_PROTOCOL */
45077
45078 SEND_PACKET_END(PACKET_START_PHASE);
45079}
45080
45081 int send_packet_start_phase(struct connection *pc, const struct packet_start_phase *packet)
45082{
45083 if (!pc->used) {
45084 log_error("WARNING: trying to send data to the closed connection %s",
45085 conn_description(pc));
45086 return -1;
45087 }
45088 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_START_PHASE].packet != nullptr, -1,
45089 "Handler for PACKET_START_PHASE not installed");
45090 return pc->phs.handlers->send[PACKET_START_PHASE].packet(pc, packet);
45091}
45092
45093 void lsend_packet_start_phase(struct conn_list *dest, const struct packet_start_phase *packet)
45094{
45095 conn_list_iterate(dest, pconn) {
45096 send_packet_start_phase(pconn, packet);
45097 } conn_list_iterate_end;
45098}
45099
45100 int dsend_packet_start_phase(struct connection *pc, int phase)
45101{
45102 struct packet_start_phase packet, *real_packet = &packet;
45103
45104 real_packet->phase = phase;
45105
45106 return send_packet_start_phase(pc, real_packet);
45107}
45108
45109 void dlsend_packet_start_phase(struct conn_list *dest, int phase)
45110{
45111 struct packet_start_phase packet, *real_packet = &packet;
45112
45113 real_packet->phase = phase;
45114
45115 lsend_packet_start_phase(dest, real_packet);
45116}
45117
45118 static inline void init_packet_new_year(struct packet_new_year *packet)
45119{
45120 memset(packet, 0, sizeof(*packet));
45121}
45122
45123#define free_packet_new_year(_packet) (void) 0
45124#define destroy_packet_new_year free
45125
45126#ifdef FREECIV_DELTA_PROTOCOL
45127#define hash_packet_new_year_100 hash_const
45128#define cmp_packet_new_year_100 cmp_const
45129 BV_DEFINE(packet_new_year_100_fields, 3);
45130#endif /* FREECIV_DELTA_PROTOCOL */
45131
45132 static struct packet_new_year *receive_packet_new_year_100(struct connection *pc)
45133{
45134#define FREE_PACKET_STRUCT(_packet) free_packet_new_year(_packet)
45135 RECEIVE_PACKET_START(packet_new_year, real_packet);
45136
45137#ifdef FREECIV_JSON_CONNECTION
45138 struct plocation field_addr;
45139 {
45140 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
45141 field_addr = *field_addr_tmp;
45142 FC_FREE(field_addr_tmp);
45143 }
45144#endif /* FREECIV_JSON_CONNECTION */
45145
45146 log_packet_detailed("packet_new_year_100: got info about ()");
45147
45148#ifdef FREECIV_DELTA_PROTOCOL
45149 packet_new_year_100_fields fields;
45150 struct packet_new_year *old;
45151 struct genhash **hash = pc->phs.received + PACKET_NEW_YEAR;
45152
45153 if (nullptr == *hash) {
45154 *hash = genhash_new_full(hash_packet_new_year_100, cmp_packet_new_year_100,
45155 nullptr, nullptr, nullptr, destroy_packet_new_year);
45156 }
45157
45158 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
45159 *real_packet = *old;
45160 } else {
45161 /* packet is already initialized empty */
45162 log_packet_detailed(" no old info");
45163 }
45164
45165#ifdef FREECIV_JSON_CONNECTION
45166 field_addr.name = "fields";
45167#endif /* FREECIV_JSON_CONNECTION */
45168 DIO_BV_GET(&din, &field_addr, fields);
45169
45170 if (BV_ISSET(fields, 0)) {
45171 log_packet_detailed(" got field 'year'");
45172
45173#ifdef FREECIV_JSON_CONNECTION
45174 field_addr.name = "year";
45175#endif /* FREECIV_JSON_CONNECTION */
45176
45177 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->year)) {
45178 RECEIVE_PACKET_FIELD_ERROR(year);
45179 }
45180 }
45181
45182 if (BV_ISSET(fields, 1)) {
45183 log_packet_detailed(" got field 'fragments'");
45184
45185#ifdef FREECIV_JSON_CONNECTION
45186 field_addr.name = "fragments";
45187#endif /* FREECIV_JSON_CONNECTION */
45188
45189 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->fragments)) {
45190 RECEIVE_PACKET_FIELD_ERROR(fragments);
45191 }
45192 }
45193
45194 if (BV_ISSET(fields, 2)) {
45195 log_packet_detailed(" got field 'turn'");
45196
45197#ifdef FREECIV_JSON_CONNECTION
45198 field_addr.name = "turn";
45199#endif /* FREECIV_JSON_CONNECTION */
45200
45201 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
45202 RECEIVE_PACKET_FIELD_ERROR(turn);
45203 }
45204 }
45205
45206 if (nullptr == old) {
45207 old = fc_malloc(sizeof(*old));
45208 init_packet_new_year(old);
45209 *old = *real_packet;
45210 genhash_insert(*hash, old, old);
45211 } else {
45212 *old = *real_packet;
45213 }
45214
45215#else /* FREECIV_DELTA_PROTOCOL */
45216#ifdef FREECIV_JSON_CONNECTION
45217 field_addr.name = "year";
45218#endif /* FREECIV_JSON_CONNECTION */
45219
45220 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->year)) {
45221 RECEIVE_PACKET_FIELD_ERROR(year);
45222 }
45223
45224#ifdef FREECIV_JSON_CONNECTION
45225 field_addr.name = "fragments";
45226#endif /* FREECIV_JSON_CONNECTION */
45227
45228 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->fragments)) {
45229 RECEIVE_PACKET_FIELD_ERROR(fragments);
45230 }
45231
45232#ifdef FREECIV_JSON_CONNECTION
45233 field_addr.name = "turn";
45234#endif /* FREECIV_JSON_CONNECTION */
45235
45236 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn)) {
45237 RECEIVE_PACKET_FIELD_ERROR(turn);
45238 }
45239#endif /* FREECIV_DELTA_PROTOCOL */
45240
45241 RECEIVE_PACKET_END(real_packet);
45242#undef FREE_PACKET_STRUCT
45243}
45244
45245 static int send_packet_new_year_100(struct connection *pc, const struct packet_new_year *packet)
45246{
45247 const struct packet_new_year *real_packet = packet;
45248 int e;
45249 SEND_PACKET_START(PACKET_NEW_YEAR);
45250
45251 log_packet_detailed("packet_new_year_100: sending info about ()");
45252
45253#ifdef FREECIV_DELTA_PROTOCOL
45254 packet_new_year_100_fields fields;
45255 struct packet_new_year *old;
45256 bool differ;
45257 struct genhash **hash = pc->phs.sent + PACKET_NEW_YEAR;
45258
45259 if (nullptr == *hash) {
45260 *hash = genhash_new_full(hash_packet_new_year_100, cmp_packet_new_year_100,
45261 nullptr, nullptr, nullptr, destroy_packet_new_year);
45262 }
45263 BV_CLR_ALL(fields);
45264
45265 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
45266 old = fc_malloc(sizeof(*old));
45267 /* temporary bitcopy just to insert correctly */
45268 *old = *real_packet;
45269 genhash_insert(*hash, old, old);
45270 init_packet_new_year(old);
45271 }
45272
45273 differ = (old->year != real_packet->year);
45274 if (differ) {
45275 BV_SET(fields, 0);
45276 }
45277
45278 differ = (old->fragments != real_packet->fragments);
45279 if (differ) {
45280 BV_SET(fields, 1);
45281 }
45282
45283 differ = (old->turn != real_packet->turn);
45284 if (differ) {
45285 BV_SET(fields, 2);
45286 }
45287#endif /* FREECIV_DELTA_PROTOCOL */
45288
45289#ifdef FREECIV_JSON_CONNECTION
45290 struct plocation field_addr;
45291 {
45292 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
45293 field_addr = *field_addr_tmp;
45294 FC_FREE(field_addr_tmp);
45295 }
45296#endif /* FREECIV_JSON_CONNECTION */
45297
45298#ifdef FREECIV_DELTA_PROTOCOL
45299#ifdef FREECIV_JSON_CONNECTION
45300 field_addr.name = "fields";
45301#endif /* FREECIV_JSON_CONNECTION */
45302 e = 0;
45303 e |= DIO_BV_PUT(&dout, &field_addr, fields);
45304 if (e) {
45305 log_packet_detailed("fields bitvector error detected");
45306 }
45307
45308 if (BV_ISSET(fields, 0)) {
45309 log_packet_detailed(" field 'year' has changed");
45310
45311#ifdef FREECIV_JSON_CONNECTION
45312 field_addr.name = "year";
45313#endif /* FREECIV_JSON_CONNECTION */
45314 e = 0;
45315
45316 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->year);
45317
45318 if (e) {
45319 log_packet_detailed("'year' field error detected");
45320 }
45321 }
45322
45323 if (BV_ISSET(fields, 1)) {
45324 log_packet_detailed(" field 'fragments' has changed");
45325
45326#ifdef FREECIV_JSON_CONNECTION
45327 field_addr.name = "fragments";
45328#endif /* FREECIV_JSON_CONNECTION */
45329 e = 0;
45330
45331 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->fragments);
45332
45333 if (e) {
45334 log_packet_detailed("'fragments' field error detected");
45335 }
45336 }
45337
45338 if (BV_ISSET(fields, 2)) {
45339 log_packet_detailed(" field 'turn' has changed");
45340
45341#ifdef FREECIV_JSON_CONNECTION
45342 field_addr.name = "turn";
45343#endif /* FREECIV_JSON_CONNECTION */
45344 e = 0;
45345
45346 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
45347
45348 if (e) {
45349 log_packet_detailed("'turn' field error detected");
45350 }
45351 }
45352
45353 *old = *real_packet;
45354
45355#else /* FREECIV_DELTA_PROTOCOL */
45356#ifdef FREECIV_JSON_CONNECTION
45357 field_addr.name = "year";
45358#endif /* FREECIV_JSON_CONNECTION */
45359 e = 0;
45360
45361 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->year);
45362
45363 if (e) {
45364 log_packet_detailed("'year' field error detected");
45365 }
45366
45367#ifdef FREECIV_JSON_CONNECTION
45368 field_addr.name = "fragments";
45369#endif /* FREECIV_JSON_CONNECTION */
45370 e = 0;
45371
45372 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->fragments);
45373
45374 if (e) {
45375 log_packet_detailed("'fragments' field error detected");
45376 }
45377
45378#ifdef FREECIV_JSON_CONNECTION
45379 field_addr.name = "turn";
45380#endif /* FREECIV_JSON_CONNECTION */
45381 e = 0;
45382
45383 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn);
45384
45385 if (e) {
45386 log_packet_detailed("'turn' field error detected");
45387 }
45388#endif /* FREECIV_DELTA_PROTOCOL */
45389
45390 SEND_PACKET_END(PACKET_NEW_YEAR);
45391}
45392
45393 int send_packet_new_year(struct connection *pc, const struct packet_new_year *packet)
45394{
45395 if (!pc->used) {
45396 log_error("WARNING: trying to send data to the closed connection %s",
45397 conn_description(pc));
45398 return -1;
45399 }
45400 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NEW_YEAR].packet != nullptr, -1,
45401 "Handler for PACKET_NEW_YEAR not installed");
45402 return pc->phs.handlers->send[PACKET_NEW_YEAR].packet(pc, packet);
45403}
45404
45405 void lsend_packet_new_year(struct conn_list *dest, const struct packet_new_year *packet)
45406{
45407 conn_list_iterate(dest, pconn) {
45408 send_packet_new_year(pconn, packet);
45409 } conn_list_iterate_end;
45410}
45411
45412 static inline void init_packet_begin_turn(struct packet_begin_turn *packet)
45413{
45414 memset(packet, 0, sizeof(*packet));
45415}
45416
45417#define free_packet_begin_turn(_packet) (void) 0
45418#define destroy_packet_begin_turn free
45419
45420 static struct packet_begin_turn *receive_packet_begin_turn_100(struct connection *pc)
45421{
45422#define FREE_PACKET_STRUCT(_packet) free_packet_begin_turn(_packet)
45423 RECEIVE_PACKET_START(packet_begin_turn, real_packet);
45424
45425 log_packet_detailed("packet_begin_turn_100: got info about ()");
45426
45427 real_packet->__dummy = 0xff;
45428
45429 RECEIVE_PACKET_END(real_packet);
45430#undef FREE_PACKET_STRUCT
45431}
45432
45433 static int send_packet_begin_turn_100(struct connection *pc)
45434{
45435 SEND_PACKET_START(PACKET_BEGIN_TURN);
45436
45437 log_packet_detailed("packet_begin_turn_100: sending info about ()");
45438
45439 SEND_PACKET_END(PACKET_BEGIN_TURN);
45440}
45441
45442 int send_packet_begin_turn(struct connection *pc)
45443{
45444 if (!pc->used) {
45445 log_error("WARNING: trying to send data to the closed connection %s",
45446 conn_description(pc));
45447 return -1;
45448 }
45449 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_BEGIN_TURN].no_packet != nullptr, -1,
45450 "Handler for PACKET_BEGIN_TURN not installed");
45451 return pc->phs.handlers->send[PACKET_BEGIN_TURN].no_packet(pc);
45452}
45453
45454 void lsend_packet_begin_turn(struct conn_list *dest)
45455{
45456 conn_list_iterate(dest, pconn) {
45457 send_packet_begin_turn(pconn);
45458 } conn_list_iterate_end;
45459}
45460
45461 static inline void init_packet_end_turn(struct packet_end_turn *packet)
45462{
45463 memset(packet, 0, sizeof(*packet));
45464}
45465
45466#define free_packet_end_turn(_packet) (void) 0
45467#define destroy_packet_end_turn free
45468
45469 static struct packet_end_turn *receive_packet_end_turn_100(struct connection *pc)
45470{
45471#define FREE_PACKET_STRUCT(_packet) free_packet_end_turn(_packet)
45472 RECEIVE_PACKET_START(packet_end_turn, real_packet);
45473
45474 log_packet_detailed("packet_end_turn_100: got info about ()");
45475
45476 real_packet->__dummy = 0xff;
45477
45478 RECEIVE_PACKET_END(real_packet);
45479#undef FREE_PACKET_STRUCT
45480}
45481
45482 static int send_packet_end_turn_100(struct connection *pc)
45483{
45484 SEND_PACKET_START(PACKET_END_TURN);
45485
45486 log_packet_detailed("packet_end_turn_100: sending info about ()");
45487
45488 SEND_PACKET_END(PACKET_END_TURN);
45489}
45490
45491 int send_packet_end_turn(struct connection *pc)
45492{
45493 if (!pc->used) {
45494 log_error("WARNING: trying to send data to the closed connection %s",
45495 conn_description(pc));
45496 return -1;
45497 }
45498 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_END_TURN].no_packet != nullptr, -1,
45499 "Handler for PACKET_END_TURN not installed");
45500 return pc->phs.handlers->send[PACKET_END_TURN].no_packet(pc);
45501}
45502
45503 void lsend_packet_end_turn(struct conn_list *dest)
45504{
45505 conn_list_iterate(dest, pconn) {
45506 send_packet_end_turn(pconn);
45507 } conn_list_iterate_end;
45508}
45509
45510 static inline void init_packet_freeze_client(struct packet_freeze_client *packet)
45511{
45512 memset(packet, 0, sizeof(*packet));
45513}
45514
45515#define free_packet_freeze_client(_packet) (void) 0
45516#define destroy_packet_freeze_client free
45517
45518 static struct packet_freeze_client *receive_packet_freeze_client_100(struct connection *pc)
45519{
45520#define FREE_PACKET_STRUCT(_packet) free_packet_freeze_client(_packet)
45521 RECEIVE_PACKET_START(packet_freeze_client, real_packet);
45522
45523 log_packet_detailed("packet_freeze_client_100: got info about ()");
45524
45525 real_packet->__dummy = 0xff;
45526
45527 RECEIVE_PACKET_END(real_packet);
45528#undef FREE_PACKET_STRUCT
45529}
45530
45531 static int send_packet_freeze_client_100(struct connection *pc)
45532{
45533 SEND_PACKET_START(PACKET_FREEZE_CLIENT);
45534
45535 log_packet_detailed("packet_freeze_client_100: sending info about ()");
45536
45537 SEND_PACKET_END(PACKET_FREEZE_CLIENT);
45538}
45539
45540 int send_packet_freeze_client(struct connection *pc)
45541{
45542 if (!pc->used) {
45543 log_error("WARNING: trying to send data to the closed connection %s",
45544 conn_description(pc));
45545 return -1;
45546 }
45547 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_FREEZE_CLIENT].no_packet != nullptr, -1,
45548 "Handler for PACKET_FREEZE_CLIENT not installed");
45549 return pc->phs.handlers->send[PACKET_FREEZE_CLIENT].no_packet(pc);
45550}
45551
45552 void lsend_packet_freeze_client(struct conn_list *dest)
45553{
45554 conn_list_iterate(dest, pconn) {
45555 send_packet_freeze_client(pconn);
45556 } conn_list_iterate_end;
45557}
45558
45559 static inline void init_packet_thaw_client(struct packet_thaw_client *packet)
45560{
45561 memset(packet, 0, sizeof(*packet));
45562}
45563
45564#define free_packet_thaw_client(_packet) (void) 0
45565#define destroy_packet_thaw_client free
45566
45567 static struct packet_thaw_client *receive_packet_thaw_client_100(struct connection *pc)
45568{
45569#define FREE_PACKET_STRUCT(_packet) free_packet_thaw_client(_packet)
45570 RECEIVE_PACKET_START(packet_thaw_client, real_packet);
45571
45572 log_packet_detailed("packet_thaw_client_100: got info about ()");
45573
45574 real_packet->__dummy = 0xff;
45575
45576 RECEIVE_PACKET_END(real_packet);
45577#undef FREE_PACKET_STRUCT
45578}
45579
45580 static int send_packet_thaw_client_100(struct connection *pc)
45581{
45582 SEND_PACKET_START(PACKET_THAW_CLIENT);
45583
45584 log_packet_detailed("packet_thaw_client_100: sending info about ()");
45585
45586 SEND_PACKET_END(PACKET_THAW_CLIENT);
45587}
45588
45589 int send_packet_thaw_client(struct connection *pc)
45590{
45591 if (!pc->used) {
45592 log_error("WARNING: trying to send data to the closed connection %s",
45593 conn_description(pc));
45594 return -1;
45595 }
45596 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_THAW_CLIENT].no_packet != nullptr, -1,
45597 "Handler for PACKET_THAW_CLIENT not installed");
45598 return pc->phs.handlers->send[PACKET_THAW_CLIENT].no_packet(pc);
45599}
45600
45601 void lsend_packet_thaw_client(struct conn_list *dest)
45602{
45603 conn_list_iterate(dest, pconn) {
45604 send_packet_thaw_client(pconn);
45605 } conn_list_iterate_end;
45606}
45607
45608 static inline void init_packet_spaceship_launch(struct packet_spaceship_launch *packet)
45609{
45610 memset(packet, 0, sizeof(*packet));
45611}
45612
45613#define free_packet_spaceship_launch(_packet) (void) 0
45614#define destroy_packet_spaceship_launch free
45615
45616 static struct packet_spaceship_launch *receive_packet_spaceship_launch_100(struct connection *pc)
45617{
45618#define FREE_PACKET_STRUCT(_packet) free_packet_spaceship_launch(_packet)
45619 RECEIVE_PACKET_START(packet_spaceship_launch, real_packet);
45620
45621 log_packet_detailed("packet_spaceship_launch_100: got info about ()");
45622
45623 real_packet->__dummy = 0xff;
45624
45625 RECEIVE_PACKET_END(real_packet);
45626#undef FREE_PACKET_STRUCT
45627}
45628
45629 static int send_packet_spaceship_launch_100(struct connection *pc)
45630{
45631 SEND_PACKET_START(PACKET_SPACESHIP_LAUNCH);
45632
45633 log_packet_detailed("packet_spaceship_launch_100: sending info about ()");
45634
45635 SEND_PACKET_END(PACKET_SPACESHIP_LAUNCH);
45636}
45637
45638 int send_packet_spaceship_launch(struct connection *pc)
45639{
45640 if (!pc->used) {
45641 log_error("WARNING: trying to send data to the closed connection %s",
45642 conn_description(pc));
45643 return -1;
45644 }
45645 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SPACESHIP_LAUNCH].no_packet != nullptr, -1,
45646 "Handler for PACKET_SPACESHIP_LAUNCH not installed");
45647 return pc->phs.handlers->send[PACKET_SPACESHIP_LAUNCH].no_packet(pc);
45648}
45649
45650 static inline void init_packet_spaceship_place(struct packet_spaceship_place *packet)
45651{
45652 memset(packet, 0, sizeof(*packet));
45653}
45654
45655#define free_packet_spaceship_place(_packet) (void) 0
45656#define destroy_packet_spaceship_place free
45657
45658#ifdef FREECIV_DELTA_PROTOCOL
45659#define hash_packet_spaceship_place_100 hash_const
45660#define cmp_packet_spaceship_place_100 cmp_const
45661 BV_DEFINE(packet_spaceship_place_100_fields, 2);
45662#endif /* FREECIV_DELTA_PROTOCOL */
45663
45664 static struct packet_spaceship_place *receive_packet_spaceship_place_100(struct connection *pc)
45665{
45666#define FREE_PACKET_STRUCT(_packet) free_packet_spaceship_place(_packet)
45667 RECEIVE_PACKET_START(packet_spaceship_place, real_packet);
45668
45669#ifdef FREECIV_JSON_CONNECTION
45670 struct plocation field_addr;
45671 {
45672 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
45673 field_addr = *field_addr_tmp;
45674 FC_FREE(field_addr_tmp);
45675 }
45676#endif /* FREECIV_JSON_CONNECTION */
45677
45678 log_packet_detailed("packet_spaceship_place_100: got info about ()");
45679
45680#ifdef FREECIV_DELTA_PROTOCOL
45681 packet_spaceship_place_100_fields fields;
45682 struct packet_spaceship_place *old;
45683 struct genhash **hash = pc->phs.received + PACKET_SPACESHIP_PLACE;
45684
45685 if (nullptr == *hash) {
45686 *hash = genhash_new_full(hash_packet_spaceship_place_100, cmp_packet_spaceship_place_100,
45687 nullptr, nullptr, nullptr, destroy_packet_spaceship_place);
45688 }
45689
45690 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
45691 *real_packet = *old;
45692 } else {
45693 /* packet is already initialized empty */
45694 log_packet_detailed(" no old info");
45695 }
45696
45697#ifdef FREECIV_JSON_CONNECTION
45698 field_addr.name = "fields";
45699#endif /* FREECIV_JSON_CONNECTION */
45700 DIO_BV_GET(&din, &field_addr, fields);
45701
45702 if (BV_ISSET(fields, 0)) {
45703 log_packet_detailed(" got field 'type'");
45704
45705#ifdef FREECIV_JSON_CONNECTION
45706 field_addr.name = "type";
45707#endif /* FREECIV_JSON_CONNECTION */
45708
45709 {
45710 int readin;
45711
45712 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
45713 RECEIVE_PACKET_FIELD_ERROR(type);
45714 }
45715 real_packet->type = readin;
45716 }
45717 }
45718
45719 if (BV_ISSET(fields, 1)) {
45720 log_packet_detailed(" got field 'num'");
45721
45722#ifdef FREECIV_JSON_CONNECTION
45723 field_addr.name = "num";
45724#endif /* FREECIV_JSON_CONNECTION */
45725
45726 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->num)) {
45727 RECEIVE_PACKET_FIELD_ERROR(num);
45728 }
45729 }
45730
45731 if (nullptr == old) {
45732 old = fc_malloc(sizeof(*old));
45733 init_packet_spaceship_place(old);
45734 *old = *real_packet;
45735 genhash_insert(*hash, old, old);
45736 } else {
45737 *old = *real_packet;
45738 }
45739
45740#else /* FREECIV_DELTA_PROTOCOL */
45741#ifdef FREECIV_JSON_CONNECTION
45742 field_addr.name = "type";
45743#endif /* FREECIV_JSON_CONNECTION */
45744
45745 {
45746 int readin;
45747
45748 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
45749 RECEIVE_PACKET_FIELD_ERROR(type);
45750 }
45751 real_packet->type = readin;
45752 }
45753
45754#ifdef FREECIV_JSON_CONNECTION
45755 field_addr.name = "num";
45756#endif /* FREECIV_JSON_CONNECTION */
45757
45758 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->num)) {
45759 RECEIVE_PACKET_FIELD_ERROR(num);
45760 }
45761#endif /* FREECIV_DELTA_PROTOCOL */
45762
45763 RECEIVE_PACKET_END(real_packet);
45764#undef FREE_PACKET_STRUCT
45765}
45766
45767 static int send_packet_spaceship_place_100(struct connection *pc, const struct packet_spaceship_place *packet)
45768{
45769 const struct packet_spaceship_place *real_packet = packet;
45770 int e;
45771 SEND_PACKET_START(PACKET_SPACESHIP_PLACE);
45772
45773 log_packet_detailed("packet_spaceship_place_100: sending info about ()");
45774
45775#ifdef FREECIV_DELTA_PROTOCOL
45776 packet_spaceship_place_100_fields fields;
45777 struct packet_spaceship_place *old;
45778 bool differ;
45779 struct genhash **hash = pc->phs.sent + PACKET_SPACESHIP_PLACE;
45780
45781 if (nullptr == *hash) {
45782 *hash = genhash_new_full(hash_packet_spaceship_place_100, cmp_packet_spaceship_place_100,
45783 nullptr, nullptr, nullptr, destroy_packet_spaceship_place);
45784 }
45785 BV_CLR_ALL(fields);
45786
45787 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
45788 old = fc_malloc(sizeof(*old));
45789 /* temporary bitcopy just to insert correctly */
45790 *old = *real_packet;
45791 genhash_insert(*hash, old, old);
45792 init_packet_spaceship_place(old);
45793 }
45794
45795 differ = (old->type != real_packet->type);
45796 if (differ) {
45797 BV_SET(fields, 0);
45798 }
45799
45800 differ = (old->num != real_packet->num);
45801 if (differ) {
45802 BV_SET(fields, 1);
45803 }
45804#endif /* FREECIV_DELTA_PROTOCOL */
45805
45806#ifdef FREECIV_JSON_CONNECTION
45807 struct plocation field_addr;
45808 {
45809 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
45810 field_addr = *field_addr_tmp;
45811 FC_FREE(field_addr_tmp);
45812 }
45813#endif /* FREECIV_JSON_CONNECTION */
45814
45815#ifdef FREECIV_DELTA_PROTOCOL
45816#ifdef FREECIV_JSON_CONNECTION
45817 field_addr.name = "fields";
45818#endif /* FREECIV_JSON_CONNECTION */
45819 e = 0;
45820 e |= DIO_BV_PUT(&dout, &field_addr, fields);
45821 if (e) {
45822 log_packet_detailed("fields bitvector error detected");
45823 }
45824
45825 if (BV_ISSET(fields, 0)) {
45826 log_packet_detailed(" field 'type' has changed");
45827
45828#ifdef FREECIV_JSON_CONNECTION
45829 field_addr.name = "type";
45830#endif /* FREECIV_JSON_CONNECTION */
45831 e = 0;
45832
45833 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
45834
45835 if (e) {
45836 log_packet_detailed("'type' field error detected");
45837 }
45838 }
45839
45840 if (BV_ISSET(fields, 1)) {
45841 log_packet_detailed(" field 'num' has changed");
45842
45843#ifdef FREECIV_JSON_CONNECTION
45844 field_addr.name = "num";
45845#endif /* FREECIV_JSON_CONNECTION */
45846 e = 0;
45847
45848 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->num);
45849
45850 if (e) {
45851 log_packet_detailed("'num' field error detected");
45852 }
45853 }
45854
45855 *old = *real_packet;
45856
45857#else /* FREECIV_DELTA_PROTOCOL */
45858#ifdef FREECIV_JSON_CONNECTION
45859 field_addr.name = "type";
45860#endif /* FREECIV_JSON_CONNECTION */
45861 e = 0;
45862
45863 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
45864
45865 if (e) {
45866 log_packet_detailed("'type' field error detected");
45867 }
45868
45869#ifdef FREECIV_JSON_CONNECTION
45870 field_addr.name = "num";
45871#endif /* FREECIV_JSON_CONNECTION */
45872 e = 0;
45873
45874 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->num);
45875
45876 if (e) {
45877 log_packet_detailed("'num' field error detected");
45878 }
45879#endif /* FREECIV_DELTA_PROTOCOL */
45880
45881 SEND_PACKET_END(PACKET_SPACESHIP_PLACE);
45882}
45883
45884 int send_packet_spaceship_place(struct connection *pc, const struct packet_spaceship_place *packet)
45885{
45886 if (!pc->used) {
45887 log_error("WARNING: trying to send data to the closed connection %s",
45888 conn_description(pc));
45889 return -1;
45890 }
45891 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SPACESHIP_PLACE].packet != nullptr, -1,
45892 "Handler for PACKET_SPACESHIP_PLACE not installed");
45893 return pc->phs.handlers->send[PACKET_SPACESHIP_PLACE].packet(pc, packet);
45894}
45895
45896 int dsend_packet_spaceship_place(struct connection *pc, enum spaceship_place_type type, int num)
45897{
45898 struct packet_spaceship_place packet, *real_packet = &packet;
45899
45900 real_packet->type = type;
45901 real_packet->num = num;
45902
45903 return send_packet_spaceship_place(pc, real_packet);
45904}
45905
45906 static inline void init_packet_spaceship_info(struct packet_spaceship_info *packet)
45907{
45908 memset(packet, 0, sizeof(*packet));
45909}
45910
45911#define free_packet_spaceship_info(_packet) (void) 0
45912#define destroy_packet_spaceship_info free
45913
45914#ifdef FREECIV_DELTA_PROTOCOL
45915static genhash_val_t hash_packet_spaceship_info_100(const void *vkey)
45916{
45917 const struct packet_spaceship_info *key = (const struct packet_spaceship_info *) vkey;
45918 genhash_val_t result = 0;
45919
45920 result += key->player_num;
45921
45922 result &= 0xFFFFFFFF;
45923 return result;
45924}
45925
45926static bool cmp_packet_spaceship_info_100(const void *vkey1, const void *vkey2)
45927{
45928 const struct packet_spaceship_info *old = (const struct packet_spaceship_info *) vkey1;
45929 const struct packet_spaceship_info *real_packet = (const struct packet_spaceship_info *) vkey2;
45930 bool differ;
45931
45932 differ = (old->player_num != real_packet->player_num);
45933
45934 return !differ;
45935}
45936 BV_DEFINE(packet_spaceship_info_100_fields, 17);
45937#endif /* FREECIV_DELTA_PROTOCOL */
45938
45939 static struct packet_spaceship_info *receive_packet_spaceship_info_100(struct connection *pc)
45940{
45941#define FREE_PACKET_STRUCT(_packet) free_packet_spaceship_info(_packet)
45942 RECEIVE_PACKET_START(packet_spaceship_info, real_packet);
45943
45944#ifdef FREECIV_JSON_CONNECTION
45945 struct plocation field_addr;
45946 {
45947 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
45948 field_addr = *field_addr_tmp;
45949 FC_FREE(field_addr_tmp);
45950 }
45951#endif /* FREECIV_JSON_CONNECTION */
45952
45953#ifdef FREECIV_JSON_CONNECTION
45954 field_addr.name = "player_num";
45955#endif /* FREECIV_JSON_CONNECTION */
45956
45957 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player_num)) {
45958 RECEIVE_PACKET_FIELD_ERROR(player_num);
45959 }
45960
45961 log_packet_detailed("packet_spaceship_info_100: got info about (%d)",
45962 real_packet->player_num);
45963
45964#ifdef FREECIV_DELTA_PROTOCOL
45965 packet_spaceship_info_100_fields fields;
45966 struct packet_spaceship_info *old;
45967 struct genhash **hash = pc->phs.received + PACKET_SPACESHIP_INFO;
45968
45969 if (nullptr == *hash) {
45970 *hash = genhash_new_full(hash_packet_spaceship_info_100, cmp_packet_spaceship_info_100,
45971 nullptr, nullptr, nullptr, destroy_packet_spaceship_info);
45972 }
45973
45974 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
45975 *real_packet = *old;
45976 } else {
45977 /* packet is already initialized empty */
45978 log_packet_detailed(" no old info");
45979 }
45980
45981#ifdef FREECIV_JSON_CONNECTION
45982 field_addr.name = "fields";
45983#endif /* FREECIV_JSON_CONNECTION */
45984 DIO_BV_GET(&din, &field_addr, fields);
45985
45986 if (BV_ISSET(fields, 0)) {
45987 log_packet_detailed(" got field 'sship_state'");
45988
45989#ifdef FREECIV_JSON_CONNECTION
45990 field_addr.name = "sship_state";
45991#endif /* FREECIV_JSON_CONNECTION */
45992
45993 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->sship_state)) {
45994 RECEIVE_PACKET_FIELD_ERROR(sship_state);
45995 }
45996 }
45997
45998 if (BV_ISSET(fields, 1)) {
45999 log_packet_detailed(" got field 'structurals'");
46000
46001#ifdef FREECIV_JSON_CONNECTION
46002 field_addr.name = "structurals";
46003#endif /* FREECIV_JSON_CONNECTION */
46004
46005 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->structurals)) {
46006 RECEIVE_PACKET_FIELD_ERROR(structurals);
46007 }
46008 }
46009
46010 if (BV_ISSET(fields, 2)) {
46011 log_packet_detailed(" got field 'components'");
46012
46013#ifdef FREECIV_JSON_CONNECTION
46014 field_addr.name = "components";
46015#endif /* FREECIV_JSON_CONNECTION */
46016
46017 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->components)) {
46018 RECEIVE_PACKET_FIELD_ERROR(components);
46019 }
46020 }
46021
46022 if (BV_ISSET(fields, 3)) {
46023 log_packet_detailed(" got field 'modules'");
46024
46025#ifdef FREECIV_JSON_CONNECTION
46026 field_addr.name = "modules";
46027#endif /* FREECIV_JSON_CONNECTION */
46028
46029 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->modules)) {
46030 RECEIVE_PACKET_FIELD_ERROR(modules);
46031 }
46032 }
46033
46034 if (BV_ISSET(fields, 4)) {
46035 log_packet_detailed(" got field 'fuel'");
46036
46037#ifdef FREECIV_JSON_CONNECTION
46038 field_addr.name = "fuel";
46039#endif /* FREECIV_JSON_CONNECTION */
46040
46041 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
46042 RECEIVE_PACKET_FIELD_ERROR(fuel);
46043 }
46044 }
46045
46046 if (BV_ISSET(fields, 5)) {
46047 log_packet_detailed(" got field 'propulsion'");
46048
46049#ifdef FREECIV_JSON_CONNECTION
46050 field_addr.name = "propulsion";
46051#endif /* FREECIV_JSON_CONNECTION */
46052
46053 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->propulsion)) {
46054 RECEIVE_PACKET_FIELD_ERROR(propulsion);
46055 }
46056 }
46057
46058 if (BV_ISSET(fields, 6)) {
46059 log_packet_detailed(" got field 'habitation'");
46060
46061#ifdef FREECIV_JSON_CONNECTION
46062 field_addr.name = "habitation";
46063#endif /* FREECIV_JSON_CONNECTION */
46064
46065 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->habitation)) {
46066 RECEIVE_PACKET_FIELD_ERROR(habitation);
46067 }
46068 }
46069
46070 if (BV_ISSET(fields, 7)) {
46071 log_packet_detailed(" got field 'life_support'");
46072
46073#ifdef FREECIV_JSON_CONNECTION
46074 field_addr.name = "life_support";
46075#endif /* FREECIV_JSON_CONNECTION */
46076
46077 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->life_support)) {
46078 RECEIVE_PACKET_FIELD_ERROR(life_support);
46079 }
46080 }
46081
46082 if (BV_ISSET(fields, 8)) {
46083 log_packet_detailed(" got field 'solar_panels'");
46084
46085#ifdef FREECIV_JSON_CONNECTION
46086 field_addr.name = "solar_panels";
46087#endif /* FREECIV_JSON_CONNECTION */
46088
46089 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->solar_panels)) {
46090 RECEIVE_PACKET_FIELD_ERROR(solar_panels);
46091 }
46092 }
46093
46094 if (BV_ISSET(fields, 9)) {
46095 log_packet_detailed(" got field 'launch_year'");
46096
46097#ifdef FREECIV_JSON_CONNECTION
46098 field_addr.name = "launch_year";
46099#endif /* FREECIV_JSON_CONNECTION */
46100
46101 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->launch_year)) {
46102 RECEIVE_PACKET_FIELD_ERROR(launch_year);
46103 }
46104 }
46105
46106 if (BV_ISSET(fields, 10)) {
46107 log_packet_detailed(" got field 'population'");
46108
46109#ifdef FREECIV_JSON_CONNECTION
46110 field_addr.name = "population";
46111#endif /* FREECIV_JSON_CONNECTION */
46112
46113 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->population)) {
46114 RECEIVE_PACKET_FIELD_ERROR(population);
46115 }
46116 }
46117
46118 if (BV_ISSET(fields, 11)) {
46119 log_packet_detailed(" got field 'mass'");
46120
46121#ifdef FREECIV_JSON_CONNECTION
46122 field_addr.name = "mass";
46123#endif /* FREECIV_JSON_CONNECTION */
46124
46125 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->mass)) {
46126 RECEIVE_PACKET_FIELD_ERROR(mass);
46127 }
46128 }
46129
46130 if (BV_ISSET(fields, 12)) {
46131 log_packet_detailed(" got field 'structure'");
46132
46133#ifdef FREECIV_JSON_CONNECTION
46134 field_addr.name = "structure";
46135#endif /* FREECIV_JSON_CONNECTION */
46136
46137 if (!DIO_BV_GET(&din, &field_addr, real_packet->structure)) {
46138 RECEIVE_PACKET_FIELD_ERROR(structure);
46139 }
46140 }
46141
46142 if (BV_ISSET(fields, 13)) {
46143 log_packet_detailed(" got field 'support_rate'");
46144
46145#ifdef FREECIV_JSON_CONNECTION
46146 field_addr.name = "support_rate";
46147#endif /* FREECIV_JSON_CONNECTION */
46148
46149 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->support_rate, 10000)) {
46150 RECEIVE_PACKET_FIELD_ERROR(support_rate);
46151 }
46152 }
46153
46154 if (BV_ISSET(fields, 14)) {
46155 log_packet_detailed(" got field 'energy_rate'");
46156
46157#ifdef FREECIV_JSON_CONNECTION
46158 field_addr.name = "energy_rate";
46159#endif /* FREECIV_JSON_CONNECTION */
46160
46161 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->energy_rate, 10000)) {
46162 RECEIVE_PACKET_FIELD_ERROR(energy_rate);
46163 }
46164 }
46165
46166 if (BV_ISSET(fields, 15)) {
46167 log_packet_detailed(" got field 'success_rate'");
46168
46169#ifdef FREECIV_JSON_CONNECTION
46170 field_addr.name = "success_rate";
46171#endif /* FREECIV_JSON_CONNECTION */
46172
46173 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->success_rate, 10000)) {
46174 RECEIVE_PACKET_FIELD_ERROR(success_rate);
46175 }
46176 }
46177
46178 if (BV_ISSET(fields, 16)) {
46179 log_packet_detailed(" got field 'travel_time'");
46180
46181#ifdef FREECIV_JSON_CONNECTION
46182 field_addr.name = "travel_time";
46183#endif /* FREECIV_JSON_CONNECTION */
46184
46185 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->travel_time, 10000)) {
46186 RECEIVE_PACKET_FIELD_ERROR(travel_time);
46187 }
46188 }
46189
46190 if (nullptr == old) {
46191 old = fc_malloc(sizeof(*old));
46192 init_packet_spaceship_info(old);
46193 *old = *real_packet;
46194 genhash_insert(*hash, old, old);
46195 } else {
46196 *old = *real_packet;
46197 }
46198
46199#else /* FREECIV_DELTA_PROTOCOL */
46200#ifdef FREECIV_JSON_CONNECTION
46201 field_addr.name = "sship_state";
46202#endif /* FREECIV_JSON_CONNECTION */
46203
46204 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->sship_state)) {
46205 RECEIVE_PACKET_FIELD_ERROR(sship_state);
46206 }
46207
46208#ifdef FREECIV_JSON_CONNECTION
46209 field_addr.name = "structurals";
46210#endif /* FREECIV_JSON_CONNECTION */
46211
46212 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->structurals)) {
46213 RECEIVE_PACKET_FIELD_ERROR(structurals);
46214 }
46215
46216#ifdef FREECIV_JSON_CONNECTION
46217 field_addr.name = "components";
46218#endif /* FREECIV_JSON_CONNECTION */
46219
46220 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->components)) {
46221 RECEIVE_PACKET_FIELD_ERROR(components);
46222 }
46223
46224#ifdef FREECIV_JSON_CONNECTION
46225 field_addr.name = "modules";
46226#endif /* FREECIV_JSON_CONNECTION */
46227
46228 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->modules)) {
46229 RECEIVE_PACKET_FIELD_ERROR(modules);
46230 }
46231
46232#ifdef FREECIV_JSON_CONNECTION
46233 field_addr.name = "fuel";
46234#endif /* FREECIV_JSON_CONNECTION */
46235
46236 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
46237 RECEIVE_PACKET_FIELD_ERROR(fuel);
46238 }
46239
46240#ifdef FREECIV_JSON_CONNECTION
46241 field_addr.name = "propulsion";
46242#endif /* FREECIV_JSON_CONNECTION */
46243
46244 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->propulsion)) {
46245 RECEIVE_PACKET_FIELD_ERROR(propulsion);
46246 }
46247
46248#ifdef FREECIV_JSON_CONNECTION
46249 field_addr.name = "habitation";
46250#endif /* FREECIV_JSON_CONNECTION */
46251
46252 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->habitation)) {
46253 RECEIVE_PACKET_FIELD_ERROR(habitation);
46254 }
46255
46256#ifdef FREECIV_JSON_CONNECTION
46257 field_addr.name = "life_support";
46258#endif /* FREECIV_JSON_CONNECTION */
46259
46260 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->life_support)) {
46261 RECEIVE_PACKET_FIELD_ERROR(life_support);
46262 }
46263
46264#ifdef FREECIV_JSON_CONNECTION
46265 field_addr.name = "solar_panels";
46266#endif /* FREECIV_JSON_CONNECTION */
46267
46268 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->solar_panels)) {
46269 RECEIVE_PACKET_FIELD_ERROR(solar_panels);
46270 }
46271
46272#ifdef FREECIV_JSON_CONNECTION
46273 field_addr.name = "launch_year";
46274#endif /* FREECIV_JSON_CONNECTION */
46275
46276 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->launch_year)) {
46277 RECEIVE_PACKET_FIELD_ERROR(launch_year);
46278 }
46279
46280#ifdef FREECIV_JSON_CONNECTION
46281 field_addr.name = "population";
46282#endif /* FREECIV_JSON_CONNECTION */
46283
46284 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->population)) {
46285 RECEIVE_PACKET_FIELD_ERROR(population);
46286 }
46287
46288#ifdef FREECIV_JSON_CONNECTION
46289 field_addr.name = "mass";
46290#endif /* FREECIV_JSON_CONNECTION */
46291
46292 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->mass)) {
46293 RECEIVE_PACKET_FIELD_ERROR(mass);
46294 }
46295
46296#ifdef FREECIV_JSON_CONNECTION
46297 field_addr.name = "structure";
46298#endif /* FREECIV_JSON_CONNECTION */
46299
46300 if (!DIO_BV_GET(&din, &field_addr, real_packet->structure)) {
46301 RECEIVE_PACKET_FIELD_ERROR(structure);
46302 }
46303
46304#ifdef FREECIV_JSON_CONNECTION
46305 field_addr.name = "support_rate";
46306#endif /* FREECIV_JSON_CONNECTION */
46307
46308 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->support_rate, 10000)) {
46309 RECEIVE_PACKET_FIELD_ERROR(support_rate);
46310 }
46311
46312#ifdef FREECIV_JSON_CONNECTION
46313 field_addr.name = "energy_rate";
46314#endif /* FREECIV_JSON_CONNECTION */
46315
46316 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->energy_rate, 10000)) {
46317 RECEIVE_PACKET_FIELD_ERROR(energy_rate);
46318 }
46319
46320#ifdef FREECIV_JSON_CONNECTION
46321 field_addr.name = "success_rate";
46322#endif /* FREECIV_JSON_CONNECTION */
46323
46324 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->success_rate, 10000)) {
46325 RECEIVE_PACKET_FIELD_ERROR(success_rate);
46326 }
46327
46328#ifdef FREECIV_JSON_CONNECTION
46329 field_addr.name = "travel_time";
46330#endif /* FREECIV_JSON_CONNECTION */
46331
46332 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->travel_time, 10000)) {
46333 RECEIVE_PACKET_FIELD_ERROR(travel_time);
46334 }
46335#endif /* FREECIV_DELTA_PROTOCOL */
46336
46337 RECEIVE_PACKET_END(real_packet);
46338#undef FREE_PACKET_STRUCT
46339}
46340
46341 static int send_packet_spaceship_info_100(struct connection *pc, const struct packet_spaceship_info *packet)
46342{
46343 const struct packet_spaceship_info *real_packet = packet;
46344 int e;
46345 SEND_PACKET_START(PACKET_SPACESHIP_INFO);
46346
46347 log_packet_detailed("packet_spaceship_info_100: sending info about (%d)",
46348 real_packet->player_num);
46349
46350#ifdef FREECIV_DELTA_PROTOCOL
46351 packet_spaceship_info_100_fields fields;
46352 struct packet_spaceship_info *old;
46353 bool differ;
46354 int different = 0;
46355 struct genhash **hash = pc->phs.sent + PACKET_SPACESHIP_INFO;
46356
46357 if (nullptr == *hash) {
46358 *hash = genhash_new_full(hash_packet_spaceship_info_100, cmp_packet_spaceship_info_100,
46359 nullptr, nullptr, nullptr, destroy_packet_spaceship_info);
46360 }
46361 BV_CLR_ALL(fields);
46362
46363 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
46364 old = fc_malloc(sizeof(*old));
46365 /* temporary bitcopy just to insert correctly */
46366 *old = *real_packet;
46367 genhash_insert(*hash, old, old);
46368 init_packet_spaceship_info(old);
46369 different = 1; /* Force to send. */
46370 }
46371
46372 differ = (old->sship_state != real_packet->sship_state);
46373 if (differ) {
46374 different++;
46375 BV_SET(fields, 0);
46376 }
46377
46378 differ = (old->structurals != real_packet->structurals);
46379 if (differ) {
46380 different++;
46381 BV_SET(fields, 1);
46382 }
46383
46384 differ = (old->components != real_packet->components);
46385 if (differ) {
46386 different++;
46387 BV_SET(fields, 2);
46388 }
46389
46390 differ = (old->modules != real_packet->modules);
46391 if (differ) {
46392 different++;
46393 BV_SET(fields, 3);
46394 }
46395
46396 differ = (old->fuel != real_packet->fuel);
46397 if (differ) {
46398 different++;
46399 BV_SET(fields, 4);
46400 }
46401
46402 differ = (old->propulsion != real_packet->propulsion);
46403 if (differ) {
46404 different++;
46405 BV_SET(fields, 5);
46406 }
46407
46408 differ = (old->habitation != real_packet->habitation);
46409 if (differ) {
46410 different++;
46411 BV_SET(fields, 6);
46412 }
46413
46414 differ = (old->life_support != real_packet->life_support);
46415 if (differ) {
46416 different++;
46417 BV_SET(fields, 7);
46418 }
46419
46420 differ = (old->solar_panels != real_packet->solar_panels);
46421 if (differ) {
46422 different++;
46423 BV_SET(fields, 8);
46424 }
46425
46426 differ = (old->launch_year != real_packet->launch_year);
46427 if (differ) {
46428 different++;
46429 BV_SET(fields, 9);
46430 }
46431
46432 differ = (old->population != real_packet->population);
46433 if (differ) {
46434 different++;
46435 BV_SET(fields, 10);
46436 }
46437
46438 differ = (old->mass != real_packet->mass);
46439 if (differ) {
46440 different++;
46441 BV_SET(fields, 11);
46442 }
46443
46444 differ = !BV_ARE_EQUAL(old->structure, real_packet->structure);
46445 if (differ) {
46446 different++;
46447 BV_SET(fields, 12);
46448 }
46449
46450 differ = ((int) (old->support_rate * 10000) != (int) (real_packet->support_rate * 10000));
46451 if (differ) {
46452 different++;
46453 BV_SET(fields, 13);
46454 }
46455
46456 differ = ((int) (old->energy_rate * 10000) != (int) (real_packet->energy_rate * 10000));
46457 if (differ) {
46458 different++;
46459 BV_SET(fields, 14);
46460 }
46461
46462 differ = ((int) (old->success_rate * 10000) != (int) (real_packet->success_rate * 10000));
46463 if (differ) {
46464 different++;
46465 BV_SET(fields, 15);
46466 }
46467
46468 differ = ((int) (old->travel_time * 10000) != (int) (real_packet->travel_time * 10000));
46469 if (differ) {
46470 different++;
46471 BV_SET(fields, 16);
46472 }
46473
46474 if (different == 0) {
46475 log_packet_detailed(" no change -> discard");
46476 SEND_PACKET_DISCARD();
46477 }
46478#endif /* FREECIV_DELTA_PROTOCOL */
46479
46480#ifdef FREECIV_JSON_CONNECTION
46481 struct plocation field_addr;
46482 {
46483 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
46484 field_addr = *field_addr_tmp;
46485 FC_FREE(field_addr_tmp);
46486 }
46487#endif /* FREECIV_JSON_CONNECTION */
46488
46489#ifdef FREECIV_JSON_CONNECTION
46490 field_addr.name = "player_num";
46491#endif /* FREECIV_JSON_CONNECTION */
46492 e = 0;
46493
46494 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player_num);
46495
46496 if (e) {
46497 log_packet_detailed("'player_num' field error detected");
46498 }
46499
46500#ifdef FREECIV_DELTA_PROTOCOL
46501#ifdef FREECIV_JSON_CONNECTION
46502 field_addr.name = "fields";
46503#endif /* FREECIV_JSON_CONNECTION */
46504 e = 0;
46505 e |= DIO_BV_PUT(&dout, &field_addr, fields);
46506 if (e) {
46507 log_packet_detailed("fields bitvector error detected");
46508 }
46509
46510 if (BV_ISSET(fields, 0)) {
46511 log_packet_detailed(" field 'sship_state' has changed");
46512
46513#ifdef FREECIV_JSON_CONNECTION
46514 field_addr.name = "sship_state";
46515#endif /* FREECIV_JSON_CONNECTION */
46516 e = 0;
46517
46518 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sship_state);
46519
46520 if (e) {
46521 log_packet_detailed("'sship_state' field error detected");
46522 }
46523 }
46524
46525 if (BV_ISSET(fields, 1)) {
46526 log_packet_detailed(" field 'structurals' has changed");
46527
46528#ifdef FREECIV_JSON_CONNECTION
46529 field_addr.name = "structurals";
46530#endif /* FREECIV_JSON_CONNECTION */
46531 e = 0;
46532
46533 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->structurals);
46534
46535 if (e) {
46536 log_packet_detailed("'structurals' field error detected");
46537 }
46538 }
46539
46540 if (BV_ISSET(fields, 2)) {
46541 log_packet_detailed(" field 'components' has changed");
46542
46543#ifdef FREECIV_JSON_CONNECTION
46544 field_addr.name = "components";
46545#endif /* FREECIV_JSON_CONNECTION */
46546 e = 0;
46547
46548 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->components);
46549
46550 if (e) {
46551 log_packet_detailed("'components' field error detected");
46552 }
46553 }
46554
46555 if (BV_ISSET(fields, 3)) {
46556 log_packet_detailed(" field 'modules' has changed");
46557
46558#ifdef FREECIV_JSON_CONNECTION
46559 field_addr.name = "modules";
46560#endif /* FREECIV_JSON_CONNECTION */
46561 e = 0;
46562
46563 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->modules);
46564
46565 if (e) {
46566 log_packet_detailed("'modules' field error detected");
46567 }
46568 }
46569
46570 if (BV_ISSET(fields, 4)) {
46571 log_packet_detailed(" field 'fuel' has changed");
46572
46573#ifdef FREECIV_JSON_CONNECTION
46574 field_addr.name = "fuel";
46575#endif /* FREECIV_JSON_CONNECTION */
46576 e = 0;
46577
46578 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
46579
46580 if (e) {
46581 log_packet_detailed("'fuel' field error detected");
46582 }
46583 }
46584
46585 if (BV_ISSET(fields, 5)) {
46586 log_packet_detailed(" field 'propulsion' has changed");
46587
46588#ifdef FREECIV_JSON_CONNECTION
46589 field_addr.name = "propulsion";
46590#endif /* FREECIV_JSON_CONNECTION */
46591 e = 0;
46592
46593 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->propulsion);
46594
46595 if (e) {
46596 log_packet_detailed("'propulsion' field error detected");
46597 }
46598 }
46599
46600 if (BV_ISSET(fields, 6)) {
46601 log_packet_detailed(" field 'habitation' has changed");
46602
46603#ifdef FREECIV_JSON_CONNECTION
46604 field_addr.name = "habitation";
46605#endif /* FREECIV_JSON_CONNECTION */
46606 e = 0;
46607
46608 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->habitation);
46609
46610 if (e) {
46611 log_packet_detailed("'habitation' field error detected");
46612 }
46613 }
46614
46615 if (BV_ISSET(fields, 7)) {
46616 log_packet_detailed(" field 'life_support' has changed");
46617
46618#ifdef FREECIV_JSON_CONNECTION
46619 field_addr.name = "life_support";
46620#endif /* FREECIV_JSON_CONNECTION */
46621 e = 0;
46622
46623 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->life_support);
46624
46625 if (e) {
46626 log_packet_detailed("'life_support' field error detected");
46627 }
46628 }
46629
46630 if (BV_ISSET(fields, 8)) {
46631 log_packet_detailed(" field 'solar_panels' has changed");
46632
46633#ifdef FREECIV_JSON_CONNECTION
46634 field_addr.name = "solar_panels";
46635#endif /* FREECIV_JSON_CONNECTION */
46636 e = 0;
46637
46638 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->solar_panels);
46639
46640 if (e) {
46641 log_packet_detailed("'solar_panels' field error detected");
46642 }
46643 }
46644
46645 if (BV_ISSET(fields, 9)) {
46646 log_packet_detailed(" field 'launch_year' has changed");
46647
46648#ifdef FREECIV_JSON_CONNECTION
46649 field_addr.name = "launch_year";
46650#endif /* FREECIV_JSON_CONNECTION */
46651 e = 0;
46652
46653 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->launch_year);
46654
46655 if (e) {
46656 log_packet_detailed("'launch_year' field error detected");
46657 }
46658 }
46659
46660 if (BV_ISSET(fields, 10)) {
46661 log_packet_detailed(" field 'population' has changed");
46662
46663#ifdef FREECIV_JSON_CONNECTION
46664 field_addr.name = "population";
46665#endif /* FREECIV_JSON_CONNECTION */
46666 e = 0;
46667
46668 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->population);
46669
46670 if (e) {
46671 log_packet_detailed("'population' field error detected");
46672 }
46673 }
46674
46675 if (BV_ISSET(fields, 11)) {
46676 log_packet_detailed(" field 'mass' has changed");
46677
46678#ifdef FREECIV_JSON_CONNECTION
46679 field_addr.name = "mass";
46680#endif /* FREECIV_JSON_CONNECTION */
46681 e = 0;
46682
46683 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->mass);
46684
46685 if (e) {
46686 log_packet_detailed("'mass' field error detected");
46687 }
46688 }
46689
46690 if (BV_ISSET(fields, 12)) {
46691 log_packet_detailed(" field 'structure' has changed");
46692
46693#ifdef FREECIV_JSON_CONNECTION
46694 field_addr.name = "structure";
46695#endif /* FREECIV_JSON_CONNECTION */
46696 e = 0;
46697
46698 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->structure);
46699
46700 if (e) {
46701 log_packet_detailed("'structure' field error detected");
46702 }
46703 }
46704
46705 if (BV_ISSET(fields, 13)) {
46706 log_packet_detailed(" field 'support_rate' has changed");
46707
46708#ifdef FREECIV_JSON_CONNECTION
46709 field_addr.name = "support_rate";
46710#endif /* FREECIV_JSON_CONNECTION */
46711 e = 0;
46712
46713 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->support_rate, 10000);
46714
46715 if (e) {
46716 log_packet_detailed("'support_rate' field error detected");
46717 }
46718 }
46719
46720 if (BV_ISSET(fields, 14)) {
46721 log_packet_detailed(" field 'energy_rate' has changed");
46722
46723#ifdef FREECIV_JSON_CONNECTION
46724 field_addr.name = "energy_rate";
46725#endif /* FREECIV_JSON_CONNECTION */
46726 e = 0;
46727
46728 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->energy_rate, 10000);
46729
46730 if (e) {
46731 log_packet_detailed("'energy_rate' field error detected");
46732 }
46733 }
46734
46735 if (BV_ISSET(fields, 15)) {
46736 log_packet_detailed(" field 'success_rate' has changed");
46737
46738#ifdef FREECIV_JSON_CONNECTION
46739 field_addr.name = "success_rate";
46740#endif /* FREECIV_JSON_CONNECTION */
46741 e = 0;
46742
46743 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->success_rate, 10000);
46744
46745 if (e) {
46746 log_packet_detailed("'success_rate' field error detected");
46747 }
46748 }
46749
46750 if (BV_ISSET(fields, 16)) {
46751 log_packet_detailed(" field 'travel_time' has changed");
46752
46753#ifdef FREECIV_JSON_CONNECTION
46754 field_addr.name = "travel_time";
46755#endif /* FREECIV_JSON_CONNECTION */
46756 e = 0;
46757
46758 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->travel_time, 10000);
46759
46760 if (e) {
46761 log_packet_detailed("'travel_time' field error detected");
46762 }
46763 }
46764
46765 *old = *real_packet;
46766
46767#else /* FREECIV_DELTA_PROTOCOL */
46768#ifdef FREECIV_JSON_CONNECTION
46769 field_addr.name = "sship_state";
46770#endif /* FREECIV_JSON_CONNECTION */
46771 e = 0;
46772
46773 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sship_state);
46774
46775 if (e) {
46776 log_packet_detailed("'sship_state' field error detected");
46777 }
46778
46779#ifdef FREECIV_JSON_CONNECTION
46780 field_addr.name = "structurals";
46781#endif /* FREECIV_JSON_CONNECTION */
46782 e = 0;
46783
46784 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->structurals);
46785
46786 if (e) {
46787 log_packet_detailed("'structurals' field error detected");
46788 }
46789
46790#ifdef FREECIV_JSON_CONNECTION
46791 field_addr.name = "components";
46792#endif /* FREECIV_JSON_CONNECTION */
46793 e = 0;
46794
46795 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->components);
46796
46797 if (e) {
46798 log_packet_detailed("'components' field error detected");
46799 }
46800
46801#ifdef FREECIV_JSON_CONNECTION
46802 field_addr.name = "modules";
46803#endif /* FREECIV_JSON_CONNECTION */
46804 e = 0;
46805
46806 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->modules);
46807
46808 if (e) {
46809 log_packet_detailed("'modules' field error detected");
46810 }
46811
46812#ifdef FREECIV_JSON_CONNECTION
46813 field_addr.name = "fuel";
46814#endif /* FREECIV_JSON_CONNECTION */
46815 e = 0;
46816
46817 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
46818
46819 if (e) {
46820 log_packet_detailed("'fuel' field error detected");
46821 }
46822
46823#ifdef FREECIV_JSON_CONNECTION
46824 field_addr.name = "propulsion";
46825#endif /* FREECIV_JSON_CONNECTION */
46826 e = 0;
46827
46828 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->propulsion);
46829
46830 if (e) {
46831 log_packet_detailed("'propulsion' field error detected");
46832 }
46833
46834#ifdef FREECIV_JSON_CONNECTION
46835 field_addr.name = "habitation";
46836#endif /* FREECIV_JSON_CONNECTION */
46837 e = 0;
46838
46839 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->habitation);
46840
46841 if (e) {
46842 log_packet_detailed("'habitation' field error detected");
46843 }
46844
46845#ifdef FREECIV_JSON_CONNECTION
46846 field_addr.name = "life_support";
46847#endif /* FREECIV_JSON_CONNECTION */
46848 e = 0;
46849
46850 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->life_support);
46851
46852 if (e) {
46853 log_packet_detailed("'life_support' field error detected");
46854 }
46855
46856#ifdef FREECIV_JSON_CONNECTION
46857 field_addr.name = "solar_panels";
46858#endif /* FREECIV_JSON_CONNECTION */
46859 e = 0;
46860
46861 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->solar_panels);
46862
46863 if (e) {
46864 log_packet_detailed("'solar_panels' field error detected");
46865 }
46866
46867#ifdef FREECIV_JSON_CONNECTION
46868 field_addr.name = "launch_year";
46869#endif /* FREECIV_JSON_CONNECTION */
46870 e = 0;
46871
46872 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->launch_year);
46873
46874 if (e) {
46875 log_packet_detailed("'launch_year' field error detected");
46876 }
46877
46878#ifdef FREECIV_JSON_CONNECTION
46879 field_addr.name = "population";
46880#endif /* FREECIV_JSON_CONNECTION */
46881 e = 0;
46882
46883 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->population);
46884
46885 if (e) {
46886 log_packet_detailed("'population' field error detected");
46887 }
46888
46889#ifdef FREECIV_JSON_CONNECTION
46890 field_addr.name = "mass";
46891#endif /* FREECIV_JSON_CONNECTION */
46892 e = 0;
46893
46894 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->mass);
46895
46896 if (e) {
46897 log_packet_detailed("'mass' field error detected");
46898 }
46899
46900#ifdef FREECIV_JSON_CONNECTION
46901 field_addr.name = "structure";
46902#endif /* FREECIV_JSON_CONNECTION */
46903 e = 0;
46904
46905 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->structure);
46906
46907 if (e) {
46908 log_packet_detailed("'structure' field error detected");
46909 }
46910
46911#ifdef FREECIV_JSON_CONNECTION
46912 field_addr.name = "support_rate";
46913#endif /* FREECIV_JSON_CONNECTION */
46914 e = 0;
46915
46916 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->support_rate, 10000);
46917
46918 if (e) {
46919 log_packet_detailed("'support_rate' field error detected");
46920 }
46921
46922#ifdef FREECIV_JSON_CONNECTION
46923 field_addr.name = "energy_rate";
46924#endif /* FREECIV_JSON_CONNECTION */
46925 e = 0;
46926
46927 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->energy_rate, 10000);
46928
46929 if (e) {
46930 log_packet_detailed("'energy_rate' field error detected");
46931 }
46932
46933#ifdef FREECIV_JSON_CONNECTION
46934 field_addr.name = "success_rate";
46935#endif /* FREECIV_JSON_CONNECTION */
46936 e = 0;
46937
46938 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->success_rate, 10000);
46939
46940 if (e) {
46941 log_packet_detailed("'success_rate' field error detected");
46942 }
46943
46944#ifdef FREECIV_JSON_CONNECTION
46945 field_addr.name = "travel_time";
46946#endif /* FREECIV_JSON_CONNECTION */
46947 e = 0;
46948
46949 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->travel_time, 10000);
46950
46951 if (e) {
46952 log_packet_detailed("'travel_time' field error detected");
46953 }
46954#endif /* FREECIV_DELTA_PROTOCOL */
46955
46956 SEND_PACKET_END(PACKET_SPACESHIP_INFO);
46957}
46958
46959 int send_packet_spaceship_info(struct connection *pc, const struct packet_spaceship_info *packet)
46960{
46961 if (!pc->used) {
46962 log_error("WARNING: trying to send data to the closed connection %s",
46963 conn_description(pc));
46964 return -1;
46965 }
46966 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SPACESHIP_INFO].packet != nullptr, -1,
46967 "Handler for PACKET_SPACESHIP_INFO not installed");
46968 return pc->phs.handlers->send[PACKET_SPACESHIP_INFO].packet(pc, packet);
46969}
46970
46971 void lsend_packet_spaceship_info(struct conn_list *dest, const struct packet_spaceship_info *packet)
46972{
46973 conn_list_iterate(dest, pconn) {
46974 send_packet_spaceship_info(pconn, packet);
46975 } conn_list_iterate_end;
46976}
46977
46978 static inline void init_packet_ruleset_unit(struct packet_ruleset_unit *packet)
46979{
46980 memset(packet, 0, sizeof(*packet));
46981
46982 requirement_vector_init(&packet->build_reqs);
46983 packet->helptext = strvec_new();
46984}
46985
46986 static inline void free_packet_ruleset_unit(struct packet_ruleset_unit *packet)
46987{
46988 if (packet->helptext) {
46989 strvec_destroy(packet->helptext);
46990 packet->helptext = nullptr;
46991 }
46992 requirement_vector_free(&packet->build_reqs);
46993}
46994
46995 static inline void destroy_packet_ruleset_unit(void *packet)
46996{
46997 free_packet_ruleset_unit((struct packet_ruleset_unit *) packet);
46998 free(packet);
46999}
47000
47001#ifdef FREECIV_DELTA_PROTOCOL
47002#define hash_packet_ruleset_unit_100 hash_const
47003#define cmp_packet_ruleset_unit_100 cmp_const
47004 BV_DEFINE(packet_ruleset_unit_100_fields, 47);
47005#endif /* FREECIV_DELTA_PROTOCOL */
47006
47007 static struct packet_ruleset_unit *receive_packet_ruleset_unit_100(struct connection *pc)
47008{
47009#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_unit(_packet)
47010 RECEIVE_PACKET_START(packet_ruleset_unit, real_packet);
47011
47012#ifdef FREECIV_JSON_CONNECTION
47013 struct plocation field_addr;
47014 {
47015 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
47016 field_addr = *field_addr_tmp;
47017 FC_FREE(field_addr_tmp);
47018 }
47019#endif /* FREECIV_JSON_CONNECTION */
47020
47021 log_packet_detailed("packet_ruleset_unit_100: got info about ()");
47022
47023#ifdef FREECIV_DELTA_PROTOCOL
47024 packet_ruleset_unit_100_fields fields;
47025 struct packet_ruleset_unit *old;
47026 struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT;
47027
47028 if (nullptr == *hash) {
47029 *hash = genhash_new_full(hash_packet_ruleset_unit_100, cmp_packet_ruleset_unit_100,
47030 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit);
47031 }
47032
47033 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
47034 real_packet->id = old->id;
47035 sz_strlcpy(real_packet->name, old->name);
47036 sz_strlcpy(real_packet->rule_name, old->rule_name);
47037 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
47038 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
47039 sz_strlcpy(real_packet->graphic_alt2, old->graphic_alt2);
47040 sz_strlcpy(real_packet->sound_move, old->sound_move);
47041 sz_strlcpy(real_packet->sound_move_alt, old->sound_move_alt);
47042 sz_strlcpy(real_packet->sound_fight, old->sound_fight);
47043 sz_strlcpy(real_packet->sound_fight_alt, old->sound_fight_alt);
47044 real_packet->unit_class_id = old->unit_class_id;
47045 real_packet->build_cost = old->build_cost;
47046 real_packet->pop_cost = old->pop_cost;
47047 real_packet->attack_strength = old->attack_strength;
47048 real_packet->defense_strength = old->defense_strength;
47049 real_packet->move_rate = old->move_rate;
47050 requirement_vector_copy(&real_packet->build_reqs, &old->build_reqs);
47051 real_packet->vision_radius_sq = old->vision_radius_sq;
47052 real_packet->transport_capacity = old->transport_capacity;
47053 real_packet->hp = old->hp;
47054 real_packet->firepower = old->firepower;
47055 real_packet->obsoleted_by = old->obsoleted_by;
47056 real_packet->converted_to = old->converted_to;
47057 real_packet->convert_time = old->convert_time;
47058 real_packet->fuel = old->fuel;
47059 real_packet->happy_cost = old->happy_cost;
47060 {
47061 int i;
47062
47063 for (i = 0; i < O_LAST; i++) {
47064 real_packet->upkeep[i] = old->upkeep[i];
47065 }
47066 }
47067 real_packet->paratroopers_range = old->paratroopers_range;
47068 real_packet->veteran_levels = old->veteran_levels;
47069 {
47070 int i;
47071
47072 for (i = 0; i < old->veteran_levels; i++) {
47073 sz_strlcpy(real_packet->veteran_name[i], old->veteran_name[i]);
47074 }
47075 }
47076 {
47077 int i;
47078
47079 for (i = 0; i < old->veteran_levels; i++) {
47080 real_packet->power_fact[i] = old->power_fact[i];
47081 }
47082 }
47083 {
47084 int i;
47085
47086 for (i = 0; i < old->veteran_levels; i++) {
47087 real_packet->move_bonus[i] = old->move_bonus[i];
47088 }
47089 }
47090 {
47091 int i;
47092
47093 for (i = 0; i < old->veteran_levels; i++) {
47094 real_packet->base_raise_chance[i] = old->base_raise_chance[i];
47095 }
47096 }
47097 {
47098 int i;
47099
47100 for (i = 0; i < old->veteran_levels; i++) {
47101 real_packet->work_raise_chance[i] = old->work_raise_chance[i];
47102 }
47103 }
47104 real_packet->bombard_rate = old->bombard_rate;
47105 real_packet->city_size = old->city_size;
47106 real_packet->city_slots = old->city_slots;
47107 real_packet->tp_defense = old->tp_defense;
47108 real_packet->cargo = old->cargo;
47109 real_packet->targets = old->targets;
47110 real_packet->embarks = old->embarks;
47111 real_packet->disembarks = old->disembarks;
47112 real_packet->vlayer = old->vlayer;
47113 if (old->helptext) {
47114 strvec_copy(real_packet->helptext, old->helptext);
47115 } else {
47116 strvec_clear(real_packet->helptext);
47117 }
47118 real_packet->flags = old->flags;
47119 real_packet->roles = old->roles;
47120 real_packet->worker = old->worker;
47121 } else {
47122 /* packet is already initialized empty */
47123 log_packet_detailed(" no old info");
47124 }
47125
47126#ifdef FREECIV_JSON_CONNECTION
47127 field_addr.name = "fields";
47128#endif /* FREECIV_JSON_CONNECTION */
47129 DIO_BV_GET(&din, &field_addr, fields);
47130
47131 if (BV_ISSET(fields, 0)) {
47132 log_packet_detailed(" got field 'id'");
47133
47134#ifdef FREECIV_JSON_CONNECTION
47135 field_addr.name = "id";
47136#endif /* FREECIV_JSON_CONNECTION */
47137
47138 {
47139 int readin;
47140
47141 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
47142 RECEIVE_PACKET_FIELD_ERROR(id);
47143 }
47144 real_packet->id = readin;
47145 }
47146 }
47147
47148 if (BV_ISSET(fields, 1)) {
47149 log_packet_detailed(" got field 'name'");
47150
47151#ifdef FREECIV_JSON_CONNECTION
47152 field_addr.name = "name";
47153#endif /* FREECIV_JSON_CONNECTION */
47154
47155 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
47156 RECEIVE_PACKET_FIELD_ERROR(name);
47157 }
47158 }
47159
47160 if (BV_ISSET(fields, 2)) {
47161 log_packet_detailed(" got field 'rule_name'");
47162
47163#ifdef FREECIV_JSON_CONNECTION
47164 field_addr.name = "rule_name";
47165#endif /* FREECIV_JSON_CONNECTION */
47166
47167 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
47168 RECEIVE_PACKET_FIELD_ERROR(rule_name);
47169 }
47170 }
47171
47172 if (BV_ISSET(fields, 3)) {
47173 log_packet_detailed(" got field 'graphic_str'");
47174
47175#ifdef FREECIV_JSON_CONNECTION
47176 field_addr.name = "graphic_str";
47177#endif /* FREECIV_JSON_CONNECTION */
47178
47179 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
47180 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
47181 }
47182 }
47183
47184 if (BV_ISSET(fields, 4)) {
47185 log_packet_detailed(" got field 'graphic_alt'");
47186
47187#ifdef FREECIV_JSON_CONNECTION
47188 field_addr.name = "graphic_alt";
47189#endif /* FREECIV_JSON_CONNECTION */
47190
47191 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
47192 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
47193 }
47194 }
47195
47196 if (BV_ISSET(fields, 5)) {
47197 log_packet_detailed(" got field 'graphic_alt2'");
47198
47199#ifdef FREECIV_JSON_CONNECTION
47200 field_addr.name = "graphic_alt2";
47201#endif /* FREECIV_JSON_CONNECTION */
47202
47203 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt2, sizeof(real_packet->graphic_alt2))) {
47204 RECEIVE_PACKET_FIELD_ERROR(graphic_alt2);
47205 }
47206 }
47207
47208 if (BV_ISSET(fields, 6)) {
47209 log_packet_detailed(" got field 'sound_move'");
47210
47211#ifdef FREECIV_JSON_CONNECTION
47212 field_addr.name = "sound_move";
47213#endif /* FREECIV_JSON_CONNECTION */
47214
47215 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_move, sizeof(real_packet->sound_move))) {
47216 RECEIVE_PACKET_FIELD_ERROR(sound_move);
47217 }
47218 }
47219
47220 if (BV_ISSET(fields, 7)) {
47221 log_packet_detailed(" got field 'sound_move_alt'");
47222
47223#ifdef FREECIV_JSON_CONNECTION
47224 field_addr.name = "sound_move_alt";
47225#endif /* FREECIV_JSON_CONNECTION */
47226
47227 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_move_alt, sizeof(real_packet->sound_move_alt))) {
47228 RECEIVE_PACKET_FIELD_ERROR(sound_move_alt);
47229 }
47230 }
47231
47232 if (BV_ISSET(fields, 8)) {
47233 log_packet_detailed(" got field 'sound_fight'");
47234
47235#ifdef FREECIV_JSON_CONNECTION
47236 field_addr.name = "sound_fight";
47237#endif /* FREECIV_JSON_CONNECTION */
47238
47239 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_fight, sizeof(real_packet->sound_fight))) {
47240 RECEIVE_PACKET_FIELD_ERROR(sound_fight);
47241 }
47242 }
47243
47244 if (BV_ISSET(fields, 9)) {
47245 log_packet_detailed(" got field 'sound_fight_alt'");
47246
47247#ifdef FREECIV_JSON_CONNECTION
47248 field_addr.name = "sound_fight_alt";
47249#endif /* FREECIV_JSON_CONNECTION */
47250
47251 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_fight_alt, sizeof(real_packet->sound_fight_alt))) {
47252 RECEIVE_PACKET_FIELD_ERROR(sound_fight_alt);
47253 }
47254 }
47255
47256 if (BV_ISSET(fields, 10)) {
47257 log_packet_detailed(" got field 'unit_class_id'");
47258
47259#ifdef FREECIV_JSON_CONNECTION
47260 field_addr.name = "unit_class_id";
47261#endif /* FREECIV_JSON_CONNECTION */
47262
47263 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->unit_class_id)) {
47264 RECEIVE_PACKET_FIELD_ERROR(unit_class_id);
47265 }
47266 }
47267
47268 if (BV_ISSET(fields, 11)) {
47269 log_packet_detailed(" got field 'build_cost'");
47270
47271#ifdef FREECIV_JSON_CONNECTION
47272 field_addr.name = "build_cost";
47273#endif /* FREECIV_JSON_CONNECTION */
47274
47275 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->build_cost)) {
47276 RECEIVE_PACKET_FIELD_ERROR(build_cost);
47277 }
47278 }
47279
47280 if (BV_ISSET(fields, 12)) {
47281 log_packet_detailed(" got field 'pop_cost'");
47282
47283#ifdef FREECIV_JSON_CONNECTION
47284 field_addr.name = "pop_cost";
47285#endif /* FREECIV_JSON_CONNECTION */
47286
47287 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->pop_cost)) {
47288 RECEIVE_PACKET_FIELD_ERROR(pop_cost);
47289 }
47290 }
47291
47292 if (BV_ISSET(fields, 13)) {
47293 log_packet_detailed(" got field 'attack_strength'");
47294
47295#ifdef FREECIV_JSON_CONNECTION
47296 field_addr.name = "attack_strength";
47297#endif /* FREECIV_JSON_CONNECTION */
47298
47299 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->attack_strength)) {
47300 RECEIVE_PACKET_FIELD_ERROR(attack_strength);
47301 }
47302 }
47303
47304 if (BV_ISSET(fields, 14)) {
47305 log_packet_detailed(" got field 'defense_strength'");
47306
47307#ifdef FREECIV_JSON_CONNECTION
47308 field_addr.name = "defense_strength";
47309#endif /* FREECIV_JSON_CONNECTION */
47310
47311 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->defense_strength)) {
47312 RECEIVE_PACKET_FIELD_ERROR(defense_strength);
47313 }
47314 }
47315
47316 if (BV_ISSET(fields, 15)) {
47317 log_packet_detailed(" got field 'move_rate'");
47318
47319#ifdef FREECIV_JSON_CONNECTION
47320 field_addr.name = "move_rate";
47321#endif /* FREECIV_JSON_CONNECTION */
47322
47323 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_rate)) {
47324 RECEIVE_PACKET_FIELD_ERROR(move_rate);
47325 }
47326 }
47327
47328 if (BV_ISSET(fields, 16)) {
47329 log_packet_detailed(" got field 'build_reqs'");
47330
47331#ifdef FREECIV_JSON_CONNECTION
47332 field_addr.name = "build_reqs";
47333#endif /* FREECIV_JSON_CONNECTION */
47334
47335 {
47336 int i;
47337
47338 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
47339 RECEIVE_PACKET_FIELD_ERROR(build_reqs);
47340 }
47341 requirement_vector_reserve(&real_packet->build_reqs, i);
47342
47343#ifdef FREECIV_JSON_CONNECTION
47344 /* Enter array. */
47345 field_addr.sub_location = plocation_elem_new(0);
47346#endif /* FREECIV_JSON_CONNECTION */
47347
47348 for (i = 0; i < requirement_vector_size(&real_packet->build_reqs); i++) {
47349#ifdef FREECIV_JSON_CONNECTION
47350 /* Next array element */
47351 field_addr.sub_location->number = i;
47352#endif /* FREECIV_JSON_CONNECTION */
47353
47354 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->build_reqs.p[i])) {
47355 RECEIVE_PACKET_FIELD_ERROR(build_reqs);
47356 }
47357 }
47358
47359#ifdef FREECIV_JSON_CONNECTION
47360 /* Exit array. */
47361 FC_FREE(field_addr.sub_location);
47362#endif /* FREECIV_JSON_CONNECTION */
47363 }
47364 }
47365
47366 if (BV_ISSET(fields, 17)) {
47367 log_packet_detailed(" got field 'vision_radius_sq'");
47368
47369#ifdef FREECIV_JSON_CONNECTION
47370 field_addr.name = "vision_radius_sq";
47371#endif /* FREECIV_JSON_CONNECTION */
47372
47373 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->vision_radius_sq)) {
47374 RECEIVE_PACKET_FIELD_ERROR(vision_radius_sq);
47375 }
47376 }
47377
47378 if (BV_ISSET(fields, 18)) {
47379 log_packet_detailed(" got field 'transport_capacity'");
47380
47381#ifdef FREECIV_JSON_CONNECTION
47382 field_addr.name = "transport_capacity";
47383#endif /* FREECIV_JSON_CONNECTION */
47384
47385 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->transport_capacity)) {
47386 RECEIVE_PACKET_FIELD_ERROR(transport_capacity);
47387 }
47388 }
47389
47390 if (BV_ISSET(fields, 19)) {
47391 log_packet_detailed(" got field 'hp'");
47392
47393#ifdef FREECIV_JSON_CONNECTION
47394 field_addr.name = "hp";
47395#endif /* FREECIV_JSON_CONNECTION */
47396
47397 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
47398 RECEIVE_PACKET_FIELD_ERROR(hp);
47399 }
47400 }
47401
47402 if (BV_ISSET(fields, 20)) {
47403 log_packet_detailed(" got field 'firepower'");
47404
47405#ifdef FREECIV_JSON_CONNECTION
47406 field_addr.name = "firepower";
47407#endif /* FREECIV_JSON_CONNECTION */
47408
47409 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->firepower)) {
47410 RECEIVE_PACKET_FIELD_ERROR(firepower);
47411 }
47412 }
47413
47414 if (BV_ISSET(fields, 21)) {
47415 log_packet_detailed(" got field 'obsoleted_by'");
47416
47417#ifdef FREECIV_JSON_CONNECTION
47418 field_addr.name = "obsoleted_by";
47419#endif /* FREECIV_JSON_CONNECTION */
47420
47421 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->obsoleted_by)) {
47422 RECEIVE_PACKET_FIELD_ERROR(obsoleted_by);
47423 }
47424 }
47425
47426 if (BV_ISSET(fields, 22)) {
47427 log_packet_detailed(" got field 'converted_to'");
47428
47429#ifdef FREECIV_JSON_CONNECTION
47430 field_addr.name = "converted_to";
47431#endif /* FREECIV_JSON_CONNECTION */
47432
47433 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->converted_to)) {
47434 RECEIVE_PACKET_FIELD_ERROR(converted_to);
47435 }
47436 }
47437
47438 if (BV_ISSET(fields, 23)) {
47439 log_packet_detailed(" got field 'convert_time'");
47440
47441#ifdef FREECIV_JSON_CONNECTION
47442 field_addr.name = "convert_time";
47443#endif /* FREECIV_JSON_CONNECTION */
47444
47445 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->convert_time)) {
47446 RECEIVE_PACKET_FIELD_ERROR(convert_time);
47447 }
47448 }
47449
47450 if (BV_ISSET(fields, 24)) {
47451 log_packet_detailed(" got field 'fuel'");
47452
47453#ifdef FREECIV_JSON_CONNECTION
47454 field_addr.name = "fuel";
47455#endif /* FREECIV_JSON_CONNECTION */
47456
47457 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
47458 RECEIVE_PACKET_FIELD_ERROR(fuel);
47459 }
47460 }
47461
47462 if (BV_ISSET(fields, 25)) {
47463 log_packet_detailed(" got field 'happy_cost'");
47464
47465#ifdef FREECIV_JSON_CONNECTION
47466 field_addr.name = "happy_cost";
47467#endif /* FREECIV_JSON_CONNECTION */
47468
47469 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->happy_cost)) {
47470 RECEIVE_PACKET_FIELD_ERROR(happy_cost);
47471 }
47472 }
47473
47474 if (BV_ISSET(fields, 26)) {
47475 log_packet_detailed(" got field 'upkeep'");
47476
47477#ifdef FREECIV_JSON_CONNECTION
47478 field_addr.name = "upkeep";
47479#endif /* FREECIV_JSON_CONNECTION */
47480
47481 {
47482 int i;
47483
47484
47485#ifdef FREECIV_JSON_CONNECTION
47486 /* Enter array. */
47487 field_addr.sub_location = plocation_elem_new(0);
47488#endif /* FREECIV_JSON_CONNECTION */
47489
47490 for (i = 0; i < O_LAST; i++) {
47491#ifdef FREECIV_JSON_CONNECTION
47492 /* Next array element */
47493 field_addr.sub_location->number = i;
47494#endif /* FREECIV_JSON_CONNECTION */
47495
47496 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->upkeep[i])) {
47497 RECEIVE_PACKET_FIELD_ERROR(upkeep);
47498 }
47499 }
47500
47501#ifdef FREECIV_JSON_CONNECTION
47502 /* Exit array. */
47503 FC_FREE(field_addr.sub_location);
47504#endif /* FREECIV_JSON_CONNECTION */
47505 }
47506 }
47507
47508 if (BV_ISSET(fields, 27)) {
47509 log_packet_detailed(" got field 'paratroopers_range'");
47510
47511#ifdef FREECIV_JSON_CONNECTION
47512 field_addr.name = "paratroopers_range";
47513#endif /* FREECIV_JSON_CONNECTION */
47514
47515 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->paratroopers_range)) {
47516 RECEIVE_PACKET_FIELD_ERROR(paratroopers_range);
47517 }
47518 }
47519
47520 if (BV_ISSET(fields, 28)) {
47521 log_packet_detailed(" got field 'veteran_levels'");
47522
47523#ifdef FREECIV_JSON_CONNECTION
47524 field_addr.name = "veteran_levels";
47525#endif /* FREECIV_JSON_CONNECTION */
47526
47527 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran_levels)) {
47528 RECEIVE_PACKET_FIELD_ERROR(veteran_levels);
47529 }
47530 }
47531
47532 if (BV_ISSET(fields, 29)) {
47533 log_packet_detailed(" got field 'veteran_name'");
47534
47535#ifdef FREECIV_JSON_CONNECTION
47536 field_addr.name = "veteran_name";
47537#endif /* FREECIV_JSON_CONNECTION */
47538
47539 {
47540 int i;
47541
47542 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
47543 RECEIVE_PACKET_FIELD_ERROR(veteran_name, ": array truncated");
47544 }
47545
47546#ifdef FREECIV_JSON_CONNECTION
47547 /* Enter array. */
47548 field_addr.sub_location = plocation_elem_new(0);
47549#endif /* FREECIV_JSON_CONNECTION */
47550
47551 for (i = 0; i < real_packet->veteran_levels; i++) {
47552#ifdef FREECIV_JSON_CONNECTION
47553 /* Next array element */
47554 field_addr.sub_location->number = i;
47555#endif /* FREECIV_JSON_CONNECTION */
47556
47557 if (!DIO_GET(string, &din, &field_addr, real_packet->veteran_name[i], sizeof(real_packet->veteran_name[i]))) {
47558 RECEIVE_PACKET_FIELD_ERROR(veteran_name);
47559 }
47560 }
47561
47562#ifdef FREECIV_JSON_CONNECTION
47563 /* Exit array. */
47564 FC_FREE(field_addr.sub_location);
47565#endif /* FREECIV_JSON_CONNECTION */
47566 }
47567 }
47568
47569 if (BV_ISSET(fields, 30)) {
47570 log_packet_detailed(" got field 'power_fact'");
47571
47572#ifdef FREECIV_JSON_CONNECTION
47573 field_addr.name = "power_fact";
47574#endif /* FREECIV_JSON_CONNECTION */
47575
47576 {
47577 int i;
47578
47579 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
47580 RECEIVE_PACKET_FIELD_ERROR(power_fact, ": array truncated");
47581 }
47582
47583#ifdef FREECIV_JSON_CONNECTION
47584 /* Enter array. */
47585 field_addr.sub_location = plocation_elem_new(0);
47586#endif /* FREECIV_JSON_CONNECTION */
47587
47588 for (i = 0; i < real_packet->veteran_levels; i++) {
47589#ifdef FREECIV_JSON_CONNECTION
47590 /* Next array element */
47591 field_addr.sub_location->number = i;
47592#endif /* FREECIV_JSON_CONNECTION */
47593
47594 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->power_fact[i])) {
47595 RECEIVE_PACKET_FIELD_ERROR(power_fact);
47596 }
47597 }
47598
47599#ifdef FREECIV_JSON_CONNECTION
47600 /* Exit array. */
47601 FC_FREE(field_addr.sub_location);
47602#endif /* FREECIV_JSON_CONNECTION */
47603 }
47604 }
47605
47606 if (BV_ISSET(fields, 31)) {
47607 log_packet_detailed(" got field 'move_bonus'");
47608
47609#ifdef FREECIV_JSON_CONNECTION
47610 field_addr.name = "move_bonus";
47611#endif /* FREECIV_JSON_CONNECTION */
47612
47613 {
47614 int i;
47615
47616 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
47617 RECEIVE_PACKET_FIELD_ERROR(move_bonus, ": array truncated");
47618 }
47619
47620#ifdef FREECIV_JSON_CONNECTION
47621 /* Enter array. */
47622 field_addr.sub_location = plocation_elem_new(0);
47623#endif /* FREECIV_JSON_CONNECTION */
47624
47625 for (i = 0; i < real_packet->veteran_levels; i++) {
47626#ifdef FREECIV_JSON_CONNECTION
47627 /* Next array element */
47628 field_addr.sub_location->number = i;
47629#endif /* FREECIV_JSON_CONNECTION */
47630
47631 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_bonus[i])) {
47632 RECEIVE_PACKET_FIELD_ERROR(move_bonus);
47633 }
47634 }
47635
47636#ifdef FREECIV_JSON_CONNECTION
47637 /* Exit array. */
47638 FC_FREE(field_addr.sub_location);
47639#endif /* FREECIV_JSON_CONNECTION */
47640 }
47641 }
47642
47643 if (BV_ISSET(fields, 32)) {
47644 log_packet_detailed(" got field 'base_raise_chance'");
47645
47646#ifdef FREECIV_JSON_CONNECTION
47647 field_addr.name = "base_raise_chance";
47648#endif /* FREECIV_JSON_CONNECTION */
47649
47650 {
47651 int i;
47652
47653 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
47654 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance, ": array truncated");
47655 }
47656
47657#ifdef FREECIV_JSON_CONNECTION
47658 /* Enter array. */
47659 field_addr.sub_location = plocation_elem_new(0);
47660#endif /* FREECIV_JSON_CONNECTION */
47661
47662 for (i = 0; i < real_packet->veteran_levels; i++) {
47663#ifdef FREECIV_JSON_CONNECTION
47664 /* Next array element */
47665 field_addr.sub_location->number = i;
47666#endif /* FREECIV_JSON_CONNECTION */
47667
47668 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->base_raise_chance[i])) {
47669 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance);
47670 }
47671 }
47672
47673#ifdef FREECIV_JSON_CONNECTION
47674 /* Exit array. */
47675 FC_FREE(field_addr.sub_location);
47676#endif /* FREECIV_JSON_CONNECTION */
47677 }
47678 }
47679
47680 if (BV_ISSET(fields, 33)) {
47681 log_packet_detailed(" got field 'work_raise_chance'");
47682
47683#ifdef FREECIV_JSON_CONNECTION
47684 field_addr.name = "work_raise_chance";
47685#endif /* FREECIV_JSON_CONNECTION */
47686
47687 {
47688 int i;
47689
47690 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
47691 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance, ": array truncated");
47692 }
47693
47694#ifdef FREECIV_JSON_CONNECTION
47695 /* Enter array. */
47696 field_addr.sub_location = plocation_elem_new(0);
47697#endif /* FREECIV_JSON_CONNECTION */
47698
47699 for (i = 0; i < real_packet->veteran_levels; i++) {
47700#ifdef FREECIV_JSON_CONNECTION
47701 /* Next array element */
47702 field_addr.sub_location->number = i;
47703#endif /* FREECIV_JSON_CONNECTION */
47704
47705 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->work_raise_chance[i])) {
47706 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance);
47707 }
47708 }
47709
47710#ifdef FREECIV_JSON_CONNECTION
47711 /* Exit array. */
47712 FC_FREE(field_addr.sub_location);
47713#endif /* FREECIV_JSON_CONNECTION */
47714 }
47715 }
47716
47717 if (BV_ISSET(fields, 34)) {
47718 log_packet_detailed(" got field 'bombard_rate'");
47719
47720#ifdef FREECIV_JSON_CONNECTION
47721 field_addr.name = "bombard_rate";
47722#endif /* FREECIV_JSON_CONNECTION */
47723
47724 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->bombard_rate)) {
47725 RECEIVE_PACKET_FIELD_ERROR(bombard_rate);
47726 }
47727 }
47728
47729 if (BV_ISSET(fields, 35)) {
47730 log_packet_detailed(" got field 'city_size'");
47731
47732#ifdef FREECIV_JSON_CONNECTION
47733 field_addr.name = "city_size";
47734#endif /* FREECIV_JSON_CONNECTION */
47735
47736 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->city_size)) {
47737 RECEIVE_PACKET_FIELD_ERROR(city_size);
47738 }
47739 }
47740
47741 if (BV_ISSET(fields, 36)) {
47742 log_packet_detailed(" got field 'city_slots'");
47743
47744#ifdef FREECIV_JSON_CONNECTION
47745 field_addr.name = "city_slots";
47746#endif /* FREECIV_JSON_CONNECTION */
47747
47748 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->city_slots)) {
47749 RECEIVE_PACKET_FIELD_ERROR(city_slots);
47750 }
47751 }
47752
47753 if (BV_ISSET(fields, 37)) {
47754 log_packet_detailed(" got field 'tp_defense'");
47755
47756#ifdef FREECIV_JSON_CONNECTION
47757 field_addr.name = "tp_defense";
47758#endif /* FREECIV_JSON_CONNECTION */
47759
47760 {
47761 int readin;
47762
47763 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
47764 RECEIVE_PACKET_FIELD_ERROR(tp_defense);
47765 }
47766 real_packet->tp_defense = readin;
47767 }
47768 }
47769
47770 if (BV_ISSET(fields, 38)) {
47771 log_packet_detailed(" got field 'cargo'");
47772
47773#ifdef FREECIV_JSON_CONNECTION
47774 field_addr.name = "cargo";
47775#endif /* FREECIV_JSON_CONNECTION */
47776
47777 if (!DIO_BV_GET(&din, &field_addr, real_packet->cargo)) {
47778 RECEIVE_PACKET_FIELD_ERROR(cargo);
47779 }
47780 }
47781
47782 if (BV_ISSET(fields, 39)) {
47783 log_packet_detailed(" got field 'targets'");
47784
47785#ifdef FREECIV_JSON_CONNECTION
47786 field_addr.name = "targets";
47787#endif /* FREECIV_JSON_CONNECTION */
47788
47789 if (!DIO_BV_GET(&din, &field_addr, real_packet->targets)) {
47790 RECEIVE_PACKET_FIELD_ERROR(targets);
47791 }
47792 }
47793
47794 if (BV_ISSET(fields, 40)) {
47795 log_packet_detailed(" got field 'embarks'");
47796
47797#ifdef FREECIV_JSON_CONNECTION
47798 field_addr.name = "embarks";
47799#endif /* FREECIV_JSON_CONNECTION */
47800
47801 if (!DIO_BV_GET(&din, &field_addr, real_packet->embarks)) {
47802 RECEIVE_PACKET_FIELD_ERROR(embarks);
47803 }
47804 }
47805
47806 if (BV_ISSET(fields, 41)) {
47807 log_packet_detailed(" got field 'disembarks'");
47808
47809#ifdef FREECIV_JSON_CONNECTION
47810 field_addr.name = "disembarks";
47811#endif /* FREECIV_JSON_CONNECTION */
47812
47813 if (!DIO_BV_GET(&din, &field_addr, real_packet->disembarks)) {
47814 RECEIVE_PACKET_FIELD_ERROR(disembarks);
47815 }
47816 }
47817
47818 if (BV_ISSET(fields, 42)) {
47819 log_packet_detailed(" got field 'vlayer'");
47820
47821#ifdef FREECIV_JSON_CONNECTION
47822 field_addr.name = "vlayer";
47823#endif /* FREECIV_JSON_CONNECTION */
47824
47825 {
47826 int readin;
47827
47828 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
47829 RECEIVE_PACKET_FIELD_ERROR(vlayer);
47830 }
47831 real_packet->vlayer = readin;
47832 }
47833 }
47834
47835 if (BV_ISSET(fields, 43)) {
47836 log_packet_detailed(" got field 'helptext'");
47837
47838#ifdef FREECIV_JSON_CONNECTION
47839 field_addr.name = "helptext";
47840#endif /* FREECIV_JSON_CONNECTION */
47841
47842 {
47843 int i;
47844
47845 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
47846 RECEIVE_PACKET_FIELD_ERROR(helptext);
47847 }
47848 strvec_reserve(real_packet->helptext, i);
47849
47850#ifdef FREECIV_JSON_CONNECTION
47851 /* Enter array. */
47852 field_addr.sub_location = plocation_elem_new(0);
47853#endif /* FREECIV_JSON_CONNECTION */
47854
47855 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
47856#ifdef FREECIV_JSON_CONNECTION
47857 /* Next array element */
47858 field_addr.sub_location->number = i;
47859#endif /* FREECIV_JSON_CONNECTION */
47860
47861 {
47862 char readin[MAX_LEN_PACKET];
47863
47864 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
47865 || !strvec_set(real_packet->helptext, i, readin)) {
47866 RECEIVE_PACKET_FIELD_ERROR(helptext);
47867 }
47868 }
47869 }
47870
47871#ifdef FREECIV_JSON_CONNECTION
47872 /* Exit array. */
47873 FC_FREE(field_addr.sub_location);
47874#endif /* FREECIV_JSON_CONNECTION */
47875 }
47876 }
47877
47878 if (BV_ISSET(fields, 44)) {
47879 log_packet_detailed(" got field 'flags'");
47880
47881#ifdef FREECIV_JSON_CONNECTION
47882 field_addr.name = "flags";
47883#endif /* FREECIV_JSON_CONNECTION */
47884
47885 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
47886 RECEIVE_PACKET_FIELD_ERROR(flags);
47887 }
47888 }
47889
47890 if (BV_ISSET(fields, 45)) {
47891 log_packet_detailed(" got field 'roles'");
47892
47893#ifdef FREECIV_JSON_CONNECTION
47894 field_addr.name = "roles";
47895#endif /* FREECIV_JSON_CONNECTION */
47896
47897 if (!DIO_BV_GET(&din, &field_addr, real_packet->roles)) {
47898 RECEIVE_PACKET_FIELD_ERROR(roles);
47899 }
47900 }
47901
47902 real_packet->worker = BV_ISSET(fields, 46);
47903
47904 if (nullptr == old) {
47905 old = fc_malloc(sizeof(*old));
47906 init_packet_ruleset_unit(old);
47907 old->id = real_packet->id;
47908 sz_strlcpy(old->name, real_packet->name);
47909 sz_strlcpy(old->rule_name, real_packet->rule_name);
47910 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
47911 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
47912 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
47913 sz_strlcpy(old->sound_move, real_packet->sound_move);
47914 sz_strlcpy(old->sound_move_alt, real_packet->sound_move_alt);
47915 sz_strlcpy(old->sound_fight, real_packet->sound_fight);
47916 sz_strlcpy(old->sound_fight_alt, real_packet->sound_fight_alt);
47917 old->unit_class_id = real_packet->unit_class_id;
47918 old->build_cost = real_packet->build_cost;
47919 old->pop_cost = real_packet->pop_cost;
47920 old->attack_strength = real_packet->attack_strength;
47921 old->defense_strength = real_packet->defense_strength;
47922 old->move_rate = real_packet->move_rate;
47923 requirement_vector_copy(&old->build_reqs, &real_packet->build_reqs);
47924 old->vision_radius_sq = real_packet->vision_radius_sq;
47925 old->transport_capacity = real_packet->transport_capacity;
47926 old->hp = real_packet->hp;
47927 old->firepower = real_packet->firepower;
47928 old->obsoleted_by = real_packet->obsoleted_by;
47929 old->converted_to = real_packet->converted_to;
47930 old->convert_time = real_packet->convert_time;
47931 old->fuel = real_packet->fuel;
47932 old->happy_cost = real_packet->happy_cost;
47933 {
47934 int i;
47935
47936 for (i = 0; i < O_LAST; i++) {
47937 old->upkeep[i] = real_packet->upkeep[i];
47938 }
47939 }
47940 old->paratroopers_range = real_packet->paratroopers_range;
47941 old->veteran_levels = real_packet->veteran_levels;
47942 {
47943 int i;
47944
47945 for (i = 0; i < real_packet->veteran_levels; i++) {
47946 sz_strlcpy(old->veteran_name[i], real_packet->veteran_name[i]);
47947 }
47948 }
47949 {
47950 int i;
47951
47952 for (i = 0; i < real_packet->veteran_levels; i++) {
47953 old->power_fact[i] = real_packet->power_fact[i];
47954 }
47955 }
47956 {
47957 int i;
47958
47959 for (i = 0; i < real_packet->veteran_levels; i++) {
47960 old->move_bonus[i] = real_packet->move_bonus[i];
47961 }
47962 }
47963 {
47964 int i;
47965
47966 for (i = 0; i < real_packet->veteran_levels; i++) {
47967 old->base_raise_chance[i] = real_packet->base_raise_chance[i];
47968 }
47969 }
47970 {
47971 int i;
47972
47973 for (i = 0; i < real_packet->veteran_levels; i++) {
47974 old->work_raise_chance[i] = real_packet->work_raise_chance[i];
47975 }
47976 }
47977 old->bombard_rate = real_packet->bombard_rate;
47978 old->city_size = real_packet->city_size;
47979 old->city_slots = real_packet->city_slots;
47980 old->tp_defense = real_packet->tp_defense;
47981 old->cargo = real_packet->cargo;
47982 old->targets = real_packet->targets;
47983 old->embarks = real_packet->embarks;
47984 old->disembarks = real_packet->disembarks;
47985 old->vlayer = real_packet->vlayer;
47986 if (real_packet->helptext) {
47987 strvec_copy(old->helptext, real_packet->helptext);
47988 } else {
47989 strvec_clear(old->helptext);
47990 }
47991 old->flags = real_packet->flags;
47992 old->roles = real_packet->roles;
47993 old->worker = real_packet->worker;
47994 genhash_insert(*hash, old, old);
47995 } else {
47996 old->id = real_packet->id;
47997 sz_strlcpy(old->name, real_packet->name);
47998 sz_strlcpy(old->rule_name, real_packet->rule_name);
47999 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
48000 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
48001 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
48002 sz_strlcpy(old->sound_move, real_packet->sound_move);
48003 sz_strlcpy(old->sound_move_alt, real_packet->sound_move_alt);
48004 sz_strlcpy(old->sound_fight, real_packet->sound_fight);
48005 sz_strlcpy(old->sound_fight_alt, real_packet->sound_fight_alt);
48006 old->unit_class_id = real_packet->unit_class_id;
48007 old->build_cost = real_packet->build_cost;
48008 old->pop_cost = real_packet->pop_cost;
48009 old->attack_strength = real_packet->attack_strength;
48010 old->defense_strength = real_packet->defense_strength;
48011 old->move_rate = real_packet->move_rate;
48012 requirement_vector_copy(&old->build_reqs, &real_packet->build_reqs);
48013 old->vision_radius_sq = real_packet->vision_radius_sq;
48014 old->transport_capacity = real_packet->transport_capacity;
48015 old->hp = real_packet->hp;
48016 old->firepower = real_packet->firepower;
48017 old->obsoleted_by = real_packet->obsoleted_by;
48018 old->converted_to = real_packet->converted_to;
48019 old->convert_time = real_packet->convert_time;
48020 old->fuel = real_packet->fuel;
48021 old->happy_cost = real_packet->happy_cost;
48022 {
48023 int i;
48024
48025 for (i = 0; i < O_LAST; i++) {
48026 old->upkeep[i] = real_packet->upkeep[i];
48027 }
48028 }
48029 old->paratroopers_range = real_packet->paratroopers_range;
48030 old->veteran_levels = real_packet->veteran_levels;
48031 {
48032 int i;
48033
48034 for (i = 0; i < real_packet->veteran_levels; i++) {
48035 sz_strlcpy(old->veteran_name[i], real_packet->veteran_name[i]);
48036 }
48037 }
48038 {
48039 int i;
48040
48041 for (i = 0; i < real_packet->veteran_levels; i++) {
48042 old->power_fact[i] = real_packet->power_fact[i];
48043 }
48044 }
48045 {
48046 int i;
48047
48048 for (i = 0; i < real_packet->veteran_levels; i++) {
48049 old->move_bonus[i] = real_packet->move_bonus[i];
48050 }
48051 }
48052 {
48053 int i;
48054
48055 for (i = 0; i < real_packet->veteran_levels; i++) {
48056 old->base_raise_chance[i] = real_packet->base_raise_chance[i];
48057 }
48058 }
48059 {
48060 int i;
48061
48062 for (i = 0; i < real_packet->veteran_levels; i++) {
48063 old->work_raise_chance[i] = real_packet->work_raise_chance[i];
48064 }
48065 }
48066 old->bombard_rate = real_packet->bombard_rate;
48067 old->city_size = real_packet->city_size;
48068 old->city_slots = real_packet->city_slots;
48069 old->tp_defense = real_packet->tp_defense;
48070 old->cargo = real_packet->cargo;
48071 old->targets = real_packet->targets;
48072 old->embarks = real_packet->embarks;
48073 old->disembarks = real_packet->disembarks;
48074 old->vlayer = real_packet->vlayer;
48075 if (real_packet->helptext) {
48076 strvec_copy(old->helptext, real_packet->helptext);
48077 } else {
48078 strvec_clear(old->helptext);
48079 }
48080 old->flags = real_packet->flags;
48081 old->roles = real_packet->roles;
48082 old->worker = real_packet->worker;
48083 }
48084
48085#else /* FREECIV_DELTA_PROTOCOL */
48086#ifdef FREECIV_JSON_CONNECTION
48087 field_addr.name = "id";
48088#endif /* FREECIV_JSON_CONNECTION */
48089
48090 {
48091 int readin;
48092
48093 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
48094 RECEIVE_PACKET_FIELD_ERROR(id);
48095 }
48096 real_packet->id = readin;
48097 }
48098
48099#ifdef FREECIV_JSON_CONNECTION
48100 field_addr.name = "name";
48101#endif /* FREECIV_JSON_CONNECTION */
48102
48103 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
48104 RECEIVE_PACKET_FIELD_ERROR(name);
48105 }
48106
48107#ifdef FREECIV_JSON_CONNECTION
48108 field_addr.name = "rule_name";
48109#endif /* FREECIV_JSON_CONNECTION */
48110
48111 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
48112 RECEIVE_PACKET_FIELD_ERROR(rule_name);
48113 }
48114
48115#ifdef FREECIV_JSON_CONNECTION
48116 field_addr.name = "graphic_str";
48117#endif /* FREECIV_JSON_CONNECTION */
48118
48119 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
48120 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
48121 }
48122
48123#ifdef FREECIV_JSON_CONNECTION
48124 field_addr.name = "graphic_alt";
48125#endif /* FREECIV_JSON_CONNECTION */
48126
48127 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
48128 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
48129 }
48130
48131#ifdef FREECIV_JSON_CONNECTION
48132 field_addr.name = "graphic_alt2";
48133#endif /* FREECIV_JSON_CONNECTION */
48134
48135 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt2, sizeof(real_packet->graphic_alt2))) {
48136 RECEIVE_PACKET_FIELD_ERROR(graphic_alt2);
48137 }
48138
48139#ifdef FREECIV_JSON_CONNECTION
48140 field_addr.name = "sound_move";
48141#endif /* FREECIV_JSON_CONNECTION */
48142
48143 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_move, sizeof(real_packet->sound_move))) {
48144 RECEIVE_PACKET_FIELD_ERROR(sound_move);
48145 }
48146
48147#ifdef FREECIV_JSON_CONNECTION
48148 field_addr.name = "sound_move_alt";
48149#endif /* FREECIV_JSON_CONNECTION */
48150
48151 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_move_alt, sizeof(real_packet->sound_move_alt))) {
48152 RECEIVE_PACKET_FIELD_ERROR(sound_move_alt);
48153 }
48154
48155#ifdef FREECIV_JSON_CONNECTION
48156 field_addr.name = "sound_fight";
48157#endif /* FREECIV_JSON_CONNECTION */
48158
48159 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_fight, sizeof(real_packet->sound_fight))) {
48160 RECEIVE_PACKET_FIELD_ERROR(sound_fight);
48161 }
48162
48163#ifdef FREECIV_JSON_CONNECTION
48164 field_addr.name = "sound_fight_alt";
48165#endif /* FREECIV_JSON_CONNECTION */
48166
48167 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_fight_alt, sizeof(real_packet->sound_fight_alt))) {
48168 RECEIVE_PACKET_FIELD_ERROR(sound_fight_alt);
48169 }
48170
48171#ifdef FREECIV_JSON_CONNECTION
48172 field_addr.name = "unit_class_id";
48173#endif /* FREECIV_JSON_CONNECTION */
48174
48175 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->unit_class_id)) {
48176 RECEIVE_PACKET_FIELD_ERROR(unit_class_id);
48177 }
48178
48179#ifdef FREECIV_JSON_CONNECTION
48180 field_addr.name = "build_cost";
48181#endif /* FREECIV_JSON_CONNECTION */
48182
48183 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->build_cost)) {
48184 RECEIVE_PACKET_FIELD_ERROR(build_cost);
48185 }
48186
48187#ifdef FREECIV_JSON_CONNECTION
48188 field_addr.name = "pop_cost";
48189#endif /* FREECIV_JSON_CONNECTION */
48190
48191 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->pop_cost)) {
48192 RECEIVE_PACKET_FIELD_ERROR(pop_cost);
48193 }
48194
48195#ifdef FREECIV_JSON_CONNECTION
48196 field_addr.name = "attack_strength";
48197#endif /* FREECIV_JSON_CONNECTION */
48198
48199 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->attack_strength)) {
48200 RECEIVE_PACKET_FIELD_ERROR(attack_strength);
48201 }
48202
48203#ifdef FREECIV_JSON_CONNECTION
48204 field_addr.name = "defense_strength";
48205#endif /* FREECIV_JSON_CONNECTION */
48206
48207 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->defense_strength)) {
48208 RECEIVE_PACKET_FIELD_ERROR(defense_strength);
48209 }
48210
48211#ifdef FREECIV_JSON_CONNECTION
48212 field_addr.name = "move_rate";
48213#endif /* FREECIV_JSON_CONNECTION */
48214
48215 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_rate)) {
48216 RECEIVE_PACKET_FIELD_ERROR(move_rate);
48217 }
48218
48219#ifdef FREECIV_JSON_CONNECTION
48220 field_addr.name = "build_reqs";
48221#endif /* FREECIV_JSON_CONNECTION */
48222
48223 {
48224 int i;
48225
48226 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
48227 RECEIVE_PACKET_FIELD_ERROR(build_reqs);
48228 }
48229 requirement_vector_reserve(&real_packet->build_reqs, i);
48230
48231#ifdef FREECIV_JSON_CONNECTION
48232 /* Enter array. */
48233 field_addr.sub_location = plocation_elem_new(0);
48234#endif /* FREECIV_JSON_CONNECTION */
48235
48236 for (i = 0; i < requirement_vector_size(&real_packet->build_reqs); i++) {
48237#ifdef FREECIV_JSON_CONNECTION
48238 /* Next array element */
48239 field_addr.sub_location->number = i;
48240#endif /* FREECIV_JSON_CONNECTION */
48241
48242 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->build_reqs.p[i])) {
48243 RECEIVE_PACKET_FIELD_ERROR(build_reqs);
48244 }
48245 }
48246
48247#ifdef FREECIV_JSON_CONNECTION
48248 /* Exit array. */
48249 FC_FREE(field_addr.sub_location);
48250#endif /* FREECIV_JSON_CONNECTION */
48251 }
48252
48253#ifdef FREECIV_JSON_CONNECTION
48254 field_addr.name = "vision_radius_sq";
48255#endif /* FREECIV_JSON_CONNECTION */
48256
48257 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->vision_radius_sq)) {
48258 RECEIVE_PACKET_FIELD_ERROR(vision_radius_sq);
48259 }
48260
48261#ifdef FREECIV_JSON_CONNECTION
48262 field_addr.name = "transport_capacity";
48263#endif /* FREECIV_JSON_CONNECTION */
48264
48265 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->transport_capacity)) {
48266 RECEIVE_PACKET_FIELD_ERROR(transport_capacity);
48267 }
48268
48269#ifdef FREECIV_JSON_CONNECTION
48270 field_addr.name = "hp";
48271#endif /* FREECIV_JSON_CONNECTION */
48272
48273 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
48274 RECEIVE_PACKET_FIELD_ERROR(hp);
48275 }
48276
48277#ifdef FREECIV_JSON_CONNECTION
48278 field_addr.name = "firepower";
48279#endif /* FREECIV_JSON_CONNECTION */
48280
48281 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->firepower)) {
48282 RECEIVE_PACKET_FIELD_ERROR(firepower);
48283 }
48284
48285#ifdef FREECIV_JSON_CONNECTION
48286 field_addr.name = "obsoleted_by";
48287#endif /* FREECIV_JSON_CONNECTION */
48288
48289 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->obsoleted_by)) {
48290 RECEIVE_PACKET_FIELD_ERROR(obsoleted_by);
48291 }
48292
48293#ifdef FREECIV_JSON_CONNECTION
48294 field_addr.name = "converted_to";
48295#endif /* FREECIV_JSON_CONNECTION */
48296
48297 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->converted_to)) {
48298 RECEIVE_PACKET_FIELD_ERROR(converted_to);
48299 }
48300
48301#ifdef FREECIV_JSON_CONNECTION
48302 field_addr.name = "convert_time";
48303#endif /* FREECIV_JSON_CONNECTION */
48304
48305 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->convert_time)) {
48306 RECEIVE_PACKET_FIELD_ERROR(convert_time);
48307 }
48308
48309#ifdef FREECIV_JSON_CONNECTION
48310 field_addr.name = "fuel";
48311#endif /* FREECIV_JSON_CONNECTION */
48312
48313 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
48314 RECEIVE_PACKET_FIELD_ERROR(fuel);
48315 }
48316
48317#ifdef FREECIV_JSON_CONNECTION
48318 field_addr.name = "happy_cost";
48319#endif /* FREECIV_JSON_CONNECTION */
48320
48321 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->happy_cost)) {
48322 RECEIVE_PACKET_FIELD_ERROR(happy_cost);
48323 }
48324
48325#ifdef FREECIV_JSON_CONNECTION
48326 field_addr.name = "upkeep";
48327#endif /* FREECIV_JSON_CONNECTION */
48328
48329 {
48330 int i;
48331
48332
48333#ifdef FREECIV_JSON_CONNECTION
48334 /* Enter array. */
48335 field_addr.sub_location = plocation_elem_new(0);
48336#endif /* FREECIV_JSON_CONNECTION */
48337
48338 for (i = 0; i < O_LAST; i++) {
48339#ifdef FREECIV_JSON_CONNECTION
48340 /* Next array element */
48341 field_addr.sub_location->number = i;
48342#endif /* FREECIV_JSON_CONNECTION */
48343
48344 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->upkeep[i])) {
48345 RECEIVE_PACKET_FIELD_ERROR(upkeep);
48346 }
48347 }
48348
48349#ifdef FREECIV_JSON_CONNECTION
48350 /* Exit array. */
48351 FC_FREE(field_addr.sub_location);
48352#endif /* FREECIV_JSON_CONNECTION */
48353 }
48354
48355#ifdef FREECIV_JSON_CONNECTION
48356 field_addr.name = "paratroopers_range";
48357#endif /* FREECIV_JSON_CONNECTION */
48358
48359 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->paratroopers_range)) {
48360 RECEIVE_PACKET_FIELD_ERROR(paratroopers_range);
48361 }
48362
48363#ifdef FREECIV_JSON_CONNECTION
48364 field_addr.name = "veteran_levels";
48365#endif /* FREECIV_JSON_CONNECTION */
48366
48367 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran_levels)) {
48368 RECEIVE_PACKET_FIELD_ERROR(veteran_levels);
48369 }
48370
48371#ifdef FREECIV_JSON_CONNECTION
48372 field_addr.name = "veteran_name";
48373#endif /* FREECIV_JSON_CONNECTION */
48374
48375 {
48376 int i;
48377
48378 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
48379 RECEIVE_PACKET_FIELD_ERROR(veteran_name, ": array truncated");
48380 }
48381
48382#ifdef FREECIV_JSON_CONNECTION
48383 /* Enter array. */
48384 field_addr.sub_location = plocation_elem_new(0);
48385#endif /* FREECIV_JSON_CONNECTION */
48386
48387 for (i = 0; i < real_packet->veteran_levels; i++) {
48388#ifdef FREECIV_JSON_CONNECTION
48389 /* Next array element */
48390 field_addr.sub_location->number = i;
48391#endif /* FREECIV_JSON_CONNECTION */
48392
48393 if (!DIO_GET(string, &din, &field_addr, real_packet->veteran_name[i], sizeof(real_packet->veteran_name[i]))) {
48394 RECEIVE_PACKET_FIELD_ERROR(veteran_name);
48395 }
48396 }
48397
48398#ifdef FREECIV_JSON_CONNECTION
48399 /* Exit array. */
48400 FC_FREE(field_addr.sub_location);
48401#endif /* FREECIV_JSON_CONNECTION */
48402 }
48403
48404#ifdef FREECIV_JSON_CONNECTION
48405 field_addr.name = "power_fact";
48406#endif /* FREECIV_JSON_CONNECTION */
48407
48408 {
48409 int i;
48410
48411 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
48412 RECEIVE_PACKET_FIELD_ERROR(power_fact, ": array truncated");
48413 }
48414
48415#ifdef FREECIV_JSON_CONNECTION
48416 /* Enter array. */
48417 field_addr.sub_location = plocation_elem_new(0);
48418#endif /* FREECIV_JSON_CONNECTION */
48419
48420 for (i = 0; i < real_packet->veteran_levels; i++) {
48421#ifdef FREECIV_JSON_CONNECTION
48422 /* Next array element */
48423 field_addr.sub_location->number = i;
48424#endif /* FREECIV_JSON_CONNECTION */
48425
48426 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->power_fact[i])) {
48427 RECEIVE_PACKET_FIELD_ERROR(power_fact);
48428 }
48429 }
48430
48431#ifdef FREECIV_JSON_CONNECTION
48432 /* Exit array. */
48433 FC_FREE(field_addr.sub_location);
48434#endif /* FREECIV_JSON_CONNECTION */
48435 }
48436
48437#ifdef FREECIV_JSON_CONNECTION
48438 field_addr.name = "move_bonus";
48439#endif /* FREECIV_JSON_CONNECTION */
48440
48441 {
48442 int i;
48443
48444 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
48445 RECEIVE_PACKET_FIELD_ERROR(move_bonus, ": array truncated");
48446 }
48447
48448#ifdef FREECIV_JSON_CONNECTION
48449 /* Enter array. */
48450 field_addr.sub_location = plocation_elem_new(0);
48451#endif /* FREECIV_JSON_CONNECTION */
48452
48453 for (i = 0; i < real_packet->veteran_levels; i++) {
48454#ifdef FREECIV_JSON_CONNECTION
48455 /* Next array element */
48456 field_addr.sub_location->number = i;
48457#endif /* FREECIV_JSON_CONNECTION */
48458
48459 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_bonus[i])) {
48460 RECEIVE_PACKET_FIELD_ERROR(move_bonus);
48461 }
48462 }
48463
48464#ifdef FREECIV_JSON_CONNECTION
48465 /* Exit array. */
48466 FC_FREE(field_addr.sub_location);
48467#endif /* FREECIV_JSON_CONNECTION */
48468 }
48469
48470#ifdef FREECIV_JSON_CONNECTION
48471 field_addr.name = "base_raise_chance";
48472#endif /* FREECIV_JSON_CONNECTION */
48473
48474 {
48475 int i;
48476
48477 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
48478 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance, ": array truncated");
48479 }
48480
48481#ifdef FREECIV_JSON_CONNECTION
48482 /* Enter array. */
48483 field_addr.sub_location = plocation_elem_new(0);
48484#endif /* FREECIV_JSON_CONNECTION */
48485
48486 for (i = 0; i < real_packet->veteran_levels; i++) {
48487#ifdef FREECIV_JSON_CONNECTION
48488 /* Next array element */
48489 field_addr.sub_location->number = i;
48490#endif /* FREECIV_JSON_CONNECTION */
48491
48492 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->base_raise_chance[i])) {
48493 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance);
48494 }
48495 }
48496
48497#ifdef FREECIV_JSON_CONNECTION
48498 /* Exit array. */
48499 FC_FREE(field_addr.sub_location);
48500#endif /* FREECIV_JSON_CONNECTION */
48501 }
48502
48503#ifdef FREECIV_JSON_CONNECTION
48504 field_addr.name = "work_raise_chance";
48505#endif /* FREECIV_JSON_CONNECTION */
48506
48507 {
48508 int i;
48509
48510 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
48511 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance, ": array truncated");
48512 }
48513
48514#ifdef FREECIV_JSON_CONNECTION
48515 /* Enter array. */
48516 field_addr.sub_location = plocation_elem_new(0);
48517#endif /* FREECIV_JSON_CONNECTION */
48518
48519 for (i = 0; i < real_packet->veteran_levels; i++) {
48520#ifdef FREECIV_JSON_CONNECTION
48521 /* Next array element */
48522 field_addr.sub_location->number = i;
48523#endif /* FREECIV_JSON_CONNECTION */
48524
48525 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->work_raise_chance[i])) {
48526 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance);
48527 }
48528 }
48529
48530#ifdef FREECIV_JSON_CONNECTION
48531 /* Exit array. */
48532 FC_FREE(field_addr.sub_location);
48533#endif /* FREECIV_JSON_CONNECTION */
48534 }
48535
48536#ifdef FREECIV_JSON_CONNECTION
48537 field_addr.name = "bombard_rate";
48538#endif /* FREECIV_JSON_CONNECTION */
48539
48540 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->bombard_rate)) {
48541 RECEIVE_PACKET_FIELD_ERROR(bombard_rate);
48542 }
48543
48544#ifdef FREECIV_JSON_CONNECTION
48545 field_addr.name = "city_size";
48546#endif /* FREECIV_JSON_CONNECTION */
48547
48548 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->city_size)) {
48549 RECEIVE_PACKET_FIELD_ERROR(city_size);
48550 }
48551
48552#ifdef FREECIV_JSON_CONNECTION
48553 field_addr.name = "city_slots";
48554#endif /* FREECIV_JSON_CONNECTION */
48555
48556 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->city_slots)) {
48557 RECEIVE_PACKET_FIELD_ERROR(city_slots);
48558 }
48559
48560#ifdef FREECIV_JSON_CONNECTION
48561 field_addr.name = "tp_defense";
48562#endif /* FREECIV_JSON_CONNECTION */
48563
48564 {
48565 int readin;
48566
48567 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
48568 RECEIVE_PACKET_FIELD_ERROR(tp_defense);
48569 }
48570 real_packet->tp_defense = readin;
48571 }
48572
48573#ifdef FREECIV_JSON_CONNECTION
48574 field_addr.name = "cargo";
48575#endif /* FREECIV_JSON_CONNECTION */
48576
48577 if (!DIO_BV_GET(&din, &field_addr, real_packet->cargo)) {
48578 RECEIVE_PACKET_FIELD_ERROR(cargo);
48579 }
48580
48581#ifdef FREECIV_JSON_CONNECTION
48582 field_addr.name = "targets";
48583#endif /* FREECIV_JSON_CONNECTION */
48584
48585 if (!DIO_BV_GET(&din, &field_addr, real_packet->targets)) {
48586 RECEIVE_PACKET_FIELD_ERROR(targets);
48587 }
48588
48589#ifdef FREECIV_JSON_CONNECTION
48590 field_addr.name = "embarks";
48591#endif /* FREECIV_JSON_CONNECTION */
48592
48593 if (!DIO_BV_GET(&din, &field_addr, real_packet->embarks)) {
48594 RECEIVE_PACKET_FIELD_ERROR(embarks);
48595 }
48596
48597#ifdef FREECIV_JSON_CONNECTION
48598 field_addr.name = "disembarks";
48599#endif /* FREECIV_JSON_CONNECTION */
48600
48601 if (!DIO_BV_GET(&din, &field_addr, real_packet->disembarks)) {
48602 RECEIVE_PACKET_FIELD_ERROR(disembarks);
48603 }
48604
48605#ifdef FREECIV_JSON_CONNECTION
48606 field_addr.name = "vlayer";
48607#endif /* FREECIV_JSON_CONNECTION */
48608
48609 {
48610 int readin;
48611
48612 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
48613 RECEIVE_PACKET_FIELD_ERROR(vlayer);
48614 }
48615 real_packet->vlayer = readin;
48616 }
48617
48618#ifdef FREECIV_JSON_CONNECTION
48619 field_addr.name = "helptext";
48620#endif /* FREECIV_JSON_CONNECTION */
48621
48622 {
48623 int i;
48624
48625 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
48626 RECEIVE_PACKET_FIELD_ERROR(helptext);
48627 }
48628 strvec_reserve(real_packet->helptext, i);
48629
48630#ifdef FREECIV_JSON_CONNECTION
48631 /* Enter array. */
48632 field_addr.sub_location = plocation_elem_new(0);
48633#endif /* FREECIV_JSON_CONNECTION */
48634
48635 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
48636#ifdef FREECIV_JSON_CONNECTION
48637 /* Next array element */
48638 field_addr.sub_location->number = i;
48639#endif /* FREECIV_JSON_CONNECTION */
48640
48641 {
48642 char readin[MAX_LEN_PACKET];
48643
48644 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
48645 || !strvec_set(real_packet->helptext, i, readin)) {
48646 RECEIVE_PACKET_FIELD_ERROR(helptext);
48647 }
48648 }
48649 }
48650
48651#ifdef FREECIV_JSON_CONNECTION
48652 /* Exit array. */
48653 FC_FREE(field_addr.sub_location);
48654#endif /* FREECIV_JSON_CONNECTION */
48655 }
48656
48657#ifdef FREECIV_JSON_CONNECTION
48658 field_addr.name = "flags";
48659#endif /* FREECIV_JSON_CONNECTION */
48660
48661 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
48662 RECEIVE_PACKET_FIELD_ERROR(flags);
48663 }
48664
48665#ifdef FREECIV_JSON_CONNECTION
48666 field_addr.name = "roles";
48667#endif /* FREECIV_JSON_CONNECTION */
48668
48669 if (!DIO_BV_GET(&din, &field_addr, real_packet->roles)) {
48670 RECEIVE_PACKET_FIELD_ERROR(roles);
48671 }
48672
48673#ifdef FREECIV_JSON_CONNECTION
48674 field_addr.name = "worker";
48675#endif /* FREECIV_JSON_CONNECTION */
48676
48677 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->worker)) {
48678 RECEIVE_PACKET_FIELD_ERROR(worker);
48679 }
48680#endif /* FREECIV_DELTA_PROTOCOL */
48681
48682 RECEIVE_PACKET_END(real_packet);
48683#undef FREE_PACKET_STRUCT
48684}
48685
48686 static int send_packet_ruleset_unit_100(struct connection *pc, const struct packet_ruleset_unit *packet)
48687{
48688 const struct packet_ruleset_unit *real_packet = packet;
48689 int e;
48690 SEND_PACKET_START(PACKET_RULESET_UNIT);
48691
48692 log_packet_detailed("packet_ruleset_unit_100: sending info about ()");
48693
48694#ifdef FREECIV_DELTA_PROTOCOL
48695 packet_ruleset_unit_100_fields fields;
48696 struct packet_ruleset_unit *old;
48697 bool differ;
48698 struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT;
48699
48700 if (nullptr == *hash) {
48701 *hash = genhash_new_full(hash_packet_ruleset_unit_100, cmp_packet_ruleset_unit_100,
48702 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit);
48703 }
48704 BV_CLR_ALL(fields);
48705
48706 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
48707 old = fc_malloc(sizeof(*old));
48708 /* temporary bitcopy just to insert correctly */
48709 *old = *real_packet;
48710 genhash_insert(*hash, old, old);
48711 init_packet_ruleset_unit(old);
48712 }
48713
48714 differ = (old->id != real_packet->id);
48715 if (differ) {
48716 BV_SET(fields, 0);
48717 }
48718
48719 differ = (strcmp(old->name, real_packet->name) != 0);
48720 if (differ) {
48721 BV_SET(fields, 1);
48722 }
48723
48724 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
48725 if (differ) {
48726 BV_SET(fields, 2);
48727 }
48728
48729 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
48730 if (differ) {
48731 BV_SET(fields, 3);
48732 }
48733
48734 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
48735 if (differ) {
48736 BV_SET(fields, 4);
48737 }
48738
48739 differ = (strcmp(old->graphic_alt2, real_packet->graphic_alt2) != 0);
48740 if (differ) {
48741 BV_SET(fields, 5);
48742 }
48743
48744 differ = (strcmp(old->sound_move, real_packet->sound_move) != 0);
48745 if (differ) {
48746 BV_SET(fields, 6);
48747 }
48748
48749 differ = (strcmp(old->sound_move_alt, real_packet->sound_move_alt) != 0);
48750 if (differ) {
48751 BV_SET(fields, 7);
48752 }
48753
48754 differ = (strcmp(old->sound_fight, real_packet->sound_fight) != 0);
48755 if (differ) {
48756 BV_SET(fields, 8);
48757 }
48758
48759 differ = (strcmp(old->sound_fight_alt, real_packet->sound_fight_alt) != 0);
48760 if (differ) {
48761 BV_SET(fields, 9);
48762 }
48763
48764 differ = (old->unit_class_id != real_packet->unit_class_id);
48765 if (differ) {
48766 BV_SET(fields, 10);
48767 }
48768
48769 differ = (old->build_cost != real_packet->build_cost);
48770 if (differ) {
48771 BV_SET(fields, 11);
48772 }
48773
48774 differ = (old->pop_cost != real_packet->pop_cost);
48775 if (differ) {
48776 BV_SET(fields, 12);
48777 }
48778
48779 differ = (old->attack_strength != real_packet->attack_strength);
48780 if (differ) {
48781 BV_SET(fields, 13);
48782 }
48783
48784 differ = (old->defense_strength != real_packet->defense_strength);
48785 if (differ) {
48786 BV_SET(fields, 14);
48787 }
48788
48789 differ = (old->move_rate != real_packet->move_rate);
48790 if (differ) {
48791 BV_SET(fields, 15);
48792 }
48793
48794 differ = (requirement_vector_size(&old->build_reqs) != requirement_vector_size(&real_packet->build_reqs));
48795 if (!differ) {
48796 int i;
48797
48798 for (i = 0; i < requirement_vector_size(&old->build_reqs); i++) {
48799 differ = !are_requirements_equal(&old->build_reqs.p[i], &real_packet->build_reqs.p[i]);
48800 if (differ) {
48801 break;
48802 }
48803 }
48804 }
48805 if (differ) {
48806 BV_SET(fields, 16);
48807 }
48808
48809 differ = (old->vision_radius_sq != real_packet->vision_radius_sq);
48810 if (differ) {
48811 BV_SET(fields, 17);
48812 }
48813
48814 differ = (old->transport_capacity != real_packet->transport_capacity);
48815 if (differ) {
48816 BV_SET(fields, 18);
48817 }
48818
48819 differ = (old->hp != real_packet->hp);
48820 if (differ) {
48821 BV_SET(fields, 19);
48822 }
48823
48824 differ = (old->firepower != real_packet->firepower);
48825 if (differ) {
48826 BV_SET(fields, 20);
48827 }
48828
48829 differ = (old->obsoleted_by != real_packet->obsoleted_by);
48830 if (differ) {
48831 BV_SET(fields, 21);
48832 }
48833
48834 differ = (old->converted_to != real_packet->converted_to);
48835 if (differ) {
48836 BV_SET(fields, 22);
48837 }
48838
48839 differ = (old->convert_time != real_packet->convert_time);
48840 if (differ) {
48841 BV_SET(fields, 23);
48842 }
48843
48844 differ = (old->fuel != real_packet->fuel);
48845 if (differ) {
48846 BV_SET(fields, 24);
48847 }
48848
48849 differ = (old->happy_cost != real_packet->happy_cost);
48850 if (differ) {
48851 BV_SET(fields, 25);
48852 }
48853
48854 differ = FALSE;
48855 {
48856 int i;
48857
48858 for (i = 0; i < O_LAST; i++) {
48859 differ = (old->upkeep[i] != real_packet->upkeep[i]);
48860 if (differ) {
48861 break;
48862 }
48863 }
48864 }
48865 if (differ) {
48866 BV_SET(fields, 26);
48867 }
48868
48869 differ = (old->paratroopers_range != real_packet->paratroopers_range);
48870 if (differ) {
48871 BV_SET(fields, 27);
48872 }
48873
48874 differ = (old->veteran_levels != real_packet->veteran_levels);
48875 if (differ) {
48876 BV_SET(fields, 28);
48877 }
48878
48879 differ = (old->veteran_levels != real_packet->veteran_levels);
48880 if (!differ) {
48881 int i;
48882
48883 for (i = 0; i < old->veteran_levels; i++) {
48884 differ = (strcmp(old->veteran_name[i], real_packet->veteran_name[i]) != 0);
48885 if (differ) {
48886 break;
48887 }
48888 }
48889 }
48890 if (differ) {
48891 BV_SET(fields, 29);
48892 }
48893
48894 differ = (old->veteran_levels != real_packet->veteran_levels);
48895 if (!differ) {
48896 int i;
48897
48898 for (i = 0; i < old->veteran_levels; i++) {
48899 differ = (old->power_fact[i] != real_packet->power_fact[i]);
48900 if (differ) {
48901 break;
48902 }
48903 }
48904 }
48905 if (differ) {
48906 BV_SET(fields, 30);
48907 }
48908
48909 differ = (old->veteran_levels != real_packet->veteran_levels);
48910 if (!differ) {
48911 int i;
48912
48913 for (i = 0; i < old->veteran_levels; i++) {
48914 differ = (old->move_bonus[i] != real_packet->move_bonus[i]);
48915 if (differ) {
48916 break;
48917 }
48918 }
48919 }
48920 if (differ) {
48921 BV_SET(fields, 31);
48922 }
48923
48924 differ = (old->veteran_levels != real_packet->veteran_levels);
48925 if (!differ) {
48926 int i;
48927
48928 for (i = 0; i < old->veteran_levels; i++) {
48929 differ = (old->base_raise_chance[i] != real_packet->base_raise_chance[i]);
48930 if (differ) {
48931 break;
48932 }
48933 }
48934 }
48935 if (differ) {
48936 BV_SET(fields, 32);
48937 }
48938
48939 differ = (old->veteran_levels != real_packet->veteran_levels);
48940 if (!differ) {
48941 int i;
48942
48943 for (i = 0; i < old->veteran_levels; i++) {
48944 differ = (old->work_raise_chance[i] != real_packet->work_raise_chance[i]);
48945 if (differ) {
48946 break;
48947 }
48948 }
48949 }
48950 if (differ) {
48951 BV_SET(fields, 33);
48952 }
48953
48954 differ = (old->bombard_rate != real_packet->bombard_rate);
48955 if (differ) {
48956 BV_SET(fields, 34);
48957 }
48958
48959 differ = (old->city_size != real_packet->city_size);
48960 if (differ) {
48961 BV_SET(fields, 35);
48962 }
48963
48964 differ = (old->city_slots != real_packet->city_slots);
48965 if (differ) {
48966 BV_SET(fields, 36);
48967 }
48968
48969 differ = (old->tp_defense != real_packet->tp_defense);
48970 if (differ) {
48971 BV_SET(fields, 37);
48972 }
48973
48974 differ = !BV_ARE_EQUAL(old->cargo, real_packet->cargo);
48975 if (differ) {
48976 BV_SET(fields, 38);
48977 }
48978
48979 differ = !BV_ARE_EQUAL(old->targets, real_packet->targets);
48980 if (differ) {
48981 BV_SET(fields, 39);
48982 }
48983
48984 differ = !BV_ARE_EQUAL(old->embarks, real_packet->embarks);
48985 if (differ) {
48986 BV_SET(fields, 40);
48987 }
48988
48989 differ = !BV_ARE_EQUAL(old->disembarks, real_packet->disembarks);
48990 if (differ) {
48991 BV_SET(fields, 41);
48992 }
48993
48994 differ = (old->vlayer != real_packet->vlayer);
48995 if (differ) {
48996 BV_SET(fields, 42);
48997 }
48998
48999 if (real_packet->helptext) {
49000 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
49001 } else {
49002 differ = (strvec_size(old->helptext) > 0);
49003 }
49004 if (differ) {
49005 BV_SET(fields, 43);
49006 }
49007
49008 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
49009 if (differ) {
49010 BV_SET(fields, 44);
49011 }
49012
49013 differ = !BV_ARE_EQUAL(old->roles, real_packet->roles);
49014 if (differ) {
49015 BV_SET(fields, 45);
49016 }
49017
49018 /* folded into head */
49019 if (real_packet->worker) {
49020 BV_SET(fields, 46);
49021 }
49022#endif /* FREECIV_DELTA_PROTOCOL */
49023
49024#ifdef FREECIV_JSON_CONNECTION
49025 struct plocation field_addr;
49026 {
49027 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
49028 field_addr = *field_addr_tmp;
49029 FC_FREE(field_addr_tmp);
49030 }
49031#endif /* FREECIV_JSON_CONNECTION */
49032
49033#ifdef FREECIV_DELTA_PROTOCOL
49034#ifdef FREECIV_JSON_CONNECTION
49035 field_addr.name = "fields";
49036#endif /* FREECIV_JSON_CONNECTION */
49037 e = 0;
49038 e |= DIO_BV_PUT(&dout, &field_addr, fields);
49039 if (e) {
49040 log_packet_detailed("fields bitvector error detected");
49041 }
49042
49043 if (BV_ISSET(fields, 0)) {
49044 log_packet_detailed(" field 'id' has changed");
49045
49046#ifdef FREECIV_JSON_CONNECTION
49047 field_addr.name = "id";
49048#endif /* FREECIV_JSON_CONNECTION */
49049 e = 0;
49050
49051 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
49052
49053 if (e) {
49054 log_packet_detailed("'id' field error detected");
49055 }
49056 }
49057
49058 if (BV_ISSET(fields, 1)) {
49059 log_packet_detailed(" field 'name' has changed");
49060
49061#ifdef FREECIV_JSON_CONNECTION
49062 field_addr.name = "name";
49063#endif /* FREECIV_JSON_CONNECTION */
49064 e = 0;
49065
49066 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
49067
49068 if (e) {
49069 log_packet_detailed("'name' field error detected");
49070 }
49071 }
49072
49073 if (BV_ISSET(fields, 2)) {
49074 log_packet_detailed(" field 'rule_name' has changed");
49075
49076#ifdef FREECIV_JSON_CONNECTION
49077 field_addr.name = "rule_name";
49078#endif /* FREECIV_JSON_CONNECTION */
49079 e = 0;
49080
49081 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
49082
49083 if (e) {
49084 log_packet_detailed("'rule_name' field error detected");
49085 }
49086 }
49087
49088 if (BV_ISSET(fields, 3)) {
49089 log_packet_detailed(" field 'graphic_str' has changed");
49090
49091#ifdef FREECIV_JSON_CONNECTION
49092 field_addr.name = "graphic_str";
49093#endif /* FREECIV_JSON_CONNECTION */
49094 e = 0;
49095
49096 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
49097
49098 if (e) {
49099 log_packet_detailed("'graphic_str' field error detected");
49100 }
49101 }
49102
49103 if (BV_ISSET(fields, 4)) {
49104 log_packet_detailed(" field 'graphic_alt' has changed");
49105
49106#ifdef FREECIV_JSON_CONNECTION
49107 field_addr.name = "graphic_alt";
49108#endif /* FREECIV_JSON_CONNECTION */
49109 e = 0;
49110
49111 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
49112
49113 if (e) {
49114 log_packet_detailed("'graphic_alt' field error detected");
49115 }
49116 }
49117
49118 if (BV_ISSET(fields, 5)) {
49119 log_packet_detailed(" field 'graphic_alt2' has changed");
49120
49121#ifdef FREECIV_JSON_CONNECTION
49122 field_addr.name = "graphic_alt2";
49123#endif /* FREECIV_JSON_CONNECTION */
49124 e = 0;
49125
49126 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt2);
49127
49128 if (e) {
49129 log_packet_detailed("'graphic_alt2' field error detected");
49130 }
49131 }
49132
49133 if (BV_ISSET(fields, 6)) {
49134 log_packet_detailed(" field 'sound_move' has changed");
49135
49136#ifdef FREECIV_JSON_CONNECTION
49137 field_addr.name = "sound_move";
49138#endif /* FREECIV_JSON_CONNECTION */
49139 e = 0;
49140
49141 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_move);
49142
49143 if (e) {
49144 log_packet_detailed("'sound_move' field error detected");
49145 }
49146 }
49147
49148 if (BV_ISSET(fields, 7)) {
49149 log_packet_detailed(" field 'sound_move_alt' has changed");
49150
49151#ifdef FREECIV_JSON_CONNECTION
49152 field_addr.name = "sound_move_alt";
49153#endif /* FREECIV_JSON_CONNECTION */
49154 e = 0;
49155
49156 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_move_alt);
49157
49158 if (e) {
49159 log_packet_detailed("'sound_move_alt' field error detected");
49160 }
49161 }
49162
49163 if (BV_ISSET(fields, 8)) {
49164 log_packet_detailed(" field 'sound_fight' has changed");
49165
49166#ifdef FREECIV_JSON_CONNECTION
49167 field_addr.name = "sound_fight";
49168#endif /* FREECIV_JSON_CONNECTION */
49169 e = 0;
49170
49171 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_fight);
49172
49173 if (e) {
49174 log_packet_detailed("'sound_fight' field error detected");
49175 }
49176 }
49177
49178 if (BV_ISSET(fields, 9)) {
49179 log_packet_detailed(" field 'sound_fight_alt' has changed");
49180
49181#ifdef FREECIV_JSON_CONNECTION
49182 field_addr.name = "sound_fight_alt";
49183#endif /* FREECIV_JSON_CONNECTION */
49184 e = 0;
49185
49186 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_fight_alt);
49187
49188 if (e) {
49189 log_packet_detailed("'sound_fight_alt' field error detected");
49190 }
49191 }
49192
49193 if (BV_ISSET(fields, 10)) {
49194 log_packet_detailed(" field 'unit_class_id' has changed");
49195
49196#ifdef FREECIV_JSON_CONNECTION
49197 field_addr.name = "unit_class_id";
49198#endif /* FREECIV_JSON_CONNECTION */
49199 e = 0;
49200
49201 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->unit_class_id);
49202
49203 if (e) {
49204 log_packet_detailed("'unit_class_id' field error detected");
49205 }
49206 }
49207
49208 if (BV_ISSET(fields, 11)) {
49209 log_packet_detailed(" field 'build_cost' has changed");
49210
49211#ifdef FREECIV_JSON_CONNECTION
49212 field_addr.name = "build_cost";
49213#endif /* FREECIV_JSON_CONNECTION */
49214 e = 0;
49215
49216 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->build_cost);
49217
49218 if (e) {
49219 log_packet_detailed("'build_cost' field error detected");
49220 }
49221 }
49222
49223 if (BV_ISSET(fields, 12)) {
49224 log_packet_detailed(" field 'pop_cost' has changed");
49225
49226#ifdef FREECIV_JSON_CONNECTION
49227 field_addr.name = "pop_cost";
49228#endif /* FREECIV_JSON_CONNECTION */
49229 e = 0;
49230
49231 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->pop_cost);
49232
49233 if (e) {
49234 log_packet_detailed("'pop_cost' field error detected");
49235 }
49236 }
49237
49238 if (BV_ISSET(fields, 13)) {
49239 log_packet_detailed(" field 'attack_strength' has changed");
49240
49241#ifdef FREECIV_JSON_CONNECTION
49242 field_addr.name = "attack_strength";
49243#endif /* FREECIV_JSON_CONNECTION */
49244 e = 0;
49245
49246 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->attack_strength);
49247
49248 if (e) {
49249 log_packet_detailed("'attack_strength' field error detected");
49250 }
49251 }
49252
49253 if (BV_ISSET(fields, 14)) {
49254 log_packet_detailed(" field 'defense_strength' has changed");
49255
49256#ifdef FREECIV_JSON_CONNECTION
49257 field_addr.name = "defense_strength";
49258#endif /* FREECIV_JSON_CONNECTION */
49259 e = 0;
49260
49261 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->defense_strength);
49262
49263 if (e) {
49264 log_packet_detailed("'defense_strength' field error detected");
49265 }
49266 }
49267
49268 if (BV_ISSET(fields, 15)) {
49269 log_packet_detailed(" field 'move_rate' has changed");
49270
49271#ifdef FREECIV_JSON_CONNECTION
49272 field_addr.name = "move_rate";
49273#endif /* FREECIV_JSON_CONNECTION */
49274 e = 0;
49275
49276 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_rate);
49277
49278 if (e) {
49279 log_packet_detailed("'move_rate' field error detected");
49280 }
49281 }
49282
49283 if (BV_ISSET(fields, 16)) {
49284 log_packet_detailed(" field 'build_reqs' has changed");
49285
49286#ifdef FREECIV_JSON_CONNECTION
49287 field_addr.name = "build_reqs";
49288#endif /* FREECIV_JSON_CONNECTION */
49289 e = 0;
49290
49291 {
49292 int i;
49293
49294 fc_assert(requirement_vector_size(&real_packet->build_reqs) < MAX_UINT16);
49295 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->build_reqs));
49296
49297#ifdef FREECIV_JSON_CONNECTION
49298 /* Enter array. */
49299 field_addr.sub_location = plocation_elem_new(0);
49300#endif /* FREECIV_JSON_CONNECTION */
49301
49302 for (i = 0; i < requirement_vector_size(&real_packet->build_reqs); i++) {
49303#ifdef FREECIV_JSON_CONNECTION
49304 /* Next array element. */
49305 field_addr.sub_location->number = i;
49306#endif /* FREECIV_JSON_CONNECTION */
49307
49308 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->build_reqs.p[i]);
49309 }
49310
49311#ifdef FREECIV_JSON_CONNECTION
49312 /* Exit array. */
49313 FC_FREE(field_addr.sub_location);
49314#endif /* FREECIV_JSON_CONNECTION */
49315 }
49316
49317 if (e) {
49318 log_packet_detailed("'build_reqs' field error detected");
49319 }
49320 }
49321
49322 if (BV_ISSET(fields, 17)) {
49323 log_packet_detailed(" field 'vision_radius_sq' has changed");
49324
49325#ifdef FREECIV_JSON_CONNECTION
49326 field_addr.name = "vision_radius_sq";
49327#endif /* FREECIV_JSON_CONNECTION */
49328 e = 0;
49329
49330 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->vision_radius_sq);
49331
49332 if (e) {
49333 log_packet_detailed("'vision_radius_sq' field error detected");
49334 }
49335 }
49336
49337 if (BV_ISSET(fields, 18)) {
49338 log_packet_detailed(" field 'transport_capacity' has changed");
49339
49340#ifdef FREECIV_JSON_CONNECTION
49341 field_addr.name = "transport_capacity";
49342#endif /* FREECIV_JSON_CONNECTION */
49343 e = 0;
49344
49345 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->transport_capacity);
49346
49347 if (e) {
49348 log_packet_detailed("'transport_capacity' field error detected");
49349 }
49350 }
49351
49352 if (BV_ISSET(fields, 19)) {
49353 log_packet_detailed(" field 'hp' has changed");
49354
49355#ifdef FREECIV_JSON_CONNECTION
49356 field_addr.name = "hp";
49357#endif /* FREECIV_JSON_CONNECTION */
49358 e = 0;
49359
49360 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
49361
49362 if (e) {
49363 log_packet_detailed("'hp' field error detected");
49364 }
49365 }
49366
49367 if (BV_ISSET(fields, 20)) {
49368 log_packet_detailed(" field 'firepower' has changed");
49369
49370#ifdef FREECIV_JSON_CONNECTION
49371 field_addr.name = "firepower";
49372#endif /* FREECIV_JSON_CONNECTION */
49373 e = 0;
49374
49375 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->firepower);
49376
49377 if (e) {
49378 log_packet_detailed("'firepower' field error detected");
49379 }
49380 }
49381
49382 if (BV_ISSET(fields, 21)) {
49383 log_packet_detailed(" field 'obsoleted_by' has changed");
49384
49385#ifdef FREECIV_JSON_CONNECTION
49386 field_addr.name = "obsoleted_by";
49387#endif /* FREECIV_JSON_CONNECTION */
49388 e = 0;
49389
49390 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->obsoleted_by);
49391
49392 if (e) {
49393 log_packet_detailed("'obsoleted_by' field error detected");
49394 }
49395 }
49396
49397 if (BV_ISSET(fields, 22)) {
49398 log_packet_detailed(" field 'converted_to' has changed");
49399
49400#ifdef FREECIV_JSON_CONNECTION
49401 field_addr.name = "converted_to";
49402#endif /* FREECIV_JSON_CONNECTION */
49403 e = 0;
49404
49405 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->converted_to);
49406
49407 if (e) {
49408 log_packet_detailed("'converted_to' field error detected");
49409 }
49410 }
49411
49412 if (BV_ISSET(fields, 23)) {
49413 log_packet_detailed(" field 'convert_time' has changed");
49414
49415#ifdef FREECIV_JSON_CONNECTION
49416 field_addr.name = "convert_time";
49417#endif /* FREECIV_JSON_CONNECTION */
49418 e = 0;
49419
49420 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->convert_time);
49421
49422 if (e) {
49423 log_packet_detailed("'convert_time' field error detected");
49424 }
49425 }
49426
49427 if (BV_ISSET(fields, 24)) {
49428 log_packet_detailed(" field 'fuel' has changed");
49429
49430#ifdef FREECIV_JSON_CONNECTION
49431 field_addr.name = "fuel";
49432#endif /* FREECIV_JSON_CONNECTION */
49433 e = 0;
49434
49435 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
49436
49437 if (e) {
49438 log_packet_detailed("'fuel' field error detected");
49439 }
49440 }
49441
49442 if (BV_ISSET(fields, 25)) {
49443 log_packet_detailed(" field 'happy_cost' has changed");
49444
49445#ifdef FREECIV_JSON_CONNECTION
49446 field_addr.name = "happy_cost";
49447#endif /* FREECIV_JSON_CONNECTION */
49448 e = 0;
49449
49450 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->happy_cost);
49451
49452 if (e) {
49453 log_packet_detailed("'happy_cost' field error detected");
49454 }
49455 }
49456
49457 if (BV_ISSET(fields, 26)) {
49458 log_packet_detailed(" field 'upkeep' has changed");
49459
49460#ifdef FREECIV_JSON_CONNECTION
49461 field_addr.name = "upkeep";
49462#endif /* FREECIV_JSON_CONNECTION */
49463 e = 0;
49464
49465 {
49466 int i;
49467
49468#ifdef FREECIV_JSON_CONNECTION
49469 /* Create the array. */
49470 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
49471
49472 /* Enter array. */
49473 field_addr.sub_location = plocation_elem_new(0);
49474#endif /* FREECIV_JSON_CONNECTION */
49475
49476 for (i = 0; i < O_LAST; i++) {
49477#ifdef FREECIV_JSON_CONNECTION
49478 /* Next array element. */
49479 field_addr.sub_location->number = i;
49480#endif /* FREECIV_JSON_CONNECTION */
49481
49482 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->upkeep[i]);
49483 }
49484
49485#ifdef FREECIV_JSON_CONNECTION
49486 /* Exit array. */
49487 FC_FREE(field_addr.sub_location);
49488#endif /* FREECIV_JSON_CONNECTION */
49489 }
49490
49491 if (e) {
49492 log_packet_detailed("'upkeep' field error detected");
49493 }
49494 }
49495
49496 if (BV_ISSET(fields, 27)) {
49497 log_packet_detailed(" field 'paratroopers_range' has changed");
49498
49499#ifdef FREECIV_JSON_CONNECTION
49500 field_addr.name = "paratroopers_range";
49501#endif /* FREECIV_JSON_CONNECTION */
49502 e = 0;
49503
49504 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->paratroopers_range);
49505
49506 if (e) {
49507 log_packet_detailed("'paratroopers_range' field error detected");
49508 }
49509 }
49510
49511 if (BV_ISSET(fields, 28)) {
49512 log_packet_detailed(" field 'veteran_levels' has changed");
49513
49514#ifdef FREECIV_JSON_CONNECTION
49515 field_addr.name = "veteran_levels";
49516#endif /* FREECIV_JSON_CONNECTION */
49517 e = 0;
49518
49519 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran_levels);
49520
49521 if (e) {
49522 log_packet_detailed("'veteran_levels' field error detected");
49523 }
49524 }
49525
49526 if (BV_ISSET(fields, 29)) {
49527 log_packet_detailed(" field 'veteran_name' has changed");
49528
49529#ifdef FREECIV_JSON_CONNECTION
49530 field_addr.name = "veteran_name";
49531#endif /* FREECIV_JSON_CONNECTION */
49532 e = 0;
49533
49534 {
49535 int i;
49536
49537#ifdef FREECIV_JSON_CONNECTION
49538 /* Create the array. */
49539 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
49540
49541 /* Enter array. */
49542 field_addr.sub_location = plocation_elem_new(0);
49543#endif /* FREECIV_JSON_CONNECTION */
49544
49545 for (i = 0; i < real_packet->veteran_levels; i++) {
49546#ifdef FREECIV_JSON_CONNECTION
49547 /* Next array element. */
49548 field_addr.sub_location->number = i;
49549#endif /* FREECIV_JSON_CONNECTION */
49550
49551 e |= DIO_PUT(string, &dout, &field_addr, real_packet->veteran_name[i]);
49552 }
49553
49554#ifdef FREECIV_JSON_CONNECTION
49555 /* Exit array. */
49556 FC_FREE(field_addr.sub_location);
49557#endif /* FREECIV_JSON_CONNECTION */
49558 }
49559
49560 if (e) {
49561 log_packet_detailed("'veteran_name' field error detected");
49562 }
49563 }
49564
49565 if (BV_ISSET(fields, 30)) {
49566 log_packet_detailed(" field 'power_fact' has changed");
49567
49568#ifdef FREECIV_JSON_CONNECTION
49569 field_addr.name = "power_fact";
49570#endif /* FREECIV_JSON_CONNECTION */
49571 e = 0;
49572
49573 {
49574 int i;
49575
49576#ifdef FREECIV_JSON_CONNECTION
49577 /* Create the array. */
49578 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
49579
49580 /* Enter array. */
49581 field_addr.sub_location = plocation_elem_new(0);
49582#endif /* FREECIV_JSON_CONNECTION */
49583
49584 for (i = 0; i < real_packet->veteran_levels; i++) {
49585#ifdef FREECIV_JSON_CONNECTION
49586 /* Next array element. */
49587 field_addr.sub_location->number = i;
49588#endif /* FREECIV_JSON_CONNECTION */
49589
49590 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->power_fact[i]);
49591 }
49592
49593#ifdef FREECIV_JSON_CONNECTION
49594 /* Exit array. */
49595 FC_FREE(field_addr.sub_location);
49596#endif /* FREECIV_JSON_CONNECTION */
49597 }
49598
49599 if (e) {
49600 log_packet_detailed("'power_fact' field error detected");
49601 }
49602 }
49603
49604 if (BV_ISSET(fields, 31)) {
49605 log_packet_detailed(" field 'move_bonus' has changed");
49606
49607#ifdef FREECIV_JSON_CONNECTION
49608 field_addr.name = "move_bonus";
49609#endif /* FREECIV_JSON_CONNECTION */
49610 e = 0;
49611
49612 {
49613 int i;
49614
49615#ifdef FREECIV_JSON_CONNECTION
49616 /* Create the array. */
49617 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
49618
49619 /* Enter array. */
49620 field_addr.sub_location = plocation_elem_new(0);
49621#endif /* FREECIV_JSON_CONNECTION */
49622
49623 for (i = 0; i < real_packet->veteran_levels; i++) {
49624#ifdef FREECIV_JSON_CONNECTION
49625 /* Next array element. */
49626 field_addr.sub_location->number = i;
49627#endif /* FREECIV_JSON_CONNECTION */
49628
49629 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_bonus[i]);
49630 }
49631
49632#ifdef FREECIV_JSON_CONNECTION
49633 /* Exit array. */
49634 FC_FREE(field_addr.sub_location);
49635#endif /* FREECIV_JSON_CONNECTION */
49636 }
49637
49638 if (e) {
49639 log_packet_detailed("'move_bonus' field error detected");
49640 }
49641 }
49642
49643 if (BV_ISSET(fields, 32)) {
49644 log_packet_detailed(" field 'base_raise_chance' has changed");
49645
49646#ifdef FREECIV_JSON_CONNECTION
49647 field_addr.name = "base_raise_chance";
49648#endif /* FREECIV_JSON_CONNECTION */
49649 e = 0;
49650
49651 {
49652 int i;
49653
49654#ifdef FREECIV_JSON_CONNECTION
49655 /* Create the array. */
49656 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
49657
49658 /* Enter array. */
49659 field_addr.sub_location = plocation_elem_new(0);
49660#endif /* FREECIV_JSON_CONNECTION */
49661
49662 for (i = 0; i < real_packet->veteran_levels; i++) {
49663#ifdef FREECIV_JSON_CONNECTION
49664 /* Next array element. */
49665 field_addr.sub_location->number = i;
49666#endif /* FREECIV_JSON_CONNECTION */
49667
49668 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->base_raise_chance[i]);
49669 }
49670
49671#ifdef FREECIV_JSON_CONNECTION
49672 /* Exit array. */
49673 FC_FREE(field_addr.sub_location);
49674#endif /* FREECIV_JSON_CONNECTION */
49675 }
49676
49677 if (e) {
49678 log_packet_detailed("'base_raise_chance' field error detected");
49679 }
49680 }
49681
49682 if (BV_ISSET(fields, 33)) {
49683 log_packet_detailed(" field 'work_raise_chance' has changed");
49684
49685#ifdef FREECIV_JSON_CONNECTION
49686 field_addr.name = "work_raise_chance";
49687#endif /* FREECIV_JSON_CONNECTION */
49688 e = 0;
49689
49690 {
49691 int i;
49692
49693#ifdef FREECIV_JSON_CONNECTION
49694 /* Create the array. */
49695 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
49696
49697 /* Enter array. */
49698 field_addr.sub_location = plocation_elem_new(0);
49699#endif /* FREECIV_JSON_CONNECTION */
49700
49701 for (i = 0; i < real_packet->veteran_levels; i++) {
49702#ifdef FREECIV_JSON_CONNECTION
49703 /* Next array element. */
49704 field_addr.sub_location->number = i;
49705#endif /* FREECIV_JSON_CONNECTION */
49706
49707 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->work_raise_chance[i]);
49708 }
49709
49710#ifdef FREECIV_JSON_CONNECTION
49711 /* Exit array. */
49712 FC_FREE(field_addr.sub_location);
49713#endif /* FREECIV_JSON_CONNECTION */
49714 }
49715
49716 if (e) {
49717 log_packet_detailed("'work_raise_chance' field error detected");
49718 }
49719 }
49720
49721 if (BV_ISSET(fields, 34)) {
49722 log_packet_detailed(" field 'bombard_rate' has changed");
49723
49724#ifdef FREECIV_JSON_CONNECTION
49725 field_addr.name = "bombard_rate";
49726#endif /* FREECIV_JSON_CONNECTION */
49727 e = 0;
49728
49729 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->bombard_rate);
49730
49731 if (e) {
49732 log_packet_detailed("'bombard_rate' field error detected");
49733 }
49734 }
49735
49736 if (BV_ISSET(fields, 35)) {
49737 log_packet_detailed(" field 'city_size' has changed");
49738
49739#ifdef FREECIV_JSON_CONNECTION
49740 field_addr.name = "city_size";
49741#endif /* FREECIV_JSON_CONNECTION */
49742 e = 0;
49743
49744 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->city_size);
49745
49746 if (e) {
49747 log_packet_detailed("'city_size' field error detected");
49748 }
49749 }
49750
49751 if (BV_ISSET(fields, 36)) {
49752 log_packet_detailed(" field 'city_slots' has changed");
49753
49754#ifdef FREECIV_JSON_CONNECTION
49755 field_addr.name = "city_slots";
49756#endif /* FREECIV_JSON_CONNECTION */
49757 e = 0;
49758
49759 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->city_slots);
49760
49761 if (e) {
49762 log_packet_detailed("'city_slots' field error detected");
49763 }
49764 }
49765
49766 if (BV_ISSET(fields, 37)) {
49767 log_packet_detailed(" field 'tp_defense' has changed");
49768
49769#ifdef FREECIV_JSON_CONNECTION
49770 field_addr.name = "tp_defense";
49771#endif /* FREECIV_JSON_CONNECTION */
49772 e = 0;
49773
49774 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tp_defense);
49775
49776 if (e) {
49777 log_packet_detailed("'tp_defense' field error detected");
49778 }
49779 }
49780
49781 if (BV_ISSET(fields, 38)) {
49782 log_packet_detailed(" field 'cargo' has changed");
49783
49784#ifdef FREECIV_JSON_CONNECTION
49785 field_addr.name = "cargo";
49786#endif /* FREECIV_JSON_CONNECTION */
49787 e = 0;
49788
49789 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->cargo);
49790
49791 if (e) {
49792 log_packet_detailed("'cargo' field error detected");
49793 }
49794 }
49795
49796 if (BV_ISSET(fields, 39)) {
49797 log_packet_detailed(" field 'targets' has changed");
49798
49799#ifdef FREECIV_JSON_CONNECTION
49800 field_addr.name = "targets";
49801#endif /* FREECIV_JSON_CONNECTION */
49802 e = 0;
49803
49804 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->targets);
49805
49806 if (e) {
49807 log_packet_detailed("'targets' field error detected");
49808 }
49809 }
49810
49811 if (BV_ISSET(fields, 40)) {
49812 log_packet_detailed(" field 'embarks' has changed");
49813
49814#ifdef FREECIV_JSON_CONNECTION
49815 field_addr.name = "embarks";
49816#endif /* FREECIV_JSON_CONNECTION */
49817 e = 0;
49818
49819 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->embarks);
49820
49821 if (e) {
49822 log_packet_detailed("'embarks' field error detected");
49823 }
49824 }
49825
49826 if (BV_ISSET(fields, 41)) {
49827 log_packet_detailed(" field 'disembarks' has changed");
49828
49829#ifdef FREECIV_JSON_CONNECTION
49830 field_addr.name = "disembarks";
49831#endif /* FREECIV_JSON_CONNECTION */
49832 e = 0;
49833
49834 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->disembarks);
49835
49836 if (e) {
49837 log_packet_detailed("'disembarks' field error detected");
49838 }
49839 }
49840
49841 if (BV_ISSET(fields, 42)) {
49842 log_packet_detailed(" field 'vlayer' has changed");
49843
49844#ifdef FREECIV_JSON_CONNECTION
49845 field_addr.name = "vlayer";
49846#endif /* FREECIV_JSON_CONNECTION */
49847 e = 0;
49848
49849 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->vlayer);
49850
49851 if (e) {
49852 log_packet_detailed("'vlayer' field error detected");
49853 }
49854 }
49855
49856 if (BV_ISSET(fields, 43)) {
49857 log_packet_detailed(" field 'helptext' has changed");
49858
49859#ifdef FREECIV_JSON_CONNECTION
49860 field_addr.name = "helptext";
49861#endif /* FREECIV_JSON_CONNECTION */
49862 e = 0;
49863
49864 if (!real_packet->helptext) {
49865 /* Transmit null as empty */
49866 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
49867 } else {
49868 int i;
49869
49870 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
49871 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
49872
49873#ifdef FREECIV_JSON_CONNECTION
49874 /* Enter array. */
49875 field_addr.sub_location = plocation_elem_new(0);
49876#endif /* FREECIV_JSON_CONNECTION */
49877
49878 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
49879#ifdef FREECIV_JSON_CONNECTION
49880 /* Next array element. */
49881 field_addr.sub_location->number = i;
49882#endif /* FREECIV_JSON_CONNECTION */
49883
49884 {
49885 const char *pstr = strvec_get(real_packet->helptext, i);
49886
49887 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
49888 }
49889 }
49890
49891#ifdef FREECIV_JSON_CONNECTION
49892 /* Exit array. */
49893 FC_FREE(field_addr.sub_location);
49894#endif /* FREECIV_JSON_CONNECTION */
49895 }
49896
49897 if (e) {
49898 log_packet_detailed("'helptext' field error detected");
49899 }
49900 }
49901
49902 if (BV_ISSET(fields, 44)) {
49903 log_packet_detailed(" field 'flags' has changed");
49904
49905#ifdef FREECIV_JSON_CONNECTION
49906 field_addr.name = "flags";
49907#endif /* FREECIV_JSON_CONNECTION */
49908 e = 0;
49909
49910 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
49911
49912 if (e) {
49913 log_packet_detailed("'flags' field error detected");
49914 }
49915 }
49916
49917 if (BV_ISSET(fields, 45)) {
49918 log_packet_detailed(" field 'roles' has changed");
49919
49920#ifdef FREECIV_JSON_CONNECTION
49921 field_addr.name = "roles";
49922#endif /* FREECIV_JSON_CONNECTION */
49923 e = 0;
49924
49925 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->roles);
49926
49927 if (e) {
49928 log_packet_detailed("'roles' field error detected");
49929 }
49930 }
49931
49932 /* field 46 is folded into the header */
49933
49934 old->id = real_packet->id;
49935 sz_strlcpy(old->name, real_packet->name);
49936 sz_strlcpy(old->rule_name, real_packet->rule_name);
49937 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
49938 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
49939 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
49940 sz_strlcpy(old->sound_move, real_packet->sound_move);
49941 sz_strlcpy(old->sound_move_alt, real_packet->sound_move_alt);
49942 sz_strlcpy(old->sound_fight, real_packet->sound_fight);
49943 sz_strlcpy(old->sound_fight_alt, real_packet->sound_fight_alt);
49944 old->unit_class_id = real_packet->unit_class_id;
49945 old->build_cost = real_packet->build_cost;
49946 old->pop_cost = real_packet->pop_cost;
49947 old->attack_strength = real_packet->attack_strength;
49948 old->defense_strength = real_packet->defense_strength;
49949 old->move_rate = real_packet->move_rate;
49950 requirement_vector_copy(&old->build_reqs, &real_packet->build_reqs);
49951 old->vision_radius_sq = real_packet->vision_radius_sq;
49952 old->transport_capacity = real_packet->transport_capacity;
49953 old->hp = real_packet->hp;
49954 old->firepower = real_packet->firepower;
49955 old->obsoleted_by = real_packet->obsoleted_by;
49956 old->converted_to = real_packet->converted_to;
49957 old->convert_time = real_packet->convert_time;
49958 old->fuel = real_packet->fuel;
49959 old->happy_cost = real_packet->happy_cost;
49960 {
49961 int i;
49962
49963 for (i = 0; i < O_LAST; i++) {
49964 old->upkeep[i] = real_packet->upkeep[i];
49965 }
49966 }
49967 old->paratroopers_range = real_packet->paratroopers_range;
49968 old->veteran_levels = real_packet->veteran_levels;
49969 {
49970 int i;
49971
49972 for (i = 0; i < real_packet->veteran_levels; i++) {
49973 sz_strlcpy(old->veteran_name[i], real_packet->veteran_name[i]);
49974 }
49975 }
49976 {
49977 int i;
49978
49979 for (i = 0; i < real_packet->veteran_levels; i++) {
49980 old->power_fact[i] = real_packet->power_fact[i];
49981 }
49982 }
49983 {
49984 int i;
49985
49986 for (i = 0; i < real_packet->veteran_levels; i++) {
49987 old->move_bonus[i] = real_packet->move_bonus[i];
49988 }
49989 }
49990 {
49991 int i;
49992
49993 for (i = 0; i < real_packet->veteran_levels; i++) {
49994 old->base_raise_chance[i] = real_packet->base_raise_chance[i];
49995 }
49996 }
49997 {
49998 int i;
49999
50000 for (i = 0; i < real_packet->veteran_levels; i++) {
50001 old->work_raise_chance[i] = real_packet->work_raise_chance[i];
50002 }
50003 }
50004 old->bombard_rate = real_packet->bombard_rate;
50005 old->city_size = real_packet->city_size;
50006 old->city_slots = real_packet->city_slots;
50007 old->tp_defense = real_packet->tp_defense;
50008 old->cargo = real_packet->cargo;
50009 old->targets = real_packet->targets;
50010 old->embarks = real_packet->embarks;
50011 old->disembarks = real_packet->disembarks;
50012 old->vlayer = real_packet->vlayer;
50013 if (real_packet->helptext) {
50014 strvec_copy(old->helptext, real_packet->helptext);
50015 } else {
50016 strvec_clear(old->helptext);
50017 }
50018 old->flags = real_packet->flags;
50019 old->roles = real_packet->roles;
50020 old->worker = real_packet->worker;
50021
50022#else /* FREECIV_DELTA_PROTOCOL */
50023#ifdef FREECIV_JSON_CONNECTION
50024 field_addr.name = "id";
50025#endif /* FREECIV_JSON_CONNECTION */
50026 e = 0;
50027
50028 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
50029
50030 if (e) {
50031 log_packet_detailed("'id' field error detected");
50032 }
50033
50034#ifdef FREECIV_JSON_CONNECTION
50035 field_addr.name = "name";
50036#endif /* FREECIV_JSON_CONNECTION */
50037 e = 0;
50038
50039 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
50040
50041 if (e) {
50042 log_packet_detailed("'name' field error detected");
50043 }
50044
50045#ifdef FREECIV_JSON_CONNECTION
50046 field_addr.name = "rule_name";
50047#endif /* FREECIV_JSON_CONNECTION */
50048 e = 0;
50049
50050 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
50051
50052 if (e) {
50053 log_packet_detailed("'rule_name' field error detected");
50054 }
50055
50056#ifdef FREECIV_JSON_CONNECTION
50057 field_addr.name = "graphic_str";
50058#endif /* FREECIV_JSON_CONNECTION */
50059 e = 0;
50060
50061 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
50062
50063 if (e) {
50064 log_packet_detailed("'graphic_str' field error detected");
50065 }
50066
50067#ifdef FREECIV_JSON_CONNECTION
50068 field_addr.name = "graphic_alt";
50069#endif /* FREECIV_JSON_CONNECTION */
50070 e = 0;
50071
50072 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
50073
50074 if (e) {
50075 log_packet_detailed("'graphic_alt' field error detected");
50076 }
50077
50078#ifdef FREECIV_JSON_CONNECTION
50079 field_addr.name = "graphic_alt2";
50080#endif /* FREECIV_JSON_CONNECTION */
50081 e = 0;
50082
50083 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt2);
50084
50085 if (e) {
50086 log_packet_detailed("'graphic_alt2' field error detected");
50087 }
50088
50089#ifdef FREECIV_JSON_CONNECTION
50090 field_addr.name = "sound_move";
50091#endif /* FREECIV_JSON_CONNECTION */
50092 e = 0;
50093
50094 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_move);
50095
50096 if (e) {
50097 log_packet_detailed("'sound_move' field error detected");
50098 }
50099
50100#ifdef FREECIV_JSON_CONNECTION
50101 field_addr.name = "sound_move_alt";
50102#endif /* FREECIV_JSON_CONNECTION */
50103 e = 0;
50104
50105 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_move_alt);
50106
50107 if (e) {
50108 log_packet_detailed("'sound_move_alt' field error detected");
50109 }
50110
50111#ifdef FREECIV_JSON_CONNECTION
50112 field_addr.name = "sound_fight";
50113#endif /* FREECIV_JSON_CONNECTION */
50114 e = 0;
50115
50116 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_fight);
50117
50118 if (e) {
50119 log_packet_detailed("'sound_fight' field error detected");
50120 }
50121
50122#ifdef FREECIV_JSON_CONNECTION
50123 field_addr.name = "sound_fight_alt";
50124#endif /* FREECIV_JSON_CONNECTION */
50125 e = 0;
50126
50127 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_fight_alt);
50128
50129 if (e) {
50130 log_packet_detailed("'sound_fight_alt' field error detected");
50131 }
50132
50133#ifdef FREECIV_JSON_CONNECTION
50134 field_addr.name = "unit_class_id";
50135#endif /* FREECIV_JSON_CONNECTION */
50136 e = 0;
50137
50138 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->unit_class_id);
50139
50140 if (e) {
50141 log_packet_detailed("'unit_class_id' field error detected");
50142 }
50143
50144#ifdef FREECIV_JSON_CONNECTION
50145 field_addr.name = "build_cost";
50146#endif /* FREECIV_JSON_CONNECTION */
50147 e = 0;
50148
50149 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->build_cost);
50150
50151 if (e) {
50152 log_packet_detailed("'build_cost' field error detected");
50153 }
50154
50155#ifdef FREECIV_JSON_CONNECTION
50156 field_addr.name = "pop_cost";
50157#endif /* FREECIV_JSON_CONNECTION */
50158 e = 0;
50159
50160 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->pop_cost);
50161
50162 if (e) {
50163 log_packet_detailed("'pop_cost' field error detected");
50164 }
50165
50166#ifdef FREECIV_JSON_CONNECTION
50167 field_addr.name = "attack_strength";
50168#endif /* FREECIV_JSON_CONNECTION */
50169 e = 0;
50170
50171 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->attack_strength);
50172
50173 if (e) {
50174 log_packet_detailed("'attack_strength' field error detected");
50175 }
50176
50177#ifdef FREECIV_JSON_CONNECTION
50178 field_addr.name = "defense_strength";
50179#endif /* FREECIV_JSON_CONNECTION */
50180 e = 0;
50181
50182 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->defense_strength);
50183
50184 if (e) {
50185 log_packet_detailed("'defense_strength' field error detected");
50186 }
50187
50188#ifdef FREECIV_JSON_CONNECTION
50189 field_addr.name = "move_rate";
50190#endif /* FREECIV_JSON_CONNECTION */
50191 e = 0;
50192
50193 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_rate);
50194
50195 if (e) {
50196 log_packet_detailed("'move_rate' field error detected");
50197 }
50198
50199#ifdef FREECIV_JSON_CONNECTION
50200 field_addr.name = "build_reqs";
50201#endif /* FREECIV_JSON_CONNECTION */
50202 e = 0;
50203
50204 {
50205 int i;
50206
50207 fc_assert(requirement_vector_size(&real_packet->build_reqs) < MAX_UINT16);
50208 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->build_reqs));
50209
50210#ifdef FREECIV_JSON_CONNECTION
50211 /* Enter array. */
50212 field_addr.sub_location = plocation_elem_new(0);
50213#endif /* FREECIV_JSON_CONNECTION */
50214
50215 for (i = 0; i < requirement_vector_size(&real_packet->build_reqs); i++) {
50216#ifdef FREECIV_JSON_CONNECTION
50217 /* Next array element. */
50218 field_addr.sub_location->number = i;
50219#endif /* FREECIV_JSON_CONNECTION */
50220
50221 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->build_reqs.p[i]);
50222 }
50223
50224#ifdef FREECIV_JSON_CONNECTION
50225 /* Exit array. */
50226 FC_FREE(field_addr.sub_location);
50227#endif /* FREECIV_JSON_CONNECTION */
50228 }
50229
50230 if (e) {
50231 log_packet_detailed("'build_reqs' field error detected");
50232 }
50233
50234#ifdef FREECIV_JSON_CONNECTION
50235 field_addr.name = "vision_radius_sq";
50236#endif /* FREECIV_JSON_CONNECTION */
50237 e = 0;
50238
50239 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->vision_radius_sq);
50240
50241 if (e) {
50242 log_packet_detailed("'vision_radius_sq' field error detected");
50243 }
50244
50245#ifdef FREECIV_JSON_CONNECTION
50246 field_addr.name = "transport_capacity";
50247#endif /* FREECIV_JSON_CONNECTION */
50248 e = 0;
50249
50250 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->transport_capacity);
50251
50252 if (e) {
50253 log_packet_detailed("'transport_capacity' field error detected");
50254 }
50255
50256#ifdef FREECIV_JSON_CONNECTION
50257 field_addr.name = "hp";
50258#endif /* FREECIV_JSON_CONNECTION */
50259 e = 0;
50260
50261 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
50262
50263 if (e) {
50264 log_packet_detailed("'hp' field error detected");
50265 }
50266
50267#ifdef FREECIV_JSON_CONNECTION
50268 field_addr.name = "firepower";
50269#endif /* FREECIV_JSON_CONNECTION */
50270 e = 0;
50271
50272 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->firepower);
50273
50274 if (e) {
50275 log_packet_detailed("'firepower' field error detected");
50276 }
50277
50278#ifdef FREECIV_JSON_CONNECTION
50279 field_addr.name = "obsoleted_by";
50280#endif /* FREECIV_JSON_CONNECTION */
50281 e = 0;
50282
50283 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->obsoleted_by);
50284
50285 if (e) {
50286 log_packet_detailed("'obsoleted_by' field error detected");
50287 }
50288
50289#ifdef FREECIV_JSON_CONNECTION
50290 field_addr.name = "converted_to";
50291#endif /* FREECIV_JSON_CONNECTION */
50292 e = 0;
50293
50294 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->converted_to);
50295
50296 if (e) {
50297 log_packet_detailed("'converted_to' field error detected");
50298 }
50299
50300#ifdef FREECIV_JSON_CONNECTION
50301 field_addr.name = "convert_time";
50302#endif /* FREECIV_JSON_CONNECTION */
50303 e = 0;
50304
50305 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->convert_time);
50306
50307 if (e) {
50308 log_packet_detailed("'convert_time' field error detected");
50309 }
50310
50311#ifdef FREECIV_JSON_CONNECTION
50312 field_addr.name = "fuel";
50313#endif /* FREECIV_JSON_CONNECTION */
50314 e = 0;
50315
50316 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
50317
50318 if (e) {
50319 log_packet_detailed("'fuel' field error detected");
50320 }
50321
50322#ifdef FREECIV_JSON_CONNECTION
50323 field_addr.name = "happy_cost";
50324#endif /* FREECIV_JSON_CONNECTION */
50325 e = 0;
50326
50327 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->happy_cost);
50328
50329 if (e) {
50330 log_packet_detailed("'happy_cost' field error detected");
50331 }
50332
50333#ifdef FREECIV_JSON_CONNECTION
50334 field_addr.name = "upkeep";
50335#endif /* FREECIV_JSON_CONNECTION */
50336 e = 0;
50337
50338 {
50339 int i;
50340
50341#ifdef FREECIV_JSON_CONNECTION
50342 /* Create the array. */
50343 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
50344
50345 /* Enter array. */
50346 field_addr.sub_location = plocation_elem_new(0);
50347#endif /* FREECIV_JSON_CONNECTION */
50348
50349 for (i = 0; i < O_LAST; i++) {
50350#ifdef FREECIV_JSON_CONNECTION
50351 /* Next array element. */
50352 field_addr.sub_location->number = i;
50353#endif /* FREECIV_JSON_CONNECTION */
50354
50355 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->upkeep[i]);
50356 }
50357
50358#ifdef FREECIV_JSON_CONNECTION
50359 /* Exit array. */
50360 FC_FREE(field_addr.sub_location);
50361#endif /* FREECIV_JSON_CONNECTION */
50362 }
50363
50364 if (e) {
50365 log_packet_detailed("'upkeep' field error detected");
50366 }
50367
50368#ifdef FREECIV_JSON_CONNECTION
50369 field_addr.name = "paratroopers_range";
50370#endif /* FREECIV_JSON_CONNECTION */
50371 e = 0;
50372
50373 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->paratroopers_range);
50374
50375 if (e) {
50376 log_packet_detailed("'paratroopers_range' field error detected");
50377 }
50378
50379#ifdef FREECIV_JSON_CONNECTION
50380 field_addr.name = "veteran_levels";
50381#endif /* FREECIV_JSON_CONNECTION */
50382 e = 0;
50383
50384 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran_levels);
50385
50386 if (e) {
50387 log_packet_detailed("'veteran_levels' field error detected");
50388 }
50389
50390#ifdef FREECIV_JSON_CONNECTION
50391 field_addr.name = "veteran_name";
50392#endif /* FREECIV_JSON_CONNECTION */
50393 e = 0;
50394
50395 {
50396 int i;
50397
50398#ifdef FREECIV_JSON_CONNECTION
50399 /* Create the array. */
50400 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
50401
50402 /* Enter array. */
50403 field_addr.sub_location = plocation_elem_new(0);
50404#endif /* FREECIV_JSON_CONNECTION */
50405
50406 for (i = 0; i < real_packet->veteran_levels; i++) {
50407#ifdef FREECIV_JSON_CONNECTION
50408 /* Next array element. */
50409 field_addr.sub_location->number = i;
50410#endif /* FREECIV_JSON_CONNECTION */
50411
50412 e |= DIO_PUT(string, &dout, &field_addr, real_packet->veteran_name[i]);
50413 }
50414
50415#ifdef FREECIV_JSON_CONNECTION
50416 /* Exit array. */
50417 FC_FREE(field_addr.sub_location);
50418#endif /* FREECIV_JSON_CONNECTION */
50419 }
50420
50421 if (e) {
50422 log_packet_detailed("'veteran_name' field error detected");
50423 }
50424
50425#ifdef FREECIV_JSON_CONNECTION
50426 field_addr.name = "power_fact";
50427#endif /* FREECIV_JSON_CONNECTION */
50428 e = 0;
50429
50430 {
50431 int i;
50432
50433#ifdef FREECIV_JSON_CONNECTION
50434 /* Create the array. */
50435 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
50436
50437 /* Enter array. */
50438 field_addr.sub_location = plocation_elem_new(0);
50439#endif /* FREECIV_JSON_CONNECTION */
50440
50441 for (i = 0; i < real_packet->veteran_levels; i++) {
50442#ifdef FREECIV_JSON_CONNECTION
50443 /* Next array element. */
50444 field_addr.sub_location->number = i;
50445#endif /* FREECIV_JSON_CONNECTION */
50446
50447 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->power_fact[i]);
50448 }
50449
50450#ifdef FREECIV_JSON_CONNECTION
50451 /* Exit array. */
50452 FC_FREE(field_addr.sub_location);
50453#endif /* FREECIV_JSON_CONNECTION */
50454 }
50455
50456 if (e) {
50457 log_packet_detailed("'power_fact' field error detected");
50458 }
50459
50460#ifdef FREECIV_JSON_CONNECTION
50461 field_addr.name = "move_bonus";
50462#endif /* FREECIV_JSON_CONNECTION */
50463 e = 0;
50464
50465 {
50466 int i;
50467
50468#ifdef FREECIV_JSON_CONNECTION
50469 /* Create the array. */
50470 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
50471
50472 /* Enter array. */
50473 field_addr.sub_location = plocation_elem_new(0);
50474#endif /* FREECIV_JSON_CONNECTION */
50475
50476 for (i = 0; i < real_packet->veteran_levels; i++) {
50477#ifdef FREECIV_JSON_CONNECTION
50478 /* Next array element. */
50479 field_addr.sub_location->number = i;
50480#endif /* FREECIV_JSON_CONNECTION */
50481
50482 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_bonus[i]);
50483 }
50484
50485#ifdef FREECIV_JSON_CONNECTION
50486 /* Exit array. */
50487 FC_FREE(field_addr.sub_location);
50488#endif /* FREECIV_JSON_CONNECTION */
50489 }
50490
50491 if (e) {
50492 log_packet_detailed("'move_bonus' field error detected");
50493 }
50494
50495#ifdef FREECIV_JSON_CONNECTION
50496 field_addr.name = "base_raise_chance";
50497#endif /* FREECIV_JSON_CONNECTION */
50498 e = 0;
50499
50500 {
50501 int i;
50502
50503#ifdef FREECIV_JSON_CONNECTION
50504 /* Create the array. */
50505 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
50506
50507 /* Enter array. */
50508 field_addr.sub_location = plocation_elem_new(0);
50509#endif /* FREECIV_JSON_CONNECTION */
50510
50511 for (i = 0; i < real_packet->veteran_levels; i++) {
50512#ifdef FREECIV_JSON_CONNECTION
50513 /* Next array element. */
50514 field_addr.sub_location->number = i;
50515#endif /* FREECIV_JSON_CONNECTION */
50516
50517 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->base_raise_chance[i]);
50518 }
50519
50520#ifdef FREECIV_JSON_CONNECTION
50521 /* Exit array. */
50522 FC_FREE(field_addr.sub_location);
50523#endif /* FREECIV_JSON_CONNECTION */
50524 }
50525
50526 if (e) {
50527 log_packet_detailed("'base_raise_chance' field error detected");
50528 }
50529
50530#ifdef FREECIV_JSON_CONNECTION
50531 field_addr.name = "work_raise_chance";
50532#endif /* FREECIV_JSON_CONNECTION */
50533 e = 0;
50534
50535 {
50536 int i;
50537
50538#ifdef FREECIV_JSON_CONNECTION
50539 /* Create the array. */
50540 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
50541
50542 /* Enter array. */
50543 field_addr.sub_location = plocation_elem_new(0);
50544#endif /* FREECIV_JSON_CONNECTION */
50545
50546 for (i = 0; i < real_packet->veteran_levels; i++) {
50547#ifdef FREECIV_JSON_CONNECTION
50548 /* Next array element. */
50549 field_addr.sub_location->number = i;
50550#endif /* FREECIV_JSON_CONNECTION */
50551
50552 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->work_raise_chance[i]);
50553 }
50554
50555#ifdef FREECIV_JSON_CONNECTION
50556 /* Exit array. */
50557 FC_FREE(field_addr.sub_location);
50558#endif /* FREECIV_JSON_CONNECTION */
50559 }
50560
50561 if (e) {
50562 log_packet_detailed("'work_raise_chance' field error detected");
50563 }
50564
50565#ifdef FREECIV_JSON_CONNECTION
50566 field_addr.name = "bombard_rate";
50567#endif /* FREECIV_JSON_CONNECTION */
50568 e = 0;
50569
50570 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->bombard_rate);
50571
50572 if (e) {
50573 log_packet_detailed("'bombard_rate' field error detected");
50574 }
50575
50576#ifdef FREECIV_JSON_CONNECTION
50577 field_addr.name = "city_size";
50578#endif /* FREECIV_JSON_CONNECTION */
50579 e = 0;
50580
50581 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->city_size);
50582
50583 if (e) {
50584 log_packet_detailed("'city_size' field error detected");
50585 }
50586
50587#ifdef FREECIV_JSON_CONNECTION
50588 field_addr.name = "city_slots";
50589#endif /* FREECIV_JSON_CONNECTION */
50590 e = 0;
50591
50592 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->city_slots);
50593
50594 if (e) {
50595 log_packet_detailed("'city_slots' field error detected");
50596 }
50597
50598#ifdef FREECIV_JSON_CONNECTION
50599 field_addr.name = "tp_defense";
50600#endif /* FREECIV_JSON_CONNECTION */
50601 e = 0;
50602
50603 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tp_defense);
50604
50605 if (e) {
50606 log_packet_detailed("'tp_defense' field error detected");
50607 }
50608
50609#ifdef FREECIV_JSON_CONNECTION
50610 field_addr.name = "cargo";
50611#endif /* FREECIV_JSON_CONNECTION */
50612 e = 0;
50613
50614 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->cargo);
50615
50616 if (e) {
50617 log_packet_detailed("'cargo' field error detected");
50618 }
50619
50620#ifdef FREECIV_JSON_CONNECTION
50621 field_addr.name = "targets";
50622#endif /* FREECIV_JSON_CONNECTION */
50623 e = 0;
50624
50625 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->targets);
50626
50627 if (e) {
50628 log_packet_detailed("'targets' field error detected");
50629 }
50630
50631#ifdef FREECIV_JSON_CONNECTION
50632 field_addr.name = "embarks";
50633#endif /* FREECIV_JSON_CONNECTION */
50634 e = 0;
50635
50636 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->embarks);
50637
50638 if (e) {
50639 log_packet_detailed("'embarks' field error detected");
50640 }
50641
50642#ifdef FREECIV_JSON_CONNECTION
50643 field_addr.name = "disembarks";
50644#endif /* FREECIV_JSON_CONNECTION */
50645 e = 0;
50646
50647 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->disembarks);
50648
50649 if (e) {
50650 log_packet_detailed("'disembarks' field error detected");
50651 }
50652
50653#ifdef FREECIV_JSON_CONNECTION
50654 field_addr.name = "vlayer";
50655#endif /* FREECIV_JSON_CONNECTION */
50656 e = 0;
50657
50658 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->vlayer);
50659
50660 if (e) {
50661 log_packet_detailed("'vlayer' field error detected");
50662 }
50663
50664#ifdef FREECIV_JSON_CONNECTION
50665 field_addr.name = "helptext";
50666#endif /* FREECIV_JSON_CONNECTION */
50667 e = 0;
50668
50669 if (!real_packet->helptext) {
50670 /* Transmit null as empty */
50671 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
50672 } else {
50673 int i;
50674
50675 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
50676 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
50677
50678#ifdef FREECIV_JSON_CONNECTION
50679 /* Enter array. */
50680 field_addr.sub_location = plocation_elem_new(0);
50681#endif /* FREECIV_JSON_CONNECTION */
50682
50683 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
50684#ifdef FREECIV_JSON_CONNECTION
50685 /* Next array element. */
50686 field_addr.sub_location->number = i;
50687#endif /* FREECIV_JSON_CONNECTION */
50688
50689 {
50690 const char *pstr = strvec_get(real_packet->helptext, i);
50691
50692 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
50693 }
50694 }
50695
50696#ifdef FREECIV_JSON_CONNECTION
50697 /* Exit array. */
50698 FC_FREE(field_addr.sub_location);
50699#endif /* FREECIV_JSON_CONNECTION */
50700 }
50701
50702 if (e) {
50703 log_packet_detailed("'helptext' field error detected");
50704 }
50705
50706#ifdef FREECIV_JSON_CONNECTION
50707 field_addr.name = "flags";
50708#endif /* FREECIV_JSON_CONNECTION */
50709 e = 0;
50710
50711 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
50712
50713 if (e) {
50714 log_packet_detailed("'flags' field error detected");
50715 }
50716
50717#ifdef FREECIV_JSON_CONNECTION
50718 field_addr.name = "roles";
50719#endif /* FREECIV_JSON_CONNECTION */
50720 e = 0;
50721
50722 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->roles);
50723
50724 if (e) {
50725 log_packet_detailed("'roles' field error detected");
50726 }
50727
50728#ifdef FREECIV_JSON_CONNECTION
50729 field_addr.name = "worker";
50730#endif /* FREECIV_JSON_CONNECTION */
50731 e = 0;
50732
50733 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->worker);
50734
50735 if (e) {
50736 log_packet_detailed("'worker' field error detected");
50737 }
50738#endif /* FREECIV_DELTA_PROTOCOL */
50739
50740 SEND_PACKET_END(PACKET_RULESET_UNIT);
50741}
50742
50743 int send_packet_ruleset_unit(struct connection *pc, const struct packet_ruleset_unit *packet)
50744{
50745 if (!pc->used) {
50746 log_error("WARNING: trying to send data to the closed connection %s",
50747 conn_description(pc));
50748 return -1;
50749 }
50750 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT].packet != nullptr, -1,
50751 "Handler for PACKET_RULESET_UNIT not installed");
50752 return pc->phs.handlers->send[PACKET_RULESET_UNIT].packet(pc, packet);
50753}
50754
50755 void lsend_packet_ruleset_unit(struct conn_list *dest, const struct packet_ruleset_unit *packet)
50756{
50757 conn_list_iterate(dest, pconn) {
50758 send_packet_ruleset_unit(pconn, packet);
50759 } conn_list_iterate_end;
50760}
50761
50762 static inline void init_packet_ruleset_unit_bonus(struct packet_ruleset_unit_bonus *packet)
50763{
50764 memset(packet, 0, sizeof(*packet));
50765}
50766
50767#define free_packet_ruleset_unit_bonus(_packet) (void) 0
50768#define destroy_packet_ruleset_unit_bonus free
50769
50770#ifdef FREECIV_DELTA_PROTOCOL
50771#define hash_packet_ruleset_unit_bonus_100 hash_const
50772#define cmp_packet_ruleset_unit_bonus_100 cmp_const
50773 BV_DEFINE(packet_ruleset_unit_bonus_100_fields, 5);
50774#endif /* FREECIV_DELTA_PROTOCOL */
50775
50776 static struct packet_ruleset_unit_bonus *receive_packet_ruleset_unit_bonus_100(struct connection *pc)
50777{
50778#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_unit_bonus(_packet)
50779 RECEIVE_PACKET_START(packet_ruleset_unit_bonus, real_packet);
50780
50781#ifdef FREECIV_JSON_CONNECTION
50782 struct plocation field_addr;
50783 {
50784 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
50785 field_addr = *field_addr_tmp;
50786 FC_FREE(field_addr_tmp);
50787 }
50788#endif /* FREECIV_JSON_CONNECTION */
50789
50790 log_packet_detailed("packet_ruleset_unit_bonus_100: got info about ()");
50791
50792#ifdef FREECIV_DELTA_PROTOCOL
50793 packet_ruleset_unit_bonus_100_fields fields;
50794 struct packet_ruleset_unit_bonus *old;
50795 struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_BONUS;
50796
50797 if (nullptr == *hash) {
50798 *hash = genhash_new_full(hash_packet_ruleset_unit_bonus_100, cmp_packet_ruleset_unit_bonus_100,
50799 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_bonus);
50800 }
50801
50802 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
50803 *real_packet = *old;
50804 } else {
50805 /* packet is already initialized empty */
50806 log_packet_detailed(" no old info");
50807 }
50808
50809#ifdef FREECIV_JSON_CONNECTION
50810 field_addr.name = "fields";
50811#endif /* FREECIV_JSON_CONNECTION */
50812 DIO_BV_GET(&din, &field_addr, fields);
50813
50814 if (BV_ISSET(fields, 0)) {
50815 log_packet_detailed(" got field 'unit'");
50816
50817#ifdef FREECIV_JSON_CONNECTION
50818 field_addr.name = "unit";
50819#endif /* FREECIV_JSON_CONNECTION */
50820
50821 {
50822 int readin;
50823
50824 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
50825 RECEIVE_PACKET_FIELD_ERROR(unit);
50826 }
50827 real_packet->unit = readin;
50828 }
50829 }
50830
50831 if (BV_ISSET(fields, 1)) {
50832 log_packet_detailed(" got field 'flag'");
50833
50834#ifdef FREECIV_JSON_CONNECTION
50835 field_addr.name = "flag";
50836#endif /* FREECIV_JSON_CONNECTION */
50837
50838 {
50839 int readin;
50840
50841 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
50842 RECEIVE_PACKET_FIELD_ERROR(flag);
50843 }
50844 real_packet->flag = readin;
50845 }
50846 }
50847
50848 if (BV_ISSET(fields, 2)) {
50849 log_packet_detailed(" got field 'type'");
50850
50851#ifdef FREECIV_JSON_CONNECTION
50852 field_addr.name = "type";
50853#endif /* FREECIV_JSON_CONNECTION */
50854
50855 {
50856 int readin;
50857
50858 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
50859 RECEIVE_PACKET_FIELD_ERROR(type);
50860 }
50861 real_packet->type = readin;
50862 }
50863 }
50864
50865 if (BV_ISSET(fields, 3)) {
50866 log_packet_detailed(" got field 'value'");
50867
50868#ifdef FREECIV_JSON_CONNECTION
50869 field_addr.name = "value";
50870#endif /* FREECIV_JSON_CONNECTION */
50871
50872 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->value)) {
50873 RECEIVE_PACKET_FIELD_ERROR(value);
50874 }
50875 }
50876
50877 real_packet->quiet = BV_ISSET(fields, 4);
50878
50879 if (nullptr == old) {
50880 old = fc_malloc(sizeof(*old));
50881 init_packet_ruleset_unit_bonus(old);
50882 *old = *real_packet;
50883 genhash_insert(*hash, old, old);
50884 } else {
50885 *old = *real_packet;
50886 }
50887
50888#else /* FREECIV_DELTA_PROTOCOL */
50889#ifdef FREECIV_JSON_CONNECTION
50890 field_addr.name = "unit";
50891#endif /* FREECIV_JSON_CONNECTION */
50892
50893 {
50894 int readin;
50895
50896 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
50897 RECEIVE_PACKET_FIELD_ERROR(unit);
50898 }
50899 real_packet->unit = readin;
50900 }
50901
50902#ifdef FREECIV_JSON_CONNECTION
50903 field_addr.name = "flag";
50904#endif /* FREECIV_JSON_CONNECTION */
50905
50906 {
50907 int readin;
50908
50909 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
50910 RECEIVE_PACKET_FIELD_ERROR(flag);
50911 }
50912 real_packet->flag = readin;
50913 }
50914
50915#ifdef FREECIV_JSON_CONNECTION
50916 field_addr.name = "type";
50917#endif /* FREECIV_JSON_CONNECTION */
50918
50919 {
50920 int readin;
50921
50922 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
50923 RECEIVE_PACKET_FIELD_ERROR(type);
50924 }
50925 real_packet->type = readin;
50926 }
50927
50928#ifdef FREECIV_JSON_CONNECTION
50929 field_addr.name = "value";
50930#endif /* FREECIV_JSON_CONNECTION */
50931
50932 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->value)) {
50933 RECEIVE_PACKET_FIELD_ERROR(value);
50934 }
50935
50936#ifdef FREECIV_JSON_CONNECTION
50937 field_addr.name = "quiet";
50938#endif /* FREECIV_JSON_CONNECTION */
50939
50940 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->quiet)) {
50941 RECEIVE_PACKET_FIELD_ERROR(quiet);
50942 }
50943#endif /* FREECIV_DELTA_PROTOCOL */
50944
50945 RECEIVE_PACKET_END(real_packet);
50946#undef FREE_PACKET_STRUCT
50947}
50948
50949 static int send_packet_ruleset_unit_bonus_100(struct connection *pc, const struct packet_ruleset_unit_bonus *packet)
50950{
50951 const struct packet_ruleset_unit_bonus *real_packet = packet;
50952 int e;
50953 SEND_PACKET_START(PACKET_RULESET_UNIT_BONUS);
50954
50955 log_packet_detailed("packet_ruleset_unit_bonus_100: sending info about ()");
50956
50957#ifdef FREECIV_DELTA_PROTOCOL
50958 packet_ruleset_unit_bonus_100_fields fields;
50959 struct packet_ruleset_unit_bonus *old;
50960 bool differ;
50961 struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_BONUS;
50962
50963 if (nullptr == *hash) {
50964 *hash = genhash_new_full(hash_packet_ruleset_unit_bonus_100, cmp_packet_ruleset_unit_bonus_100,
50965 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_bonus);
50966 }
50967 BV_CLR_ALL(fields);
50968
50969 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
50970 old = fc_malloc(sizeof(*old));
50971 /* temporary bitcopy just to insert correctly */
50972 *old = *real_packet;
50973 genhash_insert(*hash, old, old);
50974 init_packet_ruleset_unit_bonus(old);
50975 }
50976
50977 differ = (old->unit != real_packet->unit);
50978 if (differ) {
50979 BV_SET(fields, 0);
50980 }
50981
50982 differ = (old->flag != real_packet->flag);
50983 if (differ) {
50984 BV_SET(fields, 1);
50985 }
50986
50987 differ = (old->type != real_packet->type);
50988 if (differ) {
50989 BV_SET(fields, 2);
50990 }
50991
50992 differ = (old->value != real_packet->value);
50993 if (differ) {
50994 BV_SET(fields, 3);
50995 }
50996
50997 /* folded into head */
50998 if (real_packet->quiet) {
50999 BV_SET(fields, 4);
51000 }
51001#endif /* FREECIV_DELTA_PROTOCOL */
51002
51003#ifdef FREECIV_JSON_CONNECTION
51004 struct plocation field_addr;
51005 {
51006 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
51007 field_addr = *field_addr_tmp;
51008 FC_FREE(field_addr_tmp);
51009 }
51010#endif /* FREECIV_JSON_CONNECTION */
51011
51012#ifdef FREECIV_DELTA_PROTOCOL
51013#ifdef FREECIV_JSON_CONNECTION
51014 field_addr.name = "fields";
51015#endif /* FREECIV_JSON_CONNECTION */
51016 e = 0;
51017 e |= DIO_BV_PUT(&dout, &field_addr, fields);
51018 if (e) {
51019 log_packet_detailed("fields bitvector error detected");
51020 }
51021
51022 if (BV_ISSET(fields, 0)) {
51023 log_packet_detailed(" field 'unit' has changed");
51024
51025#ifdef FREECIV_JSON_CONNECTION
51026 field_addr.name = "unit";
51027#endif /* FREECIV_JSON_CONNECTION */
51028 e = 0;
51029
51030 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->unit);
51031
51032 if (e) {
51033 log_packet_detailed("'unit' field error detected");
51034 }
51035 }
51036
51037 if (BV_ISSET(fields, 1)) {
51038 log_packet_detailed(" field 'flag' has changed");
51039
51040#ifdef FREECIV_JSON_CONNECTION
51041 field_addr.name = "flag";
51042#endif /* FREECIV_JSON_CONNECTION */
51043 e = 0;
51044
51045 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->flag);
51046
51047 if (e) {
51048 log_packet_detailed("'flag' field error detected");
51049 }
51050 }
51051
51052 if (BV_ISSET(fields, 2)) {
51053 log_packet_detailed(" field 'type' has changed");
51054
51055#ifdef FREECIV_JSON_CONNECTION
51056 field_addr.name = "type";
51057#endif /* FREECIV_JSON_CONNECTION */
51058 e = 0;
51059
51060 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
51061
51062 if (e) {
51063 log_packet_detailed("'type' field error detected");
51064 }
51065 }
51066
51067 if (BV_ISSET(fields, 3)) {
51068 log_packet_detailed(" field 'value' has changed");
51069
51070#ifdef FREECIV_JSON_CONNECTION
51071 field_addr.name = "value";
51072#endif /* FREECIV_JSON_CONNECTION */
51073 e = 0;
51074
51075 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->value);
51076
51077 if (e) {
51078 log_packet_detailed("'value' field error detected");
51079 }
51080 }
51081
51082 /* field 4 is folded into the header */
51083
51084 *old = *real_packet;
51085
51086#else /* FREECIV_DELTA_PROTOCOL */
51087#ifdef FREECIV_JSON_CONNECTION
51088 field_addr.name = "unit";
51089#endif /* FREECIV_JSON_CONNECTION */
51090 e = 0;
51091
51092 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->unit);
51093
51094 if (e) {
51095 log_packet_detailed("'unit' field error detected");
51096 }
51097
51098#ifdef FREECIV_JSON_CONNECTION
51099 field_addr.name = "flag";
51100#endif /* FREECIV_JSON_CONNECTION */
51101 e = 0;
51102
51103 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->flag);
51104
51105 if (e) {
51106 log_packet_detailed("'flag' field error detected");
51107 }
51108
51109#ifdef FREECIV_JSON_CONNECTION
51110 field_addr.name = "type";
51111#endif /* FREECIV_JSON_CONNECTION */
51112 e = 0;
51113
51114 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
51115
51116 if (e) {
51117 log_packet_detailed("'type' field error detected");
51118 }
51119
51120#ifdef FREECIV_JSON_CONNECTION
51121 field_addr.name = "value";
51122#endif /* FREECIV_JSON_CONNECTION */
51123 e = 0;
51124
51125 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->value);
51126
51127 if (e) {
51128 log_packet_detailed("'value' field error detected");
51129 }
51130
51131#ifdef FREECIV_JSON_CONNECTION
51132 field_addr.name = "quiet";
51133#endif /* FREECIV_JSON_CONNECTION */
51134 e = 0;
51135
51136 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->quiet);
51137
51138 if (e) {
51139 log_packet_detailed("'quiet' field error detected");
51140 }
51141#endif /* FREECIV_DELTA_PROTOCOL */
51142
51143 SEND_PACKET_END(PACKET_RULESET_UNIT_BONUS);
51144}
51145
51146 int send_packet_ruleset_unit_bonus(struct connection *pc, const struct packet_ruleset_unit_bonus *packet)
51147{
51148 if (!pc->used) {
51149 log_error("WARNING: trying to send data to the closed connection %s",
51150 conn_description(pc));
51151 return -1;
51152 }
51153 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_BONUS].packet != nullptr, -1,
51154 "Handler for PACKET_RULESET_UNIT_BONUS not installed");
51155 return pc->phs.handlers->send[PACKET_RULESET_UNIT_BONUS].packet(pc, packet);
51156}
51157
51158 void lsend_packet_ruleset_unit_bonus(struct conn_list *dest, const struct packet_ruleset_unit_bonus *packet)
51159{
51160 conn_list_iterate(dest, pconn) {
51161 send_packet_ruleset_unit_bonus(pconn, packet);
51162 } conn_list_iterate_end;
51163}
51164
51165 static inline void init_packet_ruleset_unit_flag(struct packet_ruleset_unit_flag *packet)
51166{
51167 memset(packet, 0, sizeof(*packet));
51168}
51169
51170#define free_packet_ruleset_unit_flag(_packet) (void) 0
51171#define destroy_packet_ruleset_unit_flag free
51172
51173#ifdef FREECIV_DELTA_PROTOCOL
51174#define hash_packet_ruleset_unit_flag_100 hash_const
51175#define cmp_packet_ruleset_unit_flag_100 cmp_const
51176 BV_DEFINE(packet_ruleset_unit_flag_100_fields, 3);
51177#endif /* FREECIV_DELTA_PROTOCOL */
51178
51179 static struct packet_ruleset_unit_flag *receive_packet_ruleset_unit_flag_100(struct connection *pc)
51180{
51181#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_unit_flag(_packet)
51182 RECEIVE_PACKET_START(packet_ruleset_unit_flag, real_packet);
51183
51184#ifdef FREECIV_JSON_CONNECTION
51185 struct plocation field_addr;
51186 {
51187 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
51188 field_addr = *field_addr_tmp;
51189 FC_FREE(field_addr_tmp);
51190 }
51191#endif /* FREECIV_JSON_CONNECTION */
51192
51193 log_packet_detailed("packet_ruleset_unit_flag_100: got info about ()");
51194
51195#ifdef FREECIV_DELTA_PROTOCOL
51196 packet_ruleset_unit_flag_100_fields fields;
51197 struct packet_ruleset_unit_flag *old;
51198 struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_FLAG;
51199
51200 if (nullptr == *hash) {
51201 *hash = genhash_new_full(hash_packet_ruleset_unit_flag_100, cmp_packet_ruleset_unit_flag_100,
51202 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_flag);
51203 }
51204
51205 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
51206 *real_packet = *old;
51207 } else {
51208 /* packet is already initialized empty */
51209 log_packet_detailed(" no old info");
51210 }
51211
51212#ifdef FREECIV_JSON_CONNECTION
51213 field_addr.name = "fields";
51214#endif /* FREECIV_JSON_CONNECTION */
51215 DIO_BV_GET(&din, &field_addr, fields);
51216
51217 if (BV_ISSET(fields, 0)) {
51218 log_packet_detailed(" got field 'id'");
51219
51220#ifdef FREECIV_JSON_CONNECTION
51221 field_addr.name = "id";
51222#endif /* FREECIV_JSON_CONNECTION */
51223
51224 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
51225 RECEIVE_PACKET_FIELD_ERROR(id);
51226 }
51227 }
51228
51229 if (BV_ISSET(fields, 1)) {
51230 log_packet_detailed(" got field 'name'");
51231
51232#ifdef FREECIV_JSON_CONNECTION
51233 field_addr.name = "name";
51234#endif /* FREECIV_JSON_CONNECTION */
51235
51236 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
51237 RECEIVE_PACKET_FIELD_ERROR(name);
51238 }
51239 }
51240
51241 if (BV_ISSET(fields, 2)) {
51242 log_packet_detailed(" got field 'helptxt'");
51243
51244#ifdef FREECIV_JSON_CONNECTION
51245 field_addr.name = "helptxt";
51246#endif /* FREECIV_JSON_CONNECTION */
51247
51248 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
51249 RECEIVE_PACKET_FIELD_ERROR(helptxt);
51250 }
51251 }
51252
51253 if (nullptr == old) {
51254 old = fc_malloc(sizeof(*old));
51255 init_packet_ruleset_unit_flag(old);
51256 *old = *real_packet;
51257 genhash_insert(*hash, old, old);
51258 } else {
51259 *old = *real_packet;
51260 }
51261
51262#else /* FREECIV_DELTA_PROTOCOL */
51263#ifdef FREECIV_JSON_CONNECTION
51264 field_addr.name = "id";
51265#endif /* FREECIV_JSON_CONNECTION */
51266
51267 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
51268 RECEIVE_PACKET_FIELD_ERROR(id);
51269 }
51270
51271#ifdef FREECIV_JSON_CONNECTION
51272 field_addr.name = "name";
51273#endif /* FREECIV_JSON_CONNECTION */
51274
51275 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
51276 RECEIVE_PACKET_FIELD_ERROR(name);
51277 }
51278
51279#ifdef FREECIV_JSON_CONNECTION
51280 field_addr.name = "helptxt";
51281#endif /* FREECIV_JSON_CONNECTION */
51282
51283 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
51284 RECEIVE_PACKET_FIELD_ERROR(helptxt);
51285 }
51286#endif /* FREECIV_DELTA_PROTOCOL */
51287
51288 RECEIVE_PACKET_END(real_packet);
51289#undef FREE_PACKET_STRUCT
51290}
51291
51292 static int send_packet_ruleset_unit_flag_100(struct connection *pc, const struct packet_ruleset_unit_flag *packet)
51293{
51294 const struct packet_ruleset_unit_flag *real_packet = packet;
51295 int e;
51296 SEND_PACKET_START(PACKET_RULESET_UNIT_FLAG);
51297
51298 log_packet_detailed("packet_ruleset_unit_flag_100: sending info about ()");
51299
51300#ifdef FREECIV_DELTA_PROTOCOL
51301 packet_ruleset_unit_flag_100_fields fields;
51302 struct packet_ruleset_unit_flag *old;
51303 bool differ;
51304 struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_FLAG;
51305
51306 if (nullptr == *hash) {
51307 *hash = genhash_new_full(hash_packet_ruleset_unit_flag_100, cmp_packet_ruleset_unit_flag_100,
51308 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_flag);
51309 }
51310 BV_CLR_ALL(fields);
51311
51312 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
51313 old = fc_malloc(sizeof(*old));
51314 /* temporary bitcopy just to insert correctly */
51315 *old = *real_packet;
51316 genhash_insert(*hash, old, old);
51317 init_packet_ruleset_unit_flag(old);
51318 }
51319
51320 differ = (old->id != real_packet->id);
51321 if (differ) {
51322 BV_SET(fields, 0);
51323 }
51324
51325 differ = (strcmp(old->name, real_packet->name) != 0);
51326 if (differ) {
51327 BV_SET(fields, 1);
51328 }
51329
51330 differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
51331 if (differ) {
51332 BV_SET(fields, 2);
51333 }
51334#endif /* FREECIV_DELTA_PROTOCOL */
51335
51336#ifdef FREECIV_JSON_CONNECTION
51337 struct plocation field_addr;
51338 {
51339 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
51340 field_addr = *field_addr_tmp;
51341 FC_FREE(field_addr_tmp);
51342 }
51343#endif /* FREECIV_JSON_CONNECTION */
51344
51345#ifdef FREECIV_DELTA_PROTOCOL
51346#ifdef FREECIV_JSON_CONNECTION
51347 field_addr.name = "fields";
51348#endif /* FREECIV_JSON_CONNECTION */
51349 e = 0;
51350 e |= DIO_BV_PUT(&dout, &field_addr, fields);
51351 if (e) {
51352 log_packet_detailed("fields bitvector error detected");
51353 }
51354
51355 if (BV_ISSET(fields, 0)) {
51356 log_packet_detailed(" field 'id' has changed");
51357
51358#ifdef FREECIV_JSON_CONNECTION
51359 field_addr.name = "id";
51360#endif /* FREECIV_JSON_CONNECTION */
51361 e = 0;
51362
51363 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
51364
51365 if (e) {
51366 log_packet_detailed("'id' field error detected");
51367 }
51368 }
51369
51370 if (BV_ISSET(fields, 1)) {
51371 log_packet_detailed(" field 'name' has changed");
51372
51373#ifdef FREECIV_JSON_CONNECTION
51374 field_addr.name = "name";
51375#endif /* FREECIV_JSON_CONNECTION */
51376 e = 0;
51377
51378 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
51379
51380 if (e) {
51381 log_packet_detailed("'name' field error detected");
51382 }
51383 }
51384
51385 if (BV_ISSET(fields, 2)) {
51386 log_packet_detailed(" field 'helptxt' has changed");
51387
51388#ifdef FREECIV_JSON_CONNECTION
51389 field_addr.name = "helptxt";
51390#endif /* FREECIV_JSON_CONNECTION */
51391 e = 0;
51392
51393 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
51394
51395 if (e) {
51396 log_packet_detailed("'helptxt' field error detected");
51397 }
51398 }
51399
51400 *old = *real_packet;
51401
51402#else /* FREECIV_DELTA_PROTOCOL */
51403#ifdef FREECIV_JSON_CONNECTION
51404 field_addr.name = "id";
51405#endif /* FREECIV_JSON_CONNECTION */
51406 e = 0;
51407
51408 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
51409
51410 if (e) {
51411 log_packet_detailed("'id' field error detected");
51412 }
51413
51414#ifdef FREECIV_JSON_CONNECTION
51415 field_addr.name = "name";
51416#endif /* FREECIV_JSON_CONNECTION */
51417 e = 0;
51418
51419 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
51420
51421 if (e) {
51422 log_packet_detailed("'name' field error detected");
51423 }
51424
51425#ifdef FREECIV_JSON_CONNECTION
51426 field_addr.name = "helptxt";
51427#endif /* FREECIV_JSON_CONNECTION */
51428 e = 0;
51429
51430 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
51431
51432 if (e) {
51433 log_packet_detailed("'helptxt' field error detected");
51434 }
51435#endif /* FREECIV_DELTA_PROTOCOL */
51436
51437 SEND_PACKET_END(PACKET_RULESET_UNIT_FLAG);
51438}
51439
51440 int send_packet_ruleset_unit_flag(struct connection *pc, const struct packet_ruleset_unit_flag *packet)
51441{
51442 if (!pc->used) {
51443 log_error("WARNING: trying to send data to the closed connection %s",
51444 conn_description(pc));
51445 return -1;
51446 }
51447 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_FLAG].packet != nullptr, -1,
51448 "Handler for PACKET_RULESET_UNIT_FLAG not installed");
51449 return pc->phs.handlers->send[PACKET_RULESET_UNIT_FLAG].packet(pc, packet);
51450}
51451
51452 void lsend_packet_ruleset_unit_flag(struct conn_list *dest, const struct packet_ruleset_unit_flag *packet)
51453{
51454 conn_list_iterate(dest, pconn) {
51455 send_packet_ruleset_unit_flag(pconn, packet);
51456 } conn_list_iterate_end;
51457}
51458
51459 static inline void init_packet_ruleset_unit_class_flag(struct packet_ruleset_unit_class_flag *packet)
51460{
51461 memset(packet, 0, sizeof(*packet));
51462}
51463
51464#define free_packet_ruleset_unit_class_flag(_packet) (void) 0
51465#define destroy_packet_ruleset_unit_class_flag free
51466
51467#ifdef FREECIV_DELTA_PROTOCOL
51468#define hash_packet_ruleset_unit_class_flag_100 hash_const
51469#define cmp_packet_ruleset_unit_class_flag_100 cmp_const
51470 BV_DEFINE(packet_ruleset_unit_class_flag_100_fields, 3);
51471#endif /* FREECIV_DELTA_PROTOCOL */
51472
51473 static struct packet_ruleset_unit_class_flag *receive_packet_ruleset_unit_class_flag_100(struct connection *pc)
51474{
51475#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_unit_class_flag(_packet)
51476 RECEIVE_PACKET_START(packet_ruleset_unit_class_flag, real_packet);
51477
51478#ifdef FREECIV_JSON_CONNECTION
51479 struct plocation field_addr;
51480 {
51481 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
51482 field_addr = *field_addr_tmp;
51483 FC_FREE(field_addr_tmp);
51484 }
51485#endif /* FREECIV_JSON_CONNECTION */
51486
51487 log_packet_detailed("packet_ruleset_unit_class_flag_100: got info about ()");
51488
51489#ifdef FREECIV_DELTA_PROTOCOL
51490 packet_ruleset_unit_class_flag_100_fields fields;
51491 struct packet_ruleset_unit_class_flag *old;
51492 struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_CLASS_FLAG;
51493
51494 if (nullptr == *hash) {
51495 *hash = genhash_new_full(hash_packet_ruleset_unit_class_flag_100, cmp_packet_ruleset_unit_class_flag_100,
51496 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_class_flag);
51497 }
51498
51499 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
51500 *real_packet = *old;
51501 } else {
51502 /* packet is already initialized empty */
51503 log_packet_detailed(" no old info");
51504 }
51505
51506#ifdef FREECIV_JSON_CONNECTION
51507 field_addr.name = "fields";
51508#endif /* FREECIV_JSON_CONNECTION */
51509 DIO_BV_GET(&din, &field_addr, fields);
51510
51511 if (BV_ISSET(fields, 0)) {
51512 log_packet_detailed(" got field 'id'");
51513
51514#ifdef FREECIV_JSON_CONNECTION
51515 field_addr.name = "id";
51516#endif /* FREECIV_JSON_CONNECTION */
51517
51518 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
51519 RECEIVE_PACKET_FIELD_ERROR(id);
51520 }
51521 }
51522
51523 if (BV_ISSET(fields, 1)) {
51524 log_packet_detailed(" got field 'name'");
51525
51526#ifdef FREECIV_JSON_CONNECTION
51527 field_addr.name = "name";
51528#endif /* FREECIV_JSON_CONNECTION */
51529
51530 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
51531 RECEIVE_PACKET_FIELD_ERROR(name);
51532 }
51533 }
51534
51535 if (BV_ISSET(fields, 2)) {
51536 log_packet_detailed(" got field 'helptxt'");
51537
51538#ifdef FREECIV_JSON_CONNECTION
51539 field_addr.name = "helptxt";
51540#endif /* FREECIV_JSON_CONNECTION */
51541
51542 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
51543 RECEIVE_PACKET_FIELD_ERROR(helptxt);
51544 }
51545 }
51546
51547 if (nullptr == old) {
51548 old = fc_malloc(sizeof(*old));
51549 init_packet_ruleset_unit_class_flag(old);
51550 *old = *real_packet;
51551 genhash_insert(*hash, old, old);
51552 } else {
51553 *old = *real_packet;
51554 }
51555
51556#else /* FREECIV_DELTA_PROTOCOL */
51557#ifdef FREECIV_JSON_CONNECTION
51558 field_addr.name = "id";
51559#endif /* FREECIV_JSON_CONNECTION */
51560
51561 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
51562 RECEIVE_PACKET_FIELD_ERROR(id);
51563 }
51564
51565#ifdef FREECIV_JSON_CONNECTION
51566 field_addr.name = "name";
51567#endif /* FREECIV_JSON_CONNECTION */
51568
51569 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
51570 RECEIVE_PACKET_FIELD_ERROR(name);
51571 }
51572
51573#ifdef FREECIV_JSON_CONNECTION
51574 field_addr.name = "helptxt";
51575#endif /* FREECIV_JSON_CONNECTION */
51576
51577 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
51578 RECEIVE_PACKET_FIELD_ERROR(helptxt);
51579 }
51580#endif /* FREECIV_DELTA_PROTOCOL */
51581
51582 RECEIVE_PACKET_END(real_packet);
51583#undef FREE_PACKET_STRUCT
51584}
51585
51586 static int send_packet_ruleset_unit_class_flag_100(struct connection *pc, const struct packet_ruleset_unit_class_flag *packet)
51587{
51588 const struct packet_ruleset_unit_class_flag *real_packet = packet;
51589 int e;
51590 SEND_PACKET_START(PACKET_RULESET_UNIT_CLASS_FLAG);
51591
51592 log_packet_detailed("packet_ruleset_unit_class_flag_100: sending info about ()");
51593
51594#ifdef FREECIV_DELTA_PROTOCOL
51595 packet_ruleset_unit_class_flag_100_fields fields;
51596 struct packet_ruleset_unit_class_flag *old;
51597 bool differ;
51598 struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_CLASS_FLAG;
51599
51600 if (nullptr == *hash) {
51601 *hash = genhash_new_full(hash_packet_ruleset_unit_class_flag_100, cmp_packet_ruleset_unit_class_flag_100,
51602 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_class_flag);
51603 }
51604 BV_CLR_ALL(fields);
51605
51606 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
51607 old = fc_malloc(sizeof(*old));
51608 /* temporary bitcopy just to insert correctly */
51609 *old = *real_packet;
51610 genhash_insert(*hash, old, old);
51611 init_packet_ruleset_unit_class_flag(old);
51612 }
51613
51614 differ = (old->id != real_packet->id);
51615 if (differ) {
51616 BV_SET(fields, 0);
51617 }
51618
51619 differ = (strcmp(old->name, real_packet->name) != 0);
51620 if (differ) {
51621 BV_SET(fields, 1);
51622 }
51623
51624 differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
51625 if (differ) {
51626 BV_SET(fields, 2);
51627 }
51628#endif /* FREECIV_DELTA_PROTOCOL */
51629
51630#ifdef FREECIV_JSON_CONNECTION
51631 struct plocation field_addr;
51632 {
51633 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
51634 field_addr = *field_addr_tmp;
51635 FC_FREE(field_addr_tmp);
51636 }
51637#endif /* FREECIV_JSON_CONNECTION */
51638
51639#ifdef FREECIV_DELTA_PROTOCOL
51640#ifdef FREECIV_JSON_CONNECTION
51641 field_addr.name = "fields";
51642#endif /* FREECIV_JSON_CONNECTION */
51643 e = 0;
51644 e |= DIO_BV_PUT(&dout, &field_addr, fields);
51645 if (e) {
51646 log_packet_detailed("fields bitvector error detected");
51647 }
51648
51649 if (BV_ISSET(fields, 0)) {
51650 log_packet_detailed(" field 'id' has changed");
51651
51652#ifdef FREECIV_JSON_CONNECTION
51653 field_addr.name = "id";
51654#endif /* FREECIV_JSON_CONNECTION */
51655 e = 0;
51656
51657 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
51658
51659 if (e) {
51660 log_packet_detailed("'id' field error detected");
51661 }
51662 }
51663
51664 if (BV_ISSET(fields, 1)) {
51665 log_packet_detailed(" field 'name' has changed");
51666
51667#ifdef FREECIV_JSON_CONNECTION
51668 field_addr.name = "name";
51669#endif /* FREECIV_JSON_CONNECTION */
51670 e = 0;
51671
51672 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
51673
51674 if (e) {
51675 log_packet_detailed("'name' field error detected");
51676 }
51677 }
51678
51679 if (BV_ISSET(fields, 2)) {
51680 log_packet_detailed(" field 'helptxt' has changed");
51681
51682#ifdef FREECIV_JSON_CONNECTION
51683 field_addr.name = "helptxt";
51684#endif /* FREECIV_JSON_CONNECTION */
51685 e = 0;
51686
51687 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
51688
51689 if (e) {
51690 log_packet_detailed("'helptxt' field error detected");
51691 }
51692 }
51693
51694 *old = *real_packet;
51695
51696#else /* FREECIV_DELTA_PROTOCOL */
51697#ifdef FREECIV_JSON_CONNECTION
51698 field_addr.name = "id";
51699#endif /* FREECIV_JSON_CONNECTION */
51700 e = 0;
51701
51702 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
51703
51704 if (e) {
51705 log_packet_detailed("'id' field error detected");
51706 }
51707
51708#ifdef FREECIV_JSON_CONNECTION
51709 field_addr.name = "name";
51710#endif /* FREECIV_JSON_CONNECTION */
51711 e = 0;
51712
51713 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
51714
51715 if (e) {
51716 log_packet_detailed("'name' field error detected");
51717 }
51718
51719#ifdef FREECIV_JSON_CONNECTION
51720 field_addr.name = "helptxt";
51721#endif /* FREECIV_JSON_CONNECTION */
51722 e = 0;
51723
51724 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
51725
51726 if (e) {
51727 log_packet_detailed("'helptxt' field error detected");
51728 }
51729#endif /* FREECIV_DELTA_PROTOCOL */
51730
51731 SEND_PACKET_END(PACKET_RULESET_UNIT_CLASS_FLAG);
51732}
51733
51734 int send_packet_ruleset_unit_class_flag(struct connection *pc, const struct packet_ruleset_unit_class_flag *packet)
51735{
51736 if (!pc->used) {
51737 log_error("WARNING: trying to send data to the closed connection %s",
51738 conn_description(pc));
51739 return -1;
51740 }
51741 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_CLASS_FLAG].packet != nullptr, -1,
51742 "Handler for PACKET_RULESET_UNIT_CLASS_FLAG not installed");
51743 return pc->phs.handlers->send[PACKET_RULESET_UNIT_CLASS_FLAG].packet(pc, packet);
51744}
51745
51746 void lsend_packet_ruleset_unit_class_flag(struct conn_list *dest, const struct packet_ruleset_unit_class_flag *packet)
51747{
51748 conn_list_iterate(dest, pconn) {
51749 send_packet_ruleset_unit_class_flag(pconn, packet);
51750 } conn_list_iterate_end;
51751}
51752
51753 static inline void init_packet_ruleset_game(struct packet_ruleset_game *packet)
51754{
51755 memset(packet, 0, sizeof(*packet));
51756}
51757
51758#define free_packet_ruleset_game(_packet) (void) 0
51759#define destroy_packet_ruleset_game free
51760
51761#ifdef FREECIV_DELTA_PROTOCOL
51762#define hash_packet_ruleset_game_100 hash_const
51763#define cmp_packet_ruleset_game_100 cmp_const
51764 BV_DEFINE(packet_ruleset_game_100_fields, 14);
51765#endif /* FREECIV_DELTA_PROTOCOL */
51766
51767 static struct packet_ruleset_game *receive_packet_ruleset_game_100(struct connection *pc)
51768{
51769#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_game(_packet)
51770 RECEIVE_PACKET_START(packet_ruleset_game, real_packet);
51771
51772#ifdef FREECIV_JSON_CONNECTION
51773 struct plocation field_addr;
51774 {
51775 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
51776 field_addr = *field_addr_tmp;
51777 FC_FREE(field_addr_tmp);
51778 }
51779#endif /* FREECIV_JSON_CONNECTION */
51780
51781 log_packet_detailed("packet_ruleset_game_100: got info about ()");
51782
51783#ifdef FREECIV_DELTA_PROTOCOL
51784 packet_ruleset_game_100_fields fields;
51785 struct packet_ruleset_game *old;
51786 struct genhash **hash = pc->phs.received + PACKET_RULESET_GAME;
51787
51788 if (nullptr == *hash) {
51789 *hash = genhash_new_full(hash_packet_ruleset_game_100, cmp_packet_ruleset_game_100,
51790 nullptr, nullptr, nullptr, destroy_packet_ruleset_game);
51791 }
51792
51793 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
51794 *real_packet = *old;
51795 } else {
51796 /* packet is already initialized empty */
51797 log_packet_detailed(" no old info");
51798 }
51799
51800#ifdef FREECIV_JSON_CONNECTION
51801 field_addr.name = "fields";
51802#endif /* FREECIV_JSON_CONNECTION */
51803 DIO_BV_GET(&din, &field_addr, fields);
51804
51805 if (BV_ISSET(fields, 0)) {
51806 log_packet_detailed(" got field 'default_specialist'");
51807
51808#ifdef FREECIV_JSON_CONNECTION
51809 field_addr.name = "default_specialist";
51810#endif /* FREECIV_JSON_CONNECTION */
51811
51812 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->default_specialist)) {
51813 RECEIVE_PACKET_FIELD_ERROR(default_specialist);
51814 }
51815 }
51816
51817 if (BV_ISSET(fields, 1)) {
51818 log_packet_detailed(" got field 'global_init_techs_count'");
51819
51820#ifdef FREECIV_JSON_CONNECTION
51821 field_addr.name = "global_init_techs_count";
51822#endif /* FREECIV_JSON_CONNECTION */
51823
51824 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->global_init_techs_count)) {
51825 RECEIVE_PACKET_FIELD_ERROR(global_init_techs_count);
51826 }
51827 }
51828
51829 if (BV_ISSET(fields, 2)) {
51830 log_packet_detailed(" got field 'global_init_techs'");
51831
51832#ifdef FREECIV_JSON_CONNECTION
51833 field_addr.name = "global_init_techs";
51834#endif /* FREECIV_JSON_CONNECTION */
51835
51836 {
51837 int i;
51838
51839 if (real_packet->global_init_techs_count > MAX_NUM_TECH_LIST) {
51840 RECEIVE_PACKET_FIELD_ERROR(global_init_techs, ": array truncated");
51841 }
51842
51843#ifdef FREECIV_JSON_CONNECTION
51844 /* Enter array. */
51845 field_addr.sub_location = plocation_elem_new(0);
51846#endif /* FREECIV_JSON_CONNECTION */
51847
51848 for (i = 0; i < real_packet->global_init_techs_count; i++) {
51849#ifdef FREECIV_JSON_CONNECTION
51850 /* Next array element */
51851 field_addr.sub_location->number = i;
51852#endif /* FREECIV_JSON_CONNECTION */
51853
51854 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->global_init_techs[i])) {
51855 RECEIVE_PACKET_FIELD_ERROR(global_init_techs);
51856 }
51857 }
51858
51859#ifdef FREECIV_JSON_CONNECTION
51860 /* Exit array. */
51861 FC_FREE(field_addr.sub_location);
51862#endif /* FREECIV_JSON_CONNECTION */
51863 }
51864 }
51865
51866 if (BV_ISSET(fields, 3)) {
51867 log_packet_detailed(" got field 'global_init_buildings_count'");
51868
51869#ifdef FREECIV_JSON_CONNECTION
51870 field_addr.name = "global_init_buildings_count";
51871#endif /* FREECIV_JSON_CONNECTION */
51872
51873 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->global_init_buildings_count)) {
51874 RECEIVE_PACKET_FIELD_ERROR(global_init_buildings_count);
51875 }
51876 }
51877
51878 if (BV_ISSET(fields, 4)) {
51879 log_packet_detailed(" got field 'global_init_buildings'");
51880
51881#ifdef FREECIV_JSON_CONNECTION
51882 field_addr.name = "global_init_buildings";
51883#endif /* FREECIV_JSON_CONNECTION */
51884
51885 {
51886 int i;
51887
51888 if (real_packet->global_init_buildings_count > MAX_NUM_BUILDING_LIST) {
51889 RECEIVE_PACKET_FIELD_ERROR(global_init_buildings, ": array truncated");
51890 }
51891
51892#ifdef FREECIV_JSON_CONNECTION
51893 /* Enter array. */
51894 field_addr.sub_location = plocation_elem_new(0);
51895#endif /* FREECIV_JSON_CONNECTION */
51896
51897 for (i = 0; i < real_packet->global_init_buildings_count; i++) {
51898#ifdef FREECIV_JSON_CONNECTION
51899 /* Next array element */
51900 field_addr.sub_location->number = i;
51901#endif /* FREECIV_JSON_CONNECTION */
51902
51903 {
51904 int readin;
51905
51906 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
51907 RECEIVE_PACKET_FIELD_ERROR(global_init_buildings);
51908 }
51909 real_packet->global_init_buildings[i] = readin;
51910 }
51911 }
51912
51913#ifdef FREECIV_JSON_CONNECTION
51914 /* Exit array. */
51915 FC_FREE(field_addr.sub_location);
51916#endif /* FREECIV_JSON_CONNECTION */
51917 }
51918 }
51919
51920 if (BV_ISSET(fields, 5)) {
51921 log_packet_detailed(" got field 'veteran_levels'");
51922
51923#ifdef FREECIV_JSON_CONNECTION
51924 field_addr.name = "veteran_levels";
51925#endif /* FREECIV_JSON_CONNECTION */
51926
51927 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran_levels)) {
51928 RECEIVE_PACKET_FIELD_ERROR(veteran_levels);
51929 }
51930 }
51931
51932 if (BV_ISSET(fields, 6)) {
51933 log_packet_detailed(" got field 'veteran_name'");
51934
51935#ifdef FREECIV_JSON_CONNECTION
51936 field_addr.name = "veteran_name";
51937#endif /* FREECIV_JSON_CONNECTION */
51938
51939 {
51940 int i;
51941
51942 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
51943 RECEIVE_PACKET_FIELD_ERROR(veteran_name, ": array truncated");
51944 }
51945
51946#ifdef FREECIV_JSON_CONNECTION
51947 /* Enter array. */
51948 field_addr.sub_location = plocation_elem_new(0);
51949#endif /* FREECIV_JSON_CONNECTION */
51950
51951 for (i = 0; i < real_packet->veteran_levels; i++) {
51952#ifdef FREECIV_JSON_CONNECTION
51953 /* Next array element */
51954 field_addr.sub_location->number = i;
51955#endif /* FREECIV_JSON_CONNECTION */
51956
51957 if (!DIO_GET(string, &din, &field_addr, real_packet->veteran_name[i], sizeof(real_packet->veteran_name[i]))) {
51958 RECEIVE_PACKET_FIELD_ERROR(veteran_name);
51959 }
51960 }
51961
51962#ifdef FREECIV_JSON_CONNECTION
51963 /* Exit array. */
51964 FC_FREE(field_addr.sub_location);
51965#endif /* FREECIV_JSON_CONNECTION */
51966 }
51967 }
51968
51969 if (BV_ISSET(fields, 7)) {
51970 log_packet_detailed(" got field 'power_fact'");
51971
51972#ifdef FREECIV_JSON_CONNECTION
51973 field_addr.name = "power_fact";
51974#endif /* FREECIV_JSON_CONNECTION */
51975
51976 {
51977 int i;
51978
51979 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
51980 RECEIVE_PACKET_FIELD_ERROR(power_fact, ": array truncated");
51981 }
51982
51983#ifdef FREECIV_JSON_CONNECTION
51984 /* Enter array. */
51985 field_addr.sub_location = plocation_elem_new(0);
51986#endif /* FREECIV_JSON_CONNECTION */
51987
51988 for (i = 0; i < real_packet->veteran_levels; i++) {
51989#ifdef FREECIV_JSON_CONNECTION
51990 /* Next array element */
51991 field_addr.sub_location->number = i;
51992#endif /* FREECIV_JSON_CONNECTION */
51993
51994 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->power_fact[i])) {
51995 RECEIVE_PACKET_FIELD_ERROR(power_fact);
51996 }
51997 }
51998
51999#ifdef FREECIV_JSON_CONNECTION
52000 /* Exit array. */
52001 FC_FREE(field_addr.sub_location);
52002#endif /* FREECIV_JSON_CONNECTION */
52003 }
52004 }
52005
52006 if (BV_ISSET(fields, 8)) {
52007 log_packet_detailed(" got field 'move_bonus'");
52008
52009#ifdef FREECIV_JSON_CONNECTION
52010 field_addr.name = "move_bonus";
52011#endif /* FREECIV_JSON_CONNECTION */
52012
52013 {
52014 int i;
52015
52016 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52017 RECEIVE_PACKET_FIELD_ERROR(move_bonus, ": array truncated");
52018 }
52019
52020#ifdef FREECIV_JSON_CONNECTION
52021 /* Enter array. */
52022 field_addr.sub_location = plocation_elem_new(0);
52023#endif /* FREECIV_JSON_CONNECTION */
52024
52025 for (i = 0; i < real_packet->veteran_levels; i++) {
52026#ifdef FREECIV_JSON_CONNECTION
52027 /* Next array element */
52028 field_addr.sub_location->number = i;
52029#endif /* FREECIV_JSON_CONNECTION */
52030
52031 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_bonus[i])) {
52032 RECEIVE_PACKET_FIELD_ERROR(move_bonus);
52033 }
52034 }
52035
52036#ifdef FREECIV_JSON_CONNECTION
52037 /* Exit array. */
52038 FC_FREE(field_addr.sub_location);
52039#endif /* FREECIV_JSON_CONNECTION */
52040 }
52041 }
52042
52043 if (BV_ISSET(fields, 9)) {
52044 log_packet_detailed(" got field 'base_raise_chance'");
52045
52046#ifdef FREECIV_JSON_CONNECTION
52047 field_addr.name = "base_raise_chance";
52048#endif /* FREECIV_JSON_CONNECTION */
52049
52050 {
52051 int i;
52052
52053 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52054 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance, ": array truncated");
52055 }
52056
52057#ifdef FREECIV_JSON_CONNECTION
52058 /* Enter array. */
52059 field_addr.sub_location = plocation_elem_new(0);
52060#endif /* FREECIV_JSON_CONNECTION */
52061
52062 for (i = 0; i < real_packet->veteran_levels; i++) {
52063#ifdef FREECIV_JSON_CONNECTION
52064 /* Next array element */
52065 field_addr.sub_location->number = i;
52066#endif /* FREECIV_JSON_CONNECTION */
52067
52068 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->base_raise_chance[i])) {
52069 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance);
52070 }
52071 }
52072
52073#ifdef FREECIV_JSON_CONNECTION
52074 /* Exit array. */
52075 FC_FREE(field_addr.sub_location);
52076#endif /* FREECIV_JSON_CONNECTION */
52077 }
52078 }
52079
52080 if (BV_ISSET(fields, 10)) {
52081 log_packet_detailed(" got field 'work_raise_chance'");
52082
52083#ifdef FREECIV_JSON_CONNECTION
52084 field_addr.name = "work_raise_chance";
52085#endif /* FREECIV_JSON_CONNECTION */
52086
52087 {
52088 int i;
52089
52090 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52091 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance, ": array truncated");
52092 }
52093
52094#ifdef FREECIV_JSON_CONNECTION
52095 /* Enter array. */
52096 field_addr.sub_location = plocation_elem_new(0);
52097#endif /* FREECIV_JSON_CONNECTION */
52098
52099 for (i = 0; i < real_packet->veteran_levels; i++) {
52100#ifdef FREECIV_JSON_CONNECTION
52101 /* Next array element */
52102 field_addr.sub_location->number = i;
52103#endif /* FREECIV_JSON_CONNECTION */
52104
52105 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->work_raise_chance[i])) {
52106 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance);
52107 }
52108 }
52109
52110#ifdef FREECIV_JSON_CONNECTION
52111 /* Exit array. */
52112 FC_FREE(field_addr.sub_location);
52113#endif /* FREECIV_JSON_CONNECTION */
52114 }
52115 }
52116
52117 if (BV_ISSET(fields, 11)) {
52118 log_packet_detailed(" got field 'background_red'");
52119
52120#ifdef FREECIV_JSON_CONNECTION
52121 field_addr.name = "background_red";
52122#endif /* FREECIV_JSON_CONNECTION */
52123
52124 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->background_red)) {
52125 RECEIVE_PACKET_FIELD_ERROR(background_red);
52126 }
52127 }
52128
52129 if (BV_ISSET(fields, 12)) {
52130 log_packet_detailed(" got field 'background_green'");
52131
52132#ifdef FREECIV_JSON_CONNECTION
52133 field_addr.name = "background_green";
52134#endif /* FREECIV_JSON_CONNECTION */
52135
52136 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->background_green)) {
52137 RECEIVE_PACKET_FIELD_ERROR(background_green);
52138 }
52139 }
52140
52141 if (BV_ISSET(fields, 13)) {
52142 log_packet_detailed(" got field 'background_blue'");
52143
52144#ifdef FREECIV_JSON_CONNECTION
52145 field_addr.name = "background_blue";
52146#endif /* FREECIV_JSON_CONNECTION */
52147
52148 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->background_blue)) {
52149 RECEIVE_PACKET_FIELD_ERROR(background_blue);
52150 }
52151 }
52152
52153 if (nullptr == old) {
52154 old = fc_malloc(sizeof(*old));
52155 init_packet_ruleset_game(old);
52156 *old = *real_packet;
52157 genhash_insert(*hash, old, old);
52158 } else {
52159 *old = *real_packet;
52160 }
52161
52162#else /* FREECIV_DELTA_PROTOCOL */
52163#ifdef FREECIV_JSON_CONNECTION
52164 field_addr.name = "default_specialist";
52165#endif /* FREECIV_JSON_CONNECTION */
52166
52167 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->default_specialist)) {
52168 RECEIVE_PACKET_FIELD_ERROR(default_specialist);
52169 }
52170
52171#ifdef FREECIV_JSON_CONNECTION
52172 field_addr.name = "global_init_techs_count";
52173#endif /* FREECIV_JSON_CONNECTION */
52174
52175 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->global_init_techs_count)) {
52176 RECEIVE_PACKET_FIELD_ERROR(global_init_techs_count);
52177 }
52178
52179#ifdef FREECIV_JSON_CONNECTION
52180 field_addr.name = "global_init_techs";
52181#endif /* FREECIV_JSON_CONNECTION */
52182
52183 {
52184 int i;
52185
52186 if (real_packet->global_init_techs_count > MAX_NUM_TECH_LIST) {
52187 RECEIVE_PACKET_FIELD_ERROR(global_init_techs, ": array truncated");
52188 }
52189
52190#ifdef FREECIV_JSON_CONNECTION
52191 /* Enter array. */
52192 field_addr.sub_location = plocation_elem_new(0);
52193#endif /* FREECIV_JSON_CONNECTION */
52194
52195 for (i = 0; i < real_packet->global_init_techs_count; i++) {
52196#ifdef FREECIV_JSON_CONNECTION
52197 /* Next array element */
52198 field_addr.sub_location->number = i;
52199#endif /* FREECIV_JSON_CONNECTION */
52200
52201 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->global_init_techs[i])) {
52202 RECEIVE_PACKET_FIELD_ERROR(global_init_techs);
52203 }
52204 }
52205
52206#ifdef FREECIV_JSON_CONNECTION
52207 /* Exit array. */
52208 FC_FREE(field_addr.sub_location);
52209#endif /* FREECIV_JSON_CONNECTION */
52210 }
52211
52212#ifdef FREECIV_JSON_CONNECTION
52213 field_addr.name = "global_init_buildings_count";
52214#endif /* FREECIV_JSON_CONNECTION */
52215
52216 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->global_init_buildings_count)) {
52217 RECEIVE_PACKET_FIELD_ERROR(global_init_buildings_count);
52218 }
52219
52220#ifdef FREECIV_JSON_CONNECTION
52221 field_addr.name = "global_init_buildings";
52222#endif /* FREECIV_JSON_CONNECTION */
52223
52224 {
52225 int i;
52226
52227 if (real_packet->global_init_buildings_count > MAX_NUM_BUILDING_LIST) {
52228 RECEIVE_PACKET_FIELD_ERROR(global_init_buildings, ": array truncated");
52229 }
52230
52231#ifdef FREECIV_JSON_CONNECTION
52232 /* Enter array. */
52233 field_addr.sub_location = plocation_elem_new(0);
52234#endif /* FREECIV_JSON_CONNECTION */
52235
52236 for (i = 0; i < real_packet->global_init_buildings_count; i++) {
52237#ifdef FREECIV_JSON_CONNECTION
52238 /* Next array element */
52239 field_addr.sub_location->number = i;
52240#endif /* FREECIV_JSON_CONNECTION */
52241
52242 {
52243 int readin;
52244
52245 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
52246 RECEIVE_PACKET_FIELD_ERROR(global_init_buildings);
52247 }
52248 real_packet->global_init_buildings[i] = readin;
52249 }
52250 }
52251
52252#ifdef FREECIV_JSON_CONNECTION
52253 /* Exit array. */
52254 FC_FREE(field_addr.sub_location);
52255#endif /* FREECIV_JSON_CONNECTION */
52256 }
52257
52258#ifdef FREECIV_JSON_CONNECTION
52259 field_addr.name = "veteran_levels";
52260#endif /* FREECIV_JSON_CONNECTION */
52261
52262 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran_levels)) {
52263 RECEIVE_PACKET_FIELD_ERROR(veteran_levels);
52264 }
52265
52266#ifdef FREECIV_JSON_CONNECTION
52267 field_addr.name = "veteran_name";
52268#endif /* FREECIV_JSON_CONNECTION */
52269
52270 {
52271 int i;
52272
52273 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52274 RECEIVE_PACKET_FIELD_ERROR(veteran_name, ": array truncated");
52275 }
52276
52277#ifdef FREECIV_JSON_CONNECTION
52278 /* Enter array. */
52279 field_addr.sub_location = plocation_elem_new(0);
52280#endif /* FREECIV_JSON_CONNECTION */
52281
52282 for (i = 0; i < real_packet->veteran_levels; i++) {
52283#ifdef FREECIV_JSON_CONNECTION
52284 /* Next array element */
52285 field_addr.sub_location->number = i;
52286#endif /* FREECIV_JSON_CONNECTION */
52287
52288 if (!DIO_GET(string, &din, &field_addr, real_packet->veteran_name[i], sizeof(real_packet->veteran_name[i]))) {
52289 RECEIVE_PACKET_FIELD_ERROR(veteran_name);
52290 }
52291 }
52292
52293#ifdef FREECIV_JSON_CONNECTION
52294 /* Exit array. */
52295 FC_FREE(field_addr.sub_location);
52296#endif /* FREECIV_JSON_CONNECTION */
52297 }
52298
52299#ifdef FREECIV_JSON_CONNECTION
52300 field_addr.name = "power_fact";
52301#endif /* FREECIV_JSON_CONNECTION */
52302
52303 {
52304 int i;
52305
52306 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52307 RECEIVE_PACKET_FIELD_ERROR(power_fact, ": array truncated");
52308 }
52309
52310#ifdef FREECIV_JSON_CONNECTION
52311 /* Enter array. */
52312 field_addr.sub_location = plocation_elem_new(0);
52313#endif /* FREECIV_JSON_CONNECTION */
52314
52315 for (i = 0; i < real_packet->veteran_levels; i++) {
52316#ifdef FREECIV_JSON_CONNECTION
52317 /* Next array element */
52318 field_addr.sub_location->number = i;
52319#endif /* FREECIV_JSON_CONNECTION */
52320
52321 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->power_fact[i])) {
52322 RECEIVE_PACKET_FIELD_ERROR(power_fact);
52323 }
52324 }
52325
52326#ifdef FREECIV_JSON_CONNECTION
52327 /* Exit array. */
52328 FC_FREE(field_addr.sub_location);
52329#endif /* FREECIV_JSON_CONNECTION */
52330 }
52331
52332#ifdef FREECIV_JSON_CONNECTION
52333 field_addr.name = "move_bonus";
52334#endif /* FREECIV_JSON_CONNECTION */
52335
52336 {
52337 int i;
52338
52339 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52340 RECEIVE_PACKET_FIELD_ERROR(move_bonus, ": array truncated");
52341 }
52342
52343#ifdef FREECIV_JSON_CONNECTION
52344 /* Enter array. */
52345 field_addr.sub_location = plocation_elem_new(0);
52346#endif /* FREECIV_JSON_CONNECTION */
52347
52348 for (i = 0; i < real_packet->veteran_levels; i++) {
52349#ifdef FREECIV_JSON_CONNECTION
52350 /* Next array element */
52351 field_addr.sub_location->number = i;
52352#endif /* FREECIV_JSON_CONNECTION */
52353
52354 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_bonus[i])) {
52355 RECEIVE_PACKET_FIELD_ERROR(move_bonus);
52356 }
52357 }
52358
52359#ifdef FREECIV_JSON_CONNECTION
52360 /* Exit array. */
52361 FC_FREE(field_addr.sub_location);
52362#endif /* FREECIV_JSON_CONNECTION */
52363 }
52364
52365#ifdef FREECIV_JSON_CONNECTION
52366 field_addr.name = "base_raise_chance";
52367#endif /* FREECIV_JSON_CONNECTION */
52368
52369 {
52370 int i;
52371
52372 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52373 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance, ": array truncated");
52374 }
52375
52376#ifdef FREECIV_JSON_CONNECTION
52377 /* Enter array. */
52378 field_addr.sub_location = plocation_elem_new(0);
52379#endif /* FREECIV_JSON_CONNECTION */
52380
52381 for (i = 0; i < real_packet->veteran_levels; i++) {
52382#ifdef FREECIV_JSON_CONNECTION
52383 /* Next array element */
52384 field_addr.sub_location->number = i;
52385#endif /* FREECIV_JSON_CONNECTION */
52386
52387 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->base_raise_chance[i])) {
52388 RECEIVE_PACKET_FIELD_ERROR(base_raise_chance);
52389 }
52390 }
52391
52392#ifdef FREECIV_JSON_CONNECTION
52393 /* Exit array. */
52394 FC_FREE(field_addr.sub_location);
52395#endif /* FREECIV_JSON_CONNECTION */
52396 }
52397
52398#ifdef FREECIV_JSON_CONNECTION
52399 field_addr.name = "work_raise_chance";
52400#endif /* FREECIV_JSON_CONNECTION */
52401
52402 {
52403 int i;
52404
52405 if (real_packet->veteran_levels > MAX_VET_LEVELS) {
52406 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance, ": array truncated");
52407 }
52408
52409#ifdef FREECIV_JSON_CONNECTION
52410 /* Enter array. */
52411 field_addr.sub_location = plocation_elem_new(0);
52412#endif /* FREECIV_JSON_CONNECTION */
52413
52414 for (i = 0; i < real_packet->veteran_levels; i++) {
52415#ifdef FREECIV_JSON_CONNECTION
52416 /* Next array element */
52417 field_addr.sub_location->number = i;
52418#endif /* FREECIV_JSON_CONNECTION */
52419
52420 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->work_raise_chance[i])) {
52421 RECEIVE_PACKET_FIELD_ERROR(work_raise_chance);
52422 }
52423 }
52424
52425#ifdef FREECIV_JSON_CONNECTION
52426 /* Exit array. */
52427 FC_FREE(field_addr.sub_location);
52428#endif /* FREECIV_JSON_CONNECTION */
52429 }
52430
52431#ifdef FREECIV_JSON_CONNECTION
52432 field_addr.name = "background_red";
52433#endif /* FREECIV_JSON_CONNECTION */
52434
52435 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->background_red)) {
52436 RECEIVE_PACKET_FIELD_ERROR(background_red);
52437 }
52438
52439#ifdef FREECIV_JSON_CONNECTION
52440 field_addr.name = "background_green";
52441#endif /* FREECIV_JSON_CONNECTION */
52442
52443 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->background_green)) {
52444 RECEIVE_PACKET_FIELD_ERROR(background_green);
52445 }
52446
52447#ifdef FREECIV_JSON_CONNECTION
52448 field_addr.name = "background_blue";
52449#endif /* FREECIV_JSON_CONNECTION */
52450
52451 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->background_blue)) {
52452 RECEIVE_PACKET_FIELD_ERROR(background_blue);
52453 }
52454#endif /* FREECIV_DELTA_PROTOCOL */
52455
52456 RECEIVE_PACKET_END(real_packet);
52457#undef FREE_PACKET_STRUCT
52458}
52459
52460 static int send_packet_ruleset_game_100(struct connection *pc, const struct packet_ruleset_game *packet)
52461{
52462 const struct packet_ruleset_game *real_packet = packet;
52463 int e;
52464 SEND_PACKET_START(PACKET_RULESET_GAME);
52465
52466 log_packet_detailed("packet_ruleset_game_100: sending info about ()");
52467
52468#ifdef FREECIV_DELTA_PROTOCOL
52469 packet_ruleset_game_100_fields fields;
52470 struct packet_ruleset_game *old;
52471 bool differ;
52472 struct genhash **hash = pc->phs.sent + PACKET_RULESET_GAME;
52473
52474 if (nullptr == *hash) {
52475 *hash = genhash_new_full(hash_packet_ruleset_game_100, cmp_packet_ruleset_game_100,
52476 nullptr, nullptr, nullptr, destroy_packet_ruleset_game);
52477 }
52478 BV_CLR_ALL(fields);
52479
52480 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
52481 old = fc_malloc(sizeof(*old));
52482 /* temporary bitcopy just to insert correctly */
52483 *old = *real_packet;
52484 genhash_insert(*hash, old, old);
52485 init_packet_ruleset_game(old);
52486 }
52487
52488 differ = (old->default_specialist != real_packet->default_specialist);
52489 if (differ) {
52490 BV_SET(fields, 0);
52491 }
52492
52493 differ = (old->global_init_techs_count != real_packet->global_init_techs_count);
52494 if (differ) {
52495 BV_SET(fields, 1);
52496 }
52497
52498 differ = (old->global_init_techs_count != real_packet->global_init_techs_count);
52499 if (!differ) {
52500 int i;
52501
52502 for (i = 0; i < old->global_init_techs_count; i++) {
52503 differ = (old->global_init_techs[i] != real_packet->global_init_techs[i]);
52504 if (differ) {
52505 break;
52506 }
52507 }
52508 }
52509 if (differ) {
52510 BV_SET(fields, 2);
52511 }
52512
52513 differ = (old->global_init_buildings_count != real_packet->global_init_buildings_count);
52514 if (differ) {
52515 BV_SET(fields, 3);
52516 }
52517
52518 differ = (old->global_init_buildings_count != real_packet->global_init_buildings_count);
52519 if (!differ) {
52520 int i;
52521
52522 for (i = 0; i < old->global_init_buildings_count; i++) {
52523 differ = (old->global_init_buildings[i] != real_packet->global_init_buildings[i]);
52524 if (differ) {
52525 break;
52526 }
52527 }
52528 }
52529 if (differ) {
52530 BV_SET(fields, 4);
52531 }
52532
52533 differ = (old->veteran_levels != real_packet->veteran_levels);
52534 if (differ) {
52535 BV_SET(fields, 5);
52536 }
52537
52538 differ = (old->veteran_levels != real_packet->veteran_levels);
52539 if (!differ) {
52540 int i;
52541
52542 for (i = 0; i < old->veteran_levels; i++) {
52543 differ = (strcmp(old->veteran_name[i], real_packet->veteran_name[i]) != 0);
52544 if (differ) {
52545 break;
52546 }
52547 }
52548 }
52549 if (differ) {
52550 BV_SET(fields, 6);
52551 }
52552
52553 differ = (old->veteran_levels != real_packet->veteran_levels);
52554 if (!differ) {
52555 int i;
52556
52557 for (i = 0; i < old->veteran_levels; i++) {
52558 differ = (old->power_fact[i] != real_packet->power_fact[i]);
52559 if (differ) {
52560 break;
52561 }
52562 }
52563 }
52564 if (differ) {
52565 BV_SET(fields, 7);
52566 }
52567
52568 differ = (old->veteran_levels != real_packet->veteran_levels);
52569 if (!differ) {
52570 int i;
52571
52572 for (i = 0; i < old->veteran_levels; i++) {
52573 differ = (old->move_bonus[i] != real_packet->move_bonus[i]);
52574 if (differ) {
52575 break;
52576 }
52577 }
52578 }
52579 if (differ) {
52580 BV_SET(fields, 8);
52581 }
52582
52583 differ = (old->veteran_levels != real_packet->veteran_levels);
52584 if (!differ) {
52585 int i;
52586
52587 for (i = 0; i < old->veteran_levels; i++) {
52588 differ = (old->base_raise_chance[i] != real_packet->base_raise_chance[i]);
52589 if (differ) {
52590 break;
52591 }
52592 }
52593 }
52594 if (differ) {
52595 BV_SET(fields, 9);
52596 }
52597
52598 differ = (old->veteran_levels != real_packet->veteran_levels);
52599 if (!differ) {
52600 int i;
52601
52602 for (i = 0; i < old->veteran_levels; i++) {
52603 differ = (old->work_raise_chance[i] != real_packet->work_raise_chance[i]);
52604 if (differ) {
52605 break;
52606 }
52607 }
52608 }
52609 if (differ) {
52610 BV_SET(fields, 10);
52611 }
52612
52613 differ = (old->background_red != real_packet->background_red);
52614 if (differ) {
52615 BV_SET(fields, 11);
52616 }
52617
52618 differ = (old->background_green != real_packet->background_green);
52619 if (differ) {
52620 BV_SET(fields, 12);
52621 }
52622
52623 differ = (old->background_blue != real_packet->background_blue);
52624 if (differ) {
52625 BV_SET(fields, 13);
52626 }
52627#endif /* FREECIV_DELTA_PROTOCOL */
52628
52629#ifdef FREECIV_JSON_CONNECTION
52630 struct plocation field_addr;
52631 {
52632 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
52633 field_addr = *field_addr_tmp;
52634 FC_FREE(field_addr_tmp);
52635 }
52636#endif /* FREECIV_JSON_CONNECTION */
52637
52638#ifdef FREECIV_DELTA_PROTOCOL
52639#ifdef FREECIV_JSON_CONNECTION
52640 field_addr.name = "fields";
52641#endif /* FREECIV_JSON_CONNECTION */
52642 e = 0;
52643 e |= DIO_BV_PUT(&dout, &field_addr, fields);
52644 if (e) {
52645 log_packet_detailed("fields bitvector error detected");
52646 }
52647
52648 if (BV_ISSET(fields, 0)) {
52649 log_packet_detailed(" field 'default_specialist' has changed");
52650
52651#ifdef FREECIV_JSON_CONNECTION
52652 field_addr.name = "default_specialist";
52653#endif /* FREECIV_JSON_CONNECTION */
52654 e = 0;
52655
52656 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->default_specialist);
52657
52658 if (e) {
52659 log_packet_detailed("'default_specialist' field error detected");
52660 }
52661 }
52662
52663 if (BV_ISSET(fields, 1)) {
52664 log_packet_detailed(" field 'global_init_techs_count' has changed");
52665
52666#ifdef FREECIV_JSON_CONNECTION
52667 field_addr.name = "global_init_techs_count";
52668#endif /* FREECIV_JSON_CONNECTION */
52669 e = 0;
52670
52671 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->global_init_techs_count);
52672
52673 if (e) {
52674 log_packet_detailed("'global_init_techs_count' field error detected");
52675 }
52676 }
52677
52678 if (BV_ISSET(fields, 2)) {
52679 log_packet_detailed(" field 'global_init_techs' has changed");
52680
52681#ifdef FREECIV_JSON_CONNECTION
52682 field_addr.name = "global_init_techs";
52683#endif /* FREECIV_JSON_CONNECTION */
52684 e = 0;
52685
52686 {
52687 int i;
52688
52689#ifdef FREECIV_JSON_CONNECTION
52690 /* Create the array. */
52691 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->global_init_techs_count);
52692
52693 /* Enter array. */
52694 field_addr.sub_location = plocation_elem_new(0);
52695#endif /* FREECIV_JSON_CONNECTION */
52696
52697 for (i = 0; i < real_packet->global_init_techs_count; i++) {
52698#ifdef FREECIV_JSON_CONNECTION
52699 /* Next array element. */
52700 field_addr.sub_location->number = i;
52701#endif /* FREECIV_JSON_CONNECTION */
52702
52703 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->global_init_techs[i]);
52704 }
52705
52706#ifdef FREECIV_JSON_CONNECTION
52707 /* Exit array. */
52708 FC_FREE(field_addr.sub_location);
52709#endif /* FREECIV_JSON_CONNECTION */
52710 }
52711
52712 if (e) {
52713 log_packet_detailed("'global_init_techs' field error detected");
52714 }
52715 }
52716
52717 if (BV_ISSET(fields, 3)) {
52718 log_packet_detailed(" field 'global_init_buildings_count' has changed");
52719
52720#ifdef FREECIV_JSON_CONNECTION
52721 field_addr.name = "global_init_buildings_count";
52722#endif /* FREECIV_JSON_CONNECTION */
52723 e = 0;
52724
52725 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->global_init_buildings_count);
52726
52727 if (e) {
52728 log_packet_detailed("'global_init_buildings_count' field error detected");
52729 }
52730 }
52731
52732 if (BV_ISSET(fields, 4)) {
52733 log_packet_detailed(" field 'global_init_buildings' has changed");
52734
52735#ifdef FREECIV_JSON_CONNECTION
52736 field_addr.name = "global_init_buildings";
52737#endif /* FREECIV_JSON_CONNECTION */
52738 e = 0;
52739
52740 {
52741 int i;
52742
52743#ifdef FREECIV_JSON_CONNECTION
52744 /* Create the array. */
52745 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->global_init_buildings_count);
52746
52747 /* Enter array. */
52748 field_addr.sub_location = plocation_elem_new(0);
52749#endif /* FREECIV_JSON_CONNECTION */
52750
52751 for (i = 0; i < real_packet->global_init_buildings_count; i++) {
52752#ifdef FREECIV_JSON_CONNECTION
52753 /* Next array element. */
52754 field_addr.sub_location->number = i;
52755#endif /* FREECIV_JSON_CONNECTION */
52756
52757 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->global_init_buildings[i]);
52758 }
52759
52760#ifdef FREECIV_JSON_CONNECTION
52761 /* Exit array. */
52762 FC_FREE(field_addr.sub_location);
52763#endif /* FREECIV_JSON_CONNECTION */
52764 }
52765
52766 if (e) {
52767 log_packet_detailed("'global_init_buildings' field error detected");
52768 }
52769 }
52770
52771 if (BV_ISSET(fields, 5)) {
52772 log_packet_detailed(" field 'veteran_levels' has changed");
52773
52774#ifdef FREECIV_JSON_CONNECTION
52775 field_addr.name = "veteran_levels";
52776#endif /* FREECIV_JSON_CONNECTION */
52777 e = 0;
52778
52779 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran_levels);
52780
52781 if (e) {
52782 log_packet_detailed("'veteran_levels' field error detected");
52783 }
52784 }
52785
52786 if (BV_ISSET(fields, 6)) {
52787 log_packet_detailed(" field 'veteran_name' has changed");
52788
52789#ifdef FREECIV_JSON_CONNECTION
52790 field_addr.name = "veteran_name";
52791#endif /* FREECIV_JSON_CONNECTION */
52792 e = 0;
52793
52794 {
52795 int i;
52796
52797#ifdef FREECIV_JSON_CONNECTION
52798 /* Create the array. */
52799 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
52800
52801 /* Enter array. */
52802 field_addr.sub_location = plocation_elem_new(0);
52803#endif /* FREECIV_JSON_CONNECTION */
52804
52805 for (i = 0; i < real_packet->veteran_levels; i++) {
52806#ifdef FREECIV_JSON_CONNECTION
52807 /* Next array element. */
52808 field_addr.sub_location->number = i;
52809#endif /* FREECIV_JSON_CONNECTION */
52810
52811 e |= DIO_PUT(string, &dout, &field_addr, real_packet->veteran_name[i]);
52812 }
52813
52814#ifdef FREECIV_JSON_CONNECTION
52815 /* Exit array. */
52816 FC_FREE(field_addr.sub_location);
52817#endif /* FREECIV_JSON_CONNECTION */
52818 }
52819
52820 if (e) {
52821 log_packet_detailed("'veteran_name' field error detected");
52822 }
52823 }
52824
52825 if (BV_ISSET(fields, 7)) {
52826 log_packet_detailed(" field 'power_fact' has changed");
52827
52828#ifdef FREECIV_JSON_CONNECTION
52829 field_addr.name = "power_fact";
52830#endif /* FREECIV_JSON_CONNECTION */
52831 e = 0;
52832
52833 {
52834 int i;
52835
52836#ifdef FREECIV_JSON_CONNECTION
52837 /* Create the array. */
52838 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
52839
52840 /* Enter array. */
52841 field_addr.sub_location = plocation_elem_new(0);
52842#endif /* FREECIV_JSON_CONNECTION */
52843
52844 for (i = 0; i < real_packet->veteran_levels; i++) {
52845#ifdef FREECIV_JSON_CONNECTION
52846 /* Next array element. */
52847 field_addr.sub_location->number = i;
52848#endif /* FREECIV_JSON_CONNECTION */
52849
52850 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->power_fact[i]);
52851 }
52852
52853#ifdef FREECIV_JSON_CONNECTION
52854 /* Exit array. */
52855 FC_FREE(field_addr.sub_location);
52856#endif /* FREECIV_JSON_CONNECTION */
52857 }
52858
52859 if (e) {
52860 log_packet_detailed("'power_fact' field error detected");
52861 }
52862 }
52863
52864 if (BV_ISSET(fields, 8)) {
52865 log_packet_detailed(" field 'move_bonus' has changed");
52866
52867#ifdef FREECIV_JSON_CONNECTION
52868 field_addr.name = "move_bonus";
52869#endif /* FREECIV_JSON_CONNECTION */
52870 e = 0;
52871
52872 {
52873 int i;
52874
52875#ifdef FREECIV_JSON_CONNECTION
52876 /* Create the array. */
52877 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
52878
52879 /* Enter array. */
52880 field_addr.sub_location = plocation_elem_new(0);
52881#endif /* FREECIV_JSON_CONNECTION */
52882
52883 for (i = 0; i < real_packet->veteran_levels; i++) {
52884#ifdef FREECIV_JSON_CONNECTION
52885 /* Next array element. */
52886 field_addr.sub_location->number = i;
52887#endif /* FREECIV_JSON_CONNECTION */
52888
52889 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_bonus[i]);
52890 }
52891
52892#ifdef FREECIV_JSON_CONNECTION
52893 /* Exit array. */
52894 FC_FREE(field_addr.sub_location);
52895#endif /* FREECIV_JSON_CONNECTION */
52896 }
52897
52898 if (e) {
52899 log_packet_detailed("'move_bonus' field error detected");
52900 }
52901 }
52902
52903 if (BV_ISSET(fields, 9)) {
52904 log_packet_detailed(" field 'base_raise_chance' has changed");
52905
52906#ifdef FREECIV_JSON_CONNECTION
52907 field_addr.name = "base_raise_chance";
52908#endif /* FREECIV_JSON_CONNECTION */
52909 e = 0;
52910
52911 {
52912 int i;
52913
52914#ifdef FREECIV_JSON_CONNECTION
52915 /* Create the array. */
52916 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
52917
52918 /* Enter array. */
52919 field_addr.sub_location = plocation_elem_new(0);
52920#endif /* FREECIV_JSON_CONNECTION */
52921
52922 for (i = 0; i < real_packet->veteran_levels; i++) {
52923#ifdef FREECIV_JSON_CONNECTION
52924 /* Next array element. */
52925 field_addr.sub_location->number = i;
52926#endif /* FREECIV_JSON_CONNECTION */
52927
52928 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->base_raise_chance[i]);
52929 }
52930
52931#ifdef FREECIV_JSON_CONNECTION
52932 /* Exit array. */
52933 FC_FREE(field_addr.sub_location);
52934#endif /* FREECIV_JSON_CONNECTION */
52935 }
52936
52937 if (e) {
52938 log_packet_detailed("'base_raise_chance' field error detected");
52939 }
52940 }
52941
52942 if (BV_ISSET(fields, 10)) {
52943 log_packet_detailed(" field 'work_raise_chance' has changed");
52944
52945#ifdef FREECIV_JSON_CONNECTION
52946 field_addr.name = "work_raise_chance";
52947#endif /* FREECIV_JSON_CONNECTION */
52948 e = 0;
52949
52950 {
52951 int i;
52952
52953#ifdef FREECIV_JSON_CONNECTION
52954 /* Create the array. */
52955 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
52956
52957 /* Enter array. */
52958 field_addr.sub_location = plocation_elem_new(0);
52959#endif /* FREECIV_JSON_CONNECTION */
52960
52961 for (i = 0; i < real_packet->veteran_levels; i++) {
52962#ifdef FREECIV_JSON_CONNECTION
52963 /* Next array element. */
52964 field_addr.sub_location->number = i;
52965#endif /* FREECIV_JSON_CONNECTION */
52966
52967 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->work_raise_chance[i]);
52968 }
52969
52970#ifdef FREECIV_JSON_CONNECTION
52971 /* Exit array. */
52972 FC_FREE(field_addr.sub_location);
52973#endif /* FREECIV_JSON_CONNECTION */
52974 }
52975
52976 if (e) {
52977 log_packet_detailed("'work_raise_chance' field error detected");
52978 }
52979 }
52980
52981 if (BV_ISSET(fields, 11)) {
52982 log_packet_detailed(" field 'background_red' has changed");
52983
52984#ifdef FREECIV_JSON_CONNECTION
52985 field_addr.name = "background_red";
52986#endif /* FREECIV_JSON_CONNECTION */
52987 e = 0;
52988
52989 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->background_red);
52990
52991 if (e) {
52992 log_packet_detailed("'background_red' field error detected");
52993 }
52994 }
52995
52996 if (BV_ISSET(fields, 12)) {
52997 log_packet_detailed(" field 'background_green' has changed");
52998
52999#ifdef FREECIV_JSON_CONNECTION
53000 field_addr.name = "background_green";
53001#endif /* FREECIV_JSON_CONNECTION */
53002 e = 0;
53003
53004 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->background_green);
53005
53006 if (e) {
53007 log_packet_detailed("'background_green' field error detected");
53008 }
53009 }
53010
53011 if (BV_ISSET(fields, 13)) {
53012 log_packet_detailed(" field 'background_blue' has changed");
53013
53014#ifdef FREECIV_JSON_CONNECTION
53015 field_addr.name = "background_blue";
53016#endif /* FREECIV_JSON_CONNECTION */
53017 e = 0;
53018
53019 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->background_blue);
53020
53021 if (e) {
53022 log_packet_detailed("'background_blue' field error detected");
53023 }
53024 }
53025
53026 *old = *real_packet;
53027
53028#else /* FREECIV_DELTA_PROTOCOL */
53029#ifdef FREECIV_JSON_CONNECTION
53030 field_addr.name = "default_specialist";
53031#endif /* FREECIV_JSON_CONNECTION */
53032 e = 0;
53033
53034 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->default_specialist);
53035
53036 if (e) {
53037 log_packet_detailed("'default_specialist' field error detected");
53038 }
53039
53040#ifdef FREECIV_JSON_CONNECTION
53041 field_addr.name = "global_init_techs_count";
53042#endif /* FREECIV_JSON_CONNECTION */
53043 e = 0;
53044
53045 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->global_init_techs_count);
53046
53047 if (e) {
53048 log_packet_detailed("'global_init_techs_count' field error detected");
53049 }
53050
53051#ifdef FREECIV_JSON_CONNECTION
53052 field_addr.name = "global_init_techs";
53053#endif /* FREECIV_JSON_CONNECTION */
53054 e = 0;
53055
53056 {
53057 int i;
53058
53059#ifdef FREECIV_JSON_CONNECTION
53060 /* Create the array. */
53061 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->global_init_techs_count);
53062
53063 /* Enter array. */
53064 field_addr.sub_location = plocation_elem_new(0);
53065#endif /* FREECIV_JSON_CONNECTION */
53066
53067 for (i = 0; i < real_packet->global_init_techs_count; i++) {
53068#ifdef FREECIV_JSON_CONNECTION
53069 /* Next array element. */
53070 field_addr.sub_location->number = i;
53071#endif /* FREECIV_JSON_CONNECTION */
53072
53073 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->global_init_techs[i]);
53074 }
53075
53076#ifdef FREECIV_JSON_CONNECTION
53077 /* Exit array. */
53078 FC_FREE(field_addr.sub_location);
53079#endif /* FREECIV_JSON_CONNECTION */
53080 }
53081
53082 if (e) {
53083 log_packet_detailed("'global_init_techs' field error detected");
53084 }
53085
53086#ifdef FREECIV_JSON_CONNECTION
53087 field_addr.name = "global_init_buildings_count";
53088#endif /* FREECIV_JSON_CONNECTION */
53089 e = 0;
53090
53091 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->global_init_buildings_count);
53092
53093 if (e) {
53094 log_packet_detailed("'global_init_buildings_count' field error detected");
53095 }
53096
53097#ifdef FREECIV_JSON_CONNECTION
53098 field_addr.name = "global_init_buildings";
53099#endif /* FREECIV_JSON_CONNECTION */
53100 e = 0;
53101
53102 {
53103 int i;
53104
53105#ifdef FREECIV_JSON_CONNECTION
53106 /* Create the array. */
53107 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->global_init_buildings_count);
53108
53109 /* Enter array. */
53110 field_addr.sub_location = plocation_elem_new(0);
53111#endif /* FREECIV_JSON_CONNECTION */
53112
53113 for (i = 0; i < real_packet->global_init_buildings_count; i++) {
53114#ifdef FREECIV_JSON_CONNECTION
53115 /* Next array element. */
53116 field_addr.sub_location->number = i;
53117#endif /* FREECIV_JSON_CONNECTION */
53118
53119 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->global_init_buildings[i]);
53120 }
53121
53122#ifdef FREECIV_JSON_CONNECTION
53123 /* Exit array. */
53124 FC_FREE(field_addr.sub_location);
53125#endif /* FREECIV_JSON_CONNECTION */
53126 }
53127
53128 if (e) {
53129 log_packet_detailed("'global_init_buildings' field error detected");
53130 }
53131
53132#ifdef FREECIV_JSON_CONNECTION
53133 field_addr.name = "veteran_levels";
53134#endif /* FREECIV_JSON_CONNECTION */
53135 e = 0;
53136
53137 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran_levels);
53138
53139 if (e) {
53140 log_packet_detailed("'veteran_levels' field error detected");
53141 }
53142
53143#ifdef FREECIV_JSON_CONNECTION
53144 field_addr.name = "veteran_name";
53145#endif /* FREECIV_JSON_CONNECTION */
53146 e = 0;
53147
53148 {
53149 int i;
53150
53151#ifdef FREECIV_JSON_CONNECTION
53152 /* Create the array. */
53153 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
53154
53155 /* Enter array. */
53156 field_addr.sub_location = plocation_elem_new(0);
53157#endif /* FREECIV_JSON_CONNECTION */
53158
53159 for (i = 0; i < real_packet->veteran_levels; i++) {
53160#ifdef FREECIV_JSON_CONNECTION
53161 /* Next array element. */
53162 field_addr.sub_location->number = i;
53163#endif /* FREECIV_JSON_CONNECTION */
53164
53165 e |= DIO_PUT(string, &dout, &field_addr, real_packet->veteran_name[i]);
53166 }
53167
53168#ifdef FREECIV_JSON_CONNECTION
53169 /* Exit array. */
53170 FC_FREE(field_addr.sub_location);
53171#endif /* FREECIV_JSON_CONNECTION */
53172 }
53173
53174 if (e) {
53175 log_packet_detailed("'veteran_name' field error detected");
53176 }
53177
53178#ifdef FREECIV_JSON_CONNECTION
53179 field_addr.name = "power_fact";
53180#endif /* FREECIV_JSON_CONNECTION */
53181 e = 0;
53182
53183 {
53184 int i;
53185
53186#ifdef FREECIV_JSON_CONNECTION
53187 /* Create the array. */
53188 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
53189
53190 /* Enter array. */
53191 field_addr.sub_location = plocation_elem_new(0);
53192#endif /* FREECIV_JSON_CONNECTION */
53193
53194 for (i = 0; i < real_packet->veteran_levels; i++) {
53195#ifdef FREECIV_JSON_CONNECTION
53196 /* Next array element. */
53197 field_addr.sub_location->number = i;
53198#endif /* FREECIV_JSON_CONNECTION */
53199
53200 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->power_fact[i]);
53201 }
53202
53203#ifdef FREECIV_JSON_CONNECTION
53204 /* Exit array. */
53205 FC_FREE(field_addr.sub_location);
53206#endif /* FREECIV_JSON_CONNECTION */
53207 }
53208
53209 if (e) {
53210 log_packet_detailed("'power_fact' field error detected");
53211 }
53212
53213#ifdef FREECIV_JSON_CONNECTION
53214 field_addr.name = "move_bonus";
53215#endif /* FREECIV_JSON_CONNECTION */
53216 e = 0;
53217
53218 {
53219 int i;
53220
53221#ifdef FREECIV_JSON_CONNECTION
53222 /* Create the array. */
53223 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
53224
53225 /* Enter array. */
53226 field_addr.sub_location = plocation_elem_new(0);
53227#endif /* FREECIV_JSON_CONNECTION */
53228
53229 for (i = 0; i < real_packet->veteran_levels; i++) {
53230#ifdef FREECIV_JSON_CONNECTION
53231 /* Next array element. */
53232 field_addr.sub_location->number = i;
53233#endif /* FREECIV_JSON_CONNECTION */
53234
53235 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_bonus[i]);
53236 }
53237
53238#ifdef FREECIV_JSON_CONNECTION
53239 /* Exit array. */
53240 FC_FREE(field_addr.sub_location);
53241#endif /* FREECIV_JSON_CONNECTION */
53242 }
53243
53244 if (e) {
53245 log_packet_detailed("'move_bonus' field error detected");
53246 }
53247
53248#ifdef FREECIV_JSON_CONNECTION
53249 field_addr.name = "base_raise_chance";
53250#endif /* FREECIV_JSON_CONNECTION */
53251 e = 0;
53252
53253 {
53254 int i;
53255
53256#ifdef FREECIV_JSON_CONNECTION
53257 /* Create the array. */
53258 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
53259
53260 /* Enter array. */
53261 field_addr.sub_location = plocation_elem_new(0);
53262#endif /* FREECIV_JSON_CONNECTION */
53263
53264 for (i = 0; i < real_packet->veteran_levels; i++) {
53265#ifdef FREECIV_JSON_CONNECTION
53266 /* Next array element. */
53267 field_addr.sub_location->number = i;
53268#endif /* FREECIV_JSON_CONNECTION */
53269
53270 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->base_raise_chance[i]);
53271 }
53272
53273#ifdef FREECIV_JSON_CONNECTION
53274 /* Exit array. */
53275 FC_FREE(field_addr.sub_location);
53276#endif /* FREECIV_JSON_CONNECTION */
53277 }
53278
53279 if (e) {
53280 log_packet_detailed("'base_raise_chance' field error detected");
53281 }
53282
53283#ifdef FREECIV_JSON_CONNECTION
53284 field_addr.name = "work_raise_chance";
53285#endif /* FREECIV_JSON_CONNECTION */
53286 e = 0;
53287
53288 {
53289 int i;
53290
53291#ifdef FREECIV_JSON_CONNECTION
53292 /* Create the array. */
53293 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->veteran_levels);
53294
53295 /* Enter array. */
53296 field_addr.sub_location = plocation_elem_new(0);
53297#endif /* FREECIV_JSON_CONNECTION */
53298
53299 for (i = 0; i < real_packet->veteran_levels; i++) {
53300#ifdef FREECIV_JSON_CONNECTION
53301 /* Next array element. */
53302 field_addr.sub_location->number = i;
53303#endif /* FREECIV_JSON_CONNECTION */
53304
53305 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->work_raise_chance[i]);
53306 }
53307
53308#ifdef FREECIV_JSON_CONNECTION
53309 /* Exit array. */
53310 FC_FREE(field_addr.sub_location);
53311#endif /* FREECIV_JSON_CONNECTION */
53312 }
53313
53314 if (e) {
53315 log_packet_detailed("'work_raise_chance' field error detected");
53316 }
53317
53318#ifdef FREECIV_JSON_CONNECTION
53319 field_addr.name = "background_red";
53320#endif /* FREECIV_JSON_CONNECTION */
53321 e = 0;
53322
53323 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->background_red);
53324
53325 if (e) {
53326 log_packet_detailed("'background_red' field error detected");
53327 }
53328
53329#ifdef FREECIV_JSON_CONNECTION
53330 field_addr.name = "background_green";
53331#endif /* FREECIV_JSON_CONNECTION */
53332 e = 0;
53333
53334 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->background_green);
53335
53336 if (e) {
53337 log_packet_detailed("'background_green' field error detected");
53338 }
53339
53340#ifdef FREECIV_JSON_CONNECTION
53341 field_addr.name = "background_blue";
53342#endif /* FREECIV_JSON_CONNECTION */
53343 e = 0;
53344
53345 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->background_blue);
53346
53347 if (e) {
53348 log_packet_detailed("'background_blue' field error detected");
53349 }
53350#endif /* FREECIV_DELTA_PROTOCOL */
53351
53352 SEND_PACKET_END(PACKET_RULESET_GAME);
53353}
53354
53355 int send_packet_ruleset_game(struct connection *pc, const struct packet_ruleset_game *packet)
53356{
53357 if (!pc->used) {
53358 log_error("WARNING: trying to send data to the closed connection %s",
53359 conn_description(pc));
53360 return -1;
53361 }
53362 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GAME].packet != nullptr, -1,
53363 "Handler for PACKET_RULESET_GAME not installed");
53364 return pc->phs.handlers->send[PACKET_RULESET_GAME].packet(pc, packet);
53365}
53366
53367 void lsend_packet_ruleset_game(struct conn_list *dest, const struct packet_ruleset_game *packet)
53368{
53369 conn_list_iterate(dest, pconn) {
53370 send_packet_ruleset_game(pconn, packet);
53371 } conn_list_iterate_end;
53372}
53373
53374 static inline void init_packet_ruleset_specialist(struct packet_ruleset_specialist *packet)
53375{
53376 memset(packet, 0, sizeof(*packet));
53377
53378 requirement_vector_init(&packet->reqs);
53379 packet->helptext = strvec_new();
53380}
53381
53382 static inline void free_packet_ruleset_specialist(struct packet_ruleset_specialist *packet)
53383{
53384 if (packet->helptext) {
53385 strvec_destroy(packet->helptext);
53386 packet->helptext = nullptr;
53387 }
53388 requirement_vector_free(&packet->reqs);
53389}
53390
53391 static inline void destroy_packet_ruleset_specialist(void *packet)
53392{
53393 free_packet_ruleset_specialist((struct packet_ruleset_specialist *) packet);
53394 free(packet);
53395}
53396
53397#ifdef FREECIV_DELTA_PROTOCOL
53398#define hash_packet_ruleset_specialist_100 hash_const
53399#define cmp_packet_ruleset_specialist_100 cmp_const
53400 BV_DEFINE(packet_ruleset_specialist_100_fields, 8);
53401#endif /* FREECIV_DELTA_PROTOCOL */
53402
53403 static struct packet_ruleset_specialist *receive_packet_ruleset_specialist_100(struct connection *pc)
53404{
53405#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_specialist(_packet)
53406 RECEIVE_PACKET_START(packet_ruleset_specialist, real_packet);
53407
53408#ifdef FREECIV_JSON_CONNECTION
53409 struct plocation field_addr;
53410 {
53411 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
53412 field_addr = *field_addr_tmp;
53413 FC_FREE(field_addr_tmp);
53414 }
53415#endif /* FREECIV_JSON_CONNECTION */
53416
53417 log_packet_detailed("packet_ruleset_specialist_100: got info about ()");
53418
53419#ifdef FREECIV_DELTA_PROTOCOL
53420 packet_ruleset_specialist_100_fields fields;
53421 struct packet_ruleset_specialist *old;
53422 struct genhash **hash = pc->phs.received + PACKET_RULESET_SPECIALIST;
53423
53424 if (nullptr == *hash) {
53425 *hash = genhash_new_full(hash_packet_ruleset_specialist_100, cmp_packet_ruleset_specialist_100,
53426 nullptr, nullptr, nullptr, destroy_packet_ruleset_specialist);
53427 }
53428
53429 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
53430 real_packet->id = old->id;
53431 sz_strlcpy(real_packet->plural_name, old->plural_name);
53432 sz_strlcpy(real_packet->rule_name, old->rule_name);
53433 sz_strlcpy(real_packet->short_name, old->short_name);
53434 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
53435 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
53436 requirement_vector_copy(&real_packet->reqs, &old->reqs);
53437 if (old->helptext) {
53438 strvec_copy(real_packet->helptext, old->helptext);
53439 } else {
53440 strvec_clear(real_packet->helptext);
53441 }
53442 } else {
53443 /* packet is already initialized empty */
53444 log_packet_detailed(" no old info");
53445 }
53446
53447#ifdef FREECIV_JSON_CONNECTION
53448 field_addr.name = "fields";
53449#endif /* FREECIV_JSON_CONNECTION */
53450 DIO_BV_GET(&din, &field_addr, fields);
53451
53452 if (BV_ISSET(fields, 0)) {
53453 log_packet_detailed(" got field 'id'");
53454
53455#ifdef FREECIV_JSON_CONNECTION
53456 field_addr.name = "id";
53457#endif /* FREECIV_JSON_CONNECTION */
53458
53459 {
53460 int readin;
53461
53462 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
53463 RECEIVE_PACKET_FIELD_ERROR(id);
53464 }
53465 real_packet->id = readin;
53466 }
53467 }
53468
53469 if (BV_ISSET(fields, 1)) {
53470 log_packet_detailed(" got field 'plural_name'");
53471
53472#ifdef FREECIV_JSON_CONNECTION
53473 field_addr.name = "plural_name";
53474#endif /* FREECIV_JSON_CONNECTION */
53475
53476 if (!DIO_GET(string, &din, &field_addr, real_packet->plural_name, sizeof(real_packet->plural_name))) {
53477 RECEIVE_PACKET_FIELD_ERROR(plural_name);
53478 }
53479 }
53480
53481 if (BV_ISSET(fields, 2)) {
53482 log_packet_detailed(" got field 'rule_name'");
53483
53484#ifdef FREECIV_JSON_CONNECTION
53485 field_addr.name = "rule_name";
53486#endif /* FREECIV_JSON_CONNECTION */
53487
53488 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
53489 RECEIVE_PACKET_FIELD_ERROR(rule_name);
53490 }
53491 }
53492
53493 if (BV_ISSET(fields, 3)) {
53494 log_packet_detailed(" got field 'short_name'");
53495
53496#ifdef FREECIV_JSON_CONNECTION
53497 field_addr.name = "short_name";
53498#endif /* FREECIV_JSON_CONNECTION */
53499
53500 if (!DIO_GET(string, &din, &field_addr, real_packet->short_name, sizeof(real_packet->short_name))) {
53501 RECEIVE_PACKET_FIELD_ERROR(short_name);
53502 }
53503 }
53504
53505 if (BV_ISSET(fields, 4)) {
53506 log_packet_detailed(" got field 'graphic_str'");
53507
53508#ifdef FREECIV_JSON_CONNECTION
53509 field_addr.name = "graphic_str";
53510#endif /* FREECIV_JSON_CONNECTION */
53511
53512 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
53513 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
53514 }
53515 }
53516
53517 if (BV_ISSET(fields, 5)) {
53518 log_packet_detailed(" got field 'graphic_alt'");
53519
53520#ifdef FREECIV_JSON_CONNECTION
53521 field_addr.name = "graphic_alt";
53522#endif /* FREECIV_JSON_CONNECTION */
53523
53524 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
53525 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
53526 }
53527 }
53528
53529 if (BV_ISSET(fields, 6)) {
53530 log_packet_detailed(" got field 'reqs'");
53531
53532#ifdef FREECIV_JSON_CONNECTION
53533 field_addr.name = "reqs";
53534#endif /* FREECIV_JSON_CONNECTION */
53535
53536 {
53537 int i;
53538
53539 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
53540 RECEIVE_PACKET_FIELD_ERROR(reqs);
53541 }
53542 requirement_vector_reserve(&real_packet->reqs, i);
53543
53544#ifdef FREECIV_JSON_CONNECTION
53545 /* Enter array. */
53546 field_addr.sub_location = plocation_elem_new(0);
53547#endif /* FREECIV_JSON_CONNECTION */
53548
53549 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
53550#ifdef FREECIV_JSON_CONNECTION
53551 /* Next array element */
53552 field_addr.sub_location->number = i;
53553#endif /* FREECIV_JSON_CONNECTION */
53554
53555 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
53556 RECEIVE_PACKET_FIELD_ERROR(reqs);
53557 }
53558 }
53559
53560#ifdef FREECIV_JSON_CONNECTION
53561 /* Exit array. */
53562 FC_FREE(field_addr.sub_location);
53563#endif /* FREECIV_JSON_CONNECTION */
53564 }
53565 }
53566
53567 if (BV_ISSET(fields, 7)) {
53568 log_packet_detailed(" got field 'helptext'");
53569
53570#ifdef FREECIV_JSON_CONNECTION
53571 field_addr.name = "helptext";
53572#endif /* FREECIV_JSON_CONNECTION */
53573
53574 {
53575 int i;
53576
53577 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
53578 RECEIVE_PACKET_FIELD_ERROR(helptext);
53579 }
53580 strvec_reserve(real_packet->helptext, i);
53581
53582#ifdef FREECIV_JSON_CONNECTION
53583 /* Enter array. */
53584 field_addr.sub_location = plocation_elem_new(0);
53585#endif /* FREECIV_JSON_CONNECTION */
53586
53587 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
53588#ifdef FREECIV_JSON_CONNECTION
53589 /* Next array element */
53590 field_addr.sub_location->number = i;
53591#endif /* FREECIV_JSON_CONNECTION */
53592
53593 {
53594 char readin[MAX_LEN_PACKET];
53595
53596 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
53597 || !strvec_set(real_packet->helptext, i, readin)) {
53598 RECEIVE_PACKET_FIELD_ERROR(helptext);
53599 }
53600 }
53601 }
53602
53603#ifdef FREECIV_JSON_CONNECTION
53604 /* Exit array. */
53605 FC_FREE(field_addr.sub_location);
53606#endif /* FREECIV_JSON_CONNECTION */
53607 }
53608 }
53609
53610 if (nullptr == old) {
53611 old = fc_malloc(sizeof(*old));
53612 init_packet_ruleset_specialist(old);
53613 old->id = real_packet->id;
53614 sz_strlcpy(old->plural_name, real_packet->plural_name);
53615 sz_strlcpy(old->rule_name, real_packet->rule_name);
53616 sz_strlcpy(old->short_name, real_packet->short_name);
53617 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
53618 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
53619 requirement_vector_copy(&old->reqs, &real_packet->reqs);
53620 if (real_packet->helptext) {
53621 strvec_copy(old->helptext, real_packet->helptext);
53622 } else {
53623 strvec_clear(old->helptext);
53624 }
53625 genhash_insert(*hash, old, old);
53626 } else {
53627 old->id = real_packet->id;
53628 sz_strlcpy(old->plural_name, real_packet->plural_name);
53629 sz_strlcpy(old->rule_name, real_packet->rule_name);
53630 sz_strlcpy(old->short_name, real_packet->short_name);
53631 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
53632 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
53633 requirement_vector_copy(&old->reqs, &real_packet->reqs);
53634 if (real_packet->helptext) {
53635 strvec_copy(old->helptext, real_packet->helptext);
53636 } else {
53637 strvec_clear(old->helptext);
53638 }
53639 }
53640
53641#else /* FREECIV_DELTA_PROTOCOL */
53642#ifdef FREECIV_JSON_CONNECTION
53643 field_addr.name = "id";
53644#endif /* FREECIV_JSON_CONNECTION */
53645
53646 {
53647 int readin;
53648
53649 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
53650 RECEIVE_PACKET_FIELD_ERROR(id);
53651 }
53652 real_packet->id = readin;
53653 }
53654
53655#ifdef FREECIV_JSON_CONNECTION
53656 field_addr.name = "plural_name";
53657#endif /* FREECIV_JSON_CONNECTION */
53658
53659 if (!DIO_GET(string, &din, &field_addr, real_packet->plural_name, sizeof(real_packet->plural_name))) {
53660 RECEIVE_PACKET_FIELD_ERROR(plural_name);
53661 }
53662
53663#ifdef FREECIV_JSON_CONNECTION
53664 field_addr.name = "rule_name";
53665#endif /* FREECIV_JSON_CONNECTION */
53666
53667 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
53668 RECEIVE_PACKET_FIELD_ERROR(rule_name);
53669 }
53670
53671#ifdef FREECIV_JSON_CONNECTION
53672 field_addr.name = "short_name";
53673#endif /* FREECIV_JSON_CONNECTION */
53674
53675 if (!DIO_GET(string, &din, &field_addr, real_packet->short_name, sizeof(real_packet->short_name))) {
53676 RECEIVE_PACKET_FIELD_ERROR(short_name);
53677 }
53678
53679#ifdef FREECIV_JSON_CONNECTION
53680 field_addr.name = "graphic_str";
53681#endif /* FREECIV_JSON_CONNECTION */
53682
53683 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
53684 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
53685 }
53686
53687#ifdef FREECIV_JSON_CONNECTION
53688 field_addr.name = "graphic_alt";
53689#endif /* FREECIV_JSON_CONNECTION */
53690
53691 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
53692 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
53693 }
53694
53695#ifdef FREECIV_JSON_CONNECTION
53696 field_addr.name = "reqs";
53697#endif /* FREECIV_JSON_CONNECTION */
53698
53699 {
53700 int i;
53701
53702 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
53703 RECEIVE_PACKET_FIELD_ERROR(reqs);
53704 }
53705 requirement_vector_reserve(&real_packet->reqs, i);
53706
53707#ifdef FREECIV_JSON_CONNECTION
53708 /* Enter array. */
53709 field_addr.sub_location = plocation_elem_new(0);
53710#endif /* FREECIV_JSON_CONNECTION */
53711
53712 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
53713#ifdef FREECIV_JSON_CONNECTION
53714 /* Next array element */
53715 field_addr.sub_location->number = i;
53716#endif /* FREECIV_JSON_CONNECTION */
53717
53718 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
53719 RECEIVE_PACKET_FIELD_ERROR(reqs);
53720 }
53721 }
53722
53723#ifdef FREECIV_JSON_CONNECTION
53724 /* Exit array. */
53725 FC_FREE(field_addr.sub_location);
53726#endif /* FREECIV_JSON_CONNECTION */
53727 }
53728
53729#ifdef FREECIV_JSON_CONNECTION
53730 field_addr.name = "helptext";
53731#endif /* FREECIV_JSON_CONNECTION */
53732
53733 {
53734 int i;
53735
53736 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
53737 RECEIVE_PACKET_FIELD_ERROR(helptext);
53738 }
53739 strvec_reserve(real_packet->helptext, i);
53740
53741#ifdef FREECIV_JSON_CONNECTION
53742 /* Enter array. */
53743 field_addr.sub_location = plocation_elem_new(0);
53744#endif /* FREECIV_JSON_CONNECTION */
53745
53746 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
53747#ifdef FREECIV_JSON_CONNECTION
53748 /* Next array element */
53749 field_addr.sub_location->number = i;
53750#endif /* FREECIV_JSON_CONNECTION */
53751
53752 {
53753 char readin[MAX_LEN_PACKET];
53754
53755 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
53756 || !strvec_set(real_packet->helptext, i, readin)) {
53757 RECEIVE_PACKET_FIELD_ERROR(helptext);
53758 }
53759 }
53760 }
53761
53762#ifdef FREECIV_JSON_CONNECTION
53763 /* Exit array. */
53764 FC_FREE(field_addr.sub_location);
53765#endif /* FREECIV_JSON_CONNECTION */
53766 }
53767#endif /* FREECIV_DELTA_PROTOCOL */
53768
53769 RECEIVE_PACKET_END(real_packet);
53770#undef FREE_PACKET_STRUCT
53771}
53772
53773 static int send_packet_ruleset_specialist_100(struct connection *pc, const struct packet_ruleset_specialist *packet)
53774{
53775 const struct packet_ruleset_specialist *real_packet = packet;
53776 int e;
53777 SEND_PACKET_START(PACKET_RULESET_SPECIALIST);
53778
53779 log_packet_detailed("packet_ruleset_specialist_100: sending info about ()");
53780
53781#ifdef FREECIV_DELTA_PROTOCOL
53782 packet_ruleset_specialist_100_fields fields;
53783 struct packet_ruleset_specialist *old;
53784 bool differ;
53785 struct genhash **hash = pc->phs.sent + PACKET_RULESET_SPECIALIST;
53786
53787 if (nullptr == *hash) {
53788 *hash = genhash_new_full(hash_packet_ruleset_specialist_100, cmp_packet_ruleset_specialist_100,
53789 nullptr, nullptr, nullptr, destroy_packet_ruleset_specialist);
53790 }
53791 BV_CLR_ALL(fields);
53792
53793 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
53794 old = fc_malloc(sizeof(*old));
53795 /* temporary bitcopy just to insert correctly */
53796 *old = *real_packet;
53797 genhash_insert(*hash, old, old);
53798 init_packet_ruleset_specialist(old);
53799 }
53800
53801 differ = (old->id != real_packet->id);
53802 if (differ) {
53803 BV_SET(fields, 0);
53804 }
53805
53806 differ = (strcmp(old->plural_name, real_packet->plural_name) != 0);
53807 if (differ) {
53808 BV_SET(fields, 1);
53809 }
53810
53811 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
53812 if (differ) {
53813 BV_SET(fields, 2);
53814 }
53815
53816 differ = (strcmp(old->short_name, real_packet->short_name) != 0);
53817 if (differ) {
53818 BV_SET(fields, 3);
53819 }
53820
53821 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
53822 if (differ) {
53823 BV_SET(fields, 4);
53824 }
53825
53826 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
53827 if (differ) {
53828 BV_SET(fields, 5);
53829 }
53830
53831 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
53832 if (!differ) {
53833 int i;
53834
53835 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
53836 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
53837 if (differ) {
53838 break;
53839 }
53840 }
53841 }
53842 if (differ) {
53843 BV_SET(fields, 6);
53844 }
53845
53846 if (real_packet->helptext) {
53847 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
53848 } else {
53849 differ = (strvec_size(old->helptext) > 0);
53850 }
53851 if (differ) {
53852 BV_SET(fields, 7);
53853 }
53854#endif /* FREECIV_DELTA_PROTOCOL */
53855
53856#ifdef FREECIV_JSON_CONNECTION
53857 struct plocation field_addr;
53858 {
53859 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
53860 field_addr = *field_addr_tmp;
53861 FC_FREE(field_addr_tmp);
53862 }
53863#endif /* FREECIV_JSON_CONNECTION */
53864
53865#ifdef FREECIV_DELTA_PROTOCOL
53866#ifdef FREECIV_JSON_CONNECTION
53867 field_addr.name = "fields";
53868#endif /* FREECIV_JSON_CONNECTION */
53869 e = 0;
53870 e |= DIO_BV_PUT(&dout, &field_addr, fields);
53871 if (e) {
53872 log_packet_detailed("fields bitvector error detected");
53873 }
53874
53875 if (BV_ISSET(fields, 0)) {
53876 log_packet_detailed(" field 'id' has changed");
53877
53878#ifdef FREECIV_JSON_CONNECTION
53879 field_addr.name = "id";
53880#endif /* FREECIV_JSON_CONNECTION */
53881 e = 0;
53882
53883 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
53884
53885 if (e) {
53886 log_packet_detailed("'id' field error detected");
53887 }
53888 }
53889
53890 if (BV_ISSET(fields, 1)) {
53891 log_packet_detailed(" field 'plural_name' has changed");
53892
53893#ifdef FREECIV_JSON_CONNECTION
53894 field_addr.name = "plural_name";
53895#endif /* FREECIV_JSON_CONNECTION */
53896 e = 0;
53897
53898 e |= DIO_PUT(string, &dout, &field_addr, real_packet->plural_name);
53899
53900 if (e) {
53901 log_packet_detailed("'plural_name' field error detected");
53902 }
53903 }
53904
53905 if (BV_ISSET(fields, 2)) {
53906 log_packet_detailed(" field 'rule_name' has changed");
53907
53908#ifdef FREECIV_JSON_CONNECTION
53909 field_addr.name = "rule_name";
53910#endif /* FREECIV_JSON_CONNECTION */
53911 e = 0;
53912
53913 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
53914
53915 if (e) {
53916 log_packet_detailed("'rule_name' field error detected");
53917 }
53918 }
53919
53920 if (BV_ISSET(fields, 3)) {
53921 log_packet_detailed(" field 'short_name' has changed");
53922
53923#ifdef FREECIV_JSON_CONNECTION
53924 field_addr.name = "short_name";
53925#endif /* FREECIV_JSON_CONNECTION */
53926 e = 0;
53927
53928 e |= DIO_PUT(string, &dout, &field_addr, real_packet->short_name);
53929
53930 if (e) {
53931 log_packet_detailed("'short_name' field error detected");
53932 }
53933 }
53934
53935 if (BV_ISSET(fields, 4)) {
53936 log_packet_detailed(" field 'graphic_str' has changed");
53937
53938#ifdef FREECIV_JSON_CONNECTION
53939 field_addr.name = "graphic_str";
53940#endif /* FREECIV_JSON_CONNECTION */
53941 e = 0;
53942
53943 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
53944
53945 if (e) {
53946 log_packet_detailed("'graphic_str' field error detected");
53947 }
53948 }
53949
53950 if (BV_ISSET(fields, 5)) {
53951 log_packet_detailed(" field 'graphic_alt' has changed");
53952
53953#ifdef FREECIV_JSON_CONNECTION
53954 field_addr.name = "graphic_alt";
53955#endif /* FREECIV_JSON_CONNECTION */
53956 e = 0;
53957
53958 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
53959
53960 if (e) {
53961 log_packet_detailed("'graphic_alt' field error detected");
53962 }
53963 }
53964
53965 if (BV_ISSET(fields, 6)) {
53966 log_packet_detailed(" field 'reqs' has changed");
53967
53968#ifdef FREECIV_JSON_CONNECTION
53969 field_addr.name = "reqs";
53970#endif /* FREECIV_JSON_CONNECTION */
53971 e = 0;
53972
53973 {
53974 int i;
53975
53976 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
53977 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
53978
53979#ifdef FREECIV_JSON_CONNECTION
53980 /* Enter array. */
53981 field_addr.sub_location = plocation_elem_new(0);
53982#endif /* FREECIV_JSON_CONNECTION */
53983
53984 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
53985#ifdef FREECIV_JSON_CONNECTION
53986 /* Next array element. */
53987 field_addr.sub_location->number = i;
53988#endif /* FREECIV_JSON_CONNECTION */
53989
53990 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
53991 }
53992
53993#ifdef FREECIV_JSON_CONNECTION
53994 /* Exit array. */
53995 FC_FREE(field_addr.sub_location);
53996#endif /* FREECIV_JSON_CONNECTION */
53997 }
53998
53999 if (e) {
54000 log_packet_detailed("'reqs' field error detected");
54001 }
54002 }
54003
54004 if (BV_ISSET(fields, 7)) {
54005 log_packet_detailed(" field 'helptext' has changed");
54006
54007#ifdef FREECIV_JSON_CONNECTION
54008 field_addr.name = "helptext";
54009#endif /* FREECIV_JSON_CONNECTION */
54010 e = 0;
54011
54012 if (!real_packet->helptext) {
54013 /* Transmit null as empty */
54014 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
54015 } else {
54016 int i;
54017
54018 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
54019 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
54020
54021#ifdef FREECIV_JSON_CONNECTION
54022 /* Enter array. */
54023 field_addr.sub_location = plocation_elem_new(0);
54024#endif /* FREECIV_JSON_CONNECTION */
54025
54026 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
54027#ifdef FREECIV_JSON_CONNECTION
54028 /* Next array element. */
54029 field_addr.sub_location->number = i;
54030#endif /* FREECIV_JSON_CONNECTION */
54031
54032 {
54033 const char *pstr = strvec_get(real_packet->helptext, i);
54034
54035 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
54036 }
54037 }
54038
54039#ifdef FREECIV_JSON_CONNECTION
54040 /* Exit array. */
54041 FC_FREE(field_addr.sub_location);
54042#endif /* FREECIV_JSON_CONNECTION */
54043 }
54044
54045 if (e) {
54046 log_packet_detailed("'helptext' field error detected");
54047 }
54048 }
54049
54050 old->id = real_packet->id;
54051 sz_strlcpy(old->plural_name, real_packet->plural_name);
54052 sz_strlcpy(old->rule_name, real_packet->rule_name);
54053 sz_strlcpy(old->short_name, real_packet->short_name);
54054 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
54055 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
54056 requirement_vector_copy(&old->reqs, &real_packet->reqs);
54057 if (real_packet->helptext) {
54058 strvec_copy(old->helptext, real_packet->helptext);
54059 } else {
54060 strvec_clear(old->helptext);
54061 }
54062
54063#else /* FREECIV_DELTA_PROTOCOL */
54064#ifdef FREECIV_JSON_CONNECTION
54065 field_addr.name = "id";
54066#endif /* FREECIV_JSON_CONNECTION */
54067 e = 0;
54068
54069 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
54070
54071 if (e) {
54072 log_packet_detailed("'id' field error detected");
54073 }
54074
54075#ifdef FREECIV_JSON_CONNECTION
54076 field_addr.name = "plural_name";
54077#endif /* FREECIV_JSON_CONNECTION */
54078 e = 0;
54079
54080 e |= DIO_PUT(string, &dout, &field_addr, real_packet->plural_name);
54081
54082 if (e) {
54083 log_packet_detailed("'plural_name' field error detected");
54084 }
54085
54086#ifdef FREECIV_JSON_CONNECTION
54087 field_addr.name = "rule_name";
54088#endif /* FREECIV_JSON_CONNECTION */
54089 e = 0;
54090
54091 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
54092
54093 if (e) {
54094 log_packet_detailed("'rule_name' field error detected");
54095 }
54096
54097#ifdef FREECIV_JSON_CONNECTION
54098 field_addr.name = "short_name";
54099#endif /* FREECIV_JSON_CONNECTION */
54100 e = 0;
54101
54102 e |= DIO_PUT(string, &dout, &field_addr, real_packet->short_name);
54103
54104 if (e) {
54105 log_packet_detailed("'short_name' field error detected");
54106 }
54107
54108#ifdef FREECIV_JSON_CONNECTION
54109 field_addr.name = "graphic_str";
54110#endif /* FREECIV_JSON_CONNECTION */
54111 e = 0;
54112
54113 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
54114
54115 if (e) {
54116 log_packet_detailed("'graphic_str' field error detected");
54117 }
54118
54119#ifdef FREECIV_JSON_CONNECTION
54120 field_addr.name = "graphic_alt";
54121#endif /* FREECIV_JSON_CONNECTION */
54122 e = 0;
54123
54124 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
54125
54126 if (e) {
54127 log_packet_detailed("'graphic_alt' field error detected");
54128 }
54129
54130#ifdef FREECIV_JSON_CONNECTION
54131 field_addr.name = "reqs";
54132#endif /* FREECIV_JSON_CONNECTION */
54133 e = 0;
54134
54135 {
54136 int i;
54137
54138 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
54139 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
54140
54141#ifdef FREECIV_JSON_CONNECTION
54142 /* Enter array. */
54143 field_addr.sub_location = plocation_elem_new(0);
54144#endif /* FREECIV_JSON_CONNECTION */
54145
54146 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
54147#ifdef FREECIV_JSON_CONNECTION
54148 /* Next array element. */
54149 field_addr.sub_location->number = i;
54150#endif /* FREECIV_JSON_CONNECTION */
54151
54152 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
54153 }
54154
54155#ifdef FREECIV_JSON_CONNECTION
54156 /* Exit array. */
54157 FC_FREE(field_addr.sub_location);
54158#endif /* FREECIV_JSON_CONNECTION */
54159 }
54160
54161 if (e) {
54162 log_packet_detailed("'reqs' field error detected");
54163 }
54164
54165#ifdef FREECIV_JSON_CONNECTION
54166 field_addr.name = "helptext";
54167#endif /* FREECIV_JSON_CONNECTION */
54168 e = 0;
54169
54170 if (!real_packet->helptext) {
54171 /* Transmit null as empty */
54172 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
54173 } else {
54174 int i;
54175
54176 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
54177 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
54178
54179#ifdef FREECIV_JSON_CONNECTION
54180 /* Enter array. */
54181 field_addr.sub_location = plocation_elem_new(0);
54182#endif /* FREECIV_JSON_CONNECTION */
54183
54184 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
54185#ifdef FREECIV_JSON_CONNECTION
54186 /* Next array element. */
54187 field_addr.sub_location->number = i;
54188#endif /* FREECIV_JSON_CONNECTION */
54189
54190 {
54191 const char *pstr = strvec_get(real_packet->helptext, i);
54192
54193 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
54194 }
54195 }
54196
54197#ifdef FREECIV_JSON_CONNECTION
54198 /* Exit array. */
54199 FC_FREE(field_addr.sub_location);
54200#endif /* FREECIV_JSON_CONNECTION */
54201 }
54202
54203 if (e) {
54204 log_packet_detailed("'helptext' field error detected");
54205 }
54206#endif /* FREECIV_DELTA_PROTOCOL */
54207
54208 SEND_PACKET_END(PACKET_RULESET_SPECIALIST);
54209}
54210
54211 int send_packet_ruleset_specialist(struct connection *pc, const struct packet_ruleset_specialist *packet)
54212{
54213 if (!pc->used) {
54214 log_error("WARNING: trying to send data to the closed connection %s",
54215 conn_description(pc));
54216 return -1;
54217 }
54218 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_SPECIALIST].packet != nullptr, -1,
54219 "Handler for PACKET_RULESET_SPECIALIST not installed");
54220 return pc->phs.handlers->send[PACKET_RULESET_SPECIALIST].packet(pc, packet);
54221}
54222
54223 void lsend_packet_ruleset_specialist(struct conn_list *dest, const struct packet_ruleset_specialist *packet)
54224{
54225 conn_list_iterate(dest, pconn) {
54226 send_packet_ruleset_specialist(pconn, packet);
54227 } conn_list_iterate_end;
54228}
54229
54230 static inline void init_packet_ruleset_government_ruler_title(struct packet_ruleset_government_ruler_title *packet)
54231{
54232 memset(packet, 0, sizeof(*packet));
54233}
54234
54235#define free_packet_ruleset_government_ruler_title(_packet) (void) 0
54236#define destroy_packet_ruleset_government_ruler_title free
54237
54238#ifdef FREECIV_DELTA_PROTOCOL
54239#define hash_packet_ruleset_government_ruler_title_100 hash_const
54240#define cmp_packet_ruleset_government_ruler_title_100 cmp_const
54241 BV_DEFINE(packet_ruleset_government_ruler_title_100_fields, 4);
54242#endif /* FREECIV_DELTA_PROTOCOL */
54243
54244 static struct packet_ruleset_government_ruler_title *receive_packet_ruleset_government_ruler_title_100(struct connection *pc)
54245{
54246#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_government_ruler_title(_packet)
54247 RECEIVE_PACKET_START(packet_ruleset_government_ruler_title, real_packet);
54248
54249#ifdef FREECIV_JSON_CONNECTION
54250 struct plocation field_addr;
54251 {
54252 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
54253 field_addr = *field_addr_tmp;
54254 FC_FREE(field_addr_tmp);
54255 }
54256#endif /* FREECIV_JSON_CONNECTION */
54257
54258 log_packet_detailed("packet_ruleset_government_ruler_title_100: got info about ()");
54259
54260#ifdef FREECIV_DELTA_PROTOCOL
54261 packet_ruleset_government_ruler_title_100_fields fields;
54262 struct packet_ruleset_government_ruler_title *old;
54263 struct genhash **hash = pc->phs.received + PACKET_RULESET_GOVERNMENT_RULER_TITLE;
54264
54265 if (nullptr == *hash) {
54266 *hash = genhash_new_full(hash_packet_ruleset_government_ruler_title_100, cmp_packet_ruleset_government_ruler_title_100,
54267 nullptr, nullptr, nullptr, destroy_packet_ruleset_government_ruler_title);
54268 }
54269
54270 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
54271 *real_packet = *old;
54272 } else {
54273 /* packet is already initialized empty */
54274 log_packet_detailed(" no old info");
54275 }
54276
54277#ifdef FREECIV_JSON_CONNECTION
54278 field_addr.name = "fields";
54279#endif /* FREECIV_JSON_CONNECTION */
54280 DIO_BV_GET(&din, &field_addr, fields);
54281
54282 if (BV_ISSET(fields, 0)) {
54283 log_packet_detailed(" got field 'gov'");
54284
54285#ifdef FREECIV_JSON_CONNECTION
54286 field_addr.name = "gov";
54287#endif /* FREECIV_JSON_CONNECTION */
54288
54289 {
54290 int readin;
54291
54292 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
54293 RECEIVE_PACKET_FIELD_ERROR(gov);
54294 }
54295 real_packet->gov = readin;
54296 }
54297 }
54298
54299 if (BV_ISSET(fields, 1)) {
54300 log_packet_detailed(" got field 'nation'");
54301
54302#ifdef FREECIV_JSON_CONNECTION
54303 field_addr.name = "nation";
54304#endif /* FREECIV_JSON_CONNECTION */
54305
54306 {
54307 int readin;
54308
54309 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
54310 RECEIVE_PACKET_FIELD_ERROR(nation);
54311 }
54312 real_packet->nation = readin;
54313 }
54314 }
54315
54316 if (BV_ISSET(fields, 2)) {
54317 log_packet_detailed(" got field 'male_title'");
54318
54319#ifdef FREECIV_JSON_CONNECTION
54320 field_addr.name = "male_title";
54321#endif /* FREECIV_JSON_CONNECTION */
54322
54323 if (!DIO_GET(string, &din, &field_addr, real_packet->male_title, sizeof(real_packet->male_title))) {
54324 RECEIVE_PACKET_FIELD_ERROR(male_title);
54325 }
54326 }
54327
54328 if (BV_ISSET(fields, 3)) {
54329 log_packet_detailed(" got field 'female_title'");
54330
54331#ifdef FREECIV_JSON_CONNECTION
54332 field_addr.name = "female_title";
54333#endif /* FREECIV_JSON_CONNECTION */
54334
54335 if (!DIO_GET(string, &din, &field_addr, real_packet->female_title, sizeof(real_packet->female_title))) {
54336 RECEIVE_PACKET_FIELD_ERROR(female_title);
54337 }
54338 }
54339
54340 if (nullptr == old) {
54341 old = fc_malloc(sizeof(*old));
54342 init_packet_ruleset_government_ruler_title(old);
54343 *old = *real_packet;
54344 genhash_insert(*hash, old, old);
54345 } else {
54346 *old = *real_packet;
54347 }
54348
54349#else /* FREECIV_DELTA_PROTOCOL */
54350#ifdef FREECIV_JSON_CONNECTION
54351 field_addr.name = "gov";
54352#endif /* FREECIV_JSON_CONNECTION */
54353
54354 {
54355 int readin;
54356
54357 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
54358 RECEIVE_PACKET_FIELD_ERROR(gov);
54359 }
54360 real_packet->gov = readin;
54361 }
54362
54363#ifdef FREECIV_JSON_CONNECTION
54364 field_addr.name = "nation";
54365#endif /* FREECIV_JSON_CONNECTION */
54366
54367 {
54368 int readin;
54369
54370 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
54371 RECEIVE_PACKET_FIELD_ERROR(nation);
54372 }
54373 real_packet->nation = readin;
54374 }
54375
54376#ifdef FREECIV_JSON_CONNECTION
54377 field_addr.name = "male_title";
54378#endif /* FREECIV_JSON_CONNECTION */
54379
54380 if (!DIO_GET(string, &din, &field_addr, real_packet->male_title, sizeof(real_packet->male_title))) {
54381 RECEIVE_PACKET_FIELD_ERROR(male_title);
54382 }
54383
54384#ifdef FREECIV_JSON_CONNECTION
54385 field_addr.name = "female_title";
54386#endif /* FREECIV_JSON_CONNECTION */
54387
54388 if (!DIO_GET(string, &din, &field_addr, real_packet->female_title, sizeof(real_packet->female_title))) {
54389 RECEIVE_PACKET_FIELD_ERROR(female_title);
54390 }
54391#endif /* FREECIV_DELTA_PROTOCOL */
54392
54393 RECEIVE_PACKET_END(real_packet);
54394#undef FREE_PACKET_STRUCT
54395}
54396
54397 static int send_packet_ruleset_government_ruler_title_100(struct connection *pc, const struct packet_ruleset_government_ruler_title *packet)
54398{
54399 const struct packet_ruleset_government_ruler_title *real_packet = packet;
54400 int e;
54401 SEND_PACKET_START(PACKET_RULESET_GOVERNMENT_RULER_TITLE);
54402
54403 log_packet_detailed("packet_ruleset_government_ruler_title_100: sending info about ()");
54404
54405#ifdef FREECIV_DELTA_PROTOCOL
54406 packet_ruleset_government_ruler_title_100_fields fields;
54407 struct packet_ruleset_government_ruler_title *old;
54408 bool differ;
54409 struct genhash **hash = pc->phs.sent + PACKET_RULESET_GOVERNMENT_RULER_TITLE;
54410
54411 if (nullptr == *hash) {
54412 *hash = genhash_new_full(hash_packet_ruleset_government_ruler_title_100, cmp_packet_ruleset_government_ruler_title_100,
54413 nullptr, nullptr, nullptr, destroy_packet_ruleset_government_ruler_title);
54414 }
54415 BV_CLR_ALL(fields);
54416
54417 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
54418 old = fc_malloc(sizeof(*old));
54419 /* temporary bitcopy just to insert correctly */
54420 *old = *real_packet;
54421 genhash_insert(*hash, old, old);
54422 init_packet_ruleset_government_ruler_title(old);
54423 }
54424
54425 differ = (old->gov != real_packet->gov);
54426 if (differ) {
54427 BV_SET(fields, 0);
54428 }
54429
54430 differ = (old->nation != real_packet->nation);
54431 if (differ) {
54432 BV_SET(fields, 1);
54433 }
54434
54435 differ = (strcmp(old->male_title, real_packet->male_title) != 0);
54436 if (differ) {
54437 BV_SET(fields, 2);
54438 }
54439
54440 differ = (strcmp(old->female_title, real_packet->female_title) != 0);
54441 if (differ) {
54442 BV_SET(fields, 3);
54443 }
54444#endif /* FREECIV_DELTA_PROTOCOL */
54445
54446#ifdef FREECIV_JSON_CONNECTION
54447 struct plocation field_addr;
54448 {
54449 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
54450 field_addr = *field_addr_tmp;
54451 FC_FREE(field_addr_tmp);
54452 }
54453#endif /* FREECIV_JSON_CONNECTION */
54454
54455#ifdef FREECIV_DELTA_PROTOCOL
54456#ifdef FREECIV_JSON_CONNECTION
54457 field_addr.name = "fields";
54458#endif /* FREECIV_JSON_CONNECTION */
54459 e = 0;
54460 e |= DIO_BV_PUT(&dout, &field_addr, fields);
54461 if (e) {
54462 log_packet_detailed("fields bitvector error detected");
54463 }
54464
54465 if (BV_ISSET(fields, 0)) {
54466 log_packet_detailed(" field 'gov' has changed");
54467
54468#ifdef FREECIV_JSON_CONNECTION
54469 field_addr.name = "gov";
54470#endif /* FREECIV_JSON_CONNECTION */
54471 e = 0;
54472
54473 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->gov);
54474
54475 if (e) {
54476 log_packet_detailed("'gov' field error detected");
54477 }
54478 }
54479
54480 if (BV_ISSET(fields, 1)) {
54481 log_packet_detailed(" field 'nation' has changed");
54482
54483#ifdef FREECIV_JSON_CONNECTION
54484 field_addr.name = "nation";
54485#endif /* FREECIV_JSON_CONNECTION */
54486 e = 0;
54487
54488 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation);
54489
54490 if (e) {
54491 log_packet_detailed("'nation' field error detected");
54492 }
54493 }
54494
54495 if (BV_ISSET(fields, 2)) {
54496 log_packet_detailed(" field 'male_title' has changed");
54497
54498#ifdef FREECIV_JSON_CONNECTION
54499 field_addr.name = "male_title";
54500#endif /* FREECIV_JSON_CONNECTION */
54501 e = 0;
54502
54503 e |= DIO_PUT(string, &dout, &field_addr, real_packet->male_title);
54504
54505 if (e) {
54506 log_packet_detailed("'male_title' field error detected");
54507 }
54508 }
54509
54510 if (BV_ISSET(fields, 3)) {
54511 log_packet_detailed(" field 'female_title' has changed");
54512
54513#ifdef FREECIV_JSON_CONNECTION
54514 field_addr.name = "female_title";
54515#endif /* FREECIV_JSON_CONNECTION */
54516 e = 0;
54517
54518 e |= DIO_PUT(string, &dout, &field_addr, real_packet->female_title);
54519
54520 if (e) {
54521 log_packet_detailed("'female_title' field error detected");
54522 }
54523 }
54524
54525 *old = *real_packet;
54526
54527#else /* FREECIV_DELTA_PROTOCOL */
54528#ifdef FREECIV_JSON_CONNECTION
54529 field_addr.name = "gov";
54530#endif /* FREECIV_JSON_CONNECTION */
54531 e = 0;
54532
54533 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->gov);
54534
54535 if (e) {
54536 log_packet_detailed("'gov' field error detected");
54537 }
54538
54539#ifdef FREECIV_JSON_CONNECTION
54540 field_addr.name = "nation";
54541#endif /* FREECIV_JSON_CONNECTION */
54542 e = 0;
54543
54544 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation);
54545
54546 if (e) {
54547 log_packet_detailed("'nation' field error detected");
54548 }
54549
54550#ifdef FREECIV_JSON_CONNECTION
54551 field_addr.name = "male_title";
54552#endif /* FREECIV_JSON_CONNECTION */
54553 e = 0;
54554
54555 e |= DIO_PUT(string, &dout, &field_addr, real_packet->male_title);
54556
54557 if (e) {
54558 log_packet_detailed("'male_title' field error detected");
54559 }
54560
54561#ifdef FREECIV_JSON_CONNECTION
54562 field_addr.name = "female_title";
54563#endif /* FREECIV_JSON_CONNECTION */
54564 e = 0;
54565
54566 e |= DIO_PUT(string, &dout, &field_addr, real_packet->female_title);
54567
54568 if (e) {
54569 log_packet_detailed("'female_title' field error detected");
54570 }
54571#endif /* FREECIV_DELTA_PROTOCOL */
54572
54573 SEND_PACKET_END(PACKET_RULESET_GOVERNMENT_RULER_TITLE);
54574}
54575
54576 int send_packet_ruleset_government_ruler_title(struct connection *pc, const struct packet_ruleset_government_ruler_title *packet)
54577{
54578 if (!pc->used) {
54579 log_error("WARNING: trying to send data to the closed connection %s",
54580 conn_description(pc));
54581 return -1;
54582 }
54583 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT_RULER_TITLE].packet != nullptr, -1,
54584 "Handler for PACKET_RULESET_GOVERNMENT_RULER_TITLE not installed");
54585 return pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT_RULER_TITLE].packet(pc, packet);
54586}
54587
54588 void lsend_packet_ruleset_government_ruler_title(struct conn_list *dest, const struct packet_ruleset_government_ruler_title *packet)
54589{
54590 conn_list_iterate(dest, pconn) {
54591 send_packet_ruleset_government_ruler_title(pconn, packet);
54592 } conn_list_iterate_end;
54593}
54594
54595 static inline void init_packet_ruleset_tech(struct packet_ruleset_tech *packet)
54596{
54597 memset(packet, 0, sizeof(*packet));
54598
54599 requirement_vector_init(&packet->research_reqs);
54600 packet->helptext = strvec_new();
54601}
54602
54603 static inline void free_packet_ruleset_tech(struct packet_ruleset_tech *packet)
54604{
54605 if (packet->helptext) {
54606 strvec_destroy(packet->helptext);
54607 packet->helptext = nullptr;
54608 }
54609 requirement_vector_free(&packet->research_reqs);
54610}
54611
54612 static inline void destroy_packet_ruleset_tech(void *packet)
54613{
54614 free_packet_ruleset_tech((struct packet_ruleset_tech *) packet);
54615 free(packet);
54616}
54617
54618#ifdef FREECIV_DELTA_PROTOCOL
54619#define hash_packet_ruleset_tech_100 hash_const
54620#define cmp_packet_ruleset_tech_100 cmp_const
54621 BV_DEFINE(packet_ruleset_tech_100_fields, 13);
54622#endif /* FREECIV_DELTA_PROTOCOL */
54623
54624 static struct packet_ruleset_tech *receive_packet_ruleset_tech_100(struct connection *pc)
54625{
54626#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_tech(_packet)
54627 RECEIVE_PACKET_START(packet_ruleset_tech, real_packet);
54628
54629#ifdef FREECIV_JSON_CONNECTION
54630 struct plocation field_addr;
54631 {
54632 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
54633 field_addr = *field_addr_tmp;
54634 FC_FREE(field_addr_tmp);
54635 }
54636#endif /* FREECIV_JSON_CONNECTION */
54637
54638 log_packet_detailed("packet_ruleset_tech_100: got info about ()");
54639
54640#ifdef FREECIV_DELTA_PROTOCOL
54641 packet_ruleset_tech_100_fields fields;
54642 struct packet_ruleset_tech *old;
54643 struct genhash **hash = pc->phs.received + PACKET_RULESET_TECH;
54644
54645 if (nullptr == *hash) {
54646 *hash = genhash_new_full(hash_packet_ruleset_tech_100, cmp_packet_ruleset_tech_100,
54647 nullptr, nullptr, nullptr, destroy_packet_ruleset_tech);
54648 }
54649
54650 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
54651 real_packet->id = old->id;
54652 real_packet->root_req = old->root_req;
54653 requirement_vector_copy(&real_packet->research_reqs, &old->research_reqs);
54654 real_packet->tclass = old->tclass;
54655 real_packet->removed = old->removed;
54656 real_packet->flags = old->flags;
54657 real_packet->cost = old->cost;
54658 real_packet->num_reqs = old->num_reqs;
54659 sz_strlcpy(real_packet->name, old->name);
54660 sz_strlcpy(real_packet->rule_name, old->rule_name);
54661 if (old->helptext) {
54662 strvec_copy(real_packet->helptext, old->helptext);
54663 } else {
54664 strvec_clear(real_packet->helptext);
54665 }
54666 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
54667 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
54668 } else {
54669 /* packet is already initialized empty */
54670 log_packet_detailed(" no old info");
54671 }
54672
54673#ifdef FREECIV_JSON_CONNECTION
54674 field_addr.name = "fields";
54675#endif /* FREECIV_JSON_CONNECTION */
54676 DIO_BV_GET(&din, &field_addr, fields);
54677
54678 if (BV_ISSET(fields, 0)) {
54679 log_packet_detailed(" got field 'id'");
54680
54681#ifdef FREECIV_JSON_CONNECTION
54682 field_addr.name = "id";
54683#endif /* FREECIV_JSON_CONNECTION */
54684
54685 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
54686 RECEIVE_PACKET_FIELD_ERROR(id);
54687 }
54688 }
54689
54690 if (BV_ISSET(fields, 1)) {
54691 log_packet_detailed(" got field 'root_req'");
54692
54693#ifdef FREECIV_JSON_CONNECTION
54694 field_addr.name = "root_req";
54695#endif /* FREECIV_JSON_CONNECTION */
54696
54697 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->root_req)) {
54698 RECEIVE_PACKET_FIELD_ERROR(root_req);
54699 }
54700 }
54701
54702 if (BV_ISSET(fields, 2)) {
54703 log_packet_detailed(" got field 'research_reqs'");
54704
54705#ifdef FREECIV_JSON_CONNECTION
54706 field_addr.name = "research_reqs";
54707#endif /* FREECIV_JSON_CONNECTION */
54708
54709 {
54710 int i;
54711
54712 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
54713 RECEIVE_PACKET_FIELD_ERROR(research_reqs);
54714 }
54715 requirement_vector_reserve(&real_packet->research_reqs, i);
54716
54717#ifdef FREECIV_JSON_CONNECTION
54718 /* Enter array. */
54719 field_addr.sub_location = plocation_elem_new(0);
54720#endif /* FREECIV_JSON_CONNECTION */
54721
54722 for (i = 0; i < requirement_vector_size(&real_packet->research_reqs); i++) {
54723#ifdef FREECIV_JSON_CONNECTION
54724 /* Next array element */
54725 field_addr.sub_location->number = i;
54726#endif /* FREECIV_JSON_CONNECTION */
54727
54728 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->research_reqs.p[i])) {
54729 RECEIVE_PACKET_FIELD_ERROR(research_reqs);
54730 }
54731 }
54732
54733#ifdef FREECIV_JSON_CONNECTION
54734 /* Exit array. */
54735 FC_FREE(field_addr.sub_location);
54736#endif /* FREECIV_JSON_CONNECTION */
54737 }
54738 }
54739
54740 if (BV_ISSET(fields, 3)) {
54741 log_packet_detailed(" got field 'tclass'");
54742
54743#ifdef FREECIV_JSON_CONNECTION
54744 field_addr.name = "tclass";
54745#endif /* FREECIV_JSON_CONNECTION */
54746
54747 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tclass)) {
54748 RECEIVE_PACKET_FIELD_ERROR(tclass);
54749 }
54750 }
54751
54752 real_packet->removed = BV_ISSET(fields, 4);
54753
54754 if (BV_ISSET(fields, 5)) {
54755 log_packet_detailed(" got field 'flags'");
54756
54757#ifdef FREECIV_JSON_CONNECTION
54758 field_addr.name = "flags";
54759#endif /* FREECIV_JSON_CONNECTION */
54760
54761 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
54762 RECEIVE_PACKET_FIELD_ERROR(flags);
54763 }
54764 }
54765
54766 if (BV_ISSET(fields, 6)) {
54767 log_packet_detailed(" got field 'cost'");
54768
54769#ifdef FREECIV_JSON_CONNECTION
54770 field_addr.name = "cost";
54771#endif /* FREECIV_JSON_CONNECTION */
54772
54773 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->cost, 100)) {
54774 RECEIVE_PACKET_FIELD_ERROR(cost);
54775 }
54776 }
54777
54778 if (BV_ISSET(fields, 7)) {
54779 log_packet_detailed(" got field 'num_reqs'");
54780
54781#ifdef FREECIV_JSON_CONNECTION
54782 field_addr.name = "num_reqs";
54783#endif /* FREECIV_JSON_CONNECTION */
54784
54785 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->num_reqs)) {
54786 RECEIVE_PACKET_FIELD_ERROR(num_reqs);
54787 }
54788 }
54789
54790 if (BV_ISSET(fields, 8)) {
54791 log_packet_detailed(" got field 'name'");
54792
54793#ifdef FREECIV_JSON_CONNECTION
54794 field_addr.name = "name";
54795#endif /* FREECIV_JSON_CONNECTION */
54796
54797 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
54798 RECEIVE_PACKET_FIELD_ERROR(name);
54799 }
54800 }
54801
54802 if (BV_ISSET(fields, 9)) {
54803 log_packet_detailed(" got field 'rule_name'");
54804
54805#ifdef FREECIV_JSON_CONNECTION
54806 field_addr.name = "rule_name";
54807#endif /* FREECIV_JSON_CONNECTION */
54808
54809 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
54810 RECEIVE_PACKET_FIELD_ERROR(rule_name);
54811 }
54812 }
54813
54814 if (BV_ISSET(fields, 10)) {
54815 log_packet_detailed(" got field 'helptext'");
54816
54817#ifdef FREECIV_JSON_CONNECTION
54818 field_addr.name = "helptext";
54819#endif /* FREECIV_JSON_CONNECTION */
54820
54821 {
54822 int i;
54823
54824 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
54825 RECEIVE_PACKET_FIELD_ERROR(helptext);
54826 }
54827 strvec_reserve(real_packet->helptext, i);
54828
54829#ifdef FREECIV_JSON_CONNECTION
54830 /* Enter array. */
54831 field_addr.sub_location = plocation_elem_new(0);
54832#endif /* FREECIV_JSON_CONNECTION */
54833
54834 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
54835#ifdef FREECIV_JSON_CONNECTION
54836 /* Next array element */
54837 field_addr.sub_location->number = i;
54838#endif /* FREECIV_JSON_CONNECTION */
54839
54840 {
54841 char readin[MAX_LEN_PACKET];
54842
54843 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
54844 || !strvec_set(real_packet->helptext, i, readin)) {
54845 RECEIVE_PACKET_FIELD_ERROR(helptext);
54846 }
54847 }
54848 }
54849
54850#ifdef FREECIV_JSON_CONNECTION
54851 /* Exit array. */
54852 FC_FREE(field_addr.sub_location);
54853#endif /* FREECIV_JSON_CONNECTION */
54854 }
54855 }
54856
54857 if (BV_ISSET(fields, 11)) {
54858 log_packet_detailed(" got field 'graphic_str'");
54859
54860#ifdef FREECIV_JSON_CONNECTION
54861 field_addr.name = "graphic_str";
54862#endif /* FREECIV_JSON_CONNECTION */
54863
54864 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
54865 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
54866 }
54867 }
54868
54869 if (BV_ISSET(fields, 12)) {
54870 log_packet_detailed(" got field 'graphic_alt'");
54871
54872#ifdef FREECIV_JSON_CONNECTION
54873 field_addr.name = "graphic_alt";
54874#endif /* FREECIV_JSON_CONNECTION */
54875
54876 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
54877 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
54878 }
54879 }
54880
54881 if (nullptr == old) {
54882 old = fc_malloc(sizeof(*old));
54883 init_packet_ruleset_tech(old);
54884 old->id = real_packet->id;
54885 old->root_req = real_packet->root_req;
54886 requirement_vector_copy(&old->research_reqs, &real_packet->research_reqs);
54887 old->tclass = real_packet->tclass;
54888 old->removed = real_packet->removed;
54889 old->flags = real_packet->flags;
54890 old->cost = real_packet->cost;
54891 old->num_reqs = real_packet->num_reqs;
54892 sz_strlcpy(old->name, real_packet->name);
54893 sz_strlcpy(old->rule_name, real_packet->rule_name);
54894 if (real_packet->helptext) {
54895 strvec_copy(old->helptext, real_packet->helptext);
54896 } else {
54897 strvec_clear(old->helptext);
54898 }
54899 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
54900 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
54901 genhash_insert(*hash, old, old);
54902 } else {
54903 old->id = real_packet->id;
54904 old->root_req = real_packet->root_req;
54905 requirement_vector_copy(&old->research_reqs, &real_packet->research_reqs);
54906 old->tclass = real_packet->tclass;
54907 old->removed = real_packet->removed;
54908 old->flags = real_packet->flags;
54909 old->cost = real_packet->cost;
54910 old->num_reqs = real_packet->num_reqs;
54911 sz_strlcpy(old->name, real_packet->name);
54912 sz_strlcpy(old->rule_name, real_packet->rule_name);
54913 if (real_packet->helptext) {
54914 strvec_copy(old->helptext, real_packet->helptext);
54915 } else {
54916 strvec_clear(old->helptext);
54917 }
54918 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
54919 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
54920 }
54921
54922#else /* FREECIV_DELTA_PROTOCOL */
54923#ifdef FREECIV_JSON_CONNECTION
54924 field_addr.name = "id";
54925#endif /* FREECIV_JSON_CONNECTION */
54926
54927 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
54928 RECEIVE_PACKET_FIELD_ERROR(id);
54929 }
54930
54931#ifdef FREECIV_JSON_CONNECTION
54932 field_addr.name = "root_req";
54933#endif /* FREECIV_JSON_CONNECTION */
54934
54935 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->root_req)) {
54936 RECEIVE_PACKET_FIELD_ERROR(root_req);
54937 }
54938
54939#ifdef FREECIV_JSON_CONNECTION
54940 field_addr.name = "research_reqs";
54941#endif /* FREECIV_JSON_CONNECTION */
54942
54943 {
54944 int i;
54945
54946 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
54947 RECEIVE_PACKET_FIELD_ERROR(research_reqs);
54948 }
54949 requirement_vector_reserve(&real_packet->research_reqs, i);
54950
54951#ifdef FREECIV_JSON_CONNECTION
54952 /* Enter array. */
54953 field_addr.sub_location = plocation_elem_new(0);
54954#endif /* FREECIV_JSON_CONNECTION */
54955
54956 for (i = 0; i < requirement_vector_size(&real_packet->research_reqs); i++) {
54957#ifdef FREECIV_JSON_CONNECTION
54958 /* Next array element */
54959 field_addr.sub_location->number = i;
54960#endif /* FREECIV_JSON_CONNECTION */
54961
54962 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->research_reqs.p[i])) {
54963 RECEIVE_PACKET_FIELD_ERROR(research_reqs);
54964 }
54965 }
54966
54967#ifdef FREECIV_JSON_CONNECTION
54968 /* Exit array. */
54969 FC_FREE(field_addr.sub_location);
54970#endif /* FREECIV_JSON_CONNECTION */
54971 }
54972
54973#ifdef FREECIV_JSON_CONNECTION
54974 field_addr.name = "tclass";
54975#endif /* FREECIV_JSON_CONNECTION */
54976
54977 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tclass)) {
54978 RECEIVE_PACKET_FIELD_ERROR(tclass);
54979 }
54980
54981#ifdef FREECIV_JSON_CONNECTION
54982 field_addr.name = "removed";
54983#endif /* FREECIV_JSON_CONNECTION */
54984
54985 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->removed)) {
54986 RECEIVE_PACKET_FIELD_ERROR(removed);
54987 }
54988
54989#ifdef FREECIV_JSON_CONNECTION
54990 field_addr.name = "flags";
54991#endif /* FREECIV_JSON_CONNECTION */
54992
54993 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
54994 RECEIVE_PACKET_FIELD_ERROR(flags);
54995 }
54996
54997#ifdef FREECIV_JSON_CONNECTION
54998 field_addr.name = "cost";
54999#endif /* FREECIV_JSON_CONNECTION */
55000
55001 if (!DIO_GET(ufloat, &din, &field_addr, &real_packet->cost, 100)) {
55002 RECEIVE_PACKET_FIELD_ERROR(cost);
55003 }
55004
55005#ifdef FREECIV_JSON_CONNECTION
55006 field_addr.name = "num_reqs";
55007#endif /* FREECIV_JSON_CONNECTION */
55008
55009 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->num_reqs)) {
55010 RECEIVE_PACKET_FIELD_ERROR(num_reqs);
55011 }
55012
55013#ifdef FREECIV_JSON_CONNECTION
55014 field_addr.name = "name";
55015#endif /* FREECIV_JSON_CONNECTION */
55016
55017 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
55018 RECEIVE_PACKET_FIELD_ERROR(name);
55019 }
55020
55021#ifdef FREECIV_JSON_CONNECTION
55022 field_addr.name = "rule_name";
55023#endif /* FREECIV_JSON_CONNECTION */
55024
55025 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
55026 RECEIVE_PACKET_FIELD_ERROR(rule_name);
55027 }
55028
55029#ifdef FREECIV_JSON_CONNECTION
55030 field_addr.name = "helptext";
55031#endif /* FREECIV_JSON_CONNECTION */
55032
55033 {
55034 int i;
55035
55036 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
55037 RECEIVE_PACKET_FIELD_ERROR(helptext);
55038 }
55039 strvec_reserve(real_packet->helptext, i);
55040
55041#ifdef FREECIV_JSON_CONNECTION
55042 /* Enter array. */
55043 field_addr.sub_location = plocation_elem_new(0);
55044#endif /* FREECIV_JSON_CONNECTION */
55045
55046 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
55047#ifdef FREECIV_JSON_CONNECTION
55048 /* Next array element */
55049 field_addr.sub_location->number = i;
55050#endif /* FREECIV_JSON_CONNECTION */
55051
55052 {
55053 char readin[MAX_LEN_PACKET];
55054
55055 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
55056 || !strvec_set(real_packet->helptext, i, readin)) {
55057 RECEIVE_PACKET_FIELD_ERROR(helptext);
55058 }
55059 }
55060 }
55061
55062#ifdef FREECIV_JSON_CONNECTION
55063 /* Exit array. */
55064 FC_FREE(field_addr.sub_location);
55065#endif /* FREECIV_JSON_CONNECTION */
55066 }
55067
55068#ifdef FREECIV_JSON_CONNECTION
55069 field_addr.name = "graphic_str";
55070#endif /* FREECIV_JSON_CONNECTION */
55071
55072 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
55073 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
55074 }
55075
55076#ifdef FREECIV_JSON_CONNECTION
55077 field_addr.name = "graphic_alt";
55078#endif /* FREECIV_JSON_CONNECTION */
55079
55080 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
55081 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
55082 }
55083#endif /* FREECIV_DELTA_PROTOCOL */
55084
55085 RECEIVE_PACKET_END(real_packet);
55086#undef FREE_PACKET_STRUCT
55087}
55088
55089 static int send_packet_ruleset_tech_100(struct connection *pc, const struct packet_ruleset_tech *packet)
55090{
55091 const struct packet_ruleset_tech *real_packet = packet;
55092 int e;
55093 SEND_PACKET_START(PACKET_RULESET_TECH);
55094
55095 log_packet_detailed("packet_ruleset_tech_100: sending info about ()");
55096
55097#ifdef FREECIV_DELTA_PROTOCOL
55098 packet_ruleset_tech_100_fields fields;
55099 struct packet_ruleset_tech *old;
55100 bool differ;
55101 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TECH;
55102
55103 if (nullptr == *hash) {
55104 *hash = genhash_new_full(hash_packet_ruleset_tech_100, cmp_packet_ruleset_tech_100,
55105 nullptr, nullptr, nullptr, destroy_packet_ruleset_tech);
55106 }
55107 BV_CLR_ALL(fields);
55108
55109 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
55110 old = fc_malloc(sizeof(*old));
55111 /* temporary bitcopy just to insert correctly */
55112 *old = *real_packet;
55113 genhash_insert(*hash, old, old);
55114 init_packet_ruleset_tech(old);
55115 }
55116
55117 differ = (old->id != real_packet->id);
55118 if (differ) {
55119 BV_SET(fields, 0);
55120 }
55121
55122 differ = (old->root_req != real_packet->root_req);
55123 if (differ) {
55124 BV_SET(fields, 1);
55125 }
55126
55127 differ = (requirement_vector_size(&old->research_reqs) != requirement_vector_size(&real_packet->research_reqs));
55128 if (!differ) {
55129 int i;
55130
55131 for (i = 0; i < requirement_vector_size(&old->research_reqs); i++) {
55132 differ = !are_requirements_equal(&old->research_reqs.p[i], &real_packet->research_reqs.p[i]);
55133 if (differ) {
55134 break;
55135 }
55136 }
55137 }
55138 if (differ) {
55139 BV_SET(fields, 2);
55140 }
55141
55142 differ = (old->tclass != real_packet->tclass);
55143 if (differ) {
55144 BV_SET(fields, 3);
55145 }
55146
55147 /* folded into head */
55148 if (real_packet->removed) {
55149 BV_SET(fields, 4);
55150 }
55151
55152 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
55153 if (differ) {
55154 BV_SET(fields, 5);
55155 }
55156
55157 differ = ((int) (old->cost * 100) != (int) (real_packet->cost * 100));
55158 if (differ) {
55159 BV_SET(fields, 6);
55160 }
55161
55162 differ = (old->num_reqs != real_packet->num_reqs);
55163 if (differ) {
55164 BV_SET(fields, 7);
55165 }
55166
55167 differ = (strcmp(old->name, real_packet->name) != 0);
55168 if (differ) {
55169 BV_SET(fields, 8);
55170 }
55171
55172 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
55173 if (differ) {
55174 BV_SET(fields, 9);
55175 }
55176
55177 if (real_packet->helptext) {
55178 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
55179 } else {
55180 differ = (strvec_size(old->helptext) > 0);
55181 }
55182 if (differ) {
55183 BV_SET(fields, 10);
55184 }
55185
55186 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
55187 if (differ) {
55188 BV_SET(fields, 11);
55189 }
55190
55191 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
55192 if (differ) {
55193 BV_SET(fields, 12);
55194 }
55195#endif /* FREECIV_DELTA_PROTOCOL */
55196
55197#ifdef FREECIV_JSON_CONNECTION
55198 struct plocation field_addr;
55199 {
55200 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
55201 field_addr = *field_addr_tmp;
55202 FC_FREE(field_addr_tmp);
55203 }
55204#endif /* FREECIV_JSON_CONNECTION */
55205
55206#ifdef FREECIV_DELTA_PROTOCOL
55207#ifdef FREECIV_JSON_CONNECTION
55208 field_addr.name = "fields";
55209#endif /* FREECIV_JSON_CONNECTION */
55210 e = 0;
55211 e |= DIO_BV_PUT(&dout, &field_addr, fields);
55212 if (e) {
55213 log_packet_detailed("fields bitvector error detected");
55214 }
55215
55216 if (BV_ISSET(fields, 0)) {
55217 log_packet_detailed(" field 'id' has changed");
55218
55219#ifdef FREECIV_JSON_CONNECTION
55220 field_addr.name = "id";
55221#endif /* FREECIV_JSON_CONNECTION */
55222 e = 0;
55223
55224 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
55225
55226 if (e) {
55227 log_packet_detailed("'id' field error detected");
55228 }
55229 }
55230
55231 if (BV_ISSET(fields, 1)) {
55232 log_packet_detailed(" field 'root_req' has changed");
55233
55234#ifdef FREECIV_JSON_CONNECTION
55235 field_addr.name = "root_req";
55236#endif /* FREECIV_JSON_CONNECTION */
55237 e = 0;
55238
55239 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->root_req);
55240
55241 if (e) {
55242 log_packet_detailed("'root_req' field error detected");
55243 }
55244 }
55245
55246 if (BV_ISSET(fields, 2)) {
55247 log_packet_detailed(" field 'research_reqs' has changed");
55248
55249#ifdef FREECIV_JSON_CONNECTION
55250 field_addr.name = "research_reqs";
55251#endif /* FREECIV_JSON_CONNECTION */
55252 e = 0;
55253
55254 {
55255 int i;
55256
55257 fc_assert(requirement_vector_size(&real_packet->research_reqs) < MAX_UINT16);
55258 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->research_reqs));
55259
55260#ifdef FREECIV_JSON_CONNECTION
55261 /* Enter array. */
55262 field_addr.sub_location = plocation_elem_new(0);
55263#endif /* FREECIV_JSON_CONNECTION */
55264
55265 for (i = 0; i < requirement_vector_size(&real_packet->research_reqs); i++) {
55266#ifdef FREECIV_JSON_CONNECTION
55267 /* Next array element. */
55268 field_addr.sub_location->number = i;
55269#endif /* FREECIV_JSON_CONNECTION */
55270
55271 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->research_reqs.p[i]);
55272 }
55273
55274#ifdef FREECIV_JSON_CONNECTION
55275 /* Exit array. */
55276 FC_FREE(field_addr.sub_location);
55277#endif /* FREECIV_JSON_CONNECTION */
55278 }
55279
55280 if (e) {
55281 log_packet_detailed("'research_reqs' field error detected");
55282 }
55283 }
55284
55285 if (BV_ISSET(fields, 3)) {
55286 log_packet_detailed(" field 'tclass' has changed");
55287
55288#ifdef FREECIV_JSON_CONNECTION
55289 field_addr.name = "tclass";
55290#endif /* FREECIV_JSON_CONNECTION */
55291 e = 0;
55292
55293 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tclass);
55294
55295 if (e) {
55296 log_packet_detailed("'tclass' field error detected");
55297 }
55298 }
55299
55300 /* field 4 is folded into the header */
55301
55302 if (BV_ISSET(fields, 5)) {
55303 log_packet_detailed(" field 'flags' has changed");
55304
55305#ifdef FREECIV_JSON_CONNECTION
55306 field_addr.name = "flags";
55307#endif /* FREECIV_JSON_CONNECTION */
55308 e = 0;
55309
55310 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
55311
55312 if (e) {
55313 log_packet_detailed("'flags' field error detected");
55314 }
55315 }
55316
55317 if (BV_ISSET(fields, 6)) {
55318 log_packet_detailed(" field 'cost' has changed");
55319
55320#ifdef FREECIV_JSON_CONNECTION
55321 field_addr.name = "cost";
55322#endif /* FREECIV_JSON_CONNECTION */
55323 e = 0;
55324
55325 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->cost, 100);
55326
55327 if (e) {
55328 log_packet_detailed("'cost' field error detected");
55329 }
55330 }
55331
55332 if (BV_ISSET(fields, 7)) {
55333 log_packet_detailed(" field 'num_reqs' has changed");
55334
55335#ifdef FREECIV_JSON_CONNECTION
55336 field_addr.name = "num_reqs";
55337#endif /* FREECIV_JSON_CONNECTION */
55338 e = 0;
55339
55340 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->num_reqs);
55341
55342 if (e) {
55343 log_packet_detailed("'num_reqs' field error detected");
55344 }
55345 }
55346
55347 if (BV_ISSET(fields, 8)) {
55348 log_packet_detailed(" field 'name' has changed");
55349
55350#ifdef FREECIV_JSON_CONNECTION
55351 field_addr.name = "name";
55352#endif /* FREECIV_JSON_CONNECTION */
55353 e = 0;
55354
55355 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
55356
55357 if (e) {
55358 log_packet_detailed("'name' field error detected");
55359 }
55360 }
55361
55362 if (BV_ISSET(fields, 9)) {
55363 log_packet_detailed(" field 'rule_name' has changed");
55364
55365#ifdef FREECIV_JSON_CONNECTION
55366 field_addr.name = "rule_name";
55367#endif /* FREECIV_JSON_CONNECTION */
55368 e = 0;
55369
55370 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
55371
55372 if (e) {
55373 log_packet_detailed("'rule_name' field error detected");
55374 }
55375 }
55376
55377 if (BV_ISSET(fields, 10)) {
55378 log_packet_detailed(" field 'helptext' has changed");
55379
55380#ifdef FREECIV_JSON_CONNECTION
55381 field_addr.name = "helptext";
55382#endif /* FREECIV_JSON_CONNECTION */
55383 e = 0;
55384
55385 if (!real_packet->helptext) {
55386 /* Transmit null as empty */
55387 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
55388 } else {
55389 int i;
55390
55391 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
55392 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
55393
55394#ifdef FREECIV_JSON_CONNECTION
55395 /* Enter array. */
55396 field_addr.sub_location = plocation_elem_new(0);
55397#endif /* FREECIV_JSON_CONNECTION */
55398
55399 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
55400#ifdef FREECIV_JSON_CONNECTION
55401 /* Next array element. */
55402 field_addr.sub_location->number = i;
55403#endif /* FREECIV_JSON_CONNECTION */
55404
55405 {
55406 const char *pstr = strvec_get(real_packet->helptext, i);
55407
55408 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
55409 }
55410 }
55411
55412#ifdef FREECIV_JSON_CONNECTION
55413 /* Exit array. */
55414 FC_FREE(field_addr.sub_location);
55415#endif /* FREECIV_JSON_CONNECTION */
55416 }
55417
55418 if (e) {
55419 log_packet_detailed("'helptext' field error detected");
55420 }
55421 }
55422
55423 if (BV_ISSET(fields, 11)) {
55424 log_packet_detailed(" field 'graphic_str' has changed");
55425
55426#ifdef FREECIV_JSON_CONNECTION
55427 field_addr.name = "graphic_str";
55428#endif /* FREECIV_JSON_CONNECTION */
55429 e = 0;
55430
55431 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
55432
55433 if (e) {
55434 log_packet_detailed("'graphic_str' field error detected");
55435 }
55436 }
55437
55438 if (BV_ISSET(fields, 12)) {
55439 log_packet_detailed(" field 'graphic_alt' has changed");
55440
55441#ifdef FREECIV_JSON_CONNECTION
55442 field_addr.name = "graphic_alt";
55443#endif /* FREECIV_JSON_CONNECTION */
55444 e = 0;
55445
55446 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
55447
55448 if (e) {
55449 log_packet_detailed("'graphic_alt' field error detected");
55450 }
55451 }
55452
55453 old->id = real_packet->id;
55454 old->root_req = real_packet->root_req;
55455 requirement_vector_copy(&old->research_reqs, &real_packet->research_reqs);
55456 old->tclass = real_packet->tclass;
55457 old->removed = real_packet->removed;
55458 old->flags = real_packet->flags;
55459 old->cost = real_packet->cost;
55460 old->num_reqs = real_packet->num_reqs;
55461 sz_strlcpy(old->name, real_packet->name);
55462 sz_strlcpy(old->rule_name, real_packet->rule_name);
55463 if (real_packet->helptext) {
55464 strvec_copy(old->helptext, real_packet->helptext);
55465 } else {
55466 strvec_clear(old->helptext);
55467 }
55468 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
55469 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
55470
55471#else /* FREECIV_DELTA_PROTOCOL */
55472#ifdef FREECIV_JSON_CONNECTION
55473 field_addr.name = "id";
55474#endif /* FREECIV_JSON_CONNECTION */
55475 e = 0;
55476
55477 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
55478
55479 if (e) {
55480 log_packet_detailed("'id' field error detected");
55481 }
55482
55483#ifdef FREECIV_JSON_CONNECTION
55484 field_addr.name = "root_req";
55485#endif /* FREECIV_JSON_CONNECTION */
55486 e = 0;
55487
55488 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->root_req);
55489
55490 if (e) {
55491 log_packet_detailed("'root_req' field error detected");
55492 }
55493
55494#ifdef FREECIV_JSON_CONNECTION
55495 field_addr.name = "research_reqs";
55496#endif /* FREECIV_JSON_CONNECTION */
55497 e = 0;
55498
55499 {
55500 int i;
55501
55502 fc_assert(requirement_vector_size(&real_packet->research_reqs) < MAX_UINT16);
55503 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->research_reqs));
55504
55505#ifdef FREECIV_JSON_CONNECTION
55506 /* Enter array. */
55507 field_addr.sub_location = plocation_elem_new(0);
55508#endif /* FREECIV_JSON_CONNECTION */
55509
55510 for (i = 0; i < requirement_vector_size(&real_packet->research_reqs); i++) {
55511#ifdef FREECIV_JSON_CONNECTION
55512 /* Next array element. */
55513 field_addr.sub_location->number = i;
55514#endif /* FREECIV_JSON_CONNECTION */
55515
55516 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->research_reqs.p[i]);
55517 }
55518
55519#ifdef FREECIV_JSON_CONNECTION
55520 /* Exit array. */
55521 FC_FREE(field_addr.sub_location);
55522#endif /* FREECIV_JSON_CONNECTION */
55523 }
55524
55525 if (e) {
55526 log_packet_detailed("'research_reqs' field error detected");
55527 }
55528
55529#ifdef FREECIV_JSON_CONNECTION
55530 field_addr.name = "tclass";
55531#endif /* FREECIV_JSON_CONNECTION */
55532 e = 0;
55533
55534 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tclass);
55535
55536 if (e) {
55537 log_packet_detailed("'tclass' field error detected");
55538 }
55539
55540#ifdef FREECIV_JSON_CONNECTION
55541 field_addr.name = "removed";
55542#endif /* FREECIV_JSON_CONNECTION */
55543 e = 0;
55544
55545 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->removed);
55546
55547 if (e) {
55548 log_packet_detailed("'removed' field error detected");
55549 }
55550
55551#ifdef FREECIV_JSON_CONNECTION
55552 field_addr.name = "flags";
55553#endif /* FREECIV_JSON_CONNECTION */
55554 e = 0;
55555
55556 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
55557
55558 if (e) {
55559 log_packet_detailed("'flags' field error detected");
55560 }
55561
55562#ifdef FREECIV_JSON_CONNECTION
55563 field_addr.name = "cost";
55564#endif /* FREECIV_JSON_CONNECTION */
55565 e = 0;
55566
55567 e |= DIO_PUT(ufloat, &dout, &field_addr, real_packet->cost, 100);
55568
55569 if (e) {
55570 log_packet_detailed("'cost' field error detected");
55571 }
55572
55573#ifdef FREECIV_JSON_CONNECTION
55574 field_addr.name = "num_reqs";
55575#endif /* FREECIV_JSON_CONNECTION */
55576 e = 0;
55577
55578 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->num_reqs);
55579
55580 if (e) {
55581 log_packet_detailed("'num_reqs' field error detected");
55582 }
55583
55584#ifdef FREECIV_JSON_CONNECTION
55585 field_addr.name = "name";
55586#endif /* FREECIV_JSON_CONNECTION */
55587 e = 0;
55588
55589 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
55590
55591 if (e) {
55592 log_packet_detailed("'name' field error detected");
55593 }
55594
55595#ifdef FREECIV_JSON_CONNECTION
55596 field_addr.name = "rule_name";
55597#endif /* FREECIV_JSON_CONNECTION */
55598 e = 0;
55599
55600 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
55601
55602 if (e) {
55603 log_packet_detailed("'rule_name' field error detected");
55604 }
55605
55606#ifdef FREECIV_JSON_CONNECTION
55607 field_addr.name = "helptext";
55608#endif /* FREECIV_JSON_CONNECTION */
55609 e = 0;
55610
55611 if (!real_packet->helptext) {
55612 /* Transmit null as empty */
55613 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
55614 } else {
55615 int i;
55616
55617 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
55618 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
55619
55620#ifdef FREECIV_JSON_CONNECTION
55621 /* Enter array. */
55622 field_addr.sub_location = plocation_elem_new(0);
55623#endif /* FREECIV_JSON_CONNECTION */
55624
55625 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
55626#ifdef FREECIV_JSON_CONNECTION
55627 /* Next array element. */
55628 field_addr.sub_location->number = i;
55629#endif /* FREECIV_JSON_CONNECTION */
55630
55631 {
55632 const char *pstr = strvec_get(real_packet->helptext, i);
55633
55634 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
55635 }
55636 }
55637
55638#ifdef FREECIV_JSON_CONNECTION
55639 /* Exit array. */
55640 FC_FREE(field_addr.sub_location);
55641#endif /* FREECIV_JSON_CONNECTION */
55642 }
55643
55644 if (e) {
55645 log_packet_detailed("'helptext' field error detected");
55646 }
55647
55648#ifdef FREECIV_JSON_CONNECTION
55649 field_addr.name = "graphic_str";
55650#endif /* FREECIV_JSON_CONNECTION */
55651 e = 0;
55652
55653 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
55654
55655 if (e) {
55656 log_packet_detailed("'graphic_str' field error detected");
55657 }
55658
55659#ifdef FREECIV_JSON_CONNECTION
55660 field_addr.name = "graphic_alt";
55661#endif /* FREECIV_JSON_CONNECTION */
55662 e = 0;
55663
55664 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
55665
55666 if (e) {
55667 log_packet_detailed("'graphic_alt' field error detected");
55668 }
55669#endif /* FREECIV_DELTA_PROTOCOL */
55670
55671 SEND_PACKET_END(PACKET_RULESET_TECH);
55672}
55673
55674 int send_packet_ruleset_tech(struct connection *pc, const struct packet_ruleset_tech *packet)
55675{
55676 if (!pc->used) {
55677 log_error("WARNING: trying to send data to the closed connection %s",
55678 conn_description(pc));
55679 return -1;
55680 }
55681 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TECH].packet != nullptr, -1,
55682 "Handler for PACKET_RULESET_TECH not installed");
55683 return pc->phs.handlers->send[PACKET_RULESET_TECH].packet(pc, packet);
55684}
55685
55686 void lsend_packet_ruleset_tech(struct conn_list *dest, const struct packet_ruleset_tech *packet)
55687{
55688 conn_list_iterate(dest, pconn) {
55689 send_packet_ruleset_tech(pconn, packet);
55690 } conn_list_iterate_end;
55691}
55692
55693 static inline void init_packet_ruleset_tech_class(struct packet_ruleset_tech_class *packet)
55694{
55695 memset(packet, 0, sizeof(*packet));
55696}
55697
55698#define free_packet_ruleset_tech_class(_packet) (void) 0
55699#define destroy_packet_ruleset_tech_class free
55700
55701#ifdef FREECIV_DELTA_PROTOCOL
55702#define hash_packet_ruleset_tech_class_100 hash_const
55703#define cmp_packet_ruleset_tech_class_100 cmp_const
55704 BV_DEFINE(packet_ruleset_tech_class_100_fields, 4);
55705#endif /* FREECIV_DELTA_PROTOCOL */
55706
55707 static struct packet_ruleset_tech_class *receive_packet_ruleset_tech_class_100(struct connection *pc)
55708{
55709#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_tech_class(_packet)
55710 RECEIVE_PACKET_START(packet_ruleset_tech_class, real_packet);
55711
55712#ifdef FREECIV_JSON_CONNECTION
55713 struct plocation field_addr;
55714 {
55715 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
55716 field_addr = *field_addr_tmp;
55717 FC_FREE(field_addr_tmp);
55718 }
55719#endif /* FREECIV_JSON_CONNECTION */
55720
55721 log_packet_detailed("packet_ruleset_tech_class_100: got info about ()");
55722
55723#ifdef FREECIV_DELTA_PROTOCOL
55724 packet_ruleset_tech_class_100_fields fields;
55725 struct packet_ruleset_tech_class *old;
55726 struct genhash **hash = pc->phs.received + PACKET_RULESET_TECH_CLASS;
55727
55728 if (nullptr == *hash) {
55729 *hash = genhash_new_full(hash_packet_ruleset_tech_class_100, cmp_packet_ruleset_tech_class_100,
55730 nullptr, nullptr, nullptr, destroy_packet_ruleset_tech_class);
55731 }
55732
55733 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
55734 *real_packet = *old;
55735 } else {
55736 /* packet is already initialized empty */
55737 log_packet_detailed(" no old info");
55738 }
55739
55740#ifdef FREECIV_JSON_CONNECTION
55741 field_addr.name = "fields";
55742#endif /* FREECIV_JSON_CONNECTION */
55743 DIO_BV_GET(&din, &field_addr, fields);
55744
55745 if (BV_ISSET(fields, 0)) {
55746 log_packet_detailed(" got field 'id'");
55747
55748#ifdef FREECIV_JSON_CONNECTION
55749 field_addr.name = "id";
55750#endif /* FREECIV_JSON_CONNECTION */
55751
55752 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
55753 RECEIVE_PACKET_FIELD_ERROR(id);
55754 }
55755 }
55756
55757 if (BV_ISSET(fields, 1)) {
55758 log_packet_detailed(" got field 'name'");
55759
55760#ifdef FREECIV_JSON_CONNECTION
55761 field_addr.name = "name";
55762#endif /* FREECIV_JSON_CONNECTION */
55763
55764 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
55765 RECEIVE_PACKET_FIELD_ERROR(name);
55766 }
55767 }
55768
55769 if (BV_ISSET(fields, 2)) {
55770 log_packet_detailed(" got field 'rule_name'");
55771
55772#ifdef FREECIV_JSON_CONNECTION
55773 field_addr.name = "rule_name";
55774#endif /* FREECIV_JSON_CONNECTION */
55775
55776 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
55777 RECEIVE_PACKET_FIELD_ERROR(rule_name);
55778 }
55779 }
55780
55781 if (BV_ISSET(fields, 3)) {
55782 log_packet_detailed(" got field 'cost_pct'");
55783
55784#ifdef FREECIV_JSON_CONNECTION
55785 field_addr.name = "cost_pct";
55786#endif /* FREECIV_JSON_CONNECTION */
55787
55788 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->cost_pct)) {
55789 RECEIVE_PACKET_FIELD_ERROR(cost_pct);
55790 }
55791 }
55792
55793 if (nullptr == old) {
55794 old = fc_malloc(sizeof(*old));
55795 init_packet_ruleset_tech_class(old);
55796 *old = *real_packet;
55797 genhash_insert(*hash, old, old);
55798 } else {
55799 *old = *real_packet;
55800 }
55801
55802#else /* FREECIV_DELTA_PROTOCOL */
55803#ifdef FREECIV_JSON_CONNECTION
55804 field_addr.name = "id";
55805#endif /* FREECIV_JSON_CONNECTION */
55806
55807 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
55808 RECEIVE_PACKET_FIELD_ERROR(id);
55809 }
55810
55811#ifdef FREECIV_JSON_CONNECTION
55812 field_addr.name = "name";
55813#endif /* FREECIV_JSON_CONNECTION */
55814
55815 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
55816 RECEIVE_PACKET_FIELD_ERROR(name);
55817 }
55818
55819#ifdef FREECIV_JSON_CONNECTION
55820 field_addr.name = "rule_name";
55821#endif /* FREECIV_JSON_CONNECTION */
55822
55823 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
55824 RECEIVE_PACKET_FIELD_ERROR(rule_name);
55825 }
55826
55827#ifdef FREECIV_JSON_CONNECTION
55828 field_addr.name = "cost_pct";
55829#endif /* FREECIV_JSON_CONNECTION */
55830
55831 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->cost_pct)) {
55832 RECEIVE_PACKET_FIELD_ERROR(cost_pct);
55833 }
55834#endif /* FREECIV_DELTA_PROTOCOL */
55835
55836 RECEIVE_PACKET_END(real_packet);
55837#undef FREE_PACKET_STRUCT
55838}
55839
55840 static int send_packet_ruleset_tech_class_100(struct connection *pc, const struct packet_ruleset_tech_class *packet)
55841{
55842 const struct packet_ruleset_tech_class *real_packet = packet;
55843 int e;
55844 SEND_PACKET_START(PACKET_RULESET_TECH_CLASS);
55845
55846 log_packet_detailed("packet_ruleset_tech_class_100: sending info about ()");
55847
55848#ifdef FREECIV_DELTA_PROTOCOL
55849 packet_ruleset_tech_class_100_fields fields;
55850 struct packet_ruleset_tech_class *old;
55851 bool differ;
55852 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TECH_CLASS;
55853
55854 if (nullptr == *hash) {
55855 *hash = genhash_new_full(hash_packet_ruleset_tech_class_100, cmp_packet_ruleset_tech_class_100,
55856 nullptr, nullptr, nullptr, destroy_packet_ruleset_tech_class);
55857 }
55858 BV_CLR_ALL(fields);
55859
55860 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
55861 old = fc_malloc(sizeof(*old));
55862 /* temporary bitcopy just to insert correctly */
55863 *old = *real_packet;
55864 genhash_insert(*hash, old, old);
55865 init_packet_ruleset_tech_class(old);
55866 }
55867
55868 differ = (old->id != real_packet->id);
55869 if (differ) {
55870 BV_SET(fields, 0);
55871 }
55872
55873 differ = (strcmp(old->name, real_packet->name) != 0);
55874 if (differ) {
55875 BV_SET(fields, 1);
55876 }
55877
55878 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
55879 if (differ) {
55880 BV_SET(fields, 2);
55881 }
55882
55883 differ = (old->cost_pct != real_packet->cost_pct);
55884 if (differ) {
55885 BV_SET(fields, 3);
55886 }
55887#endif /* FREECIV_DELTA_PROTOCOL */
55888
55889#ifdef FREECIV_JSON_CONNECTION
55890 struct plocation field_addr;
55891 {
55892 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
55893 field_addr = *field_addr_tmp;
55894 FC_FREE(field_addr_tmp);
55895 }
55896#endif /* FREECIV_JSON_CONNECTION */
55897
55898#ifdef FREECIV_DELTA_PROTOCOL
55899#ifdef FREECIV_JSON_CONNECTION
55900 field_addr.name = "fields";
55901#endif /* FREECIV_JSON_CONNECTION */
55902 e = 0;
55903 e |= DIO_BV_PUT(&dout, &field_addr, fields);
55904 if (e) {
55905 log_packet_detailed("fields bitvector error detected");
55906 }
55907
55908 if (BV_ISSET(fields, 0)) {
55909 log_packet_detailed(" field 'id' has changed");
55910
55911#ifdef FREECIV_JSON_CONNECTION
55912 field_addr.name = "id";
55913#endif /* FREECIV_JSON_CONNECTION */
55914 e = 0;
55915
55916 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
55917
55918 if (e) {
55919 log_packet_detailed("'id' field error detected");
55920 }
55921 }
55922
55923 if (BV_ISSET(fields, 1)) {
55924 log_packet_detailed(" field 'name' has changed");
55925
55926#ifdef FREECIV_JSON_CONNECTION
55927 field_addr.name = "name";
55928#endif /* FREECIV_JSON_CONNECTION */
55929 e = 0;
55930
55931 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
55932
55933 if (e) {
55934 log_packet_detailed("'name' field error detected");
55935 }
55936 }
55937
55938 if (BV_ISSET(fields, 2)) {
55939 log_packet_detailed(" field 'rule_name' has changed");
55940
55941#ifdef FREECIV_JSON_CONNECTION
55942 field_addr.name = "rule_name";
55943#endif /* FREECIV_JSON_CONNECTION */
55944 e = 0;
55945
55946 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
55947
55948 if (e) {
55949 log_packet_detailed("'rule_name' field error detected");
55950 }
55951 }
55952
55953 if (BV_ISSET(fields, 3)) {
55954 log_packet_detailed(" field 'cost_pct' has changed");
55955
55956#ifdef FREECIV_JSON_CONNECTION
55957 field_addr.name = "cost_pct";
55958#endif /* FREECIV_JSON_CONNECTION */
55959 e = 0;
55960
55961 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->cost_pct);
55962
55963 if (e) {
55964 log_packet_detailed("'cost_pct' field error detected");
55965 }
55966 }
55967
55968 *old = *real_packet;
55969
55970#else /* FREECIV_DELTA_PROTOCOL */
55971#ifdef FREECIV_JSON_CONNECTION
55972 field_addr.name = "id";
55973#endif /* FREECIV_JSON_CONNECTION */
55974 e = 0;
55975
55976 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
55977
55978 if (e) {
55979 log_packet_detailed("'id' field error detected");
55980 }
55981
55982#ifdef FREECIV_JSON_CONNECTION
55983 field_addr.name = "name";
55984#endif /* FREECIV_JSON_CONNECTION */
55985 e = 0;
55986
55987 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
55988
55989 if (e) {
55990 log_packet_detailed("'name' field error detected");
55991 }
55992
55993#ifdef FREECIV_JSON_CONNECTION
55994 field_addr.name = "rule_name";
55995#endif /* FREECIV_JSON_CONNECTION */
55996 e = 0;
55997
55998 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
55999
56000 if (e) {
56001 log_packet_detailed("'rule_name' field error detected");
56002 }
56003
56004#ifdef FREECIV_JSON_CONNECTION
56005 field_addr.name = "cost_pct";
56006#endif /* FREECIV_JSON_CONNECTION */
56007 e = 0;
56008
56009 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->cost_pct);
56010
56011 if (e) {
56012 log_packet_detailed("'cost_pct' field error detected");
56013 }
56014#endif /* FREECIV_DELTA_PROTOCOL */
56015
56016 SEND_PACKET_END(PACKET_RULESET_TECH_CLASS);
56017}
56018
56019 int send_packet_ruleset_tech_class(struct connection *pc, const struct packet_ruleset_tech_class *packet)
56020{
56021 if (!pc->used) {
56022 log_error("WARNING: trying to send data to the closed connection %s",
56023 conn_description(pc));
56024 return -1;
56025 }
56026 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TECH_CLASS].packet != nullptr, -1,
56027 "Handler for PACKET_RULESET_TECH_CLASS not installed");
56028 return pc->phs.handlers->send[PACKET_RULESET_TECH_CLASS].packet(pc, packet);
56029}
56030
56031 void lsend_packet_ruleset_tech_class(struct conn_list *dest, const struct packet_ruleset_tech_class *packet)
56032{
56033 conn_list_iterate(dest, pconn) {
56034 send_packet_ruleset_tech_class(pconn, packet);
56035 } conn_list_iterate_end;
56036}
56037
56038 static inline void init_packet_ruleset_tech_flag(struct packet_ruleset_tech_flag *packet)
56039{
56040 memset(packet, 0, sizeof(*packet));
56041}
56042
56043#define free_packet_ruleset_tech_flag(_packet) (void) 0
56044#define destroy_packet_ruleset_tech_flag free
56045
56046#ifdef FREECIV_DELTA_PROTOCOL
56047#define hash_packet_ruleset_tech_flag_100 hash_const
56048#define cmp_packet_ruleset_tech_flag_100 cmp_const
56049 BV_DEFINE(packet_ruleset_tech_flag_100_fields, 3);
56050#endif /* FREECIV_DELTA_PROTOCOL */
56051
56052 static struct packet_ruleset_tech_flag *receive_packet_ruleset_tech_flag_100(struct connection *pc)
56053{
56054#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_tech_flag(_packet)
56055 RECEIVE_PACKET_START(packet_ruleset_tech_flag, real_packet);
56056
56057#ifdef FREECIV_JSON_CONNECTION
56058 struct plocation field_addr;
56059 {
56060 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
56061 field_addr = *field_addr_tmp;
56062 FC_FREE(field_addr_tmp);
56063 }
56064#endif /* FREECIV_JSON_CONNECTION */
56065
56066 log_packet_detailed("packet_ruleset_tech_flag_100: got info about ()");
56067
56068#ifdef FREECIV_DELTA_PROTOCOL
56069 packet_ruleset_tech_flag_100_fields fields;
56070 struct packet_ruleset_tech_flag *old;
56071 struct genhash **hash = pc->phs.received + PACKET_RULESET_TECH_FLAG;
56072
56073 if (nullptr == *hash) {
56074 *hash = genhash_new_full(hash_packet_ruleset_tech_flag_100, cmp_packet_ruleset_tech_flag_100,
56075 nullptr, nullptr, nullptr, destroy_packet_ruleset_tech_flag);
56076 }
56077
56078 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
56079 *real_packet = *old;
56080 } else {
56081 /* packet is already initialized empty */
56082 log_packet_detailed(" no old info");
56083 }
56084
56085#ifdef FREECIV_JSON_CONNECTION
56086 field_addr.name = "fields";
56087#endif /* FREECIV_JSON_CONNECTION */
56088 DIO_BV_GET(&din, &field_addr, fields);
56089
56090 if (BV_ISSET(fields, 0)) {
56091 log_packet_detailed(" got field 'id'");
56092
56093#ifdef FREECIV_JSON_CONNECTION
56094 field_addr.name = "id";
56095#endif /* FREECIV_JSON_CONNECTION */
56096
56097 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
56098 RECEIVE_PACKET_FIELD_ERROR(id);
56099 }
56100 }
56101
56102 if (BV_ISSET(fields, 1)) {
56103 log_packet_detailed(" got field 'name'");
56104
56105#ifdef FREECIV_JSON_CONNECTION
56106 field_addr.name = "name";
56107#endif /* FREECIV_JSON_CONNECTION */
56108
56109 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
56110 RECEIVE_PACKET_FIELD_ERROR(name);
56111 }
56112 }
56113
56114 if (BV_ISSET(fields, 2)) {
56115 log_packet_detailed(" got field 'helptxt'");
56116
56117#ifdef FREECIV_JSON_CONNECTION
56118 field_addr.name = "helptxt";
56119#endif /* FREECIV_JSON_CONNECTION */
56120
56121 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
56122 RECEIVE_PACKET_FIELD_ERROR(helptxt);
56123 }
56124 }
56125
56126 if (nullptr == old) {
56127 old = fc_malloc(sizeof(*old));
56128 init_packet_ruleset_tech_flag(old);
56129 *old = *real_packet;
56130 genhash_insert(*hash, old, old);
56131 } else {
56132 *old = *real_packet;
56133 }
56134
56135#else /* FREECIV_DELTA_PROTOCOL */
56136#ifdef FREECIV_JSON_CONNECTION
56137 field_addr.name = "id";
56138#endif /* FREECIV_JSON_CONNECTION */
56139
56140 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
56141 RECEIVE_PACKET_FIELD_ERROR(id);
56142 }
56143
56144#ifdef FREECIV_JSON_CONNECTION
56145 field_addr.name = "name";
56146#endif /* FREECIV_JSON_CONNECTION */
56147
56148 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
56149 RECEIVE_PACKET_FIELD_ERROR(name);
56150 }
56151
56152#ifdef FREECIV_JSON_CONNECTION
56153 field_addr.name = "helptxt";
56154#endif /* FREECIV_JSON_CONNECTION */
56155
56156 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
56157 RECEIVE_PACKET_FIELD_ERROR(helptxt);
56158 }
56159#endif /* FREECIV_DELTA_PROTOCOL */
56160
56161 RECEIVE_PACKET_END(real_packet);
56162#undef FREE_PACKET_STRUCT
56163}
56164
56165 static int send_packet_ruleset_tech_flag_100(struct connection *pc, const struct packet_ruleset_tech_flag *packet)
56166{
56167 const struct packet_ruleset_tech_flag *real_packet = packet;
56168 int e;
56169 SEND_PACKET_START(PACKET_RULESET_TECH_FLAG);
56170
56171 log_packet_detailed("packet_ruleset_tech_flag_100: sending info about ()");
56172
56173#ifdef FREECIV_DELTA_PROTOCOL
56174 packet_ruleset_tech_flag_100_fields fields;
56175 struct packet_ruleset_tech_flag *old;
56176 bool differ;
56177 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TECH_FLAG;
56178
56179 if (nullptr == *hash) {
56180 *hash = genhash_new_full(hash_packet_ruleset_tech_flag_100, cmp_packet_ruleset_tech_flag_100,
56181 nullptr, nullptr, nullptr, destroy_packet_ruleset_tech_flag);
56182 }
56183 BV_CLR_ALL(fields);
56184
56185 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
56186 old = fc_malloc(sizeof(*old));
56187 /* temporary bitcopy just to insert correctly */
56188 *old = *real_packet;
56189 genhash_insert(*hash, old, old);
56190 init_packet_ruleset_tech_flag(old);
56191 }
56192
56193 differ = (old->id != real_packet->id);
56194 if (differ) {
56195 BV_SET(fields, 0);
56196 }
56197
56198 differ = (strcmp(old->name, real_packet->name) != 0);
56199 if (differ) {
56200 BV_SET(fields, 1);
56201 }
56202
56203 differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
56204 if (differ) {
56205 BV_SET(fields, 2);
56206 }
56207#endif /* FREECIV_DELTA_PROTOCOL */
56208
56209#ifdef FREECIV_JSON_CONNECTION
56210 struct plocation field_addr;
56211 {
56212 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
56213 field_addr = *field_addr_tmp;
56214 FC_FREE(field_addr_tmp);
56215 }
56216#endif /* FREECIV_JSON_CONNECTION */
56217
56218#ifdef FREECIV_DELTA_PROTOCOL
56219#ifdef FREECIV_JSON_CONNECTION
56220 field_addr.name = "fields";
56221#endif /* FREECIV_JSON_CONNECTION */
56222 e = 0;
56223 e |= DIO_BV_PUT(&dout, &field_addr, fields);
56224 if (e) {
56225 log_packet_detailed("fields bitvector error detected");
56226 }
56227
56228 if (BV_ISSET(fields, 0)) {
56229 log_packet_detailed(" field 'id' has changed");
56230
56231#ifdef FREECIV_JSON_CONNECTION
56232 field_addr.name = "id";
56233#endif /* FREECIV_JSON_CONNECTION */
56234 e = 0;
56235
56236 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
56237
56238 if (e) {
56239 log_packet_detailed("'id' field error detected");
56240 }
56241 }
56242
56243 if (BV_ISSET(fields, 1)) {
56244 log_packet_detailed(" field 'name' has changed");
56245
56246#ifdef FREECIV_JSON_CONNECTION
56247 field_addr.name = "name";
56248#endif /* FREECIV_JSON_CONNECTION */
56249 e = 0;
56250
56251 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
56252
56253 if (e) {
56254 log_packet_detailed("'name' field error detected");
56255 }
56256 }
56257
56258 if (BV_ISSET(fields, 2)) {
56259 log_packet_detailed(" field 'helptxt' has changed");
56260
56261#ifdef FREECIV_JSON_CONNECTION
56262 field_addr.name = "helptxt";
56263#endif /* FREECIV_JSON_CONNECTION */
56264 e = 0;
56265
56266 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
56267
56268 if (e) {
56269 log_packet_detailed("'helptxt' field error detected");
56270 }
56271 }
56272
56273 *old = *real_packet;
56274
56275#else /* FREECIV_DELTA_PROTOCOL */
56276#ifdef FREECIV_JSON_CONNECTION
56277 field_addr.name = "id";
56278#endif /* FREECIV_JSON_CONNECTION */
56279 e = 0;
56280
56281 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
56282
56283 if (e) {
56284 log_packet_detailed("'id' field error detected");
56285 }
56286
56287#ifdef FREECIV_JSON_CONNECTION
56288 field_addr.name = "name";
56289#endif /* FREECIV_JSON_CONNECTION */
56290 e = 0;
56291
56292 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
56293
56294 if (e) {
56295 log_packet_detailed("'name' field error detected");
56296 }
56297
56298#ifdef FREECIV_JSON_CONNECTION
56299 field_addr.name = "helptxt";
56300#endif /* FREECIV_JSON_CONNECTION */
56301 e = 0;
56302
56303 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
56304
56305 if (e) {
56306 log_packet_detailed("'helptxt' field error detected");
56307 }
56308#endif /* FREECIV_DELTA_PROTOCOL */
56309
56310 SEND_PACKET_END(PACKET_RULESET_TECH_FLAG);
56311}
56312
56313 int send_packet_ruleset_tech_flag(struct connection *pc, const struct packet_ruleset_tech_flag *packet)
56314{
56315 if (!pc->used) {
56316 log_error("WARNING: trying to send data to the closed connection %s",
56317 conn_description(pc));
56318 return -1;
56319 }
56320 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TECH_FLAG].packet != nullptr, -1,
56321 "Handler for PACKET_RULESET_TECH_FLAG not installed");
56322 return pc->phs.handlers->send[PACKET_RULESET_TECH_FLAG].packet(pc, packet);
56323}
56324
56325 void lsend_packet_ruleset_tech_flag(struct conn_list *dest, const struct packet_ruleset_tech_flag *packet)
56326{
56327 conn_list_iterate(dest, pconn) {
56328 send_packet_ruleset_tech_flag(pconn, packet);
56329 } conn_list_iterate_end;
56330}
56331
56332 static inline void init_packet_ruleset_government(struct packet_ruleset_government *packet)
56333{
56334 memset(packet, 0, sizeof(*packet));
56335
56336 requirement_vector_init(&packet->reqs);
56337 packet->helptext = strvec_new();
56338}
56339
56340 static inline void free_packet_ruleset_government(struct packet_ruleset_government *packet)
56341{
56342 if (packet->helptext) {
56343 strvec_destroy(packet->helptext);
56344 packet->helptext = nullptr;
56345 }
56346 requirement_vector_free(&packet->reqs);
56347}
56348
56349 static inline void destroy_packet_ruleset_government(void *packet)
56350{
56351 free_packet_ruleset_government((struct packet_ruleset_government *) packet);
56352 free(packet);
56353}
56354
56355#ifdef FREECIV_DELTA_PROTOCOL
56356#define hash_packet_ruleset_government_100 hash_const
56357#define cmp_packet_ruleset_government_100 cmp_const
56358 BV_DEFINE(packet_ruleset_government_100_fields, 9);
56359#endif /* FREECIV_DELTA_PROTOCOL */
56360
56361 static struct packet_ruleset_government *receive_packet_ruleset_government_100(struct connection *pc)
56362{
56363#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_government(_packet)
56364 RECEIVE_PACKET_START(packet_ruleset_government, real_packet);
56365
56366#ifdef FREECIV_JSON_CONNECTION
56367 struct plocation field_addr;
56368 {
56369 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
56370 field_addr = *field_addr_tmp;
56371 FC_FREE(field_addr_tmp);
56372 }
56373#endif /* FREECIV_JSON_CONNECTION */
56374
56375 log_packet_detailed("packet_ruleset_government_100: got info about ()");
56376
56377#ifdef FREECIV_DELTA_PROTOCOL
56378 packet_ruleset_government_100_fields fields;
56379 struct packet_ruleset_government *old;
56380 struct genhash **hash = pc->phs.received + PACKET_RULESET_GOVERNMENT;
56381
56382 if (nullptr == *hash) {
56383 *hash = genhash_new_full(hash_packet_ruleset_government_100, cmp_packet_ruleset_government_100,
56384 nullptr, nullptr, nullptr, destroy_packet_ruleset_government);
56385 }
56386
56387 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
56388 real_packet->id = old->id;
56389 requirement_vector_copy(&real_packet->reqs, &old->reqs);
56390 sz_strlcpy(real_packet->name, old->name);
56391 sz_strlcpy(real_packet->rule_name, old->rule_name);
56392 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
56393 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
56394 sz_strlcpy(real_packet->sound_str, old->sound_str);
56395 sz_strlcpy(real_packet->sound_alt, old->sound_alt);
56396 if (old->helptext) {
56397 strvec_copy(real_packet->helptext, old->helptext);
56398 } else {
56399 strvec_clear(real_packet->helptext);
56400 }
56401 } else {
56402 /* packet is already initialized empty */
56403 log_packet_detailed(" no old info");
56404 }
56405
56406#ifdef FREECIV_JSON_CONNECTION
56407 field_addr.name = "fields";
56408#endif /* FREECIV_JSON_CONNECTION */
56409 DIO_BV_GET(&din, &field_addr, fields);
56410
56411 if (BV_ISSET(fields, 0)) {
56412 log_packet_detailed(" got field 'id'");
56413
56414#ifdef FREECIV_JSON_CONNECTION
56415 field_addr.name = "id";
56416#endif /* FREECIV_JSON_CONNECTION */
56417
56418 {
56419 int readin;
56420
56421 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
56422 RECEIVE_PACKET_FIELD_ERROR(id);
56423 }
56424 real_packet->id = readin;
56425 }
56426 }
56427
56428 if (BV_ISSET(fields, 1)) {
56429 log_packet_detailed(" got field 'reqs'");
56430
56431#ifdef FREECIV_JSON_CONNECTION
56432 field_addr.name = "reqs";
56433#endif /* FREECIV_JSON_CONNECTION */
56434
56435 {
56436 int i;
56437
56438 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
56439 RECEIVE_PACKET_FIELD_ERROR(reqs);
56440 }
56441 requirement_vector_reserve(&real_packet->reqs, i);
56442
56443#ifdef FREECIV_JSON_CONNECTION
56444 /* Enter array. */
56445 field_addr.sub_location = plocation_elem_new(0);
56446#endif /* FREECIV_JSON_CONNECTION */
56447
56448 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
56449#ifdef FREECIV_JSON_CONNECTION
56450 /* Next array element */
56451 field_addr.sub_location->number = i;
56452#endif /* FREECIV_JSON_CONNECTION */
56453
56454 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
56455 RECEIVE_PACKET_FIELD_ERROR(reqs);
56456 }
56457 }
56458
56459#ifdef FREECIV_JSON_CONNECTION
56460 /* Exit array. */
56461 FC_FREE(field_addr.sub_location);
56462#endif /* FREECIV_JSON_CONNECTION */
56463 }
56464 }
56465
56466 if (BV_ISSET(fields, 2)) {
56467 log_packet_detailed(" got field 'name'");
56468
56469#ifdef FREECIV_JSON_CONNECTION
56470 field_addr.name = "name";
56471#endif /* FREECIV_JSON_CONNECTION */
56472
56473 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
56474 RECEIVE_PACKET_FIELD_ERROR(name);
56475 }
56476 }
56477
56478 if (BV_ISSET(fields, 3)) {
56479 log_packet_detailed(" got field 'rule_name'");
56480
56481#ifdef FREECIV_JSON_CONNECTION
56482 field_addr.name = "rule_name";
56483#endif /* FREECIV_JSON_CONNECTION */
56484
56485 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
56486 RECEIVE_PACKET_FIELD_ERROR(rule_name);
56487 }
56488 }
56489
56490 if (BV_ISSET(fields, 4)) {
56491 log_packet_detailed(" got field 'graphic_str'");
56492
56493#ifdef FREECIV_JSON_CONNECTION
56494 field_addr.name = "graphic_str";
56495#endif /* FREECIV_JSON_CONNECTION */
56496
56497 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
56498 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
56499 }
56500 }
56501
56502 if (BV_ISSET(fields, 5)) {
56503 log_packet_detailed(" got field 'graphic_alt'");
56504
56505#ifdef FREECIV_JSON_CONNECTION
56506 field_addr.name = "graphic_alt";
56507#endif /* FREECIV_JSON_CONNECTION */
56508
56509 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
56510 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
56511 }
56512 }
56513
56514 if (BV_ISSET(fields, 6)) {
56515 log_packet_detailed(" got field 'sound_str'");
56516
56517#ifdef FREECIV_JSON_CONNECTION
56518 field_addr.name = "sound_str";
56519#endif /* FREECIV_JSON_CONNECTION */
56520
56521 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_str, sizeof(real_packet->sound_str))) {
56522 RECEIVE_PACKET_FIELD_ERROR(sound_str);
56523 }
56524 }
56525
56526 if (BV_ISSET(fields, 7)) {
56527 log_packet_detailed(" got field 'sound_alt'");
56528
56529#ifdef FREECIV_JSON_CONNECTION
56530 field_addr.name = "sound_alt";
56531#endif /* FREECIV_JSON_CONNECTION */
56532
56533 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_alt, sizeof(real_packet->sound_alt))) {
56534 RECEIVE_PACKET_FIELD_ERROR(sound_alt);
56535 }
56536 }
56537
56538 if (BV_ISSET(fields, 8)) {
56539 log_packet_detailed(" got field 'helptext'");
56540
56541#ifdef FREECIV_JSON_CONNECTION
56542 field_addr.name = "helptext";
56543#endif /* FREECIV_JSON_CONNECTION */
56544
56545 {
56546 int i;
56547
56548 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
56549 RECEIVE_PACKET_FIELD_ERROR(helptext);
56550 }
56551 strvec_reserve(real_packet->helptext, i);
56552
56553#ifdef FREECIV_JSON_CONNECTION
56554 /* Enter array. */
56555 field_addr.sub_location = plocation_elem_new(0);
56556#endif /* FREECIV_JSON_CONNECTION */
56557
56558 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
56559#ifdef FREECIV_JSON_CONNECTION
56560 /* Next array element */
56561 field_addr.sub_location->number = i;
56562#endif /* FREECIV_JSON_CONNECTION */
56563
56564 {
56565 char readin[MAX_LEN_PACKET];
56566
56567 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
56568 || !strvec_set(real_packet->helptext, i, readin)) {
56569 RECEIVE_PACKET_FIELD_ERROR(helptext);
56570 }
56571 }
56572 }
56573
56574#ifdef FREECIV_JSON_CONNECTION
56575 /* Exit array. */
56576 FC_FREE(field_addr.sub_location);
56577#endif /* FREECIV_JSON_CONNECTION */
56578 }
56579 }
56580
56581 if (nullptr == old) {
56582 old = fc_malloc(sizeof(*old));
56583 init_packet_ruleset_government(old);
56584 old->id = real_packet->id;
56585 requirement_vector_copy(&old->reqs, &real_packet->reqs);
56586 sz_strlcpy(old->name, real_packet->name);
56587 sz_strlcpy(old->rule_name, real_packet->rule_name);
56588 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
56589 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
56590 sz_strlcpy(old->sound_str, real_packet->sound_str);
56591 sz_strlcpy(old->sound_alt, real_packet->sound_alt);
56592 if (real_packet->helptext) {
56593 strvec_copy(old->helptext, real_packet->helptext);
56594 } else {
56595 strvec_clear(old->helptext);
56596 }
56597 genhash_insert(*hash, old, old);
56598 } else {
56599 old->id = real_packet->id;
56600 requirement_vector_copy(&old->reqs, &real_packet->reqs);
56601 sz_strlcpy(old->name, real_packet->name);
56602 sz_strlcpy(old->rule_name, real_packet->rule_name);
56603 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
56604 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
56605 sz_strlcpy(old->sound_str, real_packet->sound_str);
56606 sz_strlcpy(old->sound_alt, real_packet->sound_alt);
56607 if (real_packet->helptext) {
56608 strvec_copy(old->helptext, real_packet->helptext);
56609 } else {
56610 strvec_clear(old->helptext);
56611 }
56612 }
56613
56614#else /* FREECIV_DELTA_PROTOCOL */
56615#ifdef FREECIV_JSON_CONNECTION
56616 field_addr.name = "id";
56617#endif /* FREECIV_JSON_CONNECTION */
56618
56619 {
56620 int readin;
56621
56622 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
56623 RECEIVE_PACKET_FIELD_ERROR(id);
56624 }
56625 real_packet->id = readin;
56626 }
56627
56628#ifdef FREECIV_JSON_CONNECTION
56629 field_addr.name = "reqs";
56630#endif /* FREECIV_JSON_CONNECTION */
56631
56632 {
56633 int i;
56634
56635 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
56636 RECEIVE_PACKET_FIELD_ERROR(reqs);
56637 }
56638 requirement_vector_reserve(&real_packet->reqs, i);
56639
56640#ifdef FREECIV_JSON_CONNECTION
56641 /* Enter array. */
56642 field_addr.sub_location = plocation_elem_new(0);
56643#endif /* FREECIV_JSON_CONNECTION */
56644
56645 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
56646#ifdef FREECIV_JSON_CONNECTION
56647 /* Next array element */
56648 field_addr.sub_location->number = i;
56649#endif /* FREECIV_JSON_CONNECTION */
56650
56651 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
56652 RECEIVE_PACKET_FIELD_ERROR(reqs);
56653 }
56654 }
56655
56656#ifdef FREECIV_JSON_CONNECTION
56657 /* Exit array. */
56658 FC_FREE(field_addr.sub_location);
56659#endif /* FREECIV_JSON_CONNECTION */
56660 }
56661
56662#ifdef FREECIV_JSON_CONNECTION
56663 field_addr.name = "name";
56664#endif /* FREECIV_JSON_CONNECTION */
56665
56666 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
56667 RECEIVE_PACKET_FIELD_ERROR(name);
56668 }
56669
56670#ifdef FREECIV_JSON_CONNECTION
56671 field_addr.name = "rule_name";
56672#endif /* FREECIV_JSON_CONNECTION */
56673
56674 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
56675 RECEIVE_PACKET_FIELD_ERROR(rule_name);
56676 }
56677
56678#ifdef FREECIV_JSON_CONNECTION
56679 field_addr.name = "graphic_str";
56680#endif /* FREECIV_JSON_CONNECTION */
56681
56682 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
56683 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
56684 }
56685
56686#ifdef FREECIV_JSON_CONNECTION
56687 field_addr.name = "graphic_alt";
56688#endif /* FREECIV_JSON_CONNECTION */
56689
56690 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
56691 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
56692 }
56693
56694#ifdef FREECIV_JSON_CONNECTION
56695 field_addr.name = "sound_str";
56696#endif /* FREECIV_JSON_CONNECTION */
56697
56698 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_str, sizeof(real_packet->sound_str))) {
56699 RECEIVE_PACKET_FIELD_ERROR(sound_str);
56700 }
56701
56702#ifdef FREECIV_JSON_CONNECTION
56703 field_addr.name = "sound_alt";
56704#endif /* FREECIV_JSON_CONNECTION */
56705
56706 if (!DIO_GET(string, &din, &field_addr, real_packet->sound_alt, sizeof(real_packet->sound_alt))) {
56707 RECEIVE_PACKET_FIELD_ERROR(sound_alt);
56708 }
56709
56710#ifdef FREECIV_JSON_CONNECTION
56711 field_addr.name = "helptext";
56712#endif /* FREECIV_JSON_CONNECTION */
56713
56714 {
56715 int i;
56716
56717 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
56718 RECEIVE_PACKET_FIELD_ERROR(helptext);
56719 }
56720 strvec_reserve(real_packet->helptext, i);
56721
56722#ifdef FREECIV_JSON_CONNECTION
56723 /* Enter array. */
56724 field_addr.sub_location = plocation_elem_new(0);
56725#endif /* FREECIV_JSON_CONNECTION */
56726
56727 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
56728#ifdef FREECIV_JSON_CONNECTION
56729 /* Next array element */
56730 field_addr.sub_location->number = i;
56731#endif /* FREECIV_JSON_CONNECTION */
56732
56733 {
56734 char readin[MAX_LEN_PACKET];
56735
56736 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
56737 || !strvec_set(real_packet->helptext, i, readin)) {
56738 RECEIVE_PACKET_FIELD_ERROR(helptext);
56739 }
56740 }
56741 }
56742
56743#ifdef FREECIV_JSON_CONNECTION
56744 /* Exit array. */
56745 FC_FREE(field_addr.sub_location);
56746#endif /* FREECIV_JSON_CONNECTION */
56747 }
56748#endif /* FREECIV_DELTA_PROTOCOL */
56749
56750 RECEIVE_PACKET_END(real_packet);
56751#undef FREE_PACKET_STRUCT
56752}
56753
56754 static int send_packet_ruleset_government_100(struct connection *pc, const struct packet_ruleset_government *packet)
56755{
56756 const struct packet_ruleset_government *real_packet = packet;
56757 int e;
56758 SEND_PACKET_START(PACKET_RULESET_GOVERNMENT);
56759
56760 log_packet_detailed("packet_ruleset_government_100: sending info about ()");
56761
56762#ifdef FREECIV_DELTA_PROTOCOL
56763 packet_ruleset_government_100_fields fields;
56764 struct packet_ruleset_government *old;
56765 bool differ;
56766 struct genhash **hash = pc->phs.sent + PACKET_RULESET_GOVERNMENT;
56767
56768 if (nullptr == *hash) {
56769 *hash = genhash_new_full(hash_packet_ruleset_government_100, cmp_packet_ruleset_government_100,
56770 nullptr, nullptr, nullptr, destroy_packet_ruleset_government);
56771 }
56772 BV_CLR_ALL(fields);
56773
56774 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
56775 old = fc_malloc(sizeof(*old));
56776 /* temporary bitcopy just to insert correctly */
56777 *old = *real_packet;
56778 genhash_insert(*hash, old, old);
56779 init_packet_ruleset_government(old);
56780 }
56781
56782 differ = (old->id != real_packet->id);
56783 if (differ) {
56784 BV_SET(fields, 0);
56785 }
56786
56787 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
56788 if (!differ) {
56789 int i;
56790
56791 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
56792 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
56793 if (differ) {
56794 break;
56795 }
56796 }
56797 }
56798 if (differ) {
56799 BV_SET(fields, 1);
56800 }
56801
56802 differ = (strcmp(old->name, real_packet->name) != 0);
56803 if (differ) {
56804 BV_SET(fields, 2);
56805 }
56806
56807 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
56808 if (differ) {
56809 BV_SET(fields, 3);
56810 }
56811
56812 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
56813 if (differ) {
56814 BV_SET(fields, 4);
56815 }
56816
56817 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
56818 if (differ) {
56819 BV_SET(fields, 5);
56820 }
56821
56822 differ = (strcmp(old->sound_str, real_packet->sound_str) != 0);
56823 if (differ) {
56824 BV_SET(fields, 6);
56825 }
56826
56827 differ = (strcmp(old->sound_alt, real_packet->sound_alt) != 0);
56828 if (differ) {
56829 BV_SET(fields, 7);
56830 }
56831
56832 if (real_packet->helptext) {
56833 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
56834 } else {
56835 differ = (strvec_size(old->helptext) > 0);
56836 }
56837 if (differ) {
56838 BV_SET(fields, 8);
56839 }
56840#endif /* FREECIV_DELTA_PROTOCOL */
56841
56842#ifdef FREECIV_JSON_CONNECTION
56843 struct plocation field_addr;
56844 {
56845 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
56846 field_addr = *field_addr_tmp;
56847 FC_FREE(field_addr_tmp);
56848 }
56849#endif /* FREECIV_JSON_CONNECTION */
56850
56851#ifdef FREECIV_DELTA_PROTOCOL
56852#ifdef FREECIV_JSON_CONNECTION
56853 field_addr.name = "fields";
56854#endif /* FREECIV_JSON_CONNECTION */
56855 e = 0;
56856 e |= DIO_BV_PUT(&dout, &field_addr, fields);
56857 if (e) {
56858 log_packet_detailed("fields bitvector error detected");
56859 }
56860
56861 if (BV_ISSET(fields, 0)) {
56862 log_packet_detailed(" field 'id' has changed");
56863
56864#ifdef FREECIV_JSON_CONNECTION
56865 field_addr.name = "id";
56866#endif /* FREECIV_JSON_CONNECTION */
56867 e = 0;
56868
56869 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->id);
56870
56871 if (e) {
56872 log_packet_detailed("'id' field error detected");
56873 }
56874 }
56875
56876 if (BV_ISSET(fields, 1)) {
56877 log_packet_detailed(" field 'reqs' has changed");
56878
56879#ifdef FREECIV_JSON_CONNECTION
56880 field_addr.name = "reqs";
56881#endif /* FREECIV_JSON_CONNECTION */
56882 e = 0;
56883
56884 {
56885 int i;
56886
56887 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
56888 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
56889
56890#ifdef FREECIV_JSON_CONNECTION
56891 /* Enter array. */
56892 field_addr.sub_location = plocation_elem_new(0);
56893#endif /* FREECIV_JSON_CONNECTION */
56894
56895 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
56896#ifdef FREECIV_JSON_CONNECTION
56897 /* Next array element. */
56898 field_addr.sub_location->number = i;
56899#endif /* FREECIV_JSON_CONNECTION */
56900
56901 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
56902 }
56903
56904#ifdef FREECIV_JSON_CONNECTION
56905 /* Exit array. */
56906 FC_FREE(field_addr.sub_location);
56907#endif /* FREECIV_JSON_CONNECTION */
56908 }
56909
56910 if (e) {
56911 log_packet_detailed("'reqs' field error detected");
56912 }
56913 }
56914
56915 if (BV_ISSET(fields, 2)) {
56916 log_packet_detailed(" field 'name' has changed");
56917
56918#ifdef FREECIV_JSON_CONNECTION
56919 field_addr.name = "name";
56920#endif /* FREECIV_JSON_CONNECTION */
56921 e = 0;
56922
56923 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
56924
56925 if (e) {
56926 log_packet_detailed("'name' field error detected");
56927 }
56928 }
56929
56930 if (BV_ISSET(fields, 3)) {
56931 log_packet_detailed(" field 'rule_name' has changed");
56932
56933#ifdef FREECIV_JSON_CONNECTION
56934 field_addr.name = "rule_name";
56935#endif /* FREECIV_JSON_CONNECTION */
56936 e = 0;
56937
56938 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
56939
56940 if (e) {
56941 log_packet_detailed("'rule_name' field error detected");
56942 }
56943 }
56944
56945 if (BV_ISSET(fields, 4)) {
56946 log_packet_detailed(" field 'graphic_str' has changed");
56947
56948#ifdef FREECIV_JSON_CONNECTION
56949 field_addr.name = "graphic_str";
56950#endif /* FREECIV_JSON_CONNECTION */
56951 e = 0;
56952
56953 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
56954
56955 if (e) {
56956 log_packet_detailed("'graphic_str' field error detected");
56957 }
56958 }
56959
56960 if (BV_ISSET(fields, 5)) {
56961 log_packet_detailed(" field 'graphic_alt' has changed");
56962
56963#ifdef FREECIV_JSON_CONNECTION
56964 field_addr.name = "graphic_alt";
56965#endif /* FREECIV_JSON_CONNECTION */
56966 e = 0;
56967
56968 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
56969
56970 if (e) {
56971 log_packet_detailed("'graphic_alt' field error detected");
56972 }
56973 }
56974
56975 if (BV_ISSET(fields, 6)) {
56976 log_packet_detailed(" field 'sound_str' has changed");
56977
56978#ifdef FREECIV_JSON_CONNECTION
56979 field_addr.name = "sound_str";
56980#endif /* FREECIV_JSON_CONNECTION */
56981 e = 0;
56982
56983 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_str);
56984
56985 if (e) {
56986 log_packet_detailed("'sound_str' field error detected");
56987 }
56988 }
56989
56990 if (BV_ISSET(fields, 7)) {
56991 log_packet_detailed(" field 'sound_alt' has changed");
56992
56993#ifdef FREECIV_JSON_CONNECTION
56994 field_addr.name = "sound_alt";
56995#endif /* FREECIV_JSON_CONNECTION */
56996 e = 0;
56997
56998 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_alt);
56999
57000 if (e) {
57001 log_packet_detailed("'sound_alt' field error detected");
57002 }
57003 }
57004
57005 if (BV_ISSET(fields, 8)) {
57006 log_packet_detailed(" field 'helptext' has changed");
57007
57008#ifdef FREECIV_JSON_CONNECTION
57009 field_addr.name = "helptext";
57010#endif /* FREECIV_JSON_CONNECTION */
57011 e = 0;
57012
57013 if (!real_packet->helptext) {
57014 /* Transmit null as empty */
57015 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
57016 } else {
57017 int i;
57018
57019 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
57020 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
57021
57022#ifdef FREECIV_JSON_CONNECTION
57023 /* Enter array. */
57024 field_addr.sub_location = plocation_elem_new(0);
57025#endif /* FREECIV_JSON_CONNECTION */
57026
57027 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
57028#ifdef FREECIV_JSON_CONNECTION
57029 /* Next array element. */
57030 field_addr.sub_location->number = i;
57031#endif /* FREECIV_JSON_CONNECTION */
57032
57033 {
57034 const char *pstr = strvec_get(real_packet->helptext, i);
57035
57036 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
57037 }
57038 }
57039
57040#ifdef FREECIV_JSON_CONNECTION
57041 /* Exit array. */
57042 FC_FREE(field_addr.sub_location);
57043#endif /* FREECIV_JSON_CONNECTION */
57044 }
57045
57046 if (e) {
57047 log_packet_detailed("'helptext' field error detected");
57048 }
57049 }
57050
57051 old->id = real_packet->id;
57052 requirement_vector_copy(&old->reqs, &real_packet->reqs);
57053 sz_strlcpy(old->name, real_packet->name);
57054 sz_strlcpy(old->rule_name, real_packet->rule_name);
57055 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
57056 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
57057 sz_strlcpy(old->sound_str, real_packet->sound_str);
57058 sz_strlcpy(old->sound_alt, real_packet->sound_alt);
57059 if (real_packet->helptext) {
57060 strvec_copy(old->helptext, real_packet->helptext);
57061 } else {
57062 strvec_clear(old->helptext);
57063 }
57064
57065#else /* FREECIV_DELTA_PROTOCOL */
57066#ifdef FREECIV_JSON_CONNECTION
57067 field_addr.name = "id";
57068#endif /* FREECIV_JSON_CONNECTION */
57069 e = 0;
57070
57071 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->id);
57072
57073 if (e) {
57074 log_packet_detailed("'id' field error detected");
57075 }
57076
57077#ifdef FREECIV_JSON_CONNECTION
57078 field_addr.name = "reqs";
57079#endif /* FREECIV_JSON_CONNECTION */
57080 e = 0;
57081
57082 {
57083 int i;
57084
57085 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
57086 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
57087
57088#ifdef FREECIV_JSON_CONNECTION
57089 /* Enter array. */
57090 field_addr.sub_location = plocation_elem_new(0);
57091#endif /* FREECIV_JSON_CONNECTION */
57092
57093 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
57094#ifdef FREECIV_JSON_CONNECTION
57095 /* Next array element. */
57096 field_addr.sub_location->number = i;
57097#endif /* FREECIV_JSON_CONNECTION */
57098
57099 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
57100 }
57101
57102#ifdef FREECIV_JSON_CONNECTION
57103 /* Exit array. */
57104 FC_FREE(field_addr.sub_location);
57105#endif /* FREECIV_JSON_CONNECTION */
57106 }
57107
57108 if (e) {
57109 log_packet_detailed("'reqs' field error detected");
57110 }
57111
57112#ifdef FREECIV_JSON_CONNECTION
57113 field_addr.name = "name";
57114#endif /* FREECIV_JSON_CONNECTION */
57115 e = 0;
57116
57117 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
57118
57119 if (e) {
57120 log_packet_detailed("'name' field error detected");
57121 }
57122
57123#ifdef FREECIV_JSON_CONNECTION
57124 field_addr.name = "rule_name";
57125#endif /* FREECIV_JSON_CONNECTION */
57126 e = 0;
57127
57128 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
57129
57130 if (e) {
57131 log_packet_detailed("'rule_name' field error detected");
57132 }
57133
57134#ifdef FREECIV_JSON_CONNECTION
57135 field_addr.name = "graphic_str";
57136#endif /* FREECIV_JSON_CONNECTION */
57137 e = 0;
57138
57139 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
57140
57141 if (e) {
57142 log_packet_detailed("'graphic_str' field error detected");
57143 }
57144
57145#ifdef FREECIV_JSON_CONNECTION
57146 field_addr.name = "graphic_alt";
57147#endif /* FREECIV_JSON_CONNECTION */
57148 e = 0;
57149
57150 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
57151
57152 if (e) {
57153 log_packet_detailed("'graphic_alt' field error detected");
57154 }
57155
57156#ifdef FREECIV_JSON_CONNECTION
57157 field_addr.name = "sound_str";
57158#endif /* FREECIV_JSON_CONNECTION */
57159 e = 0;
57160
57161 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_str);
57162
57163 if (e) {
57164 log_packet_detailed("'sound_str' field error detected");
57165 }
57166
57167#ifdef FREECIV_JSON_CONNECTION
57168 field_addr.name = "sound_alt";
57169#endif /* FREECIV_JSON_CONNECTION */
57170 e = 0;
57171
57172 e |= DIO_PUT(string, &dout, &field_addr, real_packet->sound_alt);
57173
57174 if (e) {
57175 log_packet_detailed("'sound_alt' field error detected");
57176 }
57177
57178#ifdef FREECIV_JSON_CONNECTION
57179 field_addr.name = "helptext";
57180#endif /* FREECIV_JSON_CONNECTION */
57181 e = 0;
57182
57183 if (!real_packet->helptext) {
57184 /* Transmit null as empty */
57185 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
57186 } else {
57187 int i;
57188
57189 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
57190 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
57191
57192#ifdef FREECIV_JSON_CONNECTION
57193 /* Enter array. */
57194 field_addr.sub_location = plocation_elem_new(0);
57195#endif /* FREECIV_JSON_CONNECTION */
57196
57197 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
57198#ifdef FREECIV_JSON_CONNECTION
57199 /* Next array element. */
57200 field_addr.sub_location->number = i;
57201#endif /* FREECIV_JSON_CONNECTION */
57202
57203 {
57204 const char *pstr = strvec_get(real_packet->helptext, i);
57205
57206 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
57207 }
57208 }
57209
57210#ifdef FREECIV_JSON_CONNECTION
57211 /* Exit array. */
57212 FC_FREE(field_addr.sub_location);
57213#endif /* FREECIV_JSON_CONNECTION */
57214 }
57215
57216 if (e) {
57217 log_packet_detailed("'helptext' field error detected");
57218 }
57219#endif /* FREECIV_DELTA_PROTOCOL */
57220
57221 SEND_PACKET_END(PACKET_RULESET_GOVERNMENT);
57222}
57223
57224 int send_packet_ruleset_government(struct connection *pc, const struct packet_ruleset_government *packet)
57225{
57226 if (!pc->used) {
57227 log_error("WARNING: trying to send data to the closed connection %s",
57228 conn_description(pc));
57229 return -1;
57230 }
57231 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT].packet != nullptr, -1,
57232 "Handler for PACKET_RULESET_GOVERNMENT not installed");
57233 return pc->phs.handlers->send[PACKET_RULESET_GOVERNMENT].packet(pc, packet);
57234}
57235
57236 void lsend_packet_ruleset_government(struct conn_list *dest, const struct packet_ruleset_government *packet)
57237{
57238 conn_list_iterate(dest, pconn) {
57239 send_packet_ruleset_government(pconn, packet);
57240 } conn_list_iterate_end;
57241}
57242
57243 static inline void init_packet_ruleset_terrain_control(struct packet_ruleset_terrain_control *packet)
57244{
57245 memset(packet, 0, sizeof(*packet));
57246}
57247
57248#define free_packet_ruleset_terrain_control(_packet) (void) 0
57249#define destroy_packet_ruleset_terrain_control free
57250
57251#ifdef FREECIV_DELTA_PROTOCOL
57252#define hash_packet_ruleset_terrain_control_100 hash_const
57253#define cmp_packet_ruleset_terrain_control_100 cmp_const
57254 BV_DEFINE(packet_ruleset_terrain_control_100_fields, 12);
57255#endif /* FREECIV_DELTA_PROTOCOL */
57256
57257 static struct packet_ruleset_terrain_control *receive_packet_ruleset_terrain_control_100(struct connection *pc)
57258{
57259#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_terrain_control(_packet)
57260 RECEIVE_PACKET_START(packet_ruleset_terrain_control, real_packet);
57261
57262#ifdef FREECIV_JSON_CONNECTION
57263 struct plocation field_addr;
57264 {
57265 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
57266 field_addr = *field_addr_tmp;
57267 FC_FREE(field_addr_tmp);
57268 }
57269#endif /* FREECIV_JSON_CONNECTION */
57270
57271 log_packet_detailed("packet_ruleset_terrain_control_100: got info about ()");
57272
57273#ifdef FREECIV_DELTA_PROTOCOL
57274 packet_ruleset_terrain_control_100_fields fields;
57275 struct packet_ruleset_terrain_control *old;
57276 struct genhash **hash = pc->phs.received + PACKET_RULESET_TERRAIN_CONTROL;
57277
57278 if (nullptr == *hash) {
57279 *hash = genhash_new_full(hash_packet_ruleset_terrain_control_100, cmp_packet_ruleset_terrain_control_100,
57280 nullptr, nullptr, nullptr, destroy_packet_ruleset_terrain_control);
57281 }
57282
57283 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
57284 *real_packet = *old;
57285 } else {
57286 /* packet is already initialized empty */
57287 log_packet_detailed(" no old info");
57288 }
57289
57290#ifdef FREECIV_JSON_CONNECTION
57291 field_addr.name = "fields";
57292#endif /* FREECIV_JSON_CONNECTION */
57293 DIO_BV_GET(&din, &field_addr, fields);
57294
57295 if (BV_ISSET(fields, 0)) {
57296 log_packet_detailed(" got field 'ocean_reclaim_requirement_pct'");
57297
57298#ifdef FREECIV_JSON_CONNECTION
57299 field_addr.name = "ocean_reclaim_requirement_pct";
57300#endif /* FREECIV_JSON_CONNECTION */
57301
57302 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ocean_reclaim_requirement_pct)) {
57303 RECEIVE_PACKET_FIELD_ERROR(ocean_reclaim_requirement_pct);
57304 }
57305 }
57306
57307 if (BV_ISSET(fields, 1)) {
57308 log_packet_detailed(" got field 'land_channel_requirement_pct'");
57309
57310#ifdef FREECIV_JSON_CONNECTION
57311 field_addr.name = "land_channel_requirement_pct";
57312#endif /* FREECIV_JSON_CONNECTION */
57313
57314 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->land_channel_requirement_pct)) {
57315 RECEIVE_PACKET_FIELD_ERROR(land_channel_requirement_pct);
57316 }
57317 }
57318
57319 if (BV_ISSET(fields, 2)) {
57320 log_packet_detailed(" got field 'terrain_thaw_requirement_pct'");
57321
57322#ifdef FREECIV_JSON_CONNECTION
57323 field_addr.name = "terrain_thaw_requirement_pct";
57324#endif /* FREECIV_JSON_CONNECTION */
57325
57326 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->terrain_thaw_requirement_pct)) {
57327 RECEIVE_PACKET_FIELD_ERROR(terrain_thaw_requirement_pct);
57328 }
57329 }
57330
57331 if (BV_ISSET(fields, 3)) {
57332 log_packet_detailed(" got field 'terrain_freeze_requirement_pct'");
57333
57334#ifdef FREECIV_JSON_CONNECTION
57335 field_addr.name = "terrain_freeze_requirement_pct";
57336#endif /* FREECIV_JSON_CONNECTION */
57337
57338 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->terrain_freeze_requirement_pct)) {
57339 RECEIVE_PACKET_FIELD_ERROR(terrain_freeze_requirement_pct);
57340 }
57341 }
57342
57343 if (BV_ISSET(fields, 4)) {
57344 log_packet_detailed(" got field 'lake_max_size'");
57345
57346#ifdef FREECIV_JSON_CONNECTION
57347 field_addr.name = "lake_max_size";
57348#endif /* FREECIV_JSON_CONNECTION */
57349
57350 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->lake_max_size)) {
57351 RECEIVE_PACKET_FIELD_ERROR(lake_max_size);
57352 }
57353 }
57354
57355 if (BV_ISSET(fields, 5)) {
57356 log_packet_detailed(" got field 'min_start_native_area'");
57357
57358#ifdef FREECIV_JSON_CONNECTION
57359 field_addr.name = "min_start_native_area";
57360#endif /* FREECIV_JSON_CONNECTION */
57361
57362 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->min_start_native_area)) {
57363 RECEIVE_PACKET_FIELD_ERROR(min_start_native_area);
57364 }
57365 }
57366
57367 if (BV_ISSET(fields, 6)) {
57368 log_packet_detailed(" got field 'move_fragments'");
57369
57370#ifdef FREECIV_JSON_CONNECTION
57371 field_addr.name = "move_fragments";
57372#endif /* FREECIV_JSON_CONNECTION */
57373
57374 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_fragments)) {
57375 RECEIVE_PACKET_FIELD_ERROR(move_fragments);
57376 }
57377 }
57378
57379 if (BV_ISSET(fields, 7)) {
57380 log_packet_detailed(" got field 'igter_cost'");
57381
57382#ifdef FREECIV_JSON_CONNECTION
57383 field_addr.name = "igter_cost";
57384#endif /* FREECIV_JSON_CONNECTION */
57385
57386 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->igter_cost)) {
57387 RECEIVE_PACKET_FIELD_ERROR(igter_cost);
57388 }
57389 }
57390
57391 real_packet->pythagorean_diagonal = BV_ISSET(fields, 8);
57392
57393 real_packet->infrapoints = BV_ISSET(fields, 9);
57394
57395 if (BV_ISSET(fields, 10)) {
57396 log_packet_detailed(" got field 'gui_type_base0'");
57397
57398#ifdef FREECIV_JSON_CONNECTION
57399 field_addr.name = "gui_type_base0";
57400#endif /* FREECIV_JSON_CONNECTION */
57401
57402 if (!DIO_GET(string, &din, &field_addr, real_packet->gui_type_base0, sizeof(real_packet->gui_type_base0))) {
57403 RECEIVE_PACKET_FIELD_ERROR(gui_type_base0);
57404 }
57405 }
57406
57407 if (BV_ISSET(fields, 11)) {
57408 log_packet_detailed(" got field 'gui_type_base1'");
57409
57410#ifdef FREECIV_JSON_CONNECTION
57411 field_addr.name = "gui_type_base1";
57412#endif /* FREECIV_JSON_CONNECTION */
57413
57414 if (!DIO_GET(string, &din, &field_addr, real_packet->gui_type_base1, sizeof(real_packet->gui_type_base1))) {
57415 RECEIVE_PACKET_FIELD_ERROR(gui_type_base1);
57416 }
57417 }
57418
57419 if (nullptr == old) {
57420 old = fc_malloc(sizeof(*old));
57421 init_packet_ruleset_terrain_control(old);
57422 *old = *real_packet;
57423 genhash_insert(*hash, old, old);
57424 } else {
57425 *old = *real_packet;
57426 }
57427
57428#else /* FREECIV_DELTA_PROTOCOL */
57429#ifdef FREECIV_JSON_CONNECTION
57430 field_addr.name = "ocean_reclaim_requirement_pct";
57431#endif /* FREECIV_JSON_CONNECTION */
57432
57433 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ocean_reclaim_requirement_pct)) {
57434 RECEIVE_PACKET_FIELD_ERROR(ocean_reclaim_requirement_pct);
57435 }
57436
57437#ifdef FREECIV_JSON_CONNECTION
57438 field_addr.name = "land_channel_requirement_pct";
57439#endif /* FREECIV_JSON_CONNECTION */
57440
57441 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->land_channel_requirement_pct)) {
57442 RECEIVE_PACKET_FIELD_ERROR(land_channel_requirement_pct);
57443 }
57444
57445#ifdef FREECIV_JSON_CONNECTION
57446 field_addr.name = "terrain_thaw_requirement_pct";
57447#endif /* FREECIV_JSON_CONNECTION */
57448
57449 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->terrain_thaw_requirement_pct)) {
57450 RECEIVE_PACKET_FIELD_ERROR(terrain_thaw_requirement_pct);
57451 }
57452
57453#ifdef FREECIV_JSON_CONNECTION
57454 field_addr.name = "terrain_freeze_requirement_pct";
57455#endif /* FREECIV_JSON_CONNECTION */
57456
57457 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->terrain_freeze_requirement_pct)) {
57458 RECEIVE_PACKET_FIELD_ERROR(terrain_freeze_requirement_pct);
57459 }
57460
57461#ifdef FREECIV_JSON_CONNECTION
57462 field_addr.name = "lake_max_size";
57463#endif /* FREECIV_JSON_CONNECTION */
57464
57465 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->lake_max_size)) {
57466 RECEIVE_PACKET_FIELD_ERROR(lake_max_size);
57467 }
57468
57469#ifdef FREECIV_JSON_CONNECTION
57470 field_addr.name = "min_start_native_area";
57471#endif /* FREECIV_JSON_CONNECTION */
57472
57473 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->min_start_native_area)) {
57474 RECEIVE_PACKET_FIELD_ERROR(min_start_native_area);
57475 }
57476
57477#ifdef FREECIV_JSON_CONNECTION
57478 field_addr.name = "move_fragments";
57479#endif /* FREECIV_JSON_CONNECTION */
57480
57481 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->move_fragments)) {
57482 RECEIVE_PACKET_FIELD_ERROR(move_fragments);
57483 }
57484
57485#ifdef FREECIV_JSON_CONNECTION
57486 field_addr.name = "igter_cost";
57487#endif /* FREECIV_JSON_CONNECTION */
57488
57489 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->igter_cost)) {
57490 RECEIVE_PACKET_FIELD_ERROR(igter_cost);
57491 }
57492
57493#ifdef FREECIV_JSON_CONNECTION
57494 field_addr.name = "pythagorean_diagonal";
57495#endif /* FREECIV_JSON_CONNECTION */
57496
57497 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->pythagorean_diagonal)) {
57498 RECEIVE_PACKET_FIELD_ERROR(pythagorean_diagonal);
57499 }
57500
57501#ifdef FREECIV_JSON_CONNECTION
57502 field_addr.name = "infrapoints";
57503#endif /* FREECIV_JSON_CONNECTION */
57504
57505 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->infrapoints)) {
57506 RECEIVE_PACKET_FIELD_ERROR(infrapoints);
57507 }
57508
57509#ifdef FREECIV_JSON_CONNECTION
57510 field_addr.name = "gui_type_base0";
57511#endif /* FREECIV_JSON_CONNECTION */
57512
57513 if (!DIO_GET(string, &din, &field_addr, real_packet->gui_type_base0, sizeof(real_packet->gui_type_base0))) {
57514 RECEIVE_PACKET_FIELD_ERROR(gui_type_base0);
57515 }
57516
57517#ifdef FREECIV_JSON_CONNECTION
57518 field_addr.name = "gui_type_base1";
57519#endif /* FREECIV_JSON_CONNECTION */
57520
57521 if (!DIO_GET(string, &din, &field_addr, real_packet->gui_type_base1, sizeof(real_packet->gui_type_base1))) {
57522 RECEIVE_PACKET_FIELD_ERROR(gui_type_base1);
57523 }
57524#endif /* FREECIV_DELTA_PROTOCOL */
57525
57526 RECEIVE_PACKET_END(real_packet);
57527#undef FREE_PACKET_STRUCT
57528}
57529
57530 static int send_packet_ruleset_terrain_control_100(struct connection *pc, const struct packet_ruleset_terrain_control *packet)
57531{
57532 const struct packet_ruleset_terrain_control *real_packet = packet;
57533 int e;
57534 SEND_PACKET_START(PACKET_RULESET_TERRAIN_CONTROL);
57535
57536 log_packet_detailed("packet_ruleset_terrain_control_100: sending info about ()");
57537
57538#ifdef FREECIV_DELTA_PROTOCOL
57539 packet_ruleset_terrain_control_100_fields fields;
57540 struct packet_ruleset_terrain_control *old;
57541 bool differ;
57542 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TERRAIN_CONTROL;
57543
57544 if (nullptr == *hash) {
57545 *hash = genhash_new_full(hash_packet_ruleset_terrain_control_100, cmp_packet_ruleset_terrain_control_100,
57546 nullptr, nullptr, nullptr, destroy_packet_ruleset_terrain_control);
57547 }
57548 BV_CLR_ALL(fields);
57549
57550 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
57551 old = fc_malloc(sizeof(*old));
57552 /* temporary bitcopy just to insert correctly */
57553 *old = *real_packet;
57554 genhash_insert(*hash, old, old);
57555 init_packet_ruleset_terrain_control(old);
57556 }
57557
57558 differ = (old->ocean_reclaim_requirement_pct != real_packet->ocean_reclaim_requirement_pct);
57559 if (differ) {
57560 BV_SET(fields, 0);
57561 }
57562
57563 differ = (old->land_channel_requirement_pct != real_packet->land_channel_requirement_pct);
57564 if (differ) {
57565 BV_SET(fields, 1);
57566 }
57567
57568 differ = (old->terrain_thaw_requirement_pct != real_packet->terrain_thaw_requirement_pct);
57569 if (differ) {
57570 BV_SET(fields, 2);
57571 }
57572
57573 differ = (old->terrain_freeze_requirement_pct != real_packet->terrain_freeze_requirement_pct);
57574 if (differ) {
57575 BV_SET(fields, 3);
57576 }
57577
57578 differ = (old->lake_max_size != real_packet->lake_max_size);
57579 if (differ) {
57580 BV_SET(fields, 4);
57581 }
57582
57583 differ = (old->min_start_native_area != real_packet->min_start_native_area);
57584 if (differ) {
57585 BV_SET(fields, 5);
57586 }
57587
57588 differ = (old->move_fragments != real_packet->move_fragments);
57589 if (differ) {
57590 BV_SET(fields, 6);
57591 }
57592
57593 differ = (old->igter_cost != real_packet->igter_cost);
57594 if (differ) {
57595 BV_SET(fields, 7);
57596 }
57597
57598 /* folded into head */
57599 if (real_packet->pythagorean_diagonal) {
57600 BV_SET(fields, 8);
57601 }
57602
57603 /* folded into head */
57604 if (real_packet->infrapoints) {
57605 BV_SET(fields, 9);
57606 }
57607
57608 differ = (strcmp(old->gui_type_base0, real_packet->gui_type_base0) != 0);
57609 if (differ) {
57610 BV_SET(fields, 10);
57611 }
57612
57613 differ = (strcmp(old->gui_type_base1, real_packet->gui_type_base1) != 0);
57614 if (differ) {
57615 BV_SET(fields, 11);
57616 }
57617#endif /* FREECIV_DELTA_PROTOCOL */
57618
57619#ifdef FREECIV_JSON_CONNECTION
57620 struct plocation field_addr;
57621 {
57622 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
57623 field_addr = *field_addr_tmp;
57624 FC_FREE(field_addr_tmp);
57625 }
57626#endif /* FREECIV_JSON_CONNECTION */
57627
57628#ifdef FREECIV_DELTA_PROTOCOL
57629#ifdef FREECIV_JSON_CONNECTION
57630 field_addr.name = "fields";
57631#endif /* FREECIV_JSON_CONNECTION */
57632 e = 0;
57633 e |= DIO_BV_PUT(&dout, &field_addr, fields);
57634 if (e) {
57635 log_packet_detailed("fields bitvector error detected");
57636 }
57637
57638 if (BV_ISSET(fields, 0)) {
57639 log_packet_detailed(" field 'ocean_reclaim_requirement_pct' has changed");
57640
57641#ifdef FREECIV_JSON_CONNECTION
57642 field_addr.name = "ocean_reclaim_requirement_pct";
57643#endif /* FREECIV_JSON_CONNECTION */
57644 e = 0;
57645
57646 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ocean_reclaim_requirement_pct);
57647
57648 if (e) {
57649 log_packet_detailed("'ocean_reclaim_requirement_pct' field error detected");
57650 }
57651 }
57652
57653 if (BV_ISSET(fields, 1)) {
57654 log_packet_detailed(" field 'land_channel_requirement_pct' has changed");
57655
57656#ifdef FREECIV_JSON_CONNECTION
57657 field_addr.name = "land_channel_requirement_pct";
57658#endif /* FREECIV_JSON_CONNECTION */
57659 e = 0;
57660
57661 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->land_channel_requirement_pct);
57662
57663 if (e) {
57664 log_packet_detailed("'land_channel_requirement_pct' field error detected");
57665 }
57666 }
57667
57668 if (BV_ISSET(fields, 2)) {
57669 log_packet_detailed(" field 'terrain_thaw_requirement_pct' has changed");
57670
57671#ifdef FREECIV_JSON_CONNECTION
57672 field_addr.name = "terrain_thaw_requirement_pct";
57673#endif /* FREECIV_JSON_CONNECTION */
57674 e = 0;
57675
57676 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain_thaw_requirement_pct);
57677
57678 if (e) {
57679 log_packet_detailed("'terrain_thaw_requirement_pct' field error detected");
57680 }
57681 }
57682
57683 if (BV_ISSET(fields, 3)) {
57684 log_packet_detailed(" field 'terrain_freeze_requirement_pct' has changed");
57685
57686#ifdef FREECIV_JSON_CONNECTION
57687 field_addr.name = "terrain_freeze_requirement_pct";
57688#endif /* FREECIV_JSON_CONNECTION */
57689 e = 0;
57690
57691 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain_freeze_requirement_pct);
57692
57693 if (e) {
57694 log_packet_detailed("'terrain_freeze_requirement_pct' field error detected");
57695 }
57696 }
57697
57698 if (BV_ISSET(fields, 4)) {
57699 log_packet_detailed(" field 'lake_max_size' has changed");
57700
57701#ifdef FREECIV_JSON_CONNECTION
57702 field_addr.name = "lake_max_size";
57703#endif /* FREECIV_JSON_CONNECTION */
57704 e = 0;
57705
57706 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->lake_max_size);
57707
57708 if (e) {
57709 log_packet_detailed("'lake_max_size' field error detected");
57710 }
57711 }
57712
57713 if (BV_ISSET(fields, 5)) {
57714 log_packet_detailed(" field 'min_start_native_area' has changed");
57715
57716#ifdef FREECIV_JSON_CONNECTION
57717 field_addr.name = "min_start_native_area";
57718#endif /* FREECIV_JSON_CONNECTION */
57719 e = 0;
57720
57721 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->min_start_native_area);
57722
57723 if (e) {
57724 log_packet_detailed("'min_start_native_area' field error detected");
57725 }
57726 }
57727
57728 if (BV_ISSET(fields, 6)) {
57729 log_packet_detailed(" field 'move_fragments' has changed");
57730
57731#ifdef FREECIV_JSON_CONNECTION
57732 field_addr.name = "move_fragments";
57733#endif /* FREECIV_JSON_CONNECTION */
57734 e = 0;
57735
57736 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_fragments);
57737
57738 if (e) {
57739 log_packet_detailed("'move_fragments' field error detected");
57740 }
57741 }
57742
57743 if (BV_ISSET(fields, 7)) {
57744 log_packet_detailed(" field 'igter_cost' has changed");
57745
57746#ifdef FREECIV_JSON_CONNECTION
57747 field_addr.name = "igter_cost";
57748#endif /* FREECIV_JSON_CONNECTION */
57749 e = 0;
57750
57751 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->igter_cost);
57752
57753 if (e) {
57754 log_packet_detailed("'igter_cost' field error detected");
57755 }
57756 }
57757
57758 /* field 8 is folded into the header */
57759
57760 /* field 9 is folded into the header */
57761
57762 if (BV_ISSET(fields, 10)) {
57763 log_packet_detailed(" field 'gui_type_base0' has changed");
57764
57765#ifdef FREECIV_JSON_CONNECTION
57766 field_addr.name = "gui_type_base0";
57767#endif /* FREECIV_JSON_CONNECTION */
57768 e = 0;
57769
57770 e |= DIO_PUT(string, &dout, &field_addr, real_packet->gui_type_base0);
57771
57772 if (e) {
57773 log_packet_detailed("'gui_type_base0' field error detected");
57774 }
57775 }
57776
57777 if (BV_ISSET(fields, 11)) {
57778 log_packet_detailed(" field 'gui_type_base1' has changed");
57779
57780#ifdef FREECIV_JSON_CONNECTION
57781 field_addr.name = "gui_type_base1";
57782#endif /* FREECIV_JSON_CONNECTION */
57783 e = 0;
57784
57785 e |= DIO_PUT(string, &dout, &field_addr, real_packet->gui_type_base1);
57786
57787 if (e) {
57788 log_packet_detailed("'gui_type_base1' field error detected");
57789 }
57790 }
57791
57792 *old = *real_packet;
57793
57794#else /* FREECIV_DELTA_PROTOCOL */
57795#ifdef FREECIV_JSON_CONNECTION
57796 field_addr.name = "ocean_reclaim_requirement_pct";
57797#endif /* FREECIV_JSON_CONNECTION */
57798 e = 0;
57799
57800 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ocean_reclaim_requirement_pct);
57801
57802 if (e) {
57803 log_packet_detailed("'ocean_reclaim_requirement_pct' field error detected");
57804 }
57805
57806#ifdef FREECIV_JSON_CONNECTION
57807 field_addr.name = "land_channel_requirement_pct";
57808#endif /* FREECIV_JSON_CONNECTION */
57809 e = 0;
57810
57811 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->land_channel_requirement_pct);
57812
57813 if (e) {
57814 log_packet_detailed("'land_channel_requirement_pct' field error detected");
57815 }
57816
57817#ifdef FREECIV_JSON_CONNECTION
57818 field_addr.name = "terrain_thaw_requirement_pct";
57819#endif /* FREECIV_JSON_CONNECTION */
57820 e = 0;
57821
57822 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain_thaw_requirement_pct);
57823
57824 if (e) {
57825 log_packet_detailed("'terrain_thaw_requirement_pct' field error detected");
57826 }
57827
57828#ifdef FREECIV_JSON_CONNECTION
57829 field_addr.name = "terrain_freeze_requirement_pct";
57830#endif /* FREECIV_JSON_CONNECTION */
57831 e = 0;
57832
57833 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain_freeze_requirement_pct);
57834
57835 if (e) {
57836 log_packet_detailed("'terrain_freeze_requirement_pct' field error detected");
57837 }
57838
57839#ifdef FREECIV_JSON_CONNECTION
57840 field_addr.name = "lake_max_size";
57841#endif /* FREECIV_JSON_CONNECTION */
57842 e = 0;
57843
57844 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->lake_max_size);
57845
57846 if (e) {
57847 log_packet_detailed("'lake_max_size' field error detected");
57848 }
57849
57850#ifdef FREECIV_JSON_CONNECTION
57851 field_addr.name = "min_start_native_area";
57852#endif /* FREECIV_JSON_CONNECTION */
57853 e = 0;
57854
57855 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->min_start_native_area);
57856
57857 if (e) {
57858 log_packet_detailed("'min_start_native_area' field error detected");
57859 }
57860
57861#ifdef FREECIV_JSON_CONNECTION
57862 field_addr.name = "move_fragments";
57863#endif /* FREECIV_JSON_CONNECTION */
57864 e = 0;
57865
57866 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->move_fragments);
57867
57868 if (e) {
57869 log_packet_detailed("'move_fragments' field error detected");
57870 }
57871
57872#ifdef FREECIV_JSON_CONNECTION
57873 field_addr.name = "igter_cost";
57874#endif /* FREECIV_JSON_CONNECTION */
57875 e = 0;
57876
57877 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->igter_cost);
57878
57879 if (e) {
57880 log_packet_detailed("'igter_cost' field error detected");
57881 }
57882
57883#ifdef FREECIV_JSON_CONNECTION
57884 field_addr.name = "pythagorean_diagonal";
57885#endif /* FREECIV_JSON_CONNECTION */
57886 e = 0;
57887
57888 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->pythagorean_diagonal);
57889
57890 if (e) {
57891 log_packet_detailed("'pythagorean_diagonal' field error detected");
57892 }
57893
57894#ifdef FREECIV_JSON_CONNECTION
57895 field_addr.name = "infrapoints";
57896#endif /* FREECIV_JSON_CONNECTION */
57897 e = 0;
57898
57899 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->infrapoints);
57900
57901 if (e) {
57902 log_packet_detailed("'infrapoints' field error detected");
57903 }
57904
57905#ifdef FREECIV_JSON_CONNECTION
57906 field_addr.name = "gui_type_base0";
57907#endif /* FREECIV_JSON_CONNECTION */
57908 e = 0;
57909
57910 e |= DIO_PUT(string, &dout, &field_addr, real_packet->gui_type_base0);
57911
57912 if (e) {
57913 log_packet_detailed("'gui_type_base0' field error detected");
57914 }
57915
57916#ifdef FREECIV_JSON_CONNECTION
57917 field_addr.name = "gui_type_base1";
57918#endif /* FREECIV_JSON_CONNECTION */
57919 e = 0;
57920
57921 e |= DIO_PUT(string, &dout, &field_addr, real_packet->gui_type_base1);
57922
57923 if (e) {
57924 log_packet_detailed("'gui_type_base1' field error detected");
57925 }
57926#endif /* FREECIV_DELTA_PROTOCOL */
57927
57928 SEND_PACKET_END(PACKET_RULESET_TERRAIN_CONTROL);
57929}
57930
57931 int send_packet_ruleset_terrain_control(struct connection *pc, const struct packet_ruleset_terrain_control *packet)
57932{
57933 if (!pc->used) {
57934 log_error("WARNING: trying to send data to the closed connection %s",
57935 conn_description(pc));
57936 return -1;
57937 }
57938 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TERRAIN_CONTROL].packet != nullptr, -1,
57939 "Handler for PACKET_RULESET_TERRAIN_CONTROL not installed");
57940 return pc->phs.handlers->send[PACKET_RULESET_TERRAIN_CONTROL].packet(pc, packet);
57941}
57942
57943 void lsend_packet_ruleset_terrain_control(struct conn_list *dest, const struct packet_ruleset_terrain_control *packet)
57944{
57945 conn_list_iterate(dest, pconn) {
57946 send_packet_ruleset_terrain_control(pconn, packet);
57947 } conn_list_iterate_end;
57948}
57949
57950 static inline void init_packet_rulesets_ready(struct packet_rulesets_ready *packet)
57951{
57952 memset(packet, 0, sizeof(*packet));
57953}
57954
57955#define free_packet_rulesets_ready(_packet) (void) 0
57956#define destroy_packet_rulesets_ready free
57957
57958 static struct packet_rulesets_ready *receive_packet_rulesets_ready_100(struct connection *pc)
57959{
57960#define FREE_PACKET_STRUCT(_packet) free_packet_rulesets_ready(_packet)
57961 RECEIVE_PACKET_START(packet_rulesets_ready, real_packet);
57962
57963 log_packet_detailed("packet_rulesets_ready_100: got info about ()");
57964
57965 real_packet->__dummy = 0xff;
57966
57967 RECEIVE_PACKET_END(real_packet);
57968#undef FREE_PACKET_STRUCT
57969}
57970
57971 static int send_packet_rulesets_ready_100(struct connection *pc)
57972{
57973 SEND_PACKET_START(PACKET_RULESETS_READY);
57974
57975 log_packet_detailed("packet_rulesets_ready_100: sending info about ()");
57976
57977 SEND_PACKET_END(PACKET_RULESETS_READY);
57978}
57979
57980 int send_packet_rulesets_ready(struct connection *pc)
57981{
57982 if (!pc->used) {
57983 log_error("WARNING: trying to send data to the closed connection %s",
57984 conn_description(pc));
57985 return -1;
57986 }
57987 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESETS_READY].no_packet != nullptr, -1,
57988 "Handler for PACKET_RULESETS_READY not installed");
57989 return pc->phs.handlers->send[PACKET_RULESETS_READY].no_packet(pc);
57990}
57991
57992 void lsend_packet_rulesets_ready(struct conn_list *dest)
57993{
57994 conn_list_iterate(dest, pconn) {
57995 send_packet_rulesets_ready(pconn);
57996 } conn_list_iterate_end;
57997}
57998
57999 static inline void init_packet_ruleset_nation_sets(struct packet_ruleset_nation_sets *packet)
58000{
58001 memset(packet, 0, sizeof(*packet));
58002}
58003
58004#define free_packet_ruleset_nation_sets(_packet) (void) 0
58005#define destroy_packet_ruleset_nation_sets free
58006
58007#ifdef FREECIV_DELTA_PROTOCOL
58008#define hash_packet_ruleset_nation_sets_100 hash_const
58009#define cmp_packet_ruleset_nation_sets_100 cmp_const
58010 BV_DEFINE(packet_ruleset_nation_sets_100_fields, 4);
58011#endif /* FREECIV_DELTA_PROTOCOL */
58012
58013 static struct packet_ruleset_nation_sets *receive_packet_ruleset_nation_sets_100(struct connection *pc)
58014{
58015#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_nation_sets(_packet)
58016 RECEIVE_PACKET_START(packet_ruleset_nation_sets, real_packet);
58017
58018#ifdef FREECIV_JSON_CONNECTION
58019 struct plocation field_addr;
58020 {
58021 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
58022 field_addr = *field_addr_tmp;
58023 FC_FREE(field_addr_tmp);
58024 }
58025#endif /* FREECIV_JSON_CONNECTION */
58026
58027 log_packet_detailed("packet_ruleset_nation_sets_100: got info about ()");
58028
58029#ifdef FREECIV_DELTA_PROTOCOL
58030 packet_ruleset_nation_sets_100_fields fields;
58031 struct packet_ruleset_nation_sets *old;
58032 struct genhash **hash = pc->phs.received + PACKET_RULESET_NATION_SETS;
58033
58034 if (nullptr == *hash) {
58035 *hash = genhash_new_full(hash_packet_ruleset_nation_sets_100, cmp_packet_ruleset_nation_sets_100,
58036 nullptr, nullptr, nullptr, destroy_packet_ruleset_nation_sets);
58037 }
58038
58039 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
58040 *real_packet = *old;
58041 } else {
58042 /* packet is already initialized empty */
58043 log_packet_detailed(" no old info");
58044 }
58045
58046#ifdef FREECIV_JSON_CONNECTION
58047 field_addr.name = "fields";
58048#endif /* FREECIV_JSON_CONNECTION */
58049 DIO_BV_GET(&din, &field_addr, fields);
58050
58051 if (BV_ISSET(fields, 0)) {
58052 log_packet_detailed(" got field 'nsets'");
58053
58054#ifdef FREECIV_JSON_CONNECTION
58055 field_addr.name = "nsets";
58056#endif /* FREECIV_JSON_CONNECTION */
58057
58058 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nsets)) {
58059 RECEIVE_PACKET_FIELD_ERROR(nsets);
58060 }
58061 }
58062
58063 if (BV_ISSET(fields, 1)) {
58064 log_packet_detailed(" got field 'names'");
58065
58066#ifdef FREECIV_JSON_CONNECTION
58067 field_addr.name = "names";
58068#endif /* FREECIV_JSON_CONNECTION */
58069
58070 {
58071 int i;
58072
58073 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
58074 RECEIVE_PACKET_FIELD_ERROR(names, ": array truncated");
58075 }
58076
58077#ifdef FREECIV_JSON_CONNECTION
58078 /* Enter array. */
58079 field_addr.sub_location = plocation_elem_new(0);
58080#endif /* FREECIV_JSON_CONNECTION */
58081
58082 for (i = 0; i < real_packet->nsets; i++) {
58083#ifdef FREECIV_JSON_CONNECTION
58084 /* Next array element */
58085 field_addr.sub_location->number = i;
58086#endif /* FREECIV_JSON_CONNECTION */
58087
58088 if (!DIO_GET(string, &din, &field_addr, real_packet->names[i], sizeof(real_packet->names[i]))) {
58089 RECEIVE_PACKET_FIELD_ERROR(names);
58090 }
58091 }
58092
58093#ifdef FREECIV_JSON_CONNECTION
58094 /* Exit array. */
58095 FC_FREE(field_addr.sub_location);
58096#endif /* FREECIV_JSON_CONNECTION */
58097 }
58098 }
58099
58100 if (BV_ISSET(fields, 2)) {
58101 log_packet_detailed(" got field 'rule_names'");
58102
58103#ifdef FREECIV_JSON_CONNECTION
58104 field_addr.name = "rule_names";
58105#endif /* FREECIV_JSON_CONNECTION */
58106
58107 {
58108 int i;
58109
58110 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
58111 RECEIVE_PACKET_FIELD_ERROR(rule_names, ": array truncated");
58112 }
58113
58114#ifdef FREECIV_JSON_CONNECTION
58115 /* Enter array. */
58116 field_addr.sub_location = plocation_elem_new(0);
58117#endif /* FREECIV_JSON_CONNECTION */
58118
58119 for (i = 0; i < real_packet->nsets; i++) {
58120#ifdef FREECIV_JSON_CONNECTION
58121 /* Next array element */
58122 field_addr.sub_location->number = i;
58123#endif /* FREECIV_JSON_CONNECTION */
58124
58125 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_names[i], sizeof(real_packet->rule_names[i]))) {
58126 RECEIVE_PACKET_FIELD_ERROR(rule_names);
58127 }
58128 }
58129
58130#ifdef FREECIV_JSON_CONNECTION
58131 /* Exit array. */
58132 FC_FREE(field_addr.sub_location);
58133#endif /* FREECIV_JSON_CONNECTION */
58134 }
58135 }
58136
58137 if (BV_ISSET(fields, 3)) {
58138 log_packet_detailed(" got field 'descriptions'");
58139
58140#ifdef FREECIV_JSON_CONNECTION
58141 field_addr.name = "descriptions";
58142#endif /* FREECIV_JSON_CONNECTION */
58143
58144 {
58145 int i;
58146
58147 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
58148 RECEIVE_PACKET_FIELD_ERROR(descriptions, ": array truncated");
58149 }
58150
58151#ifdef FREECIV_JSON_CONNECTION
58152 /* Enter array. */
58153 field_addr.sub_location = plocation_elem_new(0);
58154#endif /* FREECIV_JSON_CONNECTION */
58155
58156 for (i = 0; i < real_packet->nsets; i++) {
58157#ifdef FREECIV_JSON_CONNECTION
58158 /* Next array element */
58159 field_addr.sub_location->number = i;
58160#endif /* FREECIV_JSON_CONNECTION */
58161
58162 if (!DIO_GET(string, &din, &field_addr, real_packet->descriptions[i], sizeof(real_packet->descriptions[i]))) {
58163 RECEIVE_PACKET_FIELD_ERROR(descriptions);
58164 }
58165 }
58166
58167#ifdef FREECIV_JSON_CONNECTION
58168 /* Exit array. */
58169 FC_FREE(field_addr.sub_location);
58170#endif /* FREECIV_JSON_CONNECTION */
58171 }
58172 }
58173
58174 if (nullptr == old) {
58175 old = fc_malloc(sizeof(*old));
58176 init_packet_ruleset_nation_sets(old);
58177 *old = *real_packet;
58178 genhash_insert(*hash, old, old);
58179 } else {
58180 *old = *real_packet;
58181 }
58182
58183#else /* FREECIV_DELTA_PROTOCOL */
58184#ifdef FREECIV_JSON_CONNECTION
58185 field_addr.name = "nsets";
58186#endif /* FREECIV_JSON_CONNECTION */
58187
58188 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nsets)) {
58189 RECEIVE_PACKET_FIELD_ERROR(nsets);
58190 }
58191
58192#ifdef FREECIV_JSON_CONNECTION
58193 field_addr.name = "names";
58194#endif /* FREECIV_JSON_CONNECTION */
58195
58196 {
58197 int i;
58198
58199 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
58200 RECEIVE_PACKET_FIELD_ERROR(names, ": array truncated");
58201 }
58202
58203#ifdef FREECIV_JSON_CONNECTION
58204 /* Enter array. */
58205 field_addr.sub_location = plocation_elem_new(0);
58206#endif /* FREECIV_JSON_CONNECTION */
58207
58208 for (i = 0; i < real_packet->nsets; i++) {
58209#ifdef FREECIV_JSON_CONNECTION
58210 /* Next array element */
58211 field_addr.sub_location->number = i;
58212#endif /* FREECIV_JSON_CONNECTION */
58213
58214 if (!DIO_GET(string, &din, &field_addr, real_packet->names[i], sizeof(real_packet->names[i]))) {
58215 RECEIVE_PACKET_FIELD_ERROR(names);
58216 }
58217 }
58218
58219#ifdef FREECIV_JSON_CONNECTION
58220 /* Exit array. */
58221 FC_FREE(field_addr.sub_location);
58222#endif /* FREECIV_JSON_CONNECTION */
58223 }
58224
58225#ifdef FREECIV_JSON_CONNECTION
58226 field_addr.name = "rule_names";
58227#endif /* FREECIV_JSON_CONNECTION */
58228
58229 {
58230 int i;
58231
58232 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
58233 RECEIVE_PACKET_FIELD_ERROR(rule_names, ": array truncated");
58234 }
58235
58236#ifdef FREECIV_JSON_CONNECTION
58237 /* Enter array. */
58238 field_addr.sub_location = plocation_elem_new(0);
58239#endif /* FREECIV_JSON_CONNECTION */
58240
58241 for (i = 0; i < real_packet->nsets; i++) {
58242#ifdef FREECIV_JSON_CONNECTION
58243 /* Next array element */
58244 field_addr.sub_location->number = i;
58245#endif /* FREECIV_JSON_CONNECTION */
58246
58247 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_names[i], sizeof(real_packet->rule_names[i]))) {
58248 RECEIVE_PACKET_FIELD_ERROR(rule_names);
58249 }
58250 }
58251
58252#ifdef FREECIV_JSON_CONNECTION
58253 /* Exit array. */
58254 FC_FREE(field_addr.sub_location);
58255#endif /* FREECIV_JSON_CONNECTION */
58256 }
58257
58258#ifdef FREECIV_JSON_CONNECTION
58259 field_addr.name = "descriptions";
58260#endif /* FREECIV_JSON_CONNECTION */
58261
58262 {
58263 int i;
58264
58265 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
58266 RECEIVE_PACKET_FIELD_ERROR(descriptions, ": array truncated");
58267 }
58268
58269#ifdef FREECIV_JSON_CONNECTION
58270 /* Enter array. */
58271 field_addr.sub_location = plocation_elem_new(0);
58272#endif /* FREECIV_JSON_CONNECTION */
58273
58274 for (i = 0; i < real_packet->nsets; i++) {
58275#ifdef FREECIV_JSON_CONNECTION
58276 /* Next array element */
58277 field_addr.sub_location->number = i;
58278#endif /* FREECIV_JSON_CONNECTION */
58279
58280 if (!DIO_GET(string, &din, &field_addr, real_packet->descriptions[i], sizeof(real_packet->descriptions[i]))) {
58281 RECEIVE_PACKET_FIELD_ERROR(descriptions);
58282 }
58283 }
58284
58285#ifdef FREECIV_JSON_CONNECTION
58286 /* Exit array. */
58287 FC_FREE(field_addr.sub_location);
58288#endif /* FREECIV_JSON_CONNECTION */
58289 }
58290#endif /* FREECIV_DELTA_PROTOCOL */
58291
58292 RECEIVE_PACKET_END(real_packet);
58293#undef FREE_PACKET_STRUCT
58294}
58295
58296 static int send_packet_ruleset_nation_sets_100(struct connection *pc, const struct packet_ruleset_nation_sets *packet)
58297{
58298 const struct packet_ruleset_nation_sets *real_packet = packet;
58299 int e;
58300 SEND_PACKET_START(PACKET_RULESET_NATION_SETS);
58301
58302 log_packet_detailed("packet_ruleset_nation_sets_100: sending info about ()");
58303
58304#ifdef FREECIV_DELTA_PROTOCOL
58305 packet_ruleset_nation_sets_100_fields fields;
58306 struct packet_ruleset_nation_sets *old;
58307 bool differ;
58308 struct genhash **hash = pc->phs.sent + PACKET_RULESET_NATION_SETS;
58309
58310 if (nullptr == *hash) {
58311 *hash = genhash_new_full(hash_packet_ruleset_nation_sets_100, cmp_packet_ruleset_nation_sets_100,
58312 nullptr, nullptr, nullptr, destroy_packet_ruleset_nation_sets);
58313 }
58314 BV_CLR_ALL(fields);
58315
58316 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
58317 old = fc_malloc(sizeof(*old));
58318 /* temporary bitcopy just to insert correctly */
58319 *old = *real_packet;
58320 genhash_insert(*hash, old, old);
58321 init_packet_ruleset_nation_sets(old);
58322 }
58323
58324 differ = (old->nsets != real_packet->nsets);
58325 if (differ) {
58326 BV_SET(fields, 0);
58327 }
58328
58329 differ = (old->nsets != real_packet->nsets);
58330 if (!differ) {
58331 int i;
58332
58333 for (i = 0; i < old->nsets; i++) {
58334 differ = (strcmp(old->names[i], real_packet->names[i]) != 0);
58335 if (differ) {
58336 break;
58337 }
58338 }
58339 }
58340 if (differ) {
58341 BV_SET(fields, 1);
58342 }
58343
58344 differ = (old->nsets != real_packet->nsets);
58345 if (!differ) {
58346 int i;
58347
58348 for (i = 0; i < old->nsets; i++) {
58349 differ = (strcmp(old->rule_names[i], real_packet->rule_names[i]) != 0);
58350 if (differ) {
58351 break;
58352 }
58353 }
58354 }
58355 if (differ) {
58356 BV_SET(fields, 2);
58357 }
58358
58359 differ = (old->nsets != real_packet->nsets);
58360 if (!differ) {
58361 int i;
58362
58363 for (i = 0; i < old->nsets; i++) {
58364 differ = (strcmp(old->descriptions[i], real_packet->descriptions[i]) != 0);
58365 if (differ) {
58366 break;
58367 }
58368 }
58369 }
58370 if (differ) {
58371 BV_SET(fields, 3);
58372 }
58373#endif /* FREECIV_DELTA_PROTOCOL */
58374
58375#ifdef FREECIV_JSON_CONNECTION
58376 struct plocation field_addr;
58377 {
58378 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
58379 field_addr = *field_addr_tmp;
58380 FC_FREE(field_addr_tmp);
58381 }
58382#endif /* FREECIV_JSON_CONNECTION */
58383
58384#ifdef FREECIV_DELTA_PROTOCOL
58385#ifdef FREECIV_JSON_CONNECTION
58386 field_addr.name = "fields";
58387#endif /* FREECIV_JSON_CONNECTION */
58388 e = 0;
58389 e |= DIO_BV_PUT(&dout, &field_addr, fields);
58390 if (e) {
58391 log_packet_detailed("fields bitvector error detected");
58392 }
58393
58394 if (BV_ISSET(fields, 0)) {
58395 log_packet_detailed(" field 'nsets' has changed");
58396
58397#ifdef FREECIV_JSON_CONNECTION
58398 field_addr.name = "nsets";
58399#endif /* FREECIV_JSON_CONNECTION */
58400 e = 0;
58401
58402 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nsets);
58403
58404 if (e) {
58405 log_packet_detailed("'nsets' field error detected");
58406 }
58407 }
58408
58409 if (BV_ISSET(fields, 1)) {
58410 log_packet_detailed(" field 'names' has changed");
58411
58412#ifdef FREECIV_JSON_CONNECTION
58413 field_addr.name = "names";
58414#endif /* FREECIV_JSON_CONNECTION */
58415 e = 0;
58416
58417 {
58418 int i;
58419
58420#ifdef FREECIV_JSON_CONNECTION
58421 /* Create the array. */
58422 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
58423
58424 /* Enter array. */
58425 field_addr.sub_location = plocation_elem_new(0);
58426#endif /* FREECIV_JSON_CONNECTION */
58427
58428 for (i = 0; i < real_packet->nsets; i++) {
58429#ifdef FREECIV_JSON_CONNECTION
58430 /* Next array element. */
58431 field_addr.sub_location->number = i;
58432#endif /* FREECIV_JSON_CONNECTION */
58433
58434 e |= DIO_PUT(string, &dout, &field_addr, real_packet->names[i]);
58435 }
58436
58437#ifdef FREECIV_JSON_CONNECTION
58438 /* Exit array. */
58439 FC_FREE(field_addr.sub_location);
58440#endif /* FREECIV_JSON_CONNECTION */
58441 }
58442
58443 if (e) {
58444 log_packet_detailed("'names' field error detected");
58445 }
58446 }
58447
58448 if (BV_ISSET(fields, 2)) {
58449 log_packet_detailed(" field 'rule_names' has changed");
58450
58451#ifdef FREECIV_JSON_CONNECTION
58452 field_addr.name = "rule_names";
58453#endif /* FREECIV_JSON_CONNECTION */
58454 e = 0;
58455
58456 {
58457 int i;
58458
58459#ifdef FREECIV_JSON_CONNECTION
58460 /* Create the array. */
58461 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
58462
58463 /* Enter array. */
58464 field_addr.sub_location = plocation_elem_new(0);
58465#endif /* FREECIV_JSON_CONNECTION */
58466
58467 for (i = 0; i < real_packet->nsets; i++) {
58468#ifdef FREECIV_JSON_CONNECTION
58469 /* Next array element. */
58470 field_addr.sub_location->number = i;
58471#endif /* FREECIV_JSON_CONNECTION */
58472
58473 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_names[i]);
58474 }
58475
58476#ifdef FREECIV_JSON_CONNECTION
58477 /* Exit array. */
58478 FC_FREE(field_addr.sub_location);
58479#endif /* FREECIV_JSON_CONNECTION */
58480 }
58481
58482 if (e) {
58483 log_packet_detailed("'rule_names' field error detected");
58484 }
58485 }
58486
58487 if (BV_ISSET(fields, 3)) {
58488 log_packet_detailed(" field 'descriptions' has changed");
58489
58490#ifdef FREECIV_JSON_CONNECTION
58491 field_addr.name = "descriptions";
58492#endif /* FREECIV_JSON_CONNECTION */
58493 e = 0;
58494
58495 {
58496 int i;
58497
58498#ifdef FREECIV_JSON_CONNECTION
58499 /* Create the array. */
58500 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
58501
58502 /* Enter array. */
58503 field_addr.sub_location = plocation_elem_new(0);
58504#endif /* FREECIV_JSON_CONNECTION */
58505
58506 for (i = 0; i < real_packet->nsets; i++) {
58507#ifdef FREECIV_JSON_CONNECTION
58508 /* Next array element. */
58509 field_addr.sub_location->number = i;
58510#endif /* FREECIV_JSON_CONNECTION */
58511
58512 e |= DIO_PUT(string, &dout, &field_addr, real_packet->descriptions[i]);
58513 }
58514
58515#ifdef FREECIV_JSON_CONNECTION
58516 /* Exit array. */
58517 FC_FREE(field_addr.sub_location);
58518#endif /* FREECIV_JSON_CONNECTION */
58519 }
58520
58521 if (e) {
58522 log_packet_detailed("'descriptions' field error detected");
58523 }
58524 }
58525
58526 *old = *real_packet;
58527
58528#else /* FREECIV_DELTA_PROTOCOL */
58529#ifdef FREECIV_JSON_CONNECTION
58530 field_addr.name = "nsets";
58531#endif /* FREECIV_JSON_CONNECTION */
58532 e = 0;
58533
58534 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nsets);
58535
58536 if (e) {
58537 log_packet_detailed("'nsets' field error detected");
58538 }
58539
58540#ifdef FREECIV_JSON_CONNECTION
58541 field_addr.name = "names";
58542#endif /* FREECIV_JSON_CONNECTION */
58543 e = 0;
58544
58545 {
58546 int i;
58547
58548#ifdef FREECIV_JSON_CONNECTION
58549 /* Create the array. */
58550 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
58551
58552 /* Enter array. */
58553 field_addr.sub_location = plocation_elem_new(0);
58554#endif /* FREECIV_JSON_CONNECTION */
58555
58556 for (i = 0; i < real_packet->nsets; i++) {
58557#ifdef FREECIV_JSON_CONNECTION
58558 /* Next array element. */
58559 field_addr.sub_location->number = i;
58560#endif /* FREECIV_JSON_CONNECTION */
58561
58562 e |= DIO_PUT(string, &dout, &field_addr, real_packet->names[i]);
58563 }
58564
58565#ifdef FREECIV_JSON_CONNECTION
58566 /* Exit array. */
58567 FC_FREE(field_addr.sub_location);
58568#endif /* FREECIV_JSON_CONNECTION */
58569 }
58570
58571 if (e) {
58572 log_packet_detailed("'names' field error detected");
58573 }
58574
58575#ifdef FREECIV_JSON_CONNECTION
58576 field_addr.name = "rule_names";
58577#endif /* FREECIV_JSON_CONNECTION */
58578 e = 0;
58579
58580 {
58581 int i;
58582
58583#ifdef FREECIV_JSON_CONNECTION
58584 /* Create the array. */
58585 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
58586
58587 /* Enter array. */
58588 field_addr.sub_location = plocation_elem_new(0);
58589#endif /* FREECIV_JSON_CONNECTION */
58590
58591 for (i = 0; i < real_packet->nsets; i++) {
58592#ifdef FREECIV_JSON_CONNECTION
58593 /* Next array element. */
58594 field_addr.sub_location->number = i;
58595#endif /* FREECIV_JSON_CONNECTION */
58596
58597 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_names[i]);
58598 }
58599
58600#ifdef FREECIV_JSON_CONNECTION
58601 /* Exit array. */
58602 FC_FREE(field_addr.sub_location);
58603#endif /* FREECIV_JSON_CONNECTION */
58604 }
58605
58606 if (e) {
58607 log_packet_detailed("'rule_names' field error detected");
58608 }
58609
58610#ifdef FREECIV_JSON_CONNECTION
58611 field_addr.name = "descriptions";
58612#endif /* FREECIV_JSON_CONNECTION */
58613 e = 0;
58614
58615 {
58616 int i;
58617
58618#ifdef FREECIV_JSON_CONNECTION
58619 /* Create the array. */
58620 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
58621
58622 /* Enter array. */
58623 field_addr.sub_location = plocation_elem_new(0);
58624#endif /* FREECIV_JSON_CONNECTION */
58625
58626 for (i = 0; i < real_packet->nsets; i++) {
58627#ifdef FREECIV_JSON_CONNECTION
58628 /* Next array element. */
58629 field_addr.sub_location->number = i;
58630#endif /* FREECIV_JSON_CONNECTION */
58631
58632 e |= DIO_PUT(string, &dout, &field_addr, real_packet->descriptions[i]);
58633 }
58634
58635#ifdef FREECIV_JSON_CONNECTION
58636 /* Exit array. */
58637 FC_FREE(field_addr.sub_location);
58638#endif /* FREECIV_JSON_CONNECTION */
58639 }
58640
58641 if (e) {
58642 log_packet_detailed("'descriptions' field error detected");
58643 }
58644#endif /* FREECIV_DELTA_PROTOCOL */
58645
58646 SEND_PACKET_END(PACKET_RULESET_NATION_SETS);
58647}
58648
58649 int send_packet_ruleset_nation_sets(struct connection *pc, const struct packet_ruleset_nation_sets *packet)
58650{
58651 if (!pc->used) {
58652 log_error("WARNING: trying to send data to the closed connection %s",
58653 conn_description(pc));
58654 return -1;
58655 }
58656 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_NATION_SETS].packet != nullptr, -1,
58657 "Handler for PACKET_RULESET_NATION_SETS not installed");
58658 return pc->phs.handlers->send[PACKET_RULESET_NATION_SETS].packet(pc, packet);
58659}
58660
58661 void lsend_packet_ruleset_nation_sets(struct conn_list *dest, const struct packet_ruleset_nation_sets *packet)
58662{
58663 conn_list_iterate(dest, pconn) {
58664 send_packet_ruleset_nation_sets(pconn, packet);
58665 } conn_list_iterate_end;
58666}
58667
58668 static inline void init_packet_ruleset_nation_groups(struct packet_ruleset_nation_groups *packet)
58669{
58670 memset(packet, 0, sizeof(*packet));
58671}
58672
58673#define free_packet_ruleset_nation_groups(_packet) (void) 0
58674#define destroy_packet_ruleset_nation_groups free
58675
58676#ifdef FREECIV_DELTA_PROTOCOL
58677#define hash_packet_ruleset_nation_groups_100 hash_const
58678#define cmp_packet_ruleset_nation_groups_100 cmp_const
58679 BV_DEFINE(packet_ruleset_nation_groups_100_fields, 3);
58680#endif /* FREECIV_DELTA_PROTOCOL */
58681
58682 static struct packet_ruleset_nation_groups *receive_packet_ruleset_nation_groups_100(struct connection *pc)
58683{
58684#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_nation_groups(_packet)
58685 RECEIVE_PACKET_START(packet_ruleset_nation_groups, real_packet);
58686
58687#ifdef FREECIV_JSON_CONNECTION
58688 struct plocation field_addr;
58689 {
58690 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
58691 field_addr = *field_addr_tmp;
58692 FC_FREE(field_addr_tmp);
58693 }
58694#endif /* FREECIV_JSON_CONNECTION */
58695
58696 log_packet_detailed("packet_ruleset_nation_groups_100: got info about ()");
58697
58698#ifdef FREECIV_DELTA_PROTOCOL
58699 packet_ruleset_nation_groups_100_fields fields;
58700 struct packet_ruleset_nation_groups *old;
58701 struct genhash **hash = pc->phs.received + PACKET_RULESET_NATION_GROUPS;
58702
58703 if (nullptr == *hash) {
58704 *hash = genhash_new_full(hash_packet_ruleset_nation_groups_100, cmp_packet_ruleset_nation_groups_100,
58705 nullptr, nullptr, nullptr, destroy_packet_ruleset_nation_groups);
58706 }
58707
58708 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
58709 *real_packet = *old;
58710 } else {
58711 /* packet is already initialized empty */
58712 log_packet_detailed(" no old info");
58713 }
58714
58715#ifdef FREECIV_JSON_CONNECTION
58716 field_addr.name = "fields";
58717#endif /* FREECIV_JSON_CONNECTION */
58718 DIO_BV_GET(&din, &field_addr, fields);
58719
58720 if (BV_ISSET(fields, 0)) {
58721 log_packet_detailed(" got field 'ngroups'");
58722
58723#ifdef FREECIV_JSON_CONNECTION
58724 field_addr.name = "ngroups";
58725#endif /* FREECIV_JSON_CONNECTION */
58726
58727 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ngroups)) {
58728 RECEIVE_PACKET_FIELD_ERROR(ngroups);
58729 }
58730 }
58731
58732 if (BV_ISSET(fields, 1)) {
58733 log_packet_detailed(" got field 'groups'");
58734
58735#ifdef FREECIV_JSON_CONNECTION
58736 field_addr.name = "groups";
58737#endif /* FREECIV_JSON_CONNECTION */
58738
58739 {
58740 int i;
58741
58742 if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
58743 RECEIVE_PACKET_FIELD_ERROR(groups, ": array truncated");
58744 }
58745
58746#ifdef FREECIV_JSON_CONNECTION
58747 /* Enter array. */
58748 field_addr.sub_location = plocation_elem_new(0);
58749#endif /* FREECIV_JSON_CONNECTION */
58750
58751 for (i = 0; i < real_packet->ngroups; i++) {
58752#ifdef FREECIV_JSON_CONNECTION
58753 /* Next array element */
58754 field_addr.sub_location->number = i;
58755#endif /* FREECIV_JSON_CONNECTION */
58756
58757 if (!DIO_GET(string, &din, &field_addr, real_packet->groups[i], sizeof(real_packet->groups[i]))) {
58758 RECEIVE_PACKET_FIELD_ERROR(groups);
58759 }
58760 }
58761
58762#ifdef FREECIV_JSON_CONNECTION
58763 /* Exit array. */
58764 FC_FREE(field_addr.sub_location);
58765#endif /* FREECIV_JSON_CONNECTION */
58766 }
58767 }
58768
58769 if (BV_ISSET(fields, 2)) {
58770 log_packet_detailed(" got field 'hidden'");
58771
58772#ifdef FREECIV_JSON_CONNECTION
58773 field_addr.name = "hidden";
58774#endif /* FREECIV_JSON_CONNECTION */
58775
58776 {
58777 int i;
58778
58779 if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
58780 RECEIVE_PACKET_FIELD_ERROR(hidden, ": array truncated");
58781 }
58782
58783#ifdef FREECIV_JSON_CONNECTION
58784 /* Enter array. */
58785 field_addr.sub_location = plocation_elem_new(0);
58786#endif /* FREECIV_JSON_CONNECTION */
58787
58788 for (i = 0; i < real_packet->ngroups; i++) {
58789#ifdef FREECIV_JSON_CONNECTION
58790 /* Next array element */
58791 field_addr.sub_location->number = i;
58792#endif /* FREECIV_JSON_CONNECTION */
58793
58794 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->hidden[i])) {
58795 RECEIVE_PACKET_FIELD_ERROR(hidden);
58796 }
58797 }
58798
58799#ifdef FREECIV_JSON_CONNECTION
58800 /* Exit array. */
58801 FC_FREE(field_addr.sub_location);
58802#endif /* FREECIV_JSON_CONNECTION */
58803 }
58804 }
58805
58806 if (nullptr == old) {
58807 old = fc_malloc(sizeof(*old));
58808 init_packet_ruleset_nation_groups(old);
58809 *old = *real_packet;
58810 genhash_insert(*hash, old, old);
58811 } else {
58812 *old = *real_packet;
58813 }
58814
58815#else /* FREECIV_DELTA_PROTOCOL */
58816#ifdef FREECIV_JSON_CONNECTION
58817 field_addr.name = "ngroups";
58818#endif /* FREECIV_JSON_CONNECTION */
58819
58820 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ngroups)) {
58821 RECEIVE_PACKET_FIELD_ERROR(ngroups);
58822 }
58823
58824#ifdef FREECIV_JSON_CONNECTION
58825 field_addr.name = "groups";
58826#endif /* FREECIV_JSON_CONNECTION */
58827
58828 {
58829 int i;
58830
58831 if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
58832 RECEIVE_PACKET_FIELD_ERROR(groups, ": array truncated");
58833 }
58834
58835#ifdef FREECIV_JSON_CONNECTION
58836 /* Enter array. */
58837 field_addr.sub_location = plocation_elem_new(0);
58838#endif /* FREECIV_JSON_CONNECTION */
58839
58840 for (i = 0; i < real_packet->ngroups; i++) {
58841#ifdef FREECIV_JSON_CONNECTION
58842 /* Next array element */
58843 field_addr.sub_location->number = i;
58844#endif /* FREECIV_JSON_CONNECTION */
58845
58846 if (!DIO_GET(string, &din, &field_addr, real_packet->groups[i], sizeof(real_packet->groups[i]))) {
58847 RECEIVE_PACKET_FIELD_ERROR(groups);
58848 }
58849 }
58850
58851#ifdef FREECIV_JSON_CONNECTION
58852 /* Exit array. */
58853 FC_FREE(field_addr.sub_location);
58854#endif /* FREECIV_JSON_CONNECTION */
58855 }
58856
58857#ifdef FREECIV_JSON_CONNECTION
58858 field_addr.name = "hidden";
58859#endif /* FREECIV_JSON_CONNECTION */
58860
58861 {
58862 int i;
58863
58864 if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
58865 RECEIVE_PACKET_FIELD_ERROR(hidden, ": array truncated");
58866 }
58867
58868#ifdef FREECIV_JSON_CONNECTION
58869 /* Enter array. */
58870 field_addr.sub_location = plocation_elem_new(0);
58871#endif /* FREECIV_JSON_CONNECTION */
58872
58873 for (i = 0; i < real_packet->ngroups; i++) {
58874#ifdef FREECIV_JSON_CONNECTION
58875 /* Next array element */
58876 field_addr.sub_location->number = i;
58877#endif /* FREECIV_JSON_CONNECTION */
58878
58879 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->hidden[i])) {
58880 RECEIVE_PACKET_FIELD_ERROR(hidden);
58881 }
58882 }
58883
58884#ifdef FREECIV_JSON_CONNECTION
58885 /* Exit array. */
58886 FC_FREE(field_addr.sub_location);
58887#endif /* FREECIV_JSON_CONNECTION */
58888 }
58889#endif /* FREECIV_DELTA_PROTOCOL */
58890
58891 RECEIVE_PACKET_END(real_packet);
58892#undef FREE_PACKET_STRUCT
58893}
58894
58895 static int send_packet_ruleset_nation_groups_100(struct connection *pc, const struct packet_ruleset_nation_groups *packet)
58896{
58897 const struct packet_ruleset_nation_groups *real_packet = packet;
58898 int e;
58899 SEND_PACKET_START(PACKET_RULESET_NATION_GROUPS);
58900
58901 log_packet_detailed("packet_ruleset_nation_groups_100: sending info about ()");
58902
58903#ifdef FREECIV_DELTA_PROTOCOL
58904 packet_ruleset_nation_groups_100_fields fields;
58905 struct packet_ruleset_nation_groups *old;
58906 bool differ;
58907 struct genhash **hash = pc->phs.sent + PACKET_RULESET_NATION_GROUPS;
58908
58909 if (nullptr == *hash) {
58910 *hash = genhash_new_full(hash_packet_ruleset_nation_groups_100, cmp_packet_ruleset_nation_groups_100,
58911 nullptr, nullptr, nullptr, destroy_packet_ruleset_nation_groups);
58912 }
58913 BV_CLR_ALL(fields);
58914
58915 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
58916 old = fc_malloc(sizeof(*old));
58917 /* temporary bitcopy just to insert correctly */
58918 *old = *real_packet;
58919 genhash_insert(*hash, old, old);
58920 init_packet_ruleset_nation_groups(old);
58921 }
58922
58923 differ = (old->ngroups != real_packet->ngroups);
58924 if (differ) {
58925 BV_SET(fields, 0);
58926 }
58927
58928 differ = (old->ngroups != real_packet->ngroups);
58929 if (!differ) {
58930 int i;
58931
58932 for (i = 0; i < old->ngroups; i++) {
58933 differ = (strcmp(old->groups[i], real_packet->groups[i]) != 0);
58934 if (differ) {
58935 break;
58936 }
58937 }
58938 }
58939 if (differ) {
58940 BV_SET(fields, 1);
58941 }
58942
58943 differ = (old->ngroups != real_packet->ngroups);
58944 if (!differ) {
58945 int i;
58946
58947 for (i = 0; i < old->ngroups; i++) {
58948 differ = (old->hidden[i] != real_packet->hidden[i]);
58949 if (differ) {
58950 break;
58951 }
58952 }
58953 }
58954 if (differ) {
58955 BV_SET(fields, 2);
58956 }
58957#endif /* FREECIV_DELTA_PROTOCOL */
58958
58959#ifdef FREECIV_JSON_CONNECTION
58960 struct plocation field_addr;
58961 {
58962 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
58963 field_addr = *field_addr_tmp;
58964 FC_FREE(field_addr_tmp);
58965 }
58966#endif /* FREECIV_JSON_CONNECTION */
58967
58968#ifdef FREECIV_DELTA_PROTOCOL
58969#ifdef FREECIV_JSON_CONNECTION
58970 field_addr.name = "fields";
58971#endif /* FREECIV_JSON_CONNECTION */
58972 e = 0;
58973 e |= DIO_BV_PUT(&dout, &field_addr, fields);
58974 if (e) {
58975 log_packet_detailed("fields bitvector error detected");
58976 }
58977
58978 if (BV_ISSET(fields, 0)) {
58979 log_packet_detailed(" field 'ngroups' has changed");
58980
58981#ifdef FREECIV_JSON_CONNECTION
58982 field_addr.name = "ngroups";
58983#endif /* FREECIV_JSON_CONNECTION */
58984 e = 0;
58985
58986 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ngroups);
58987
58988 if (e) {
58989 log_packet_detailed("'ngroups' field error detected");
58990 }
58991 }
58992
58993 if (BV_ISSET(fields, 1)) {
58994 log_packet_detailed(" field 'groups' has changed");
58995
58996#ifdef FREECIV_JSON_CONNECTION
58997 field_addr.name = "groups";
58998#endif /* FREECIV_JSON_CONNECTION */
58999 e = 0;
59000
59001 {
59002 int i;
59003
59004#ifdef FREECIV_JSON_CONNECTION
59005 /* Create the array. */
59006 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ngroups);
59007
59008 /* Enter array. */
59009 field_addr.sub_location = plocation_elem_new(0);
59010#endif /* FREECIV_JSON_CONNECTION */
59011
59012 for (i = 0; i < real_packet->ngroups; i++) {
59013#ifdef FREECIV_JSON_CONNECTION
59014 /* Next array element. */
59015 field_addr.sub_location->number = i;
59016#endif /* FREECIV_JSON_CONNECTION */
59017
59018 e |= DIO_PUT(string, &dout, &field_addr, real_packet->groups[i]);
59019 }
59020
59021#ifdef FREECIV_JSON_CONNECTION
59022 /* Exit array. */
59023 FC_FREE(field_addr.sub_location);
59024#endif /* FREECIV_JSON_CONNECTION */
59025 }
59026
59027 if (e) {
59028 log_packet_detailed("'groups' field error detected");
59029 }
59030 }
59031
59032 if (BV_ISSET(fields, 2)) {
59033 log_packet_detailed(" field 'hidden' has changed");
59034
59035#ifdef FREECIV_JSON_CONNECTION
59036 field_addr.name = "hidden";
59037#endif /* FREECIV_JSON_CONNECTION */
59038 e = 0;
59039
59040 {
59041 int i;
59042
59043#ifdef FREECIV_JSON_CONNECTION
59044 /* Create the array. */
59045 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ngroups);
59046
59047 /* Enter array. */
59048 field_addr.sub_location = plocation_elem_new(0);
59049#endif /* FREECIV_JSON_CONNECTION */
59050
59051 for (i = 0; i < real_packet->ngroups; i++) {
59052#ifdef FREECIV_JSON_CONNECTION
59053 /* Next array element. */
59054 field_addr.sub_location->number = i;
59055#endif /* FREECIV_JSON_CONNECTION */
59056
59057 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->hidden[i]);
59058 }
59059
59060#ifdef FREECIV_JSON_CONNECTION
59061 /* Exit array. */
59062 FC_FREE(field_addr.sub_location);
59063#endif /* FREECIV_JSON_CONNECTION */
59064 }
59065
59066 if (e) {
59067 log_packet_detailed("'hidden' field error detected");
59068 }
59069 }
59070
59071 *old = *real_packet;
59072
59073#else /* FREECIV_DELTA_PROTOCOL */
59074#ifdef FREECIV_JSON_CONNECTION
59075 field_addr.name = "ngroups";
59076#endif /* FREECIV_JSON_CONNECTION */
59077 e = 0;
59078
59079 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ngroups);
59080
59081 if (e) {
59082 log_packet_detailed("'ngroups' field error detected");
59083 }
59084
59085#ifdef FREECIV_JSON_CONNECTION
59086 field_addr.name = "groups";
59087#endif /* FREECIV_JSON_CONNECTION */
59088 e = 0;
59089
59090 {
59091 int i;
59092
59093#ifdef FREECIV_JSON_CONNECTION
59094 /* Create the array. */
59095 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ngroups);
59096
59097 /* Enter array. */
59098 field_addr.sub_location = plocation_elem_new(0);
59099#endif /* FREECIV_JSON_CONNECTION */
59100
59101 for (i = 0; i < real_packet->ngroups; i++) {
59102#ifdef FREECIV_JSON_CONNECTION
59103 /* Next array element. */
59104 field_addr.sub_location->number = i;
59105#endif /* FREECIV_JSON_CONNECTION */
59106
59107 e |= DIO_PUT(string, &dout, &field_addr, real_packet->groups[i]);
59108 }
59109
59110#ifdef FREECIV_JSON_CONNECTION
59111 /* Exit array. */
59112 FC_FREE(field_addr.sub_location);
59113#endif /* FREECIV_JSON_CONNECTION */
59114 }
59115
59116 if (e) {
59117 log_packet_detailed("'groups' field error detected");
59118 }
59119
59120#ifdef FREECIV_JSON_CONNECTION
59121 field_addr.name = "hidden";
59122#endif /* FREECIV_JSON_CONNECTION */
59123 e = 0;
59124
59125 {
59126 int i;
59127
59128#ifdef FREECIV_JSON_CONNECTION
59129 /* Create the array. */
59130 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ngroups);
59131
59132 /* Enter array. */
59133 field_addr.sub_location = plocation_elem_new(0);
59134#endif /* FREECIV_JSON_CONNECTION */
59135
59136 for (i = 0; i < real_packet->ngroups; i++) {
59137#ifdef FREECIV_JSON_CONNECTION
59138 /* Next array element. */
59139 field_addr.sub_location->number = i;
59140#endif /* FREECIV_JSON_CONNECTION */
59141
59142 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->hidden[i]);
59143 }
59144
59145#ifdef FREECIV_JSON_CONNECTION
59146 /* Exit array. */
59147 FC_FREE(field_addr.sub_location);
59148#endif /* FREECIV_JSON_CONNECTION */
59149 }
59150
59151 if (e) {
59152 log_packet_detailed("'hidden' field error detected");
59153 }
59154#endif /* FREECIV_DELTA_PROTOCOL */
59155
59156 SEND_PACKET_END(PACKET_RULESET_NATION_GROUPS);
59157}
59158
59159 int send_packet_ruleset_nation_groups(struct connection *pc, const struct packet_ruleset_nation_groups *packet)
59160{
59161 if (!pc->used) {
59162 log_error("WARNING: trying to send data to the closed connection %s",
59163 conn_description(pc));
59164 return -1;
59165 }
59166 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_NATION_GROUPS].packet != nullptr, -1,
59167 "Handler for PACKET_RULESET_NATION_GROUPS not installed");
59168 return pc->phs.handlers->send[PACKET_RULESET_NATION_GROUPS].packet(pc, packet);
59169}
59170
59171 void lsend_packet_ruleset_nation_groups(struct conn_list *dest, const struct packet_ruleset_nation_groups *packet)
59172{
59173 conn_list_iterate(dest, pconn) {
59174 send_packet_ruleset_nation_groups(pconn, packet);
59175 } conn_list_iterate_end;
59176}
59177
59178 static inline void init_packet_ruleset_nation(struct packet_ruleset_nation *packet)
59179{
59180 memset(packet, 0, sizeof(*packet));
59181}
59182
59183#define free_packet_ruleset_nation(_packet) (void) 0
59184#define destroy_packet_ruleset_nation free
59185
59186#ifdef FREECIV_DELTA_PROTOCOL
59187static genhash_val_t hash_packet_ruleset_nation_100(const void *vkey)
59188{
59189 const struct packet_ruleset_nation *key = (const struct packet_ruleset_nation *) vkey;
59190 genhash_val_t result = 0;
59191
59192 result += key->id;
59193
59194 result &= 0xFFFFFFFF;
59195 return result;
59196}
59197
59198static bool cmp_packet_ruleset_nation_100(const void *vkey1, const void *vkey2)
59199{
59200 const struct packet_ruleset_nation *old = (const struct packet_ruleset_nation *) vkey1;
59201 const struct packet_ruleset_nation *real_packet = (const struct packet_ruleset_nation *) vkey2;
59202 bool differ;
59203
59204 differ = (old->id != real_packet->id);
59205
59206 return !differ;
59207}
59208 BV_DEFINE(packet_ruleset_nation_100_fields, 24);
59209#endif /* FREECIV_DELTA_PROTOCOL */
59210
59211 static struct packet_ruleset_nation *receive_packet_ruleset_nation_100(struct connection *pc)
59212{
59213#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_nation(_packet)
59214 RECEIVE_PACKET_START(packet_ruleset_nation, real_packet);
59215
59216#ifdef FREECIV_JSON_CONNECTION
59217 struct plocation field_addr;
59218 {
59219 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
59220 field_addr = *field_addr_tmp;
59221 FC_FREE(field_addr_tmp);
59222 }
59223#endif /* FREECIV_JSON_CONNECTION */
59224
59225#ifdef FREECIV_JSON_CONNECTION
59226 field_addr.name = "id";
59227#endif /* FREECIV_JSON_CONNECTION */
59228
59229 {
59230 int readin;
59231
59232 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
59233 RECEIVE_PACKET_FIELD_ERROR(id);
59234 }
59235 real_packet->id = readin;
59236 }
59237
59238 log_packet_detailed("packet_ruleset_nation_100: got info about (%d)",
59239 real_packet->id);
59240
59241#ifdef FREECIV_DELTA_PROTOCOL
59242 packet_ruleset_nation_100_fields fields;
59243 struct packet_ruleset_nation *old;
59244 struct genhash **hash = pc->phs.received + PACKET_RULESET_NATION;
59245
59246 if (nullptr == *hash) {
59247 *hash = genhash_new_full(hash_packet_ruleset_nation_100, cmp_packet_ruleset_nation_100,
59248 nullptr, nullptr, nullptr, destroy_packet_ruleset_nation);
59249 }
59250
59251 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
59252 *real_packet = *old;
59253 } else {
59254 /* packet is already initialized empty */
59255 log_packet_detailed(" no old info");
59256 }
59257
59258#ifdef FREECIV_JSON_CONNECTION
59259 field_addr.name = "fields";
59260#endif /* FREECIV_JSON_CONNECTION */
59261 DIO_BV_GET(&din, &field_addr, fields);
59262
59263 if (BV_ISSET(fields, 0)) {
59264 log_packet_detailed(" got field 'translation_domain'");
59265
59266#ifdef FREECIV_JSON_CONNECTION
59267 field_addr.name = "translation_domain";
59268#endif /* FREECIV_JSON_CONNECTION */
59269
59270 if (!DIO_GET(string, &din, &field_addr, real_packet->translation_domain, sizeof(real_packet->translation_domain))) {
59271 RECEIVE_PACKET_FIELD_ERROR(translation_domain);
59272 }
59273 }
59274
59275 if (BV_ISSET(fields, 1)) {
59276 log_packet_detailed(" got field 'adjective'");
59277
59278#ifdef FREECIV_JSON_CONNECTION
59279 field_addr.name = "adjective";
59280#endif /* FREECIV_JSON_CONNECTION */
59281
59282 if (!DIO_GET(string, &din, &field_addr, real_packet->adjective, sizeof(real_packet->adjective))) {
59283 RECEIVE_PACKET_FIELD_ERROR(adjective);
59284 }
59285 }
59286
59287 if (BV_ISSET(fields, 2)) {
59288 log_packet_detailed(" got field 'rule_name'");
59289
59290#ifdef FREECIV_JSON_CONNECTION
59291 field_addr.name = "rule_name";
59292#endif /* FREECIV_JSON_CONNECTION */
59293
59294 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
59295 RECEIVE_PACKET_FIELD_ERROR(rule_name);
59296 }
59297 }
59298
59299 if (BV_ISSET(fields, 3)) {
59300 log_packet_detailed(" got field 'noun_plural'");
59301
59302#ifdef FREECIV_JSON_CONNECTION
59303 field_addr.name = "noun_plural";
59304#endif /* FREECIV_JSON_CONNECTION */
59305
59306 if (!DIO_GET(string, &din, &field_addr, real_packet->noun_plural, sizeof(real_packet->noun_plural))) {
59307 RECEIVE_PACKET_FIELD_ERROR(noun_plural);
59308 }
59309 }
59310
59311 if (BV_ISSET(fields, 4)) {
59312 log_packet_detailed(" got field 'graphic_str'");
59313
59314#ifdef FREECIV_JSON_CONNECTION
59315 field_addr.name = "graphic_str";
59316#endif /* FREECIV_JSON_CONNECTION */
59317
59318 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
59319 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
59320 }
59321 }
59322
59323 if (BV_ISSET(fields, 5)) {
59324 log_packet_detailed(" got field 'graphic_alt'");
59325
59326#ifdef FREECIV_JSON_CONNECTION
59327 field_addr.name = "graphic_alt";
59328#endif /* FREECIV_JSON_CONNECTION */
59329
59330 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
59331 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
59332 }
59333 }
59334
59335 if (BV_ISSET(fields, 6)) {
59336 log_packet_detailed(" got field 'legend'");
59337
59338#ifdef FREECIV_JSON_CONNECTION
59339 field_addr.name = "legend";
59340#endif /* FREECIV_JSON_CONNECTION */
59341
59342 if (!DIO_GET(string, &din, &field_addr, real_packet->legend, sizeof(real_packet->legend))) {
59343 RECEIVE_PACKET_FIELD_ERROR(legend);
59344 }
59345 }
59346
59347 if (BV_ISSET(fields, 7)) {
59348 log_packet_detailed(" got field 'style'");
59349
59350#ifdef FREECIV_JSON_CONNECTION
59351 field_addr.name = "style";
59352#endif /* FREECIV_JSON_CONNECTION */
59353
59354 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
59355 RECEIVE_PACKET_FIELD_ERROR(style);
59356 }
59357 }
59358
59359 if (BV_ISSET(fields, 8)) {
59360 log_packet_detailed(" got field 'leader_count'");
59361
59362#ifdef FREECIV_JSON_CONNECTION
59363 field_addr.name = "leader_count";
59364#endif /* FREECIV_JSON_CONNECTION */
59365
59366 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->leader_count)) {
59367 RECEIVE_PACKET_FIELD_ERROR(leader_count);
59368 }
59369 }
59370
59371 if (BV_ISSET(fields, 9)) {
59372 log_packet_detailed(" got field 'leader_name'");
59373
59374#ifdef FREECIV_JSON_CONNECTION
59375 field_addr.name = "leader_name";
59376#endif /* FREECIV_JSON_CONNECTION */
59377
59378 {
59379 int i;
59380
59381 if (real_packet->leader_count > MAX_NUM_LEADERS) {
59382 RECEIVE_PACKET_FIELD_ERROR(leader_name, ": array truncated");
59383 }
59384
59385#ifdef FREECIV_JSON_CONNECTION
59386 /* Enter array. */
59387 field_addr.sub_location = plocation_elem_new(0);
59388#endif /* FREECIV_JSON_CONNECTION */
59389
59390 for (i = 0; i < real_packet->leader_count; i++) {
59391#ifdef FREECIV_JSON_CONNECTION
59392 /* Next array element */
59393 field_addr.sub_location->number = i;
59394#endif /* FREECIV_JSON_CONNECTION */
59395
59396 if (!DIO_GET(string, &din, &field_addr, real_packet->leader_name[i], sizeof(real_packet->leader_name[i]))) {
59397 RECEIVE_PACKET_FIELD_ERROR(leader_name);
59398 }
59399 }
59400
59401#ifdef FREECIV_JSON_CONNECTION
59402 /* Exit array. */
59403 FC_FREE(field_addr.sub_location);
59404#endif /* FREECIV_JSON_CONNECTION */
59405 }
59406 }
59407
59408 if (BV_ISSET(fields, 10)) {
59409 log_packet_detailed(" got field 'leader_is_male'");
59410
59411#ifdef FREECIV_JSON_CONNECTION
59412 field_addr.name = "leader_is_male";
59413#endif /* FREECIV_JSON_CONNECTION */
59414
59415 {
59416 int i;
59417
59418 if (real_packet->leader_count > MAX_NUM_LEADERS) {
59419 RECEIVE_PACKET_FIELD_ERROR(leader_is_male, ": array truncated");
59420 }
59421
59422#ifdef FREECIV_JSON_CONNECTION
59423 /* Enter array. */
59424 field_addr.sub_location = plocation_elem_new(0);
59425#endif /* FREECIV_JSON_CONNECTION */
59426
59427 for (i = 0; i < real_packet->leader_count; i++) {
59428#ifdef FREECIV_JSON_CONNECTION
59429 /* Next array element */
59430 field_addr.sub_location->number = i;
59431#endif /* FREECIV_JSON_CONNECTION */
59432
59433 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->leader_is_male[i])) {
59434 RECEIVE_PACKET_FIELD_ERROR(leader_is_male);
59435 }
59436 }
59437
59438#ifdef FREECIV_JSON_CONNECTION
59439 /* Exit array. */
59440 FC_FREE(field_addr.sub_location);
59441#endif /* FREECIV_JSON_CONNECTION */
59442 }
59443 }
59444
59445 real_packet->is_playable = BV_ISSET(fields, 11);
59446
59447 if (BV_ISSET(fields, 12)) {
59448 log_packet_detailed(" got field 'barbarian_type'");
59449
59450#ifdef FREECIV_JSON_CONNECTION
59451 field_addr.name = "barbarian_type";
59452#endif /* FREECIV_JSON_CONNECTION */
59453
59454 {
59455 int readin;
59456
59457 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
59458 RECEIVE_PACKET_FIELD_ERROR(barbarian_type);
59459 }
59460 real_packet->barbarian_type = readin;
59461 }
59462 }
59463
59464 if (BV_ISSET(fields, 13)) {
59465 log_packet_detailed(" got field 'nsets'");
59466
59467#ifdef FREECIV_JSON_CONNECTION
59468 field_addr.name = "nsets";
59469#endif /* FREECIV_JSON_CONNECTION */
59470
59471 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nsets)) {
59472 RECEIVE_PACKET_FIELD_ERROR(nsets);
59473 }
59474 }
59475
59476 if (BV_ISSET(fields, 14)) {
59477 log_packet_detailed(" got field 'sets'");
59478
59479#ifdef FREECIV_JSON_CONNECTION
59480 field_addr.name = "sets";
59481#endif /* FREECIV_JSON_CONNECTION */
59482
59483 {
59484 int i;
59485
59486 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
59487 RECEIVE_PACKET_FIELD_ERROR(sets, ": array truncated");
59488 }
59489
59490#ifdef FREECIV_JSON_CONNECTION
59491 /* Enter array. */
59492 field_addr.sub_location = plocation_elem_new(0);
59493#endif /* FREECIV_JSON_CONNECTION */
59494
59495 for (i = 0; i < real_packet->nsets; i++) {
59496#ifdef FREECIV_JSON_CONNECTION
59497 /* Next array element */
59498 field_addr.sub_location->number = i;
59499#endif /* FREECIV_JSON_CONNECTION */
59500
59501 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->sets[i])) {
59502 RECEIVE_PACKET_FIELD_ERROR(sets);
59503 }
59504 }
59505
59506#ifdef FREECIV_JSON_CONNECTION
59507 /* Exit array. */
59508 FC_FREE(field_addr.sub_location);
59509#endif /* FREECIV_JSON_CONNECTION */
59510 }
59511 }
59512
59513 if (BV_ISSET(fields, 15)) {
59514 log_packet_detailed(" got field 'ngroups'");
59515
59516#ifdef FREECIV_JSON_CONNECTION
59517 field_addr.name = "ngroups";
59518#endif /* FREECIV_JSON_CONNECTION */
59519
59520 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ngroups)) {
59521 RECEIVE_PACKET_FIELD_ERROR(ngroups);
59522 }
59523 }
59524
59525 if (BV_ISSET(fields, 16)) {
59526 log_packet_detailed(" got field 'groups'");
59527
59528#ifdef FREECIV_JSON_CONNECTION
59529 field_addr.name = "groups";
59530#endif /* FREECIV_JSON_CONNECTION */
59531
59532 {
59533 int i;
59534
59535 if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
59536 RECEIVE_PACKET_FIELD_ERROR(groups, ": array truncated");
59537 }
59538
59539#ifdef FREECIV_JSON_CONNECTION
59540 /* Enter array. */
59541 field_addr.sub_location = plocation_elem_new(0);
59542#endif /* FREECIV_JSON_CONNECTION */
59543
59544 for (i = 0; i < real_packet->ngroups; i++) {
59545#ifdef FREECIV_JSON_CONNECTION
59546 /* Next array element */
59547 field_addr.sub_location->number = i;
59548#endif /* FREECIV_JSON_CONNECTION */
59549
59550 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->groups[i])) {
59551 RECEIVE_PACKET_FIELD_ERROR(groups);
59552 }
59553 }
59554
59555#ifdef FREECIV_JSON_CONNECTION
59556 /* Exit array. */
59557 FC_FREE(field_addr.sub_location);
59558#endif /* FREECIV_JSON_CONNECTION */
59559 }
59560 }
59561
59562 if (BV_ISSET(fields, 17)) {
59563 log_packet_detailed(" got field 'init_government_id'");
59564
59565#ifdef FREECIV_JSON_CONNECTION
59566 field_addr.name = "init_government_id";
59567#endif /* FREECIV_JSON_CONNECTION */
59568
59569 {
59570 int readin;
59571
59572 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
59573 RECEIVE_PACKET_FIELD_ERROR(init_government_id);
59574 }
59575 real_packet->init_government_id = readin;
59576 }
59577 }
59578
59579 if (BV_ISSET(fields, 18)) {
59580 log_packet_detailed(" got field 'init_techs_count'");
59581
59582#ifdef FREECIV_JSON_CONNECTION
59583 field_addr.name = "init_techs_count";
59584#endif /* FREECIV_JSON_CONNECTION */
59585
59586 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_techs_count)) {
59587 RECEIVE_PACKET_FIELD_ERROR(init_techs_count);
59588 }
59589 }
59590
59591 if (BV_ISSET(fields, 19)) {
59592 log_packet_detailed(" got field 'init_techs'");
59593
59594#ifdef FREECIV_JSON_CONNECTION
59595 field_addr.name = "init_techs";
59596#endif /* FREECIV_JSON_CONNECTION */
59597
59598 {
59599 int i;
59600
59601 if (real_packet->init_techs_count > MAX_NUM_TECH_LIST) {
59602 RECEIVE_PACKET_FIELD_ERROR(init_techs, ": array truncated");
59603 }
59604
59605#ifdef FREECIV_JSON_CONNECTION
59606 /* Enter array. */
59607 field_addr.sub_location = plocation_elem_new(0);
59608#endif /* FREECIV_JSON_CONNECTION */
59609
59610 for (i = 0; i < real_packet->init_techs_count; i++) {
59611#ifdef FREECIV_JSON_CONNECTION
59612 /* Next array element */
59613 field_addr.sub_location->number = i;
59614#endif /* FREECIV_JSON_CONNECTION */
59615
59616 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->init_techs[i])) {
59617 RECEIVE_PACKET_FIELD_ERROR(init_techs);
59618 }
59619 }
59620
59621#ifdef FREECIV_JSON_CONNECTION
59622 /* Exit array. */
59623 FC_FREE(field_addr.sub_location);
59624#endif /* FREECIV_JSON_CONNECTION */
59625 }
59626 }
59627
59628 if (BV_ISSET(fields, 20)) {
59629 log_packet_detailed(" got field 'init_units_count'");
59630
59631#ifdef FREECIV_JSON_CONNECTION
59632 field_addr.name = "init_units_count";
59633#endif /* FREECIV_JSON_CONNECTION */
59634
59635 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_units_count)) {
59636 RECEIVE_PACKET_FIELD_ERROR(init_units_count);
59637 }
59638 }
59639
59640 if (BV_ISSET(fields, 21)) {
59641 log_packet_detailed(" got field 'init_units'");
59642
59643#ifdef FREECIV_JSON_CONNECTION
59644 field_addr.name = "init_units";
59645#endif /* FREECIV_JSON_CONNECTION */
59646
59647 {
59648 int i;
59649
59650 if (real_packet->init_units_count > MAX_NUM_UNIT_LIST) {
59651 RECEIVE_PACKET_FIELD_ERROR(init_units, ": array truncated");
59652 }
59653
59654#ifdef FREECIV_JSON_CONNECTION
59655 /* Enter array. */
59656 field_addr.sub_location = plocation_elem_new(0);
59657#endif /* FREECIV_JSON_CONNECTION */
59658
59659 for (i = 0; i < real_packet->init_units_count; i++) {
59660#ifdef FREECIV_JSON_CONNECTION
59661 /* Next array element */
59662 field_addr.sub_location->number = i;
59663#endif /* FREECIV_JSON_CONNECTION */
59664
59665 {
59666 int readin;
59667
59668 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
59669 RECEIVE_PACKET_FIELD_ERROR(init_units);
59670 }
59671 real_packet->init_units[i] = readin;
59672 }
59673 }
59674
59675#ifdef FREECIV_JSON_CONNECTION
59676 /* Exit array. */
59677 FC_FREE(field_addr.sub_location);
59678#endif /* FREECIV_JSON_CONNECTION */
59679 }
59680 }
59681
59682 if (BV_ISSET(fields, 22)) {
59683 log_packet_detailed(" got field 'init_buildings_count'");
59684
59685#ifdef FREECIV_JSON_CONNECTION
59686 field_addr.name = "init_buildings_count";
59687#endif /* FREECIV_JSON_CONNECTION */
59688
59689 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_buildings_count)) {
59690 RECEIVE_PACKET_FIELD_ERROR(init_buildings_count);
59691 }
59692 }
59693
59694 if (BV_ISSET(fields, 23)) {
59695 log_packet_detailed(" got field 'init_buildings'");
59696
59697#ifdef FREECIV_JSON_CONNECTION
59698 field_addr.name = "init_buildings";
59699#endif /* FREECIV_JSON_CONNECTION */
59700
59701 {
59702 int i;
59703
59704 if (real_packet->init_buildings_count > MAX_NUM_BUILDING_LIST) {
59705 RECEIVE_PACKET_FIELD_ERROR(init_buildings, ": array truncated");
59706 }
59707
59708#ifdef FREECIV_JSON_CONNECTION
59709 /* Enter array. */
59710 field_addr.sub_location = plocation_elem_new(0);
59711#endif /* FREECIV_JSON_CONNECTION */
59712
59713 for (i = 0; i < real_packet->init_buildings_count; i++) {
59714#ifdef FREECIV_JSON_CONNECTION
59715 /* Next array element */
59716 field_addr.sub_location->number = i;
59717#endif /* FREECIV_JSON_CONNECTION */
59718
59719 {
59720 int readin;
59721
59722 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
59723 RECEIVE_PACKET_FIELD_ERROR(init_buildings);
59724 }
59725 real_packet->init_buildings[i] = readin;
59726 }
59727 }
59728
59729#ifdef FREECIV_JSON_CONNECTION
59730 /* Exit array. */
59731 FC_FREE(field_addr.sub_location);
59732#endif /* FREECIV_JSON_CONNECTION */
59733 }
59734 }
59735
59736 if (nullptr == old) {
59737 old = fc_malloc(sizeof(*old));
59738 init_packet_ruleset_nation(old);
59739 *old = *real_packet;
59740 genhash_insert(*hash, old, old);
59741 } else {
59742 *old = *real_packet;
59743 }
59744
59745#else /* FREECIV_DELTA_PROTOCOL */
59746#ifdef FREECIV_JSON_CONNECTION
59747 field_addr.name = "translation_domain";
59748#endif /* FREECIV_JSON_CONNECTION */
59749
59750 if (!DIO_GET(string, &din, &field_addr, real_packet->translation_domain, sizeof(real_packet->translation_domain))) {
59751 RECEIVE_PACKET_FIELD_ERROR(translation_domain);
59752 }
59753
59754#ifdef FREECIV_JSON_CONNECTION
59755 field_addr.name = "adjective";
59756#endif /* FREECIV_JSON_CONNECTION */
59757
59758 if (!DIO_GET(string, &din, &field_addr, real_packet->adjective, sizeof(real_packet->adjective))) {
59759 RECEIVE_PACKET_FIELD_ERROR(adjective);
59760 }
59761
59762#ifdef FREECIV_JSON_CONNECTION
59763 field_addr.name = "rule_name";
59764#endif /* FREECIV_JSON_CONNECTION */
59765
59766 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
59767 RECEIVE_PACKET_FIELD_ERROR(rule_name);
59768 }
59769
59770#ifdef FREECIV_JSON_CONNECTION
59771 field_addr.name = "noun_plural";
59772#endif /* FREECIV_JSON_CONNECTION */
59773
59774 if (!DIO_GET(string, &din, &field_addr, real_packet->noun_plural, sizeof(real_packet->noun_plural))) {
59775 RECEIVE_PACKET_FIELD_ERROR(noun_plural);
59776 }
59777
59778#ifdef FREECIV_JSON_CONNECTION
59779 field_addr.name = "graphic_str";
59780#endif /* FREECIV_JSON_CONNECTION */
59781
59782 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
59783 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
59784 }
59785
59786#ifdef FREECIV_JSON_CONNECTION
59787 field_addr.name = "graphic_alt";
59788#endif /* FREECIV_JSON_CONNECTION */
59789
59790 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
59791 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
59792 }
59793
59794#ifdef FREECIV_JSON_CONNECTION
59795 field_addr.name = "legend";
59796#endif /* FREECIV_JSON_CONNECTION */
59797
59798 if (!DIO_GET(string, &din, &field_addr, real_packet->legend, sizeof(real_packet->legend))) {
59799 RECEIVE_PACKET_FIELD_ERROR(legend);
59800 }
59801
59802#ifdef FREECIV_JSON_CONNECTION
59803 field_addr.name = "style";
59804#endif /* FREECIV_JSON_CONNECTION */
59805
59806 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style)) {
59807 RECEIVE_PACKET_FIELD_ERROR(style);
59808 }
59809
59810#ifdef FREECIV_JSON_CONNECTION
59811 field_addr.name = "leader_count";
59812#endif /* FREECIV_JSON_CONNECTION */
59813
59814 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->leader_count)) {
59815 RECEIVE_PACKET_FIELD_ERROR(leader_count);
59816 }
59817
59818#ifdef FREECIV_JSON_CONNECTION
59819 field_addr.name = "leader_name";
59820#endif /* FREECIV_JSON_CONNECTION */
59821
59822 {
59823 int i;
59824
59825 if (real_packet->leader_count > MAX_NUM_LEADERS) {
59826 RECEIVE_PACKET_FIELD_ERROR(leader_name, ": array truncated");
59827 }
59828
59829#ifdef FREECIV_JSON_CONNECTION
59830 /* Enter array. */
59831 field_addr.sub_location = plocation_elem_new(0);
59832#endif /* FREECIV_JSON_CONNECTION */
59833
59834 for (i = 0; i < real_packet->leader_count; i++) {
59835#ifdef FREECIV_JSON_CONNECTION
59836 /* Next array element */
59837 field_addr.sub_location->number = i;
59838#endif /* FREECIV_JSON_CONNECTION */
59839
59840 if (!DIO_GET(string, &din, &field_addr, real_packet->leader_name[i], sizeof(real_packet->leader_name[i]))) {
59841 RECEIVE_PACKET_FIELD_ERROR(leader_name);
59842 }
59843 }
59844
59845#ifdef FREECIV_JSON_CONNECTION
59846 /* Exit array. */
59847 FC_FREE(field_addr.sub_location);
59848#endif /* FREECIV_JSON_CONNECTION */
59849 }
59850
59851#ifdef FREECIV_JSON_CONNECTION
59852 field_addr.name = "leader_is_male";
59853#endif /* FREECIV_JSON_CONNECTION */
59854
59855 {
59856 int i;
59857
59858 if (real_packet->leader_count > MAX_NUM_LEADERS) {
59859 RECEIVE_PACKET_FIELD_ERROR(leader_is_male, ": array truncated");
59860 }
59861
59862#ifdef FREECIV_JSON_CONNECTION
59863 /* Enter array. */
59864 field_addr.sub_location = plocation_elem_new(0);
59865#endif /* FREECIV_JSON_CONNECTION */
59866
59867 for (i = 0; i < real_packet->leader_count; i++) {
59868#ifdef FREECIV_JSON_CONNECTION
59869 /* Next array element */
59870 field_addr.sub_location->number = i;
59871#endif /* FREECIV_JSON_CONNECTION */
59872
59873 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->leader_is_male[i])) {
59874 RECEIVE_PACKET_FIELD_ERROR(leader_is_male);
59875 }
59876 }
59877
59878#ifdef FREECIV_JSON_CONNECTION
59879 /* Exit array. */
59880 FC_FREE(field_addr.sub_location);
59881#endif /* FREECIV_JSON_CONNECTION */
59882 }
59883
59884#ifdef FREECIV_JSON_CONNECTION
59885 field_addr.name = "is_playable";
59886#endif /* FREECIV_JSON_CONNECTION */
59887
59888 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_playable)) {
59889 RECEIVE_PACKET_FIELD_ERROR(is_playable);
59890 }
59891
59892#ifdef FREECIV_JSON_CONNECTION
59893 field_addr.name = "barbarian_type";
59894#endif /* FREECIV_JSON_CONNECTION */
59895
59896 {
59897 int readin;
59898
59899 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
59900 RECEIVE_PACKET_FIELD_ERROR(barbarian_type);
59901 }
59902 real_packet->barbarian_type = readin;
59903 }
59904
59905#ifdef FREECIV_JSON_CONNECTION
59906 field_addr.name = "nsets";
59907#endif /* FREECIV_JSON_CONNECTION */
59908
59909 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->nsets)) {
59910 RECEIVE_PACKET_FIELD_ERROR(nsets);
59911 }
59912
59913#ifdef FREECIV_JSON_CONNECTION
59914 field_addr.name = "sets";
59915#endif /* FREECIV_JSON_CONNECTION */
59916
59917 {
59918 int i;
59919
59920 if (real_packet->nsets > MAX_NUM_NATION_SETS) {
59921 RECEIVE_PACKET_FIELD_ERROR(sets, ": array truncated");
59922 }
59923
59924#ifdef FREECIV_JSON_CONNECTION
59925 /* Enter array. */
59926 field_addr.sub_location = plocation_elem_new(0);
59927#endif /* FREECIV_JSON_CONNECTION */
59928
59929 for (i = 0; i < real_packet->nsets; i++) {
59930#ifdef FREECIV_JSON_CONNECTION
59931 /* Next array element */
59932 field_addr.sub_location->number = i;
59933#endif /* FREECIV_JSON_CONNECTION */
59934
59935 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->sets[i])) {
59936 RECEIVE_PACKET_FIELD_ERROR(sets);
59937 }
59938 }
59939
59940#ifdef FREECIV_JSON_CONNECTION
59941 /* Exit array. */
59942 FC_FREE(field_addr.sub_location);
59943#endif /* FREECIV_JSON_CONNECTION */
59944 }
59945
59946#ifdef FREECIV_JSON_CONNECTION
59947 field_addr.name = "ngroups";
59948#endif /* FREECIV_JSON_CONNECTION */
59949
59950 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ngroups)) {
59951 RECEIVE_PACKET_FIELD_ERROR(ngroups);
59952 }
59953
59954#ifdef FREECIV_JSON_CONNECTION
59955 field_addr.name = "groups";
59956#endif /* FREECIV_JSON_CONNECTION */
59957
59958 {
59959 int i;
59960
59961 if (real_packet->ngroups > MAX_NUM_NATION_GROUPS) {
59962 RECEIVE_PACKET_FIELD_ERROR(groups, ": array truncated");
59963 }
59964
59965#ifdef FREECIV_JSON_CONNECTION
59966 /* Enter array. */
59967 field_addr.sub_location = plocation_elem_new(0);
59968#endif /* FREECIV_JSON_CONNECTION */
59969
59970 for (i = 0; i < real_packet->ngroups; i++) {
59971#ifdef FREECIV_JSON_CONNECTION
59972 /* Next array element */
59973 field_addr.sub_location->number = i;
59974#endif /* FREECIV_JSON_CONNECTION */
59975
59976 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->groups[i])) {
59977 RECEIVE_PACKET_FIELD_ERROR(groups);
59978 }
59979 }
59980
59981#ifdef FREECIV_JSON_CONNECTION
59982 /* Exit array. */
59983 FC_FREE(field_addr.sub_location);
59984#endif /* FREECIV_JSON_CONNECTION */
59985 }
59986
59987#ifdef FREECIV_JSON_CONNECTION
59988 field_addr.name = "init_government_id";
59989#endif /* FREECIV_JSON_CONNECTION */
59990
59991 {
59992 int readin;
59993
59994 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
59995 RECEIVE_PACKET_FIELD_ERROR(init_government_id);
59996 }
59997 real_packet->init_government_id = readin;
59998 }
59999
60000#ifdef FREECIV_JSON_CONNECTION
60001 field_addr.name = "init_techs_count";
60002#endif /* FREECIV_JSON_CONNECTION */
60003
60004 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_techs_count)) {
60005 RECEIVE_PACKET_FIELD_ERROR(init_techs_count);
60006 }
60007
60008#ifdef FREECIV_JSON_CONNECTION
60009 field_addr.name = "init_techs";
60010#endif /* FREECIV_JSON_CONNECTION */
60011
60012 {
60013 int i;
60014
60015 if (real_packet->init_techs_count > MAX_NUM_TECH_LIST) {
60016 RECEIVE_PACKET_FIELD_ERROR(init_techs, ": array truncated");
60017 }
60018
60019#ifdef FREECIV_JSON_CONNECTION
60020 /* Enter array. */
60021 field_addr.sub_location = plocation_elem_new(0);
60022#endif /* FREECIV_JSON_CONNECTION */
60023
60024 for (i = 0; i < real_packet->init_techs_count; i++) {
60025#ifdef FREECIV_JSON_CONNECTION
60026 /* Next array element */
60027 field_addr.sub_location->number = i;
60028#endif /* FREECIV_JSON_CONNECTION */
60029
60030 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->init_techs[i])) {
60031 RECEIVE_PACKET_FIELD_ERROR(init_techs);
60032 }
60033 }
60034
60035#ifdef FREECIV_JSON_CONNECTION
60036 /* Exit array. */
60037 FC_FREE(field_addr.sub_location);
60038#endif /* FREECIV_JSON_CONNECTION */
60039 }
60040
60041#ifdef FREECIV_JSON_CONNECTION
60042 field_addr.name = "init_units_count";
60043#endif /* FREECIV_JSON_CONNECTION */
60044
60045 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_units_count)) {
60046 RECEIVE_PACKET_FIELD_ERROR(init_units_count);
60047 }
60048
60049#ifdef FREECIV_JSON_CONNECTION
60050 field_addr.name = "init_units";
60051#endif /* FREECIV_JSON_CONNECTION */
60052
60053 {
60054 int i;
60055
60056 if (real_packet->init_units_count > MAX_NUM_UNIT_LIST) {
60057 RECEIVE_PACKET_FIELD_ERROR(init_units, ": array truncated");
60058 }
60059
60060#ifdef FREECIV_JSON_CONNECTION
60061 /* Enter array. */
60062 field_addr.sub_location = plocation_elem_new(0);
60063#endif /* FREECIV_JSON_CONNECTION */
60064
60065 for (i = 0; i < real_packet->init_units_count; i++) {
60066#ifdef FREECIV_JSON_CONNECTION
60067 /* Next array element */
60068 field_addr.sub_location->number = i;
60069#endif /* FREECIV_JSON_CONNECTION */
60070
60071 {
60072 int readin;
60073
60074 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
60075 RECEIVE_PACKET_FIELD_ERROR(init_units);
60076 }
60077 real_packet->init_units[i] = readin;
60078 }
60079 }
60080
60081#ifdef FREECIV_JSON_CONNECTION
60082 /* Exit array. */
60083 FC_FREE(field_addr.sub_location);
60084#endif /* FREECIV_JSON_CONNECTION */
60085 }
60086
60087#ifdef FREECIV_JSON_CONNECTION
60088 field_addr.name = "init_buildings_count";
60089#endif /* FREECIV_JSON_CONNECTION */
60090
60091 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->init_buildings_count)) {
60092 RECEIVE_PACKET_FIELD_ERROR(init_buildings_count);
60093 }
60094
60095#ifdef FREECIV_JSON_CONNECTION
60096 field_addr.name = "init_buildings";
60097#endif /* FREECIV_JSON_CONNECTION */
60098
60099 {
60100 int i;
60101
60102 if (real_packet->init_buildings_count > MAX_NUM_BUILDING_LIST) {
60103 RECEIVE_PACKET_FIELD_ERROR(init_buildings, ": array truncated");
60104 }
60105
60106#ifdef FREECIV_JSON_CONNECTION
60107 /* Enter array. */
60108 field_addr.sub_location = plocation_elem_new(0);
60109#endif /* FREECIV_JSON_CONNECTION */
60110
60111 for (i = 0; i < real_packet->init_buildings_count; i++) {
60112#ifdef FREECIV_JSON_CONNECTION
60113 /* Next array element */
60114 field_addr.sub_location->number = i;
60115#endif /* FREECIV_JSON_CONNECTION */
60116
60117 {
60118 int readin;
60119
60120 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
60121 RECEIVE_PACKET_FIELD_ERROR(init_buildings);
60122 }
60123 real_packet->init_buildings[i] = readin;
60124 }
60125 }
60126
60127#ifdef FREECIV_JSON_CONNECTION
60128 /* Exit array. */
60129 FC_FREE(field_addr.sub_location);
60130#endif /* FREECIV_JSON_CONNECTION */
60131 }
60132#endif /* FREECIV_DELTA_PROTOCOL */
60133
60134 RECEIVE_PACKET_END(real_packet);
60135#undef FREE_PACKET_STRUCT
60136}
60137
60138 static int send_packet_ruleset_nation_100(struct connection *pc, const struct packet_ruleset_nation *packet)
60139{
60140 const struct packet_ruleset_nation *real_packet = packet;
60141 int e;
60142 SEND_PACKET_START(PACKET_RULESET_NATION);
60143
60144 log_packet_detailed("packet_ruleset_nation_100: sending info about (%d)",
60145 real_packet->id);
60146
60147#ifdef FREECIV_DELTA_PROTOCOL
60148 packet_ruleset_nation_100_fields fields;
60149 struct packet_ruleset_nation *old;
60150 bool differ;
60151 struct genhash **hash = pc->phs.sent + PACKET_RULESET_NATION;
60152
60153 if (nullptr == *hash) {
60154 *hash = genhash_new_full(hash_packet_ruleset_nation_100, cmp_packet_ruleset_nation_100,
60155 nullptr, nullptr, nullptr, destroy_packet_ruleset_nation);
60156 }
60157 BV_CLR_ALL(fields);
60158
60159 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
60160 old = fc_malloc(sizeof(*old));
60161 /* temporary bitcopy just to insert correctly */
60162 *old = *real_packet;
60163 genhash_insert(*hash, old, old);
60164 init_packet_ruleset_nation(old);
60165 }
60166
60167 differ = (strcmp(old->translation_domain, real_packet->translation_domain) != 0);
60168 if (differ) {
60169 BV_SET(fields, 0);
60170 }
60171
60172 differ = (strcmp(old->adjective, real_packet->adjective) != 0);
60173 if (differ) {
60174 BV_SET(fields, 1);
60175 }
60176
60177 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
60178 if (differ) {
60179 BV_SET(fields, 2);
60180 }
60181
60182 differ = (strcmp(old->noun_plural, real_packet->noun_plural) != 0);
60183 if (differ) {
60184 BV_SET(fields, 3);
60185 }
60186
60187 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
60188 if (differ) {
60189 BV_SET(fields, 4);
60190 }
60191
60192 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
60193 if (differ) {
60194 BV_SET(fields, 5);
60195 }
60196
60197 differ = (strcmp(old->legend, real_packet->legend) != 0);
60198 if (differ) {
60199 BV_SET(fields, 6);
60200 }
60201
60202 differ = (old->style != real_packet->style);
60203 if (differ) {
60204 BV_SET(fields, 7);
60205 }
60206
60207 differ = (old->leader_count != real_packet->leader_count);
60208 if (differ) {
60209 BV_SET(fields, 8);
60210 }
60211
60212 differ = (old->leader_count != real_packet->leader_count);
60213 if (!differ) {
60214 int i;
60215
60216 for (i = 0; i < old->leader_count; i++) {
60217 differ = (strcmp(old->leader_name[i], real_packet->leader_name[i]) != 0);
60218 if (differ) {
60219 break;
60220 }
60221 }
60222 }
60223 if (differ) {
60224 BV_SET(fields, 9);
60225 }
60226
60227 differ = (old->leader_count != real_packet->leader_count);
60228 if (!differ) {
60229 int i;
60230
60231 for (i = 0; i < old->leader_count; i++) {
60232 differ = (old->leader_is_male[i] != real_packet->leader_is_male[i]);
60233 if (differ) {
60234 break;
60235 }
60236 }
60237 }
60238 if (differ) {
60239 BV_SET(fields, 10);
60240 }
60241
60242 /* folded into head */
60243 if (real_packet->is_playable) {
60244 BV_SET(fields, 11);
60245 }
60246
60247 differ = (old->barbarian_type != real_packet->barbarian_type);
60248 if (differ) {
60249 BV_SET(fields, 12);
60250 }
60251
60252 differ = (old->nsets != real_packet->nsets);
60253 if (differ) {
60254 BV_SET(fields, 13);
60255 }
60256
60257 differ = (old->nsets != real_packet->nsets);
60258 if (!differ) {
60259 int i;
60260
60261 for (i = 0; i < old->nsets; i++) {
60262 differ = (old->sets[i] != real_packet->sets[i]);
60263 if (differ) {
60264 break;
60265 }
60266 }
60267 }
60268 if (differ) {
60269 BV_SET(fields, 14);
60270 }
60271
60272 differ = (old->ngroups != real_packet->ngroups);
60273 if (differ) {
60274 BV_SET(fields, 15);
60275 }
60276
60277 differ = (old->ngroups != real_packet->ngroups);
60278 if (!differ) {
60279 int i;
60280
60281 for (i = 0; i < old->ngroups; i++) {
60282 differ = (old->groups[i] != real_packet->groups[i]);
60283 if (differ) {
60284 break;
60285 }
60286 }
60287 }
60288 if (differ) {
60289 BV_SET(fields, 16);
60290 }
60291
60292 differ = (old->init_government_id != real_packet->init_government_id);
60293 if (differ) {
60294 BV_SET(fields, 17);
60295 }
60296
60297 differ = (old->init_techs_count != real_packet->init_techs_count);
60298 if (differ) {
60299 BV_SET(fields, 18);
60300 }
60301
60302 differ = (old->init_techs_count != real_packet->init_techs_count);
60303 if (!differ) {
60304 int i;
60305
60306 for (i = 0; i < old->init_techs_count; i++) {
60307 differ = (old->init_techs[i] != real_packet->init_techs[i]);
60308 if (differ) {
60309 break;
60310 }
60311 }
60312 }
60313 if (differ) {
60314 BV_SET(fields, 19);
60315 }
60316
60317 differ = (old->init_units_count != real_packet->init_units_count);
60318 if (differ) {
60319 BV_SET(fields, 20);
60320 }
60321
60322 differ = (old->init_units_count != real_packet->init_units_count);
60323 if (!differ) {
60324 int i;
60325
60326 for (i = 0; i < old->init_units_count; i++) {
60327 differ = (old->init_units[i] != real_packet->init_units[i]);
60328 if (differ) {
60329 break;
60330 }
60331 }
60332 }
60333 if (differ) {
60334 BV_SET(fields, 21);
60335 }
60336
60337 differ = (old->init_buildings_count != real_packet->init_buildings_count);
60338 if (differ) {
60339 BV_SET(fields, 22);
60340 }
60341
60342 differ = (old->init_buildings_count != real_packet->init_buildings_count);
60343 if (!differ) {
60344 int i;
60345
60346 for (i = 0; i < old->init_buildings_count; i++) {
60347 differ = (old->init_buildings[i] != real_packet->init_buildings[i]);
60348 if (differ) {
60349 break;
60350 }
60351 }
60352 }
60353 if (differ) {
60354 BV_SET(fields, 23);
60355 }
60356#endif /* FREECIV_DELTA_PROTOCOL */
60357
60358#ifdef FREECIV_JSON_CONNECTION
60359 struct plocation field_addr;
60360 {
60361 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
60362 field_addr = *field_addr_tmp;
60363 FC_FREE(field_addr_tmp);
60364 }
60365#endif /* FREECIV_JSON_CONNECTION */
60366
60367#ifdef FREECIV_JSON_CONNECTION
60368 field_addr.name = "id";
60369#endif /* FREECIV_JSON_CONNECTION */
60370 e = 0;
60371
60372 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->id);
60373
60374 if (e) {
60375 log_packet_detailed("'id' field error detected");
60376 }
60377
60378#ifdef FREECIV_DELTA_PROTOCOL
60379#ifdef FREECIV_JSON_CONNECTION
60380 field_addr.name = "fields";
60381#endif /* FREECIV_JSON_CONNECTION */
60382 e = 0;
60383 e |= DIO_BV_PUT(&dout, &field_addr, fields);
60384 if (e) {
60385 log_packet_detailed("fields bitvector error detected");
60386 }
60387
60388 if (BV_ISSET(fields, 0)) {
60389 log_packet_detailed(" field 'translation_domain' has changed");
60390
60391#ifdef FREECIV_JSON_CONNECTION
60392 field_addr.name = "translation_domain";
60393#endif /* FREECIV_JSON_CONNECTION */
60394 e = 0;
60395
60396 e |= DIO_PUT(string, &dout, &field_addr, real_packet->translation_domain);
60397
60398 if (e) {
60399 log_packet_detailed("'translation_domain' field error detected");
60400 }
60401 }
60402
60403 if (BV_ISSET(fields, 1)) {
60404 log_packet_detailed(" field 'adjective' has changed");
60405
60406#ifdef FREECIV_JSON_CONNECTION
60407 field_addr.name = "adjective";
60408#endif /* FREECIV_JSON_CONNECTION */
60409 e = 0;
60410
60411 e |= DIO_PUT(string, &dout, &field_addr, real_packet->adjective);
60412
60413 if (e) {
60414 log_packet_detailed("'adjective' field error detected");
60415 }
60416 }
60417
60418 if (BV_ISSET(fields, 2)) {
60419 log_packet_detailed(" field 'rule_name' has changed");
60420
60421#ifdef FREECIV_JSON_CONNECTION
60422 field_addr.name = "rule_name";
60423#endif /* FREECIV_JSON_CONNECTION */
60424 e = 0;
60425
60426 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
60427
60428 if (e) {
60429 log_packet_detailed("'rule_name' field error detected");
60430 }
60431 }
60432
60433 if (BV_ISSET(fields, 3)) {
60434 log_packet_detailed(" field 'noun_plural' has changed");
60435
60436#ifdef FREECIV_JSON_CONNECTION
60437 field_addr.name = "noun_plural";
60438#endif /* FREECIV_JSON_CONNECTION */
60439 e = 0;
60440
60441 e |= DIO_PUT(string, &dout, &field_addr, real_packet->noun_plural);
60442
60443 if (e) {
60444 log_packet_detailed("'noun_plural' field error detected");
60445 }
60446 }
60447
60448 if (BV_ISSET(fields, 4)) {
60449 log_packet_detailed(" field 'graphic_str' has changed");
60450
60451#ifdef FREECIV_JSON_CONNECTION
60452 field_addr.name = "graphic_str";
60453#endif /* FREECIV_JSON_CONNECTION */
60454 e = 0;
60455
60456 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
60457
60458 if (e) {
60459 log_packet_detailed("'graphic_str' field error detected");
60460 }
60461 }
60462
60463 if (BV_ISSET(fields, 5)) {
60464 log_packet_detailed(" field 'graphic_alt' has changed");
60465
60466#ifdef FREECIV_JSON_CONNECTION
60467 field_addr.name = "graphic_alt";
60468#endif /* FREECIV_JSON_CONNECTION */
60469 e = 0;
60470
60471 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
60472
60473 if (e) {
60474 log_packet_detailed("'graphic_alt' field error detected");
60475 }
60476 }
60477
60478 if (BV_ISSET(fields, 6)) {
60479 log_packet_detailed(" field 'legend' has changed");
60480
60481#ifdef FREECIV_JSON_CONNECTION
60482 field_addr.name = "legend";
60483#endif /* FREECIV_JSON_CONNECTION */
60484 e = 0;
60485
60486 e |= DIO_PUT(string, &dout, &field_addr, real_packet->legend);
60487
60488 if (e) {
60489 log_packet_detailed("'legend' field error detected");
60490 }
60491 }
60492
60493 if (BV_ISSET(fields, 7)) {
60494 log_packet_detailed(" field 'style' has changed");
60495
60496#ifdef FREECIV_JSON_CONNECTION
60497 field_addr.name = "style";
60498#endif /* FREECIV_JSON_CONNECTION */
60499 e = 0;
60500
60501 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
60502
60503 if (e) {
60504 log_packet_detailed("'style' field error detected");
60505 }
60506 }
60507
60508 if (BV_ISSET(fields, 8)) {
60509 log_packet_detailed(" field 'leader_count' has changed");
60510
60511#ifdef FREECIV_JSON_CONNECTION
60512 field_addr.name = "leader_count";
60513#endif /* FREECIV_JSON_CONNECTION */
60514 e = 0;
60515
60516 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->leader_count);
60517
60518 if (e) {
60519 log_packet_detailed("'leader_count' field error detected");
60520 }
60521 }
60522
60523 if (BV_ISSET(fields, 9)) {
60524 log_packet_detailed(" field 'leader_name' has changed");
60525
60526#ifdef FREECIV_JSON_CONNECTION
60527 field_addr.name = "leader_name";
60528#endif /* FREECIV_JSON_CONNECTION */
60529 e = 0;
60530
60531 {
60532 int i;
60533
60534#ifdef FREECIV_JSON_CONNECTION
60535 /* Create the array. */
60536 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->leader_count);
60537
60538 /* Enter array. */
60539 field_addr.sub_location = plocation_elem_new(0);
60540#endif /* FREECIV_JSON_CONNECTION */
60541
60542 for (i = 0; i < real_packet->leader_count; i++) {
60543#ifdef FREECIV_JSON_CONNECTION
60544 /* Next array element. */
60545 field_addr.sub_location->number = i;
60546#endif /* FREECIV_JSON_CONNECTION */
60547
60548 e |= DIO_PUT(string, &dout, &field_addr, real_packet->leader_name[i]);
60549 }
60550
60551#ifdef FREECIV_JSON_CONNECTION
60552 /* Exit array. */
60553 FC_FREE(field_addr.sub_location);
60554#endif /* FREECIV_JSON_CONNECTION */
60555 }
60556
60557 if (e) {
60558 log_packet_detailed("'leader_name' field error detected");
60559 }
60560 }
60561
60562 if (BV_ISSET(fields, 10)) {
60563 log_packet_detailed(" field 'leader_is_male' has changed");
60564
60565#ifdef FREECIV_JSON_CONNECTION
60566 field_addr.name = "leader_is_male";
60567#endif /* FREECIV_JSON_CONNECTION */
60568 e = 0;
60569
60570 {
60571 int i;
60572
60573#ifdef FREECIV_JSON_CONNECTION
60574 /* Create the array. */
60575 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->leader_count);
60576
60577 /* Enter array. */
60578 field_addr.sub_location = plocation_elem_new(0);
60579#endif /* FREECIV_JSON_CONNECTION */
60580
60581 for (i = 0; i < real_packet->leader_count; i++) {
60582#ifdef FREECIV_JSON_CONNECTION
60583 /* Next array element. */
60584 field_addr.sub_location->number = i;
60585#endif /* FREECIV_JSON_CONNECTION */
60586
60587 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->leader_is_male[i]);
60588 }
60589
60590#ifdef FREECIV_JSON_CONNECTION
60591 /* Exit array. */
60592 FC_FREE(field_addr.sub_location);
60593#endif /* FREECIV_JSON_CONNECTION */
60594 }
60595
60596 if (e) {
60597 log_packet_detailed("'leader_is_male' field error detected");
60598 }
60599 }
60600
60601 /* field 11 is folded into the header */
60602
60603 if (BV_ISSET(fields, 12)) {
60604 log_packet_detailed(" field 'barbarian_type' has changed");
60605
60606#ifdef FREECIV_JSON_CONNECTION
60607 field_addr.name = "barbarian_type";
60608#endif /* FREECIV_JSON_CONNECTION */
60609 e = 0;
60610
60611 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->barbarian_type);
60612
60613 if (e) {
60614 log_packet_detailed("'barbarian_type' field error detected");
60615 }
60616 }
60617
60618 if (BV_ISSET(fields, 13)) {
60619 log_packet_detailed(" field 'nsets' has changed");
60620
60621#ifdef FREECIV_JSON_CONNECTION
60622 field_addr.name = "nsets";
60623#endif /* FREECIV_JSON_CONNECTION */
60624 e = 0;
60625
60626 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nsets);
60627
60628 if (e) {
60629 log_packet_detailed("'nsets' field error detected");
60630 }
60631 }
60632
60633 if (BV_ISSET(fields, 14)) {
60634 log_packet_detailed(" field 'sets' has changed");
60635
60636#ifdef FREECIV_JSON_CONNECTION
60637 field_addr.name = "sets";
60638#endif /* FREECIV_JSON_CONNECTION */
60639 e = 0;
60640
60641 {
60642 int i;
60643
60644#ifdef FREECIV_JSON_CONNECTION
60645 /* Create the array. */
60646 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
60647
60648 /* Enter array. */
60649 field_addr.sub_location = plocation_elem_new(0);
60650#endif /* FREECIV_JSON_CONNECTION */
60651
60652 for (i = 0; i < real_packet->nsets; i++) {
60653#ifdef FREECIV_JSON_CONNECTION
60654 /* Next array element. */
60655 field_addr.sub_location->number = i;
60656#endif /* FREECIV_JSON_CONNECTION */
60657
60658 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sets[i]);
60659 }
60660
60661#ifdef FREECIV_JSON_CONNECTION
60662 /* Exit array. */
60663 FC_FREE(field_addr.sub_location);
60664#endif /* FREECIV_JSON_CONNECTION */
60665 }
60666
60667 if (e) {
60668 log_packet_detailed("'sets' field error detected");
60669 }
60670 }
60671
60672 if (BV_ISSET(fields, 15)) {
60673 log_packet_detailed(" field 'ngroups' has changed");
60674
60675#ifdef FREECIV_JSON_CONNECTION
60676 field_addr.name = "ngroups";
60677#endif /* FREECIV_JSON_CONNECTION */
60678 e = 0;
60679
60680 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ngroups);
60681
60682 if (e) {
60683 log_packet_detailed("'ngroups' field error detected");
60684 }
60685 }
60686
60687 if (BV_ISSET(fields, 16)) {
60688 log_packet_detailed(" field 'groups' has changed");
60689
60690#ifdef FREECIV_JSON_CONNECTION
60691 field_addr.name = "groups";
60692#endif /* FREECIV_JSON_CONNECTION */
60693 e = 0;
60694
60695 {
60696 int i;
60697
60698#ifdef FREECIV_JSON_CONNECTION
60699 /* Create the array. */
60700 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ngroups);
60701
60702 /* Enter array. */
60703 field_addr.sub_location = plocation_elem_new(0);
60704#endif /* FREECIV_JSON_CONNECTION */
60705
60706 for (i = 0; i < real_packet->ngroups; i++) {
60707#ifdef FREECIV_JSON_CONNECTION
60708 /* Next array element. */
60709 field_addr.sub_location->number = i;
60710#endif /* FREECIV_JSON_CONNECTION */
60711
60712 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->groups[i]);
60713 }
60714
60715#ifdef FREECIV_JSON_CONNECTION
60716 /* Exit array. */
60717 FC_FREE(field_addr.sub_location);
60718#endif /* FREECIV_JSON_CONNECTION */
60719 }
60720
60721 if (e) {
60722 log_packet_detailed("'groups' field error detected");
60723 }
60724 }
60725
60726 if (BV_ISSET(fields, 17)) {
60727 log_packet_detailed(" field 'init_government_id' has changed");
60728
60729#ifdef FREECIV_JSON_CONNECTION
60730 field_addr.name = "init_government_id";
60731#endif /* FREECIV_JSON_CONNECTION */
60732 e = 0;
60733
60734 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->init_government_id);
60735
60736 if (e) {
60737 log_packet_detailed("'init_government_id' field error detected");
60738 }
60739 }
60740
60741 if (BV_ISSET(fields, 18)) {
60742 log_packet_detailed(" field 'init_techs_count' has changed");
60743
60744#ifdef FREECIV_JSON_CONNECTION
60745 field_addr.name = "init_techs_count";
60746#endif /* FREECIV_JSON_CONNECTION */
60747 e = 0;
60748
60749 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_techs_count);
60750
60751 if (e) {
60752 log_packet_detailed("'init_techs_count' field error detected");
60753 }
60754 }
60755
60756 if (BV_ISSET(fields, 19)) {
60757 log_packet_detailed(" field 'init_techs' has changed");
60758
60759#ifdef FREECIV_JSON_CONNECTION
60760 field_addr.name = "init_techs";
60761#endif /* FREECIV_JSON_CONNECTION */
60762 e = 0;
60763
60764 {
60765 int i;
60766
60767#ifdef FREECIV_JSON_CONNECTION
60768 /* Create the array. */
60769 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->init_techs_count);
60770
60771 /* Enter array. */
60772 field_addr.sub_location = plocation_elem_new(0);
60773#endif /* FREECIV_JSON_CONNECTION */
60774
60775 for (i = 0; i < real_packet->init_techs_count; i++) {
60776#ifdef FREECIV_JSON_CONNECTION
60777 /* Next array element. */
60778 field_addr.sub_location->number = i;
60779#endif /* FREECIV_JSON_CONNECTION */
60780
60781 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->init_techs[i]);
60782 }
60783
60784#ifdef FREECIV_JSON_CONNECTION
60785 /* Exit array. */
60786 FC_FREE(field_addr.sub_location);
60787#endif /* FREECIV_JSON_CONNECTION */
60788 }
60789
60790 if (e) {
60791 log_packet_detailed("'init_techs' field error detected");
60792 }
60793 }
60794
60795 if (BV_ISSET(fields, 20)) {
60796 log_packet_detailed(" field 'init_units_count' has changed");
60797
60798#ifdef FREECIV_JSON_CONNECTION
60799 field_addr.name = "init_units_count";
60800#endif /* FREECIV_JSON_CONNECTION */
60801 e = 0;
60802
60803 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_units_count);
60804
60805 if (e) {
60806 log_packet_detailed("'init_units_count' field error detected");
60807 }
60808 }
60809
60810 if (BV_ISSET(fields, 21)) {
60811 log_packet_detailed(" field 'init_units' has changed");
60812
60813#ifdef FREECIV_JSON_CONNECTION
60814 field_addr.name = "init_units";
60815#endif /* FREECIV_JSON_CONNECTION */
60816 e = 0;
60817
60818 {
60819 int i;
60820
60821#ifdef FREECIV_JSON_CONNECTION
60822 /* Create the array. */
60823 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->init_units_count);
60824
60825 /* Enter array. */
60826 field_addr.sub_location = plocation_elem_new(0);
60827#endif /* FREECIV_JSON_CONNECTION */
60828
60829 for (i = 0; i < real_packet->init_units_count; i++) {
60830#ifdef FREECIV_JSON_CONNECTION
60831 /* Next array element. */
60832 field_addr.sub_location->number = i;
60833#endif /* FREECIV_JSON_CONNECTION */
60834
60835 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->init_units[i]);
60836 }
60837
60838#ifdef FREECIV_JSON_CONNECTION
60839 /* Exit array. */
60840 FC_FREE(field_addr.sub_location);
60841#endif /* FREECIV_JSON_CONNECTION */
60842 }
60843
60844 if (e) {
60845 log_packet_detailed("'init_units' field error detected");
60846 }
60847 }
60848
60849 if (BV_ISSET(fields, 22)) {
60850 log_packet_detailed(" field 'init_buildings_count' has changed");
60851
60852#ifdef FREECIV_JSON_CONNECTION
60853 field_addr.name = "init_buildings_count";
60854#endif /* FREECIV_JSON_CONNECTION */
60855 e = 0;
60856
60857 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_buildings_count);
60858
60859 if (e) {
60860 log_packet_detailed("'init_buildings_count' field error detected");
60861 }
60862 }
60863
60864 if (BV_ISSET(fields, 23)) {
60865 log_packet_detailed(" field 'init_buildings' has changed");
60866
60867#ifdef FREECIV_JSON_CONNECTION
60868 field_addr.name = "init_buildings";
60869#endif /* FREECIV_JSON_CONNECTION */
60870 e = 0;
60871
60872 {
60873 int i;
60874
60875#ifdef FREECIV_JSON_CONNECTION
60876 /* Create the array. */
60877 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->init_buildings_count);
60878
60879 /* Enter array. */
60880 field_addr.sub_location = plocation_elem_new(0);
60881#endif /* FREECIV_JSON_CONNECTION */
60882
60883 for (i = 0; i < real_packet->init_buildings_count; i++) {
60884#ifdef FREECIV_JSON_CONNECTION
60885 /* Next array element. */
60886 field_addr.sub_location->number = i;
60887#endif /* FREECIV_JSON_CONNECTION */
60888
60889 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_buildings[i]);
60890 }
60891
60892#ifdef FREECIV_JSON_CONNECTION
60893 /* Exit array. */
60894 FC_FREE(field_addr.sub_location);
60895#endif /* FREECIV_JSON_CONNECTION */
60896 }
60897
60898 if (e) {
60899 log_packet_detailed("'init_buildings' field error detected");
60900 }
60901 }
60902
60903 *old = *real_packet;
60904
60905#else /* FREECIV_DELTA_PROTOCOL */
60906#ifdef FREECIV_JSON_CONNECTION
60907 field_addr.name = "translation_domain";
60908#endif /* FREECIV_JSON_CONNECTION */
60909 e = 0;
60910
60911 e |= DIO_PUT(string, &dout, &field_addr, real_packet->translation_domain);
60912
60913 if (e) {
60914 log_packet_detailed("'translation_domain' field error detected");
60915 }
60916
60917#ifdef FREECIV_JSON_CONNECTION
60918 field_addr.name = "adjective";
60919#endif /* FREECIV_JSON_CONNECTION */
60920 e = 0;
60921
60922 e |= DIO_PUT(string, &dout, &field_addr, real_packet->adjective);
60923
60924 if (e) {
60925 log_packet_detailed("'adjective' field error detected");
60926 }
60927
60928#ifdef FREECIV_JSON_CONNECTION
60929 field_addr.name = "rule_name";
60930#endif /* FREECIV_JSON_CONNECTION */
60931 e = 0;
60932
60933 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
60934
60935 if (e) {
60936 log_packet_detailed("'rule_name' field error detected");
60937 }
60938
60939#ifdef FREECIV_JSON_CONNECTION
60940 field_addr.name = "noun_plural";
60941#endif /* FREECIV_JSON_CONNECTION */
60942 e = 0;
60943
60944 e |= DIO_PUT(string, &dout, &field_addr, real_packet->noun_plural);
60945
60946 if (e) {
60947 log_packet_detailed("'noun_plural' field error detected");
60948 }
60949
60950#ifdef FREECIV_JSON_CONNECTION
60951 field_addr.name = "graphic_str";
60952#endif /* FREECIV_JSON_CONNECTION */
60953 e = 0;
60954
60955 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
60956
60957 if (e) {
60958 log_packet_detailed("'graphic_str' field error detected");
60959 }
60960
60961#ifdef FREECIV_JSON_CONNECTION
60962 field_addr.name = "graphic_alt";
60963#endif /* FREECIV_JSON_CONNECTION */
60964 e = 0;
60965
60966 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
60967
60968 if (e) {
60969 log_packet_detailed("'graphic_alt' field error detected");
60970 }
60971
60972#ifdef FREECIV_JSON_CONNECTION
60973 field_addr.name = "legend";
60974#endif /* FREECIV_JSON_CONNECTION */
60975 e = 0;
60976
60977 e |= DIO_PUT(string, &dout, &field_addr, real_packet->legend);
60978
60979 if (e) {
60980 log_packet_detailed("'legend' field error detected");
60981 }
60982
60983#ifdef FREECIV_JSON_CONNECTION
60984 field_addr.name = "style";
60985#endif /* FREECIV_JSON_CONNECTION */
60986 e = 0;
60987
60988 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style);
60989
60990 if (e) {
60991 log_packet_detailed("'style' field error detected");
60992 }
60993
60994#ifdef FREECIV_JSON_CONNECTION
60995 field_addr.name = "leader_count";
60996#endif /* FREECIV_JSON_CONNECTION */
60997 e = 0;
60998
60999 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->leader_count);
61000
61001 if (e) {
61002 log_packet_detailed("'leader_count' field error detected");
61003 }
61004
61005#ifdef FREECIV_JSON_CONNECTION
61006 field_addr.name = "leader_name";
61007#endif /* FREECIV_JSON_CONNECTION */
61008 e = 0;
61009
61010 {
61011 int i;
61012
61013#ifdef FREECIV_JSON_CONNECTION
61014 /* Create the array. */
61015 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->leader_count);
61016
61017 /* Enter array. */
61018 field_addr.sub_location = plocation_elem_new(0);
61019#endif /* FREECIV_JSON_CONNECTION */
61020
61021 for (i = 0; i < real_packet->leader_count; i++) {
61022#ifdef FREECIV_JSON_CONNECTION
61023 /* Next array element. */
61024 field_addr.sub_location->number = i;
61025#endif /* FREECIV_JSON_CONNECTION */
61026
61027 e |= DIO_PUT(string, &dout, &field_addr, real_packet->leader_name[i]);
61028 }
61029
61030#ifdef FREECIV_JSON_CONNECTION
61031 /* Exit array. */
61032 FC_FREE(field_addr.sub_location);
61033#endif /* FREECIV_JSON_CONNECTION */
61034 }
61035
61036 if (e) {
61037 log_packet_detailed("'leader_name' field error detected");
61038 }
61039
61040#ifdef FREECIV_JSON_CONNECTION
61041 field_addr.name = "leader_is_male";
61042#endif /* FREECIV_JSON_CONNECTION */
61043 e = 0;
61044
61045 {
61046 int i;
61047
61048#ifdef FREECIV_JSON_CONNECTION
61049 /* Create the array. */
61050 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->leader_count);
61051
61052 /* Enter array. */
61053 field_addr.sub_location = plocation_elem_new(0);
61054#endif /* FREECIV_JSON_CONNECTION */
61055
61056 for (i = 0; i < real_packet->leader_count; i++) {
61057#ifdef FREECIV_JSON_CONNECTION
61058 /* Next array element. */
61059 field_addr.sub_location->number = i;
61060#endif /* FREECIV_JSON_CONNECTION */
61061
61062 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->leader_is_male[i]);
61063 }
61064
61065#ifdef FREECIV_JSON_CONNECTION
61066 /* Exit array. */
61067 FC_FREE(field_addr.sub_location);
61068#endif /* FREECIV_JSON_CONNECTION */
61069 }
61070
61071 if (e) {
61072 log_packet_detailed("'leader_is_male' field error detected");
61073 }
61074
61075#ifdef FREECIV_JSON_CONNECTION
61076 field_addr.name = "is_playable";
61077#endif /* FREECIV_JSON_CONNECTION */
61078 e = 0;
61079
61080 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_playable);
61081
61082 if (e) {
61083 log_packet_detailed("'is_playable' field error detected");
61084 }
61085
61086#ifdef FREECIV_JSON_CONNECTION
61087 field_addr.name = "barbarian_type";
61088#endif /* FREECIV_JSON_CONNECTION */
61089 e = 0;
61090
61091 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->barbarian_type);
61092
61093 if (e) {
61094 log_packet_detailed("'barbarian_type' field error detected");
61095 }
61096
61097#ifdef FREECIV_JSON_CONNECTION
61098 field_addr.name = "nsets";
61099#endif /* FREECIV_JSON_CONNECTION */
61100 e = 0;
61101
61102 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->nsets);
61103
61104 if (e) {
61105 log_packet_detailed("'nsets' field error detected");
61106 }
61107
61108#ifdef FREECIV_JSON_CONNECTION
61109 field_addr.name = "sets";
61110#endif /* FREECIV_JSON_CONNECTION */
61111 e = 0;
61112
61113 {
61114 int i;
61115
61116#ifdef FREECIV_JSON_CONNECTION
61117 /* Create the array. */
61118 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->nsets);
61119
61120 /* Enter array. */
61121 field_addr.sub_location = plocation_elem_new(0);
61122#endif /* FREECIV_JSON_CONNECTION */
61123
61124 for (i = 0; i < real_packet->nsets; i++) {
61125#ifdef FREECIV_JSON_CONNECTION
61126 /* Next array element. */
61127 field_addr.sub_location->number = i;
61128#endif /* FREECIV_JSON_CONNECTION */
61129
61130 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sets[i]);
61131 }
61132
61133#ifdef FREECIV_JSON_CONNECTION
61134 /* Exit array. */
61135 FC_FREE(field_addr.sub_location);
61136#endif /* FREECIV_JSON_CONNECTION */
61137 }
61138
61139 if (e) {
61140 log_packet_detailed("'sets' field error detected");
61141 }
61142
61143#ifdef FREECIV_JSON_CONNECTION
61144 field_addr.name = "ngroups";
61145#endif /* FREECIV_JSON_CONNECTION */
61146 e = 0;
61147
61148 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ngroups);
61149
61150 if (e) {
61151 log_packet_detailed("'ngroups' field error detected");
61152 }
61153
61154#ifdef FREECIV_JSON_CONNECTION
61155 field_addr.name = "groups";
61156#endif /* FREECIV_JSON_CONNECTION */
61157 e = 0;
61158
61159 {
61160 int i;
61161
61162#ifdef FREECIV_JSON_CONNECTION
61163 /* Create the array. */
61164 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ngroups);
61165
61166 /* Enter array. */
61167 field_addr.sub_location = plocation_elem_new(0);
61168#endif /* FREECIV_JSON_CONNECTION */
61169
61170 for (i = 0; i < real_packet->ngroups; i++) {
61171#ifdef FREECIV_JSON_CONNECTION
61172 /* Next array element. */
61173 field_addr.sub_location->number = i;
61174#endif /* FREECIV_JSON_CONNECTION */
61175
61176 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->groups[i]);
61177 }
61178
61179#ifdef FREECIV_JSON_CONNECTION
61180 /* Exit array. */
61181 FC_FREE(field_addr.sub_location);
61182#endif /* FREECIV_JSON_CONNECTION */
61183 }
61184
61185 if (e) {
61186 log_packet_detailed("'groups' field error detected");
61187 }
61188
61189#ifdef FREECIV_JSON_CONNECTION
61190 field_addr.name = "init_government_id";
61191#endif /* FREECIV_JSON_CONNECTION */
61192 e = 0;
61193
61194 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->init_government_id);
61195
61196 if (e) {
61197 log_packet_detailed("'init_government_id' field error detected");
61198 }
61199
61200#ifdef FREECIV_JSON_CONNECTION
61201 field_addr.name = "init_techs_count";
61202#endif /* FREECIV_JSON_CONNECTION */
61203 e = 0;
61204
61205 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_techs_count);
61206
61207 if (e) {
61208 log_packet_detailed("'init_techs_count' field error detected");
61209 }
61210
61211#ifdef FREECIV_JSON_CONNECTION
61212 field_addr.name = "init_techs";
61213#endif /* FREECIV_JSON_CONNECTION */
61214 e = 0;
61215
61216 {
61217 int i;
61218
61219#ifdef FREECIV_JSON_CONNECTION
61220 /* Create the array. */
61221 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->init_techs_count);
61222
61223 /* Enter array. */
61224 field_addr.sub_location = plocation_elem_new(0);
61225#endif /* FREECIV_JSON_CONNECTION */
61226
61227 for (i = 0; i < real_packet->init_techs_count; i++) {
61228#ifdef FREECIV_JSON_CONNECTION
61229 /* Next array element. */
61230 field_addr.sub_location->number = i;
61231#endif /* FREECIV_JSON_CONNECTION */
61232
61233 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->init_techs[i]);
61234 }
61235
61236#ifdef FREECIV_JSON_CONNECTION
61237 /* Exit array. */
61238 FC_FREE(field_addr.sub_location);
61239#endif /* FREECIV_JSON_CONNECTION */
61240 }
61241
61242 if (e) {
61243 log_packet_detailed("'init_techs' field error detected");
61244 }
61245
61246#ifdef FREECIV_JSON_CONNECTION
61247 field_addr.name = "init_units_count";
61248#endif /* FREECIV_JSON_CONNECTION */
61249 e = 0;
61250
61251 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_units_count);
61252
61253 if (e) {
61254 log_packet_detailed("'init_units_count' field error detected");
61255 }
61256
61257#ifdef FREECIV_JSON_CONNECTION
61258 field_addr.name = "init_units";
61259#endif /* FREECIV_JSON_CONNECTION */
61260 e = 0;
61261
61262 {
61263 int i;
61264
61265#ifdef FREECIV_JSON_CONNECTION
61266 /* Create the array. */
61267 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->init_units_count);
61268
61269 /* Enter array. */
61270 field_addr.sub_location = plocation_elem_new(0);
61271#endif /* FREECIV_JSON_CONNECTION */
61272
61273 for (i = 0; i < real_packet->init_units_count; i++) {
61274#ifdef FREECIV_JSON_CONNECTION
61275 /* Next array element. */
61276 field_addr.sub_location->number = i;
61277#endif /* FREECIV_JSON_CONNECTION */
61278
61279 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->init_units[i]);
61280 }
61281
61282#ifdef FREECIV_JSON_CONNECTION
61283 /* Exit array. */
61284 FC_FREE(field_addr.sub_location);
61285#endif /* FREECIV_JSON_CONNECTION */
61286 }
61287
61288 if (e) {
61289 log_packet_detailed("'init_units' field error detected");
61290 }
61291
61292#ifdef FREECIV_JSON_CONNECTION
61293 field_addr.name = "init_buildings_count";
61294#endif /* FREECIV_JSON_CONNECTION */
61295 e = 0;
61296
61297 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_buildings_count);
61298
61299 if (e) {
61300 log_packet_detailed("'init_buildings_count' field error detected");
61301 }
61302
61303#ifdef FREECIV_JSON_CONNECTION
61304 field_addr.name = "init_buildings";
61305#endif /* FREECIV_JSON_CONNECTION */
61306 e = 0;
61307
61308 {
61309 int i;
61310
61311#ifdef FREECIV_JSON_CONNECTION
61312 /* Create the array. */
61313 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->init_buildings_count);
61314
61315 /* Enter array. */
61316 field_addr.sub_location = plocation_elem_new(0);
61317#endif /* FREECIV_JSON_CONNECTION */
61318
61319 for (i = 0; i < real_packet->init_buildings_count; i++) {
61320#ifdef FREECIV_JSON_CONNECTION
61321 /* Next array element. */
61322 field_addr.sub_location->number = i;
61323#endif /* FREECIV_JSON_CONNECTION */
61324
61325 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->init_buildings[i]);
61326 }
61327
61328#ifdef FREECIV_JSON_CONNECTION
61329 /* Exit array. */
61330 FC_FREE(field_addr.sub_location);
61331#endif /* FREECIV_JSON_CONNECTION */
61332 }
61333
61334 if (e) {
61335 log_packet_detailed("'init_buildings' field error detected");
61336 }
61337#endif /* FREECIV_DELTA_PROTOCOL */
61338
61339 SEND_PACKET_END(PACKET_RULESET_NATION);
61340}
61341
61342 int send_packet_ruleset_nation(struct connection *pc, const struct packet_ruleset_nation *packet)
61343{
61344 if (!pc->used) {
61345 log_error("WARNING: trying to send data to the closed connection %s",
61346 conn_description(pc));
61347 return -1;
61348 }
61349 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_NATION].packet != nullptr, -1,
61350 "Handler for PACKET_RULESET_NATION not installed");
61351 return pc->phs.handlers->send[PACKET_RULESET_NATION].packet(pc, packet);
61352}
61353
61354 void lsend_packet_ruleset_nation(struct conn_list *dest, const struct packet_ruleset_nation *packet)
61355{
61356 conn_list_iterate(dest, pconn) {
61357 send_packet_ruleset_nation(pconn, packet);
61358 } conn_list_iterate_end;
61359}
61360
61361 static inline void init_packet_nation_availability(struct packet_nation_availability *packet)
61362{
61363 memset(packet, 0, sizeof(*packet));
61364}
61365
61366#define free_packet_nation_availability(_packet) (void) 0
61367#define destroy_packet_nation_availability free
61368
61369#ifdef FREECIV_DELTA_PROTOCOL
61370#define hash_packet_nation_availability_100 hash_const
61371#define cmp_packet_nation_availability_100 cmp_const
61372 BV_DEFINE(packet_nation_availability_100_fields, 3);
61373#endif /* FREECIV_DELTA_PROTOCOL */
61374
61375 static struct packet_nation_availability *receive_packet_nation_availability_100(struct connection *pc)
61376{
61377#define FREE_PACKET_STRUCT(_packet) free_packet_nation_availability(_packet)
61378 RECEIVE_PACKET_START(packet_nation_availability, real_packet);
61379
61380#ifdef FREECIV_JSON_CONNECTION
61381 struct plocation field_addr;
61382 {
61383 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
61384 field_addr = *field_addr_tmp;
61385 FC_FREE(field_addr_tmp);
61386 }
61387#endif /* FREECIV_JSON_CONNECTION */
61388
61389 log_packet_detailed("packet_nation_availability_100: got info about ()");
61390
61391#ifdef FREECIV_DELTA_PROTOCOL
61392 packet_nation_availability_100_fields fields;
61393 struct packet_nation_availability *old;
61394 struct genhash **hash = pc->phs.received + PACKET_NATION_AVAILABILITY;
61395
61396 if (nullptr == *hash) {
61397 *hash = genhash_new_full(hash_packet_nation_availability_100, cmp_packet_nation_availability_100,
61398 nullptr, nullptr, nullptr, destroy_packet_nation_availability);
61399 }
61400
61401 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
61402 *real_packet = *old;
61403 } else {
61404 /* packet is already initialized empty */
61405 log_packet_detailed(" no old info");
61406 }
61407
61408#ifdef FREECIV_JSON_CONNECTION
61409 field_addr.name = "fields";
61410#endif /* FREECIV_JSON_CONNECTION */
61411 DIO_BV_GET(&din, &field_addr, fields);
61412
61413 if (BV_ISSET(fields, 0)) {
61414 log_packet_detailed(" got field 'ncount'");
61415
61416#ifdef FREECIV_JSON_CONNECTION
61417 field_addr.name = "ncount";
61418#endif /* FREECIV_JSON_CONNECTION */
61419
61420 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->ncount)) {
61421 RECEIVE_PACKET_FIELD_ERROR(ncount);
61422 }
61423 }
61424
61425 if (BV_ISSET(fields, 1)) {
61426 log_packet_detailed(" got field 'is_pickable'");
61427
61428#ifdef FREECIV_JSON_CONNECTION
61429 field_addr.name = "is_pickable";
61430#endif /* FREECIV_JSON_CONNECTION */
61431
61432 {
61433 int i;
61434
61435 if (real_packet->ncount > MAX_NUM_NATIONS) {
61436 RECEIVE_PACKET_FIELD_ERROR(is_pickable, ": array truncated");
61437 }
61438
61439#ifdef FREECIV_JSON_CONNECTION
61440 /* Enter array. */
61441 field_addr.sub_location = plocation_elem_new(0);
61442#endif /* FREECIV_JSON_CONNECTION */
61443
61444 for (i = 0; i < real_packet->ncount; i++) {
61445#ifdef FREECIV_JSON_CONNECTION
61446 /* Next array element */
61447 field_addr.sub_location->number = i;
61448#endif /* FREECIV_JSON_CONNECTION */
61449
61450 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_pickable[i])) {
61451 RECEIVE_PACKET_FIELD_ERROR(is_pickable);
61452 }
61453 }
61454
61455#ifdef FREECIV_JSON_CONNECTION
61456 /* Exit array. */
61457 FC_FREE(field_addr.sub_location);
61458#endif /* FREECIV_JSON_CONNECTION */
61459 }
61460 }
61461
61462 real_packet->nationset_change = BV_ISSET(fields, 2);
61463
61464 if (nullptr == old) {
61465 old = fc_malloc(sizeof(*old));
61466 init_packet_nation_availability(old);
61467 *old = *real_packet;
61468 genhash_insert(*hash, old, old);
61469 } else {
61470 *old = *real_packet;
61471 }
61472
61473#else /* FREECIV_DELTA_PROTOCOL */
61474#ifdef FREECIV_JSON_CONNECTION
61475 field_addr.name = "ncount";
61476#endif /* FREECIV_JSON_CONNECTION */
61477
61478 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->ncount)) {
61479 RECEIVE_PACKET_FIELD_ERROR(ncount);
61480 }
61481
61482#ifdef FREECIV_JSON_CONNECTION
61483 field_addr.name = "is_pickable";
61484#endif /* FREECIV_JSON_CONNECTION */
61485
61486 {
61487 int i;
61488
61489 if (real_packet->ncount > MAX_NUM_NATIONS) {
61490 RECEIVE_PACKET_FIELD_ERROR(is_pickable, ": array truncated");
61491 }
61492
61493#ifdef FREECIV_JSON_CONNECTION
61494 /* Enter array. */
61495 field_addr.sub_location = plocation_elem_new(0);
61496#endif /* FREECIV_JSON_CONNECTION */
61497
61498 for (i = 0; i < real_packet->ncount; i++) {
61499#ifdef FREECIV_JSON_CONNECTION
61500 /* Next array element */
61501 field_addr.sub_location->number = i;
61502#endif /* FREECIV_JSON_CONNECTION */
61503
61504 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_pickable[i])) {
61505 RECEIVE_PACKET_FIELD_ERROR(is_pickable);
61506 }
61507 }
61508
61509#ifdef FREECIV_JSON_CONNECTION
61510 /* Exit array. */
61511 FC_FREE(field_addr.sub_location);
61512#endif /* FREECIV_JSON_CONNECTION */
61513 }
61514
61515#ifdef FREECIV_JSON_CONNECTION
61516 field_addr.name = "nationset_change";
61517#endif /* FREECIV_JSON_CONNECTION */
61518
61519 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->nationset_change)) {
61520 RECEIVE_PACKET_FIELD_ERROR(nationset_change);
61521 }
61522#endif /* FREECIV_DELTA_PROTOCOL */
61523
61524 RECEIVE_PACKET_END(real_packet);
61525#undef FREE_PACKET_STRUCT
61526}
61527
61528 static int send_packet_nation_availability_100(struct connection *pc, const struct packet_nation_availability *packet)
61529{
61530 const struct packet_nation_availability *real_packet = packet;
61531 int e;
61532 SEND_PACKET_START(PACKET_NATION_AVAILABILITY);
61533
61534 log_packet_detailed("packet_nation_availability_100: sending info about ()");
61535
61536#ifdef FREECIV_DELTA_PROTOCOL
61537 packet_nation_availability_100_fields fields;
61538 struct packet_nation_availability *old;
61539 bool differ;
61540 struct genhash **hash = pc->phs.sent + PACKET_NATION_AVAILABILITY;
61541
61542 if (nullptr == *hash) {
61543 *hash = genhash_new_full(hash_packet_nation_availability_100, cmp_packet_nation_availability_100,
61544 nullptr, nullptr, nullptr, destroy_packet_nation_availability);
61545 }
61546 BV_CLR_ALL(fields);
61547
61548 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
61549 old = fc_malloc(sizeof(*old));
61550 /* temporary bitcopy just to insert correctly */
61551 *old = *real_packet;
61552 genhash_insert(*hash, old, old);
61553 init_packet_nation_availability(old);
61554 }
61555
61556 differ = (old->ncount != real_packet->ncount);
61557 if (differ) {
61558 BV_SET(fields, 0);
61559 }
61560
61561 differ = (old->ncount != real_packet->ncount);
61562 if (!differ) {
61563 int i;
61564
61565 for (i = 0; i < old->ncount; i++) {
61566 differ = (old->is_pickable[i] != real_packet->is_pickable[i]);
61567 if (differ) {
61568 break;
61569 }
61570 }
61571 }
61572 if (differ) {
61573 BV_SET(fields, 1);
61574 }
61575
61576 /* folded into head */
61577 if (real_packet->nationset_change) {
61578 BV_SET(fields, 2);
61579 }
61580#endif /* FREECIV_DELTA_PROTOCOL */
61581
61582#ifdef FREECIV_JSON_CONNECTION
61583 struct plocation field_addr;
61584 {
61585 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
61586 field_addr = *field_addr_tmp;
61587 FC_FREE(field_addr_tmp);
61588 }
61589#endif /* FREECIV_JSON_CONNECTION */
61590
61591#ifdef FREECIV_DELTA_PROTOCOL
61592#ifdef FREECIV_JSON_CONNECTION
61593 field_addr.name = "fields";
61594#endif /* FREECIV_JSON_CONNECTION */
61595 e = 0;
61596 e |= DIO_BV_PUT(&dout, &field_addr, fields);
61597 if (e) {
61598 log_packet_detailed("fields bitvector error detected");
61599 }
61600
61601 if (BV_ISSET(fields, 0)) {
61602 log_packet_detailed(" field 'ncount' has changed");
61603
61604#ifdef FREECIV_JSON_CONNECTION
61605 field_addr.name = "ncount";
61606#endif /* FREECIV_JSON_CONNECTION */
61607 e = 0;
61608
61609 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->ncount);
61610
61611 if (e) {
61612 log_packet_detailed("'ncount' field error detected");
61613 }
61614 }
61615
61616 if (BV_ISSET(fields, 1)) {
61617 log_packet_detailed(" field 'is_pickable' has changed");
61618
61619#ifdef FREECIV_JSON_CONNECTION
61620 field_addr.name = "is_pickable";
61621#endif /* FREECIV_JSON_CONNECTION */
61622 e = 0;
61623
61624 {
61625 int i;
61626
61627#ifdef FREECIV_JSON_CONNECTION
61628 /* Create the array. */
61629 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ncount);
61630
61631 /* Enter array. */
61632 field_addr.sub_location = plocation_elem_new(0);
61633#endif /* FREECIV_JSON_CONNECTION */
61634
61635 for (i = 0; i < real_packet->ncount; i++) {
61636#ifdef FREECIV_JSON_CONNECTION
61637 /* Next array element. */
61638 field_addr.sub_location->number = i;
61639#endif /* FREECIV_JSON_CONNECTION */
61640
61641 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_pickable[i]);
61642 }
61643
61644#ifdef FREECIV_JSON_CONNECTION
61645 /* Exit array. */
61646 FC_FREE(field_addr.sub_location);
61647#endif /* FREECIV_JSON_CONNECTION */
61648 }
61649
61650 if (e) {
61651 log_packet_detailed("'is_pickable' field error detected");
61652 }
61653 }
61654
61655 /* field 2 is folded into the header */
61656
61657 *old = *real_packet;
61658
61659#else /* FREECIV_DELTA_PROTOCOL */
61660#ifdef FREECIV_JSON_CONNECTION
61661 field_addr.name = "ncount";
61662#endif /* FREECIV_JSON_CONNECTION */
61663 e = 0;
61664
61665 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->ncount);
61666
61667 if (e) {
61668 log_packet_detailed("'ncount' field error detected");
61669 }
61670
61671#ifdef FREECIV_JSON_CONNECTION
61672 field_addr.name = "is_pickable";
61673#endif /* FREECIV_JSON_CONNECTION */
61674 e = 0;
61675
61676 {
61677 int i;
61678
61679#ifdef FREECIV_JSON_CONNECTION
61680 /* Create the array. */
61681 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ncount);
61682
61683 /* Enter array. */
61684 field_addr.sub_location = plocation_elem_new(0);
61685#endif /* FREECIV_JSON_CONNECTION */
61686
61687 for (i = 0; i < real_packet->ncount; i++) {
61688#ifdef FREECIV_JSON_CONNECTION
61689 /* Next array element. */
61690 field_addr.sub_location->number = i;
61691#endif /* FREECIV_JSON_CONNECTION */
61692
61693 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_pickable[i]);
61694 }
61695
61696#ifdef FREECIV_JSON_CONNECTION
61697 /* Exit array. */
61698 FC_FREE(field_addr.sub_location);
61699#endif /* FREECIV_JSON_CONNECTION */
61700 }
61701
61702 if (e) {
61703 log_packet_detailed("'is_pickable' field error detected");
61704 }
61705
61706#ifdef FREECIV_JSON_CONNECTION
61707 field_addr.name = "nationset_change";
61708#endif /* FREECIV_JSON_CONNECTION */
61709 e = 0;
61710
61711 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->nationset_change);
61712
61713 if (e) {
61714 log_packet_detailed("'nationset_change' field error detected");
61715 }
61716#endif /* FREECIV_DELTA_PROTOCOL */
61717
61718 SEND_PACKET_END(PACKET_NATION_AVAILABILITY);
61719}
61720
61721 int send_packet_nation_availability(struct connection *pc, const struct packet_nation_availability *packet)
61722{
61723 if (!pc->used) {
61724 log_error("WARNING: trying to send data to the closed connection %s",
61725 conn_description(pc));
61726 return -1;
61727 }
61728 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_NATION_AVAILABILITY].packet != nullptr, -1,
61729 "Handler for PACKET_NATION_AVAILABILITY not installed");
61730 return pc->phs.handlers->send[PACKET_NATION_AVAILABILITY].packet(pc, packet);
61731}
61732
61733 void lsend_packet_nation_availability(struct conn_list *dest, const struct packet_nation_availability *packet)
61734{
61735 conn_list_iterate(dest, pconn) {
61736 send_packet_nation_availability(pconn, packet);
61737 } conn_list_iterate_end;
61738}
61739
61740 static inline void init_packet_ruleset_style(struct packet_ruleset_style *packet)
61741{
61742 memset(packet, 0, sizeof(*packet));
61743}
61744
61745#define free_packet_ruleset_style(_packet) (void) 0
61746#define destroy_packet_ruleset_style free
61747
61748#ifdef FREECIV_DELTA_PROTOCOL
61749#define hash_packet_ruleset_style_100 hash_const
61750#define cmp_packet_ruleset_style_100 cmp_const
61751 BV_DEFINE(packet_ruleset_style_100_fields, 3);
61752#endif /* FREECIV_DELTA_PROTOCOL */
61753
61754 static struct packet_ruleset_style *receive_packet_ruleset_style_100(struct connection *pc)
61755{
61756#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_style(_packet)
61757 RECEIVE_PACKET_START(packet_ruleset_style, real_packet);
61758
61759#ifdef FREECIV_JSON_CONNECTION
61760 struct plocation field_addr;
61761 {
61762 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
61763 field_addr = *field_addr_tmp;
61764 FC_FREE(field_addr_tmp);
61765 }
61766#endif /* FREECIV_JSON_CONNECTION */
61767
61768 log_packet_detailed("packet_ruleset_style_100: got info about ()");
61769
61770#ifdef FREECIV_DELTA_PROTOCOL
61771 packet_ruleset_style_100_fields fields;
61772 struct packet_ruleset_style *old;
61773 struct genhash **hash = pc->phs.received + PACKET_RULESET_STYLE;
61774
61775 if (nullptr == *hash) {
61776 *hash = genhash_new_full(hash_packet_ruleset_style_100, cmp_packet_ruleset_style_100,
61777 nullptr, nullptr, nullptr, destroy_packet_ruleset_style);
61778 }
61779
61780 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
61781 *real_packet = *old;
61782 } else {
61783 /* packet is already initialized empty */
61784 log_packet_detailed(" no old info");
61785 }
61786
61787#ifdef FREECIV_JSON_CONNECTION
61788 field_addr.name = "fields";
61789#endif /* FREECIV_JSON_CONNECTION */
61790 DIO_BV_GET(&din, &field_addr, fields);
61791
61792 if (BV_ISSET(fields, 0)) {
61793 log_packet_detailed(" got field 'id'");
61794
61795#ifdef FREECIV_JSON_CONNECTION
61796 field_addr.name = "id";
61797#endif /* FREECIV_JSON_CONNECTION */
61798
61799 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
61800 RECEIVE_PACKET_FIELD_ERROR(id);
61801 }
61802 }
61803
61804 if (BV_ISSET(fields, 1)) {
61805 log_packet_detailed(" got field 'name'");
61806
61807#ifdef FREECIV_JSON_CONNECTION
61808 field_addr.name = "name";
61809#endif /* FREECIV_JSON_CONNECTION */
61810
61811 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
61812 RECEIVE_PACKET_FIELD_ERROR(name);
61813 }
61814 }
61815
61816 if (BV_ISSET(fields, 2)) {
61817 log_packet_detailed(" got field 'rule_name'");
61818
61819#ifdef FREECIV_JSON_CONNECTION
61820 field_addr.name = "rule_name";
61821#endif /* FREECIV_JSON_CONNECTION */
61822
61823 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
61824 RECEIVE_PACKET_FIELD_ERROR(rule_name);
61825 }
61826 }
61827
61828 if (nullptr == old) {
61829 old = fc_malloc(sizeof(*old));
61830 init_packet_ruleset_style(old);
61831 *old = *real_packet;
61832 genhash_insert(*hash, old, old);
61833 } else {
61834 *old = *real_packet;
61835 }
61836
61837#else /* FREECIV_DELTA_PROTOCOL */
61838#ifdef FREECIV_JSON_CONNECTION
61839 field_addr.name = "id";
61840#endif /* FREECIV_JSON_CONNECTION */
61841
61842 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
61843 RECEIVE_PACKET_FIELD_ERROR(id);
61844 }
61845
61846#ifdef FREECIV_JSON_CONNECTION
61847 field_addr.name = "name";
61848#endif /* FREECIV_JSON_CONNECTION */
61849
61850 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
61851 RECEIVE_PACKET_FIELD_ERROR(name);
61852 }
61853
61854#ifdef FREECIV_JSON_CONNECTION
61855 field_addr.name = "rule_name";
61856#endif /* FREECIV_JSON_CONNECTION */
61857
61858 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
61859 RECEIVE_PACKET_FIELD_ERROR(rule_name);
61860 }
61861#endif /* FREECIV_DELTA_PROTOCOL */
61862
61863 RECEIVE_PACKET_END(real_packet);
61864#undef FREE_PACKET_STRUCT
61865}
61866
61867 static int send_packet_ruleset_style_100(struct connection *pc, const struct packet_ruleset_style *packet)
61868{
61869 const struct packet_ruleset_style *real_packet = packet;
61870 int e;
61871 SEND_PACKET_START(PACKET_RULESET_STYLE);
61872
61873 log_packet_detailed("packet_ruleset_style_100: sending info about ()");
61874
61875#ifdef FREECIV_DELTA_PROTOCOL
61876 packet_ruleset_style_100_fields fields;
61877 struct packet_ruleset_style *old;
61878 bool differ;
61879 struct genhash **hash = pc->phs.sent + PACKET_RULESET_STYLE;
61880
61881 if (nullptr == *hash) {
61882 *hash = genhash_new_full(hash_packet_ruleset_style_100, cmp_packet_ruleset_style_100,
61883 nullptr, nullptr, nullptr, destroy_packet_ruleset_style);
61884 }
61885 BV_CLR_ALL(fields);
61886
61887 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
61888 old = fc_malloc(sizeof(*old));
61889 /* temporary bitcopy just to insert correctly */
61890 *old = *real_packet;
61891 genhash_insert(*hash, old, old);
61892 init_packet_ruleset_style(old);
61893 }
61894
61895 differ = (old->id != real_packet->id);
61896 if (differ) {
61897 BV_SET(fields, 0);
61898 }
61899
61900 differ = (strcmp(old->name, real_packet->name) != 0);
61901 if (differ) {
61902 BV_SET(fields, 1);
61903 }
61904
61905 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
61906 if (differ) {
61907 BV_SET(fields, 2);
61908 }
61909#endif /* FREECIV_DELTA_PROTOCOL */
61910
61911#ifdef FREECIV_JSON_CONNECTION
61912 struct plocation field_addr;
61913 {
61914 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
61915 field_addr = *field_addr_tmp;
61916 FC_FREE(field_addr_tmp);
61917 }
61918#endif /* FREECIV_JSON_CONNECTION */
61919
61920#ifdef FREECIV_DELTA_PROTOCOL
61921#ifdef FREECIV_JSON_CONNECTION
61922 field_addr.name = "fields";
61923#endif /* FREECIV_JSON_CONNECTION */
61924 e = 0;
61925 e |= DIO_BV_PUT(&dout, &field_addr, fields);
61926 if (e) {
61927 log_packet_detailed("fields bitvector error detected");
61928 }
61929
61930 if (BV_ISSET(fields, 0)) {
61931 log_packet_detailed(" field 'id' has changed");
61932
61933#ifdef FREECIV_JSON_CONNECTION
61934 field_addr.name = "id";
61935#endif /* FREECIV_JSON_CONNECTION */
61936 e = 0;
61937
61938 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
61939
61940 if (e) {
61941 log_packet_detailed("'id' field error detected");
61942 }
61943 }
61944
61945 if (BV_ISSET(fields, 1)) {
61946 log_packet_detailed(" field 'name' has changed");
61947
61948#ifdef FREECIV_JSON_CONNECTION
61949 field_addr.name = "name";
61950#endif /* FREECIV_JSON_CONNECTION */
61951 e = 0;
61952
61953 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
61954
61955 if (e) {
61956 log_packet_detailed("'name' field error detected");
61957 }
61958 }
61959
61960 if (BV_ISSET(fields, 2)) {
61961 log_packet_detailed(" field 'rule_name' has changed");
61962
61963#ifdef FREECIV_JSON_CONNECTION
61964 field_addr.name = "rule_name";
61965#endif /* FREECIV_JSON_CONNECTION */
61966 e = 0;
61967
61968 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
61969
61970 if (e) {
61971 log_packet_detailed("'rule_name' field error detected");
61972 }
61973 }
61974
61975 *old = *real_packet;
61976
61977#else /* FREECIV_DELTA_PROTOCOL */
61978#ifdef FREECIV_JSON_CONNECTION
61979 field_addr.name = "id";
61980#endif /* FREECIV_JSON_CONNECTION */
61981 e = 0;
61982
61983 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
61984
61985 if (e) {
61986 log_packet_detailed("'id' field error detected");
61987 }
61988
61989#ifdef FREECIV_JSON_CONNECTION
61990 field_addr.name = "name";
61991#endif /* FREECIV_JSON_CONNECTION */
61992 e = 0;
61993
61994 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
61995
61996 if (e) {
61997 log_packet_detailed("'name' field error detected");
61998 }
61999
62000#ifdef FREECIV_JSON_CONNECTION
62001 field_addr.name = "rule_name";
62002#endif /* FREECIV_JSON_CONNECTION */
62003 e = 0;
62004
62005 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
62006
62007 if (e) {
62008 log_packet_detailed("'rule_name' field error detected");
62009 }
62010#endif /* FREECIV_DELTA_PROTOCOL */
62011
62012 SEND_PACKET_END(PACKET_RULESET_STYLE);
62013}
62014
62015 int send_packet_ruleset_style(struct connection *pc, const struct packet_ruleset_style *packet)
62016{
62017 if (!pc->used) {
62018 log_error("WARNING: trying to send data to the closed connection %s",
62019 conn_description(pc));
62020 return -1;
62021 }
62022 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_STYLE].packet != nullptr, -1,
62023 "Handler for PACKET_RULESET_STYLE not installed");
62024 return pc->phs.handlers->send[PACKET_RULESET_STYLE].packet(pc, packet);
62025}
62026
62027 void lsend_packet_ruleset_style(struct conn_list *dest, const struct packet_ruleset_style *packet)
62028{
62029 conn_list_iterate(dest, pconn) {
62030 send_packet_ruleset_style(pconn, packet);
62031 } conn_list_iterate_end;
62032}
62033
62034 static inline void init_packet_ruleset_city(struct packet_ruleset_city *packet)
62035{
62036 memset(packet, 0, sizeof(*packet));
62037
62038 requirement_vector_init(&packet->reqs);
62039}
62040
62041 static inline void free_packet_ruleset_city(struct packet_ruleset_city *packet)
62042{
62043 requirement_vector_free(&packet->reqs);
62044}
62045
62046 static inline void destroy_packet_ruleset_city(void *packet)
62047{
62048 free_packet_ruleset_city((struct packet_ruleset_city *) packet);
62049 free(packet);
62050}
62051
62052#ifdef FREECIV_DELTA_PROTOCOL
62053#define hash_packet_ruleset_city_100 hash_const
62054#define cmp_packet_ruleset_city_100 cmp_const
62055 BV_DEFINE(packet_ruleset_city_100_fields, 7);
62056#endif /* FREECIV_DELTA_PROTOCOL */
62057
62058 static struct packet_ruleset_city *receive_packet_ruleset_city_100(struct connection *pc)
62059{
62060#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_city(_packet)
62061 RECEIVE_PACKET_START(packet_ruleset_city, real_packet);
62062
62063#ifdef FREECIV_JSON_CONNECTION
62064 struct plocation field_addr;
62065 {
62066 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
62067 field_addr = *field_addr_tmp;
62068 FC_FREE(field_addr_tmp);
62069 }
62070#endif /* FREECIV_JSON_CONNECTION */
62071
62072 log_packet_detailed("packet_ruleset_city_100: got info about ()");
62073
62074#ifdef FREECIV_DELTA_PROTOCOL
62075 packet_ruleset_city_100_fields fields;
62076 struct packet_ruleset_city *old;
62077 struct genhash **hash = pc->phs.received + PACKET_RULESET_CITY;
62078
62079 if (nullptr == *hash) {
62080 *hash = genhash_new_full(hash_packet_ruleset_city_100, cmp_packet_ruleset_city_100,
62081 nullptr, nullptr, nullptr, destroy_packet_ruleset_city);
62082 }
62083
62084 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
62085 real_packet->style_id = old->style_id;
62086 sz_strlcpy(real_packet->name, old->name);
62087 sz_strlcpy(real_packet->rule_name, old->rule_name);
62088 sz_strlcpy(real_packet->citizens_graphic, old->citizens_graphic);
62089 requirement_vector_copy(&real_packet->reqs, &old->reqs);
62090 sz_strlcpy(real_packet->graphic, old->graphic);
62091 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
62092 } else {
62093 /* packet is already initialized empty */
62094 log_packet_detailed(" no old info");
62095 }
62096
62097#ifdef FREECIV_JSON_CONNECTION
62098 field_addr.name = "fields";
62099#endif /* FREECIV_JSON_CONNECTION */
62100 DIO_BV_GET(&din, &field_addr, fields);
62101
62102 if (BV_ISSET(fields, 0)) {
62103 log_packet_detailed(" got field 'style_id'");
62104
62105#ifdef FREECIV_JSON_CONNECTION
62106 field_addr.name = "style_id";
62107#endif /* FREECIV_JSON_CONNECTION */
62108
62109 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style_id)) {
62110 RECEIVE_PACKET_FIELD_ERROR(style_id);
62111 }
62112 }
62113
62114 if (BV_ISSET(fields, 1)) {
62115 log_packet_detailed(" got field 'name'");
62116
62117#ifdef FREECIV_JSON_CONNECTION
62118 field_addr.name = "name";
62119#endif /* FREECIV_JSON_CONNECTION */
62120
62121 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
62122 RECEIVE_PACKET_FIELD_ERROR(name);
62123 }
62124 }
62125
62126 if (BV_ISSET(fields, 2)) {
62127 log_packet_detailed(" got field 'rule_name'");
62128
62129#ifdef FREECIV_JSON_CONNECTION
62130 field_addr.name = "rule_name";
62131#endif /* FREECIV_JSON_CONNECTION */
62132
62133 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
62134 RECEIVE_PACKET_FIELD_ERROR(rule_name);
62135 }
62136 }
62137
62138 if (BV_ISSET(fields, 3)) {
62139 log_packet_detailed(" got field 'citizens_graphic'");
62140
62141#ifdef FREECIV_JSON_CONNECTION
62142 field_addr.name = "citizens_graphic";
62143#endif /* FREECIV_JSON_CONNECTION */
62144
62145 if (!DIO_GET(string, &din, &field_addr, real_packet->citizens_graphic, sizeof(real_packet->citizens_graphic))) {
62146 RECEIVE_PACKET_FIELD_ERROR(citizens_graphic);
62147 }
62148 }
62149
62150 if (BV_ISSET(fields, 4)) {
62151 log_packet_detailed(" got field 'reqs'");
62152
62153#ifdef FREECIV_JSON_CONNECTION
62154 field_addr.name = "reqs";
62155#endif /* FREECIV_JSON_CONNECTION */
62156
62157 {
62158 int i;
62159
62160 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
62161 RECEIVE_PACKET_FIELD_ERROR(reqs);
62162 }
62163 requirement_vector_reserve(&real_packet->reqs, i);
62164
62165#ifdef FREECIV_JSON_CONNECTION
62166 /* Enter array. */
62167 field_addr.sub_location = plocation_elem_new(0);
62168#endif /* FREECIV_JSON_CONNECTION */
62169
62170 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
62171#ifdef FREECIV_JSON_CONNECTION
62172 /* Next array element */
62173 field_addr.sub_location->number = i;
62174#endif /* FREECIV_JSON_CONNECTION */
62175
62176 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
62177 RECEIVE_PACKET_FIELD_ERROR(reqs);
62178 }
62179 }
62180
62181#ifdef FREECIV_JSON_CONNECTION
62182 /* Exit array. */
62183 FC_FREE(field_addr.sub_location);
62184#endif /* FREECIV_JSON_CONNECTION */
62185 }
62186 }
62187
62188 if (BV_ISSET(fields, 5)) {
62189 log_packet_detailed(" got field 'graphic'");
62190
62191#ifdef FREECIV_JSON_CONNECTION
62192 field_addr.name = "graphic";
62193#endif /* FREECIV_JSON_CONNECTION */
62194
62195 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic, sizeof(real_packet->graphic))) {
62196 RECEIVE_PACKET_FIELD_ERROR(graphic);
62197 }
62198 }
62199
62200 if (BV_ISSET(fields, 6)) {
62201 log_packet_detailed(" got field 'graphic_alt'");
62202
62203#ifdef FREECIV_JSON_CONNECTION
62204 field_addr.name = "graphic_alt";
62205#endif /* FREECIV_JSON_CONNECTION */
62206
62207 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
62208 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
62209 }
62210 }
62211
62212 if (nullptr == old) {
62213 old = fc_malloc(sizeof(*old));
62214 init_packet_ruleset_city(old);
62215 old->style_id = real_packet->style_id;
62216 sz_strlcpy(old->name, real_packet->name);
62217 sz_strlcpy(old->rule_name, real_packet->rule_name);
62218 sz_strlcpy(old->citizens_graphic, real_packet->citizens_graphic);
62219 requirement_vector_copy(&old->reqs, &real_packet->reqs);
62220 sz_strlcpy(old->graphic, real_packet->graphic);
62221 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
62222 genhash_insert(*hash, old, old);
62223 } else {
62224 old->style_id = real_packet->style_id;
62225 sz_strlcpy(old->name, real_packet->name);
62226 sz_strlcpy(old->rule_name, real_packet->rule_name);
62227 sz_strlcpy(old->citizens_graphic, real_packet->citizens_graphic);
62228 requirement_vector_copy(&old->reqs, &real_packet->reqs);
62229 sz_strlcpy(old->graphic, real_packet->graphic);
62230 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
62231 }
62232
62233#else /* FREECIV_DELTA_PROTOCOL */
62234#ifdef FREECIV_JSON_CONNECTION
62235 field_addr.name = "style_id";
62236#endif /* FREECIV_JSON_CONNECTION */
62237
62238 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->style_id)) {
62239 RECEIVE_PACKET_FIELD_ERROR(style_id);
62240 }
62241
62242#ifdef FREECIV_JSON_CONNECTION
62243 field_addr.name = "name";
62244#endif /* FREECIV_JSON_CONNECTION */
62245
62246 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
62247 RECEIVE_PACKET_FIELD_ERROR(name);
62248 }
62249
62250#ifdef FREECIV_JSON_CONNECTION
62251 field_addr.name = "rule_name";
62252#endif /* FREECIV_JSON_CONNECTION */
62253
62254 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
62255 RECEIVE_PACKET_FIELD_ERROR(rule_name);
62256 }
62257
62258#ifdef FREECIV_JSON_CONNECTION
62259 field_addr.name = "citizens_graphic";
62260#endif /* FREECIV_JSON_CONNECTION */
62261
62262 if (!DIO_GET(string, &din, &field_addr, real_packet->citizens_graphic, sizeof(real_packet->citizens_graphic))) {
62263 RECEIVE_PACKET_FIELD_ERROR(citizens_graphic);
62264 }
62265
62266#ifdef FREECIV_JSON_CONNECTION
62267 field_addr.name = "reqs";
62268#endif /* FREECIV_JSON_CONNECTION */
62269
62270 {
62271 int i;
62272
62273 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
62274 RECEIVE_PACKET_FIELD_ERROR(reqs);
62275 }
62276 requirement_vector_reserve(&real_packet->reqs, i);
62277
62278#ifdef FREECIV_JSON_CONNECTION
62279 /* Enter array. */
62280 field_addr.sub_location = plocation_elem_new(0);
62281#endif /* FREECIV_JSON_CONNECTION */
62282
62283 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
62284#ifdef FREECIV_JSON_CONNECTION
62285 /* Next array element */
62286 field_addr.sub_location->number = i;
62287#endif /* FREECIV_JSON_CONNECTION */
62288
62289 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
62290 RECEIVE_PACKET_FIELD_ERROR(reqs);
62291 }
62292 }
62293
62294#ifdef FREECIV_JSON_CONNECTION
62295 /* Exit array. */
62296 FC_FREE(field_addr.sub_location);
62297#endif /* FREECIV_JSON_CONNECTION */
62298 }
62299
62300#ifdef FREECIV_JSON_CONNECTION
62301 field_addr.name = "graphic";
62302#endif /* FREECIV_JSON_CONNECTION */
62303
62304 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic, sizeof(real_packet->graphic))) {
62305 RECEIVE_PACKET_FIELD_ERROR(graphic);
62306 }
62307
62308#ifdef FREECIV_JSON_CONNECTION
62309 field_addr.name = "graphic_alt";
62310#endif /* FREECIV_JSON_CONNECTION */
62311
62312 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
62313 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
62314 }
62315#endif /* FREECIV_DELTA_PROTOCOL */
62316
62317 RECEIVE_PACKET_END(real_packet);
62318#undef FREE_PACKET_STRUCT
62319}
62320
62321 static int send_packet_ruleset_city_100(struct connection *pc, const struct packet_ruleset_city *packet)
62322{
62323 const struct packet_ruleset_city *real_packet = packet;
62324 int e;
62325 SEND_PACKET_START(PACKET_RULESET_CITY);
62326
62327 log_packet_detailed("packet_ruleset_city_100: sending info about ()");
62328
62329#ifdef FREECIV_DELTA_PROTOCOL
62330 packet_ruleset_city_100_fields fields;
62331 struct packet_ruleset_city *old;
62332 bool differ;
62333 struct genhash **hash = pc->phs.sent + PACKET_RULESET_CITY;
62334
62335 if (nullptr == *hash) {
62336 *hash = genhash_new_full(hash_packet_ruleset_city_100, cmp_packet_ruleset_city_100,
62337 nullptr, nullptr, nullptr, destroy_packet_ruleset_city);
62338 }
62339 BV_CLR_ALL(fields);
62340
62341 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
62342 old = fc_malloc(sizeof(*old));
62343 /* temporary bitcopy just to insert correctly */
62344 *old = *real_packet;
62345 genhash_insert(*hash, old, old);
62346 init_packet_ruleset_city(old);
62347 }
62348
62349 differ = (old->style_id != real_packet->style_id);
62350 if (differ) {
62351 BV_SET(fields, 0);
62352 }
62353
62354 differ = (strcmp(old->name, real_packet->name) != 0);
62355 if (differ) {
62356 BV_SET(fields, 1);
62357 }
62358
62359 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
62360 if (differ) {
62361 BV_SET(fields, 2);
62362 }
62363
62364 differ = (strcmp(old->citizens_graphic, real_packet->citizens_graphic) != 0);
62365 if (differ) {
62366 BV_SET(fields, 3);
62367 }
62368
62369 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
62370 if (!differ) {
62371 int i;
62372
62373 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
62374 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
62375 if (differ) {
62376 break;
62377 }
62378 }
62379 }
62380 if (differ) {
62381 BV_SET(fields, 4);
62382 }
62383
62384 differ = (strcmp(old->graphic, real_packet->graphic) != 0);
62385 if (differ) {
62386 BV_SET(fields, 5);
62387 }
62388
62389 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
62390 if (differ) {
62391 BV_SET(fields, 6);
62392 }
62393#endif /* FREECIV_DELTA_PROTOCOL */
62394
62395#ifdef FREECIV_JSON_CONNECTION
62396 struct plocation field_addr;
62397 {
62398 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
62399 field_addr = *field_addr_tmp;
62400 FC_FREE(field_addr_tmp);
62401 }
62402#endif /* FREECIV_JSON_CONNECTION */
62403
62404#ifdef FREECIV_DELTA_PROTOCOL
62405#ifdef FREECIV_JSON_CONNECTION
62406 field_addr.name = "fields";
62407#endif /* FREECIV_JSON_CONNECTION */
62408 e = 0;
62409 e |= DIO_BV_PUT(&dout, &field_addr, fields);
62410 if (e) {
62411 log_packet_detailed("fields bitvector error detected");
62412 }
62413
62414 if (BV_ISSET(fields, 0)) {
62415 log_packet_detailed(" field 'style_id' has changed");
62416
62417#ifdef FREECIV_JSON_CONNECTION
62418 field_addr.name = "style_id";
62419#endif /* FREECIV_JSON_CONNECTION */
62420 e = 0;
62421
62422 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style_id);
62423
62424 if (e) {
62425 log_packet_detailed("'style_id' field error detected");
62426 }
62427 }
62428
62429 if (BV_ISSET(fields, 1)) {
62430 log_packet_detailed(" field 'name' has changed");
62431
62432#ifdef FREECIV_JSON_CONNECTION
62433 field_addr.name = "name";
62434#endif /* FREECIV_JSON_CONNECTION */
62435 e = 0;
62436
62437 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
62438
62439 if (e) {
62440 log_packet_detailed("'name' field error detected");
62441 }
62442 }
62443
62444 if (BV_ISSET(fields, 2)) {
62445 log_packet_detailed(" field 'rule_name' has changed");
62446
62447#ifdef FREECIV_JSON_CONNECTION
62448 field_addr.name = "rule_name";
62449#endif /* FREECIV_JSON_CONNECTION */
62450 e = 0;
62451
62452 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
62453
62454 if (e) {
62455 log_packet_detailed("'rule_name' field error detected");
62456 }
62457 }
62458
62459 if (BV_ISSET(fields, 3)) {
62460 log_packet_detailed(" field 'citizens_graphic' has changed");
62461
62462#ifdef FREECIV_JSON_CONNECTION
62463 field_addr.name = "citizens_graphic";
62464#endif /* FREECIV_JSON_CONNECTION */
62465 e = 0;
62466
62467 e |= DIO_PUT(string, &dout, &field_addr, real_packet->citizens_graphic);
62468
62469 if (e) {
62470 log_packet_detailed("'citizens_graphic' field error detected");
62471 }
62472 }
62473
62474 if (BV_ISSET(fields, 4)) {
62475 log_packet_detailed(" field 'reqs' has changed");
62476
62477#ifdef FREECIV_JSON_CONNECTION
62478 field_addr.name = "reqs";
62479#endif /* FREECIV_JSON_CONNECTION */
62480 e = 0;
62481
62482 {
62483 int i;
62484
62485 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
62486 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
62487
62488#ifdef FREECIV_JSON_CONNECTION
62489 /* Enter array. */
62490 field_addr.sub_location = plocation_elem_new(0);
62491#endif /* FREECIV_JSON_CONNECTION */
62492
62493 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
62494#ifdef FREECIV_JSON_CONNECTION
62495 /* Next array element. */
62496 field_addr.sub_location->number = i;
62497#endif /* FREECIV_JSON_CONNECTION */
62498
62499 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
62500 }
62501
62502#ifdef FREECIV_JSON_CONNECTION
62503 /* Exit array. */
62504 FC_FREE(field_addr.sub_location);
62505#endif /* FREECIV_JSON_CONNECTION */
62506 }
62507
62508 if (e) {
62509 log_packet_detailed("'reqs' field error detected");
62510 }
62511 }
62512
62513 if (BV_ISSET(fields, 5)) {
62514 log_packet_detailed(" field 'graphic' has changed");
62515
62516#ifdef FREECIV_JSON_CONNECTION
62517 field_addr.name = "graphic";
62518#endif /* FREECIV_JSON_CONNECTION */
62519 e = 0;
62520
62521 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic);
62522
62523 if (e) {
62524 log_packet_detailed("'graphic' field error detected");
62525 }
62526 }
62527
62528 if (BV_ISSET(fields, 6)) {
62529 log_packet_detailed(" field 'graphic_alt' has changed");
62530
62531#ifdef FREECIV_JSON_CONNECTION
62532 field_addr.name = "graphic_alt";
62533#endif /* FREECIV_JSON_CONNECTION */
62534 e = 0;
62535
62536 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
62537
62538 if (e) {
62539 log_packet_detailed("'graphic_alt' field error detected");
62540 }
62541 }
62542
62543 old->style_id = real_packet->style_id;
62544 sz_strlcpy(old->name, real_packet->name);
62545 sz_strlcpy(old->rule_name, real_packet->rule_name);
62546 sz_strlcpy(old->citizens_graphic, real_packet->citizens_graphic);
62547 requirement_vector_copy(&old->reqs, &real_packet->reqs);
62548 sz_strlcpy(old->graphic, real_packet->graphic);
62549 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
62550
62551#else /* FREECIV_DELTA_PROTOCOL */
62552#ifdef FREECIV_JSON_CONNECTION
62553 field_addr.name = "style_id";
62554#endif /* FREECIV_JSON_CONNECTION */
62555 e = 0;
62556
62557 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->style_id);
62558
62559 if (e) {
62560 log_packet_detailed("'style_id' field error detected");
62561 }
62562
62563#ifdef FREECIV_JSON_CONNECTION
62564 field_addr.name = "name";
62565#endif /* FREECIV_JSON_CONNECTION */
62566 e = 0;
62567
62568 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
62569
62570 if (e) {
62571 log_packet_detailed("'name' field error detected");
62572 }
62573
62574#ifdef FREECIV_JSON_CONNECTION
62575 field_addr.name = "rule_name";
62576#endif /* FREECIV_JSON_CONNECTION */
62577 e = 0;
62578
62579 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
62580
62581 if (e) {
62582 log_packet_detailed("'rule_name' field error detected");
62583 }
62584
62585#ifdef FREECIV_JSON_CONNECTION
62586 field_addr.name = "citizens_graphic";
62587#endif /* FREECIV_JSON_CONNECTION */
62588 e = 0;
62589
62590 e |= DIO_PUT(string, &dout, &field_addr, real_packet->citizens_graphic);
62591
62592 if (e) {
62593 log_packet_detailed("'citizens_graphic' field error detected");
62594 }
62595
62596#ifdef FREECIV_JSON_CONNECTION
62597 field_addr.name = "reqs";
62598#endif /* FREECIV_JSON_CONNECTION */
62599 e = 0;
62600
62601 {
62602 int i;
62603
62604 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
62605 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
62606
62607#ifdef FREECIV_JSON_CONNECTION
62608 /* Enter array. */
62609 field_addr.sub_location = plocation_elem_new(0);
62610#endif /* FREECIV_JSON_CONNECTION */
62611
62612 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
62613#ifdef FREECIV_JSON_CONNECTION
62614 /* Next array element. */
62615 field_addr.sub_location->number = i;
62616#endif /* FREECIV_JSON_CONNECTION */
62617
62618 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
62619 }
62620
62621#ifdef FREECIV_JSON_CONNECTION
62622 /* Exit array. */
62623 FC_FREE(field_addr.sub_location);
62624#endif /* FREECIV_JSON_CONNECTION */
62625 }
62626
62627 if (e) {
62628 log_packet_detailed("'reqs' field error detected");
62629 }
62630
62631#ifdef FREECIV_JSON_CONNECTION
62632 field_addr.name = "graphic";
62633#endif /* FREECIV_JSON_CONNECTION */
62634 e = 0;
62635
62636 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic);
62637
62638 if (e) {
62639 log_packet_detailed("'graphic' field error detected");
62640 }
62641
62642#ifdef FREECIV_JSON_CONNECTION
62643 field_addr.name = "graphic_alt";
62644#endif /* FREECIV_JSON_CONNECTION */
62645 e = 0;
62646
62647 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
62648
62649 if (e) {
62650 log_packet_detailed("'graphic_alt' field error detected");
62651 }
62652#endif /* FREECIV_DELTA_PROTOCOL */
62653
62654 SEND_PACKET_END(PACKET_RULESET_CITY);
62655}
62656
62657 int send_packet_ruleset_city(struct connection *pc, const struct packet_ruleset_city *packet)
62658{
62659 if (!pc->used) {
62660 log_error("WARNING: trying to send data to the closed connection %s",
62661 conn_description(pc));
62662 return -1;
62663 }
62664 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CITY].packet != nullptr, -1,
62665 "Handler for PACKET_RULESET_CITY not installed");
62666 return pc->phs.handlers->send[PACKET_RULESET_CITY].packet(pc, packet);
62667}
62668
62669 void lsend_packet_ruleset_city(struct conn_list *dest, const struct packet_ruleset_city *packet)
62670{
62671 conn_list_iterate(dest, pconn) {
62672 send_packet_ruleset_city(pconn, packet);
62673 } conn_list_iterate_end;
62674}
62675
62676 static inline void init_packet_ruleset_building(struct packet_ruleset_building *packet)
62677{
62678 memset(packet, 0, sizeof(*packet));
62679
62680 requirement_vector_init(&packet->reqs);
62681 requirement_vector_init(&packet->obs_reqs);
62682 packet->helptext = strvec_new();
62683}
62684
62685 static inline void free_packet_ruleset_building(struct packet_ruleset_building *packet)
62686{
62687 if (packet->helptext) {
62688 strvec_destroy(packet->helptext);
62689 packet->helptext = nullptr;
62690 }
62691 requirement_vector_free(&packet->obs_reqs);
62692 requirement_vector_free(&packet->reqs);
62693}
62694
62695 static inline void destroy_packet_ruleset_building(void *packet)
62696{
62697 free_packet_ruleset_building((struct packet_ruleset_building *) packet);
62698 free(packet);
62699}
62700
62701#ifdef FREECIV_DELTA_PROTOCOL
62702#define hash_packet_ruleset_building_100 hash_const
62703#define cmp_packet_ruleset_building_100 cmp_const
62704 BV_DEFINE(packet_ruleset_building_100_fields, 17);
62705#endif /* FREECIV_DELTA_PROTOCOL */
62706
62707 static struct packet_ruleset_building *receive_packet_ruleset_building_100(struct connection *pc)
62708{
62709#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_building(_packet)
62710 RECEIVE_PACKET_START(packet_ruleset_building, real_packet);
62711
62712#ifdef FREECIV_JSON_CONNECTION
62713 struct plocation field_addr;
62714 {
62715 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
62716 field_addr = *field_addr_tmp;
62717 FC_FREE(field_addr_tmp);
62718 }
62719#endif /* FREECIV_JSON_CONNECTION */
62720
62721 log_packet_detailed("packet_ruleset_building_100: got info about ()");
62722
62723#ifdef FREECIV_DELTA_PROTOCOL
62724 packet_ruleset_building_100_fields fields;
62725 struct packet_ruleset_building *old;
62726 struct genhash **hash = pc->phs.received + PACKET_RULESET_BUILDING;
62727
62728 if (nullptr == *hash) {
62729 *hash = genhash_new_full(hash_packet_ruleset_building_100, cmp_packet_ruleset_building_100,
62730 nullptr, nullptr, nullptr, destroy_packet_ruleset_building);
62731 }
62732
62733 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
62734 real_packet->id = old->id;
62735 real_packet->genus = old->genus;
62736 sz_strlcpy(real_packet->name, old->name);
62737 sz_strlcpy(real_packet->rule_name, old->rule_name);
62738 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
62739 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
62740 sz_strlcpy(real_packet->graphic_alt2, old->graphic_alt2);
62741 requirement_vector_copy(&real_packet->reqs, &old->reqs);
62742 requirement_vector_copy(&real_packet->obs_reqs, &old->obs_reqs);
62743 real_packet->build_cost = old->build_cost;
62744 real_packet->upkeep = old->upkeep;
62745 real_packet->sabotage = old->sabotage;
62746 real_packet->flags = old->flags;
62747 sz_strlcpy(real_packet->soundtag, old->soundtag);
62748 sz_strlcpy(real_packet->soundtag_alt, old->soundtag_alt);
62749 sz_strlcpy(real_packet->soundtag_alt2, old->soundtag_alt2);
62750 if (old->helptext) {
62751 strvec_copy(real_packet->helptext, old->helptext);
62752 } else {
62753 strvec_clear(real_packet->helptext);
62754 }
62755 } else {
62756 /* packet is already initialized empty */
62757 log_packet_detailed(" no old info");
62758 }
62759
62760#ifdef FREECIV_JSON_CONNECTION
62761 field_addr.name = "fields";
62762#endif /* FREECIV_JSON_CONNECTION */
62763 DIO_BV_GET(&din, &field_addr, fields);
62764
62765 if (BV_ISSET(fields, 0)) {
62766 log_packet_detailed(" got field 'id'");
62767
62768#ifdef FREECIV_JSON_CONNECTION
62769 field_addr.name = "id";
62770#endif /* FREECIV_JSON_CONNECTION */
62771
62772 {
62773 int readin;
62774
62775 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
62776 RECEIVE_PACKET_FIELD_ERROR(id);
62777 }
62778 real_packet->id = readin;
62779 }
62780 }
62781
62782 if (BV_ISSET(fields, 1)) {
62783 log_packet_detailed(" got field 'genus'");
62784
62785#ifdef FREECIV_JSON_CONNECTION
62786 field_addr.name = "genus";
62787#endif /* FREECIV_JSON_CONNECTION */
62788
62789 {
62790 int readin;
62791
62792 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
62793 RECEIVE_PACKET_FIELD_ERROR(genus);
62794 }
62795 real_packet->genus = readin;
62796 }
62797 }
62798
62799 if (BV_ISSET(fields, 2)) {
62800 log_packet_detailed(" got field 'name'");
62801
62802#ifdef FREECIV_JSON_CONNECTION
62803 field_addr.name = "name";
62804#endif /* FREECIV_JSON_CONNECTION */
62805
62806 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
62807 RECEIVE_PACKET_FIELD_ERROR(name);
62808 }
62809 }
62810
62811 if (BV_ISSET(fields, 3)) {
62812 log_packet_detailed(" got field 'rule_name'");
62813
62814#ifdef FREECIV_JSON_CONNECTION
62815 field_addr.name = "rule_name";
62816#endif /* FREECIV_JSON_CONNECTION */
62817
62818 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
62819 RECEIVE_PACKET_FIELD_ERROR(rule_name);
62820 }
62821 }
62822
62823 if (BV_ISSET(fields, 4)) {
62824 log_packet_detailed(" got field 'graphic_str'");
62825
62826#ifdef FREECIV_JSON_CONNECTION
62827 field_addr.name = "graphic_str";
62828#endif /* FREECIV_JSON_CONNECTION */
62829
62830 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
62831 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
62832 }
62833 }
62834
62835 if (BV_ISSET(fields, 5)) {
62836 log_packet_detailed(" got field 'graphic_alt'");
62837
62838#ifdef FREECIV_JSON_CONNECTION
62839 field_addr.name = "graphic_alt";
62840#endif /* FREECIV_JSON_CONNECTION */
62841
62842 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
62843 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
62844 }
62845 }
62846
62847 if (BV_ISSET(fields, 6)) {
62848 log_packet_detailed(" got field 'graphic_alt2'");
62849
62850#ifdef FREECIV_JSON_CONNECTION
62851 field_addr.name = "graphic_alt2";
62852#endif /* FREECIV_JSON_CONNECTION */
62853
62854 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt2, sizeof(real_packet->graphic_alt2))) {
62855 RECEIVE_PACKET_FIELD_ERROR(graphic_alt2);
62856 }
62857 }
62858
62859 if (BV_ISSET(fields, 7)) {
62860 log_packet_detailed(" got field 'reqs'");
62861
62862#ifdef FREECIV_JSON_CONNECTION
62863 field_addr.name = "reqs";
62864#endif /* FREECIV_JSON_CONNECTION */
62865
62866 {
62867 int i;
62868
62869 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
62870 RECEIVE_PACKET_FIELD_ERROR(reqs);
62871 }
62872 requirement_vector_reserve(&real_packet->reqs, i);
62873
62874#ifdef FREECIV_JSON_CONNECTION
62875 /* Enter array. */
62876 field_addr.sub_location = plocation_elem_new(0);
62877#endif /* FREECIV_JSON_CONNECTION */
62878
62879 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
62880#ifdef FREECIV_JSON_CONNECTION
62881 /* Next array element */
62882 field_addr.sub_location->number = i;
62883#endif /* FREECIV_JSON_CONNECTION */
62884
62885 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
62886 RECEIVE_PACKET_FIELD_ERROR(reqs);
62887 }
62888 }
62889
62890#ifdef FREECIV_JSON_CONNECTION
62891 /* Exit array. */
62892 FC_FREE(field_addr.sub_location);
62893#endif /* FREECIV_JSON_CONNECTION */
62894 }
62895 }
62896
62897 if (BV_ISSET(fields, 8)) {
62898 log_packet_detailed(" got field 'obs_reqs'");
62899
62900#ifdef FREECIV_JSON_CONNECTION
62901 field_addr.name = "obs_reqs";
62902#endif /* FREECIV_JSON_CONNECTION */
62903
62904 {
62905 int i;
62906
62907 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
62908 RECEIVE_PACKET_FIELD_ERROR(obs_reqs);
62909 }
62910 requirement_vector_reserve(&real_packet->obs_reqs, i);
62911
62912#ifdef FREECIV_JSON_CONNECTION
62913 /* Enter array. */
62914 field_addr.sub_location = plocation_elem_new(0);
62915#endif /* FREECIV_JSON_CONNECTION */
62916
62917 for (i = 0; i < requirement_vector_size(&real_packet->obs_reqs); i++) {
62918#ifdef FREECIV_JSON_CONNECTION
62919 /* Next array element */
62920 field_addr.sub_location->number = i;
62921#endif /* FREECIV_JSON_CONNECTION */
62922
62923 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->obs_reqs.p[i])) {
62924 RECEIVE_PACKET_FIELD_ERROR(obs_reqs);
62925 }
62926 }
62927
62928#ifdef FREECIV_JSON_CONNECTION
62929 /* Exit array. */
62930 FC_FREE(field_addr.sub_location);
62931#endif /* FREECIV_JSON_CONNECTION */
62932 }
62933 }
62934
62935 if (BV_ISSET(fields, 9)) {
62936 log_packet_detailed(" got field 'build_cost'");
62937
62938#ifdef FREECIV_JSON_CONNECTION
62939 field_addr.name = "build_cost";
62940#endif /* FREECIV_JSON_CONNECTION */
62941
62942 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->build_cost)) {
62943 RECEIVE_PACKET_FIELD_ERROR(build_cost);
62944 }
62945 }
62946
62947 if (BV_ISSET(fields, 10)) {
62948 log_packet_detailed(" got field 'upkeep'");
62949
62950#ifdef FREECIV_JSON_CONNECTION
62951 field_addr.name = "upkeep";
62952#endif /* FREECIV_JSON_CONNECTION */
62953
62954 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->upkeep)) {
62955 RECEIVE_PACKET_FIELD_ERROR(upkeep);
62956 }
62957 }
62958
62959 if (BV_ISSET(fields, 11)) {
62960 log_packet_detailed(" got field 'sabotage'");
62961
62962#ifdef FREECIV_JSON_CONNECTION
62963 field_addr.name = "sabotage";
62964#endif /* FREECIV_JSON_CONNECTION */
62965
62966 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->sabotage)) {
62967 RECEIVE_PACKET_FIELD_ERROR(sabotage);
62968 }
62969 }
62970
62971 if (BV_ISSET(fields, 12)) {
62972 log_packet_detailed(" got field 'flags'");
62973
62974#ifdef FREECIV_JSON_CONNECTION
62975 field_addr.name = "flags";
62976#endif /* FREECIV_JSON_CONNECTION */
62977
62978 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
62979 RECEIVE_PACKET_FIELD_ERROR(flags);
62980 }
62981 }
62982
62983 if (BV_ISSET(fields, 13)) {
62984 log_packet_detailed(" got field 'soundtag'");
62985
62986#ifdef FREECIV_JSON_CONNECTION
62987 field_addr.name = "soundtag";
62988#endif /* FREECIV_JSON_CONNECTION */
62989
62990 if (!DIO_GET(string, &din, &field_addr, real_packet->soundtag, sizeof(real_packet->soundtag))) {
62991 RECEIVE_PACKET_FIELD_ERROR(soundtag);
62992 }
62993 }
62994
62995 if (BV_ISSET(fields, 14)) {
62996 log_packet_detailed(" got field 'soundtag_alt'");
62997
62998#ifdef FREECIV_JSON_CONNECTION
62999 field_addr.name = "soundtag_alt";
63000#endif /* FREECIV_JSON_CONNECTION */
63001
63002 if (!DIO_GET(string, &din, &field_addr, real_packet->soundtag_alt, sizeof(real_packet->soundtag_alt))) {
63003 RECEIVE_PACKET_FIELD_ERROR(soundtag_alt);
63004 }
63005 }
63006
63007 if (BV_ISSET(fields, 15)) {
63008 log_packet_detailed(" got field 'soundtag_alt2'");
63009
63010#ifdef FREECIV_JSON_CONNECTION
63011 field_addr.name = "soundtag_alt2";
63012#endif /* FREECIV_JSON_CONNECTION */
63013
63014 if (!DIO_GET(string, &din, &field_addr, real_packet->soundtag_alt2, sizeof(real_packet->soundtag_alt2))) {
63015 RECEIVE_PACKET_FIELD_ERROR(soundtag_alt2);
63016 }
63017 }
63018
63019 if (BV_ISSET(fields, 16)) {
63020 log_packet_detailed(" got field 'helptext'");
63021
63022#ifdef FREECIV_JSON_CONNECTION
63023 field_addr.name = "helptext";
63024#endif /* FREECIV_JSON_CONNECTION */
63025
63026 {
63027 int i;
63028
63029 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
63030 RECEIVE_PACKET_FIELD_ERROR(helptext);
63031 }
63032 strvec_reserve(real_packet->helptext, i);
63033
63034#ifdef FREECIV_JSON_CONNECTION
63035 /* Enter array. */
63036 field_addr.sub_location = plocation_elem_new(0);
63037#endif /* FREECIV_JSON_CONNECTION */
63038
63039 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
63040#ifdef FREECIV_JSON_CONNECTION
63041 /* Next array element */
63042 field_addr.sub_location->number = i;
63043#endif /* FREECIV_JSON_CONNECTION */
63044
63045 {
63046 char readin[MAX_LEN_PACKET];
63047
63048 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
63049 || !strvec_set(real_packet->helptext, i, readin)) {
63050 RECEIVE_PACKET_FIELD_ERROR(helptext);
63051 }
63052 }
63053 }
63054
63055#ifdef FREECIV_JSON_CONNECTION
63056 /* Exit array. */
63057 FC_FREE(field_addr.sub_location);
63058#endif /* FREECIV_JSON_CONNECTION */
63059 }
63060 }
63061
63062 if (nullptr == old) {
63063 old = fc_malloc(sizeof(*old));
63064 init_packet_ruleset_building(old);
63065 old->id = real_packet->id;
63066 old->genus = real_packet->genus;
63067 sz_strlcpy(old->name, real_packet->name);
63068 sz_strlcpy(old->rule_name, real_packet->rule_name);
63069 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
63070 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
63071 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
63072 requirement_vector_copy(&old->reqs, &real_packet->reqs);
63073 requirement_vector_copy(&old->obs_reqs, &real_packet->obs_reqs);
63074 old->build_cost = real_packet->build_cost;
63075 old->upkeep = real_packet->upkeep;
63076 old->sabotage = real_packet->sabotage;
63077 old->flags = real_packet->flags;
63078 sz_strlcpy(old->soundtag, real_packet->soundtag);
63079 sz_strlcpy(old->soundtag_alt, real_packet->soundtag_alt);
63080 sz_strlcpy(old->soundtag_alt2, real_packet->soundtag_alt2);
63081 if (real_packet->helptext) {
63082 strvec_copy(old->helptext, real_packet->helptext);
63083 } else {
63084 strvec_clear(old->helptext);
63085 }
63086 genhash_insert(*hash, old, old);
63087 } else {
63088 old->id = real_packet->id;
63089 old->genus = real_packet->genus;
63090 sz_strlcpy(old->name, real_packet->name);
63091 sz_strlcpy(old->rule_name, real_packet->rule_name);
63092 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
63093 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
63094 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
63095 requirement_vector_copy(&old->reqs, &real_packet->reqs);
63096 requirement_vector_copy(&old->obs_reqs, &real_packet->obs_reqs);
63097 old->build_cost = real_packet->build_cost;
63098 old->upkeep = real_packet->upkeep;
63099 old->sabotage = real_packet->sabotage;
63100 old->flags = real_packet->flags;
63101 sz_strlcpy(old->soundtag, real_packet->soundtag);
63102 sz_strlcpy(old->soundtag_alt, real_packet->soundtag_alt);
63103 sz_strlcpy(old->soundtag_alt2, real_packet->soundtag_alt2);
63104 if (real_packet->helptext) {
63105 strvec_copy(old->helptext, real_packet->helptext);
63106 } else {
63107 strvec_clear(old->helptext);
63108 }
63109 }
63110
63111#else /* FREECIV_DELTA_PROTOCOL */
63112#ifdef FREECIV_JSON_CONNECTION
63113 field_addr.name = "id";
63114#endif /* FREECIV_JSON_CONNECTION */
63115
63116 {
63117 int readin;
63118
63119 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
63120 RECEIVE_PACKET_FIELD_ERROR(id);
63121 }
63122 real_packet->id = readin;
63123 }
63124
63125#ifdef FREECIV_JSON_CONNECTION
63126 field_addr.name = "genus";
63127#endif /* FREECIV_JSON_CONNECTION */
63128
63129 {
63130 int readin;
63131
63132 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
63133 RECEIVE_PACKET_FIELD_ERROR(genus);
63134 }
63135 real_packet->genus = readin;
63136 }
63137
63138#ifdef FREECIV_JSON_CONNECTION
63139 field_addr.name = "name";
63140#endif /* FREECIV_JSON_CONNECTION */
63141
63142 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
63143 RECEIVE_PACKET_FIELD_ERROR(name);
63144 }
63145
63146#ifdef FREECIV_JSON_CONNECTION
63147 field_addr.name = "rule_name";
63148#endif /* FREECIV_JSON_CONNECTION */
63149
63150 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
63151 RECEIVE_PACKET_FIELD_ERROR(rule_name);
63152 }
63153
63154#ifdef FREECIV_JSON_CONNECTION
63155 field_addr.name = "graphic_str";
63156#endif /* FREECIV_JSON_CONNECTION */
63157
63158 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
63159 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
63160 }
63161
63162#ifdef FREECIV_JSON_CONNECTION
63163 field_addr.name = "graphic_alt";
63164#endif /* FREECIV_JSON_CONNECTION */
63165
63166 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
63167 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
63168 }
63169
63170#ifdef FREECIV_JSON_CONNECTION
63171 field_addr.name = "graphic_alt2";
63172#endif /* FREECIV_JSON_CONNECTION */
63173
63174 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt2, sizeof(real_packet->graphic_alt2))) {
63175 RECEIVE_PACKET_FIELD_ERROR(graphic_alt2);
63176 }
63177
63178#ifdef FREECIV_JSON_CONNECTION
63179 field_addr.name = "reqs";
63180#endif /* FREECIV_JSON_CONNECTION */
63181
63182 {
63183 int i;
63184
63185 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
63186 RECEIVE_PACKET_FIELD_ERROR(reqs);
63187 }
63188 requirement_vector_reserve(&real_packet->reqs, i);
63189
63190#ifdef FREECIV_JSON_CONNECTION
63191 /* Enter array. */
63192 field_addr.sub_location = plocation_elem_new(0);
63193#endif /* FREECIV_JSON_CONNECTION */
63194
63195 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
63196#ifdef FREECIV_JSON_CONNECTION
63197 /* Next array element */
63198 field_addr.sub_location->number = i;
63199#endif /* FREECIV_JSON_CONNECTION */
63200
63201 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
63202 RECEIVE_PACKET_FIELD_ERROR(reqs);
63203 }
63204 }
63205
63206#ifdef FREECIV_JSON_CONNECTION
63207 /* Exit array. */
63208 FC_FREE(field_addr.sub_location);
63209#endif /* FREECIV_JSON_CONNECTION */
63210 }
63211
63212#ifdef FREECIV_JSON_CONNECTION
63213 field_addr.name = "obs_reqs";
63214#endif /* FREECIV_JSON_CONNECTION */
63215
63216 {
63217 int i;
63218
63219 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
63220 RECEIVE_PACKET_FIELD_ERROR(obs_reqs);
63221 }
63222 requirement_vector_reserve(&real_packet->obs_reqs, i);
63223
63224#ifdef FREECIV_JSON_CONNECTION
63225 /* Enter array. */
63226 field_addr.sub_location = plocation_elem_new(0);
63227#endif /* FREECIV_JSON_CONNECTION */
63228
63229 for (i = 0; i < requirement_vector_size(&real_packet->obs_reqs); i++) {
63230#ifdef FREECIV_JSON_CONNECTION
63231 /* Next array element */
63232 field_addr.sub_location->number = i;
63233#endif /* FREECIV_JSON_CONNECTION */
63234
63235 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->obs_reqs.p[i])) {
63236 RECEIVE_PACKET_FIELD_ERROR(obs_reqs);
63237 }
63238 }
63239
63240#ifdef FREECIV_JSON_CONNECTION
63241 /* Exit array. */
63242 FC_FREE(field_addr.sub_location);
63243#endif /* FREECIV_JSON_CONNECTION */
63244 }
63245
63246#ifdef FREECIV_JSON_CONNECTION
63247 field_addr.name = "build_cost";
63248#endif /* FREECIV_JSON_CONNECTION */
63249
63250 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->build_cost)) {
63251 RECEIVE_PACKET_FIELD_ERROR(build_cost);
63252 }
63253
63254#ifdef FREECIV_JSON_CONNECTION
63255 field_addr.name = "upkeep";
63256#endif /* FREECIV_JSON_CONNECTION */
63257
63258 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->upkeep)) {
63259 RECEIVE_PACKET_FIELD_ERROR(upkeep);
63260 }
63261
63262#ifdef FREECIV_JSON_CONNECTION
63263 field_addr.name = "sabotage";
63264#endif /* FREECIV_JSON_CONNECTION */
63265
63266 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->sabotage)) {
63267 RECEIVE_PACKET_FIELD_ERROR(sabotage);
63268 }
63269
63270#ifdef FREECIV_JSON_CONNECTION
63271 field_addr.name = "flags";
63272#endif /* FREECIV_JSON_CONNECTION */
63273
63274 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
63275 RECEIVE_PACKET_FIELD_ERROR(flags);
63276 }
63277
63278#ifdef FREECIV_JSON_CONNECTION
63279 field_addr.name = "soundtag";
63280#endif /* FREECIV_JSON_CONNECTION */
63281
63282 if (!DIO_GET(string, &din, &field_addr, real_packet->soundtag, sizeof(real_packet->soundtag))) {
63283 RECEIVE_PACKET_FIELD_ERROR(soundtag);
63284 }
63285
63286#ifdef FREECIV_JSON_CONNECTION
63287 field_addr.name = "soundtag_alt";
63288#endif /* FREECIV_JSON_CONNECTION */
63289
63290 if (!DIO_GET(string, &din, &field_addr, real_packet->soundtag_alt, sizeof(real_packet->soundtag_alt))) {
63291 RECEIVE_PACKET_FIELD_ERROR(soundtag_alt);
63292 }
63293
63294#ifdef FREECIV_JSON_CONNECTION
63295 field_addr.name = "soundtag_alt2";
63296#endif /* FREECIV_JSON_CONNECTION */
63297
63298 if (!DIO_GET(string, &din, &field_addr, real_packet->soundtag_alt2, sizeof(real_packet->soundtag_alt2))) {
63299 RECEIVE_PACKET_FIELD_ERROR(soundtag_alt2);
63300 }
63301
63302#ifdef FREECIV_JSON_CONNECTION
63303 field_addr.name = "helptext";
63304#endif /* FREECIV_JSON_CONNECTION */
63305
63306 {
63307 int i;
63308
63309 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
63310 RECEIVE_PACKET_FIELD_ERROR(helptext);
63311 }
63312 strvec_reserve(real_packet->helptext, i);
63313
63314#ifdef FREECIV_JSON_CONNECTION
63315 /* Enter array. */
63316 field_addr.sub_location = plocation_elem_new(0);
63317#endif /* FREECIV_JSON_CONNECTION */
63318
63319 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
63320#ifdef FREECIV_JSON_CONNECTION
63321 /* Next array element */
63322 field_addr.sub_location->number = i;
63323#endif /* FREECIV_JSON_CONNECTION */
63324
63325 {
63326 char readin[MAX_LEN_PACKET];
63327
63328 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
63329 || !strvec_set(real_packet->helptext, i, readin)) {
63330 RECEIVE_PACKET_FIELD_ERROR(helptext);
63331 }
63332 }
63333 }
63334
63335#ifdef FREECIV_JSON_CONNECTION
63336 /* Exit array. */
63337 FC_FREE(field_addr.sub_location);
63338#endif /* FREECIV_JSON_CONNECTION */
63339 }
63340#endif /* FREECIV_DELTA_PROTOCOL */
63341
63342 RECEIVE_PACKET_END(real_packet);
63343#undef FREE_PACKET_STRUCT
63344}
63345
63346 static int send_packet_ruleset_building_100(struct connection *pc, const struct packet_ruleset_building *packet)
63347{
63348 const struct packet_ruleset_building *real_packet = packet;
63349 int e;
63350 SEND_PACKET_START(PACKET_RULESET_BUILDING);
63351
63352 log_packet_detailed("packet_ruleset_building_100: sending info about ()");
63353
63354#ifdef FREECIV_DELTA_PROTOCOL
63355 packet_ruleset_building_100_fields fields;
63356 struct packet_ruleset_building *old;
63357 bool differ;
63358 struct genhash **hash = pc->phs.sent + PACKET_RULESET_BUILDING;
63359
63360 if (nullptr == *hash) {
63361 *hash = genhash_new_full(hash_packet_ruleset_building_100, cmp_packet_ruleset_building_100,
63362 nullptr, nullptr, nullptr, destroy_packet_ruleset_building);
63363 }
63364 BV_CLR_ALL(fields);
63365
63366 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
63367 old = fc_malloc(sizeof(*old));
63368 /* temporary bitcopy just to insert correctly */
63369 *old = *real_packet;
63370 genhash_insert(*hash, old, old);
63371 init_packet_ruleset_building(old);
63372 }
63373
63374 differ = (old->id != real_packet->id);
63375 if (differ) {
63376 BV_SET(fields, 0);
63377 }
63378
63379 differ = (old->genus != real_packet->genus);
63380 if (differ) {
63381 BV_SET(fields, 1);
63382 }
63383
63384 differ = (strcmp(old->name, real_packet->name) != 0);
63385 if (differ) {
63386 BV_SET(fields, 2);
63387 }
63388
63389 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
63390 if (differ) {
63391 BV_SET(fields, 3);
63392 }
63393
63394 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
63395 if (differ) {
63396 BV_SET(fields, 4);
63397 }
63398
63399 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
63400 if (differ) {
63401 BV_SET(fields, 5);
63402 }
63403
63404 differ = (strcmp(old->graphic_alt2, real_packet->graphic_alt2) != 0);
63405 if (differ) {
63406 BV_SET(fields, 6);
63407 }
63408
63409 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
63410 if (!differ) {
63411 int i;
63412
63413 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
63414 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
63415 if (differ) {
63416 break;
63417 }
63418 }
63419 }
63420 if (differ) {
63421 BV_SET(fields, 7);
63422 }
63423
63424 differ = (requirement_vector_size(&old->obs_reqs) != requirement_vector_size(&real_packet->obs_reqs));
63425 if (!differ) {
63426 int i;
63427
63428 for (i = 0; i < requirement_vector_size(&old->obs_reqs); i++) {
63429 differ = !are_requirements_equal(&old->obs_reqs.p[i], &real_packet->obs_reqs.p[i]);
63430 if (differ) {
63431 break;
63432 }
63433 }
63434 }
63435 if (differ) {
63436 BV_SET(fields, 8);
63437 }
63438
63439 differ = (old->build_cost != real_packet->build_cost);
63440 if (differ) {
63441 BV_SET(fields, 9);
63442 }
63443
63444 differ = (old->upkeep != real_packet->upkeep);
63445 if (differ) {
63446 BV_SET(fields, 10);
63447 }
63448
63449 differ = (old->sabotage != real_packet->sabotage);
63450 if (differ) {
63451 BV_SET(fields, 11);
63452 }
63453
63454 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
63455 if (differ) {
63456 BV_SET(fields, 12);
63457 }
63458
63459 differ = (strcmp(old->soundtag, real_packet->soundtag) != 0);
63460 if (differ) {
63461 BV_SET(fields, 13);
63462 }
63463
63464 differ = (strcmp(old->soundtag_alt, real_packet->soundtag_alt) != 0);
63465 if (differ) {
63466 BV_SET(fields, 14);
63467 }
63468
63469 differ = (strcmp(old->soundtag_alt2, real_packet->soundtag_alt2) != 0);
63470 if (differ) {
63471 BV_SET(fields, 15);
63472 }
63473
63474 if (real_packet->helptext) {
63475 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
63476 } else {
63477 differ = (strvec_size(old->helptext) > 0);
63478 }
63479 if (differ) {
63480 BV_SET(fields, 16);
63481 }
63482#endif /* FREECIV_DELTA_PROTOCOL */
63483
63484#ifdef FREECIV_JSON_CONNECTION
63485 struct plocation field_addr;
63486 {
63487 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
63488 field_addr = *field_addr_tmp;
63489 FC_FREE(field_addr_tmp);
63490 }
63491#endif /* FREECIV_JSON_CONNECTION */
63492
63493#ifdef FREECIV_DELTA_PROTOCOL
63494#ifdef FREECIV_JSON_CONNECTION
63495 field_addr.name = "fields";
63496#endif /* FREECIV_JSON_CONNECTION */
63497 e = 0;
63498 e |= DIO_BV_PUT(&dout, &field_addr, fields);
63499 if (e) {
63500 log_packet_detailed("fields bitvector error detected");
63501 }
63502
63503 if (BV_ISSET(fields, 0)) {
63504 log_packet_detailed(" field 'id' has changed");
63505
63506#ifdef FREECIV_JSON_CONNECTION
63507 field_addr.name = "id";
63508#endif /* FREECIV_JSON_CONNECTION */
63509 e = 0;
63510
63511 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
63512
63513 if (e) {
63514 log_packet_detailed("'id' field error detected");
63515 }
63516 }
63517
63518 if (BV_ISSET(fields, 1)) {
63519 log_packet_detailed(" field 'genus' has changed");
63520
63521#ifdef FREECIV_JSON_CONNECTION
63522 field_addr.name = "genus";
63523#endif /* FREECIV_JSON_CONNECTION */
63524 e = 0;
63525
63526 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->genus);
63527
63528 if (e) {
63529 log_packet_detailed("'genus' field error detected");
63530 }
63531 }
63532
63533 if (BV_ISSET(fields, 2)) {
63534 log_packet_detailed(" field 'name' has changed");
63535
63536#ifdef FREECIV_JSON_CONNECTION
63537 field_addr.name = "name";
63538#endif /* FREECIV_JSON_CONNECTION */
63539 e = 0;
63540
63541 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
63542
63543 if (e) {
63544 log_packet_detailed("'name' field error detected");
63545 }
63546 }
63547
63548 if (BV_ISSET(fields, 3)) {
63549 log_packet_detailed(" field 'rule_name' has changed");
63550
63551#ifdef FREECIV_JSON_CONNECTION
63552 field_addr.name = "rule_name";
63553#endif /* FREECIV_JSON_CONNECTION */
63554 e = 0;
63555
63556 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
63557
63558 if (e) {
63559 log_packet_detailed("'rule_name' field error detected");
63560 }
63561 }
63562
63563 if (BV_ISSET(fields, 4)) {
63564 log_packet_detailed(" field 'graphic_str' has changed");
63565
63566#ifdef FREECIV_JSON_CONNECTION
63567 field_addr.name = "graphic_str";
63568#endif /* FREECIV_JSON_CONNECTION */
63569 e = 0;
63570
63571 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
63572
63573 if (e) {
63574 log_packet_detailed("'graphic_str' field error detected");
63575 }
63576 }
63577
63578 if (BV_ISSET(fields, 5)) {
63579 log_packet_detailed(" field 'graphic_alt' has changed");
63580
63581#ifdef FREECIV_JSON_CONNECTION
63582 field_addr.name = "graphic_alt";
63583#endif /* FREECIV_JSON_CONNECTION */
63584 e = 0;
63585
63586 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
63587
63588 if (e) {
63589 log_packet_detailed("'graphic_alt' field error detected");
63590 }
63591 }
63592
63593 if (BV_ISSET(fields, 6)) {
63594 log_packet_detailed(" field 'graphic_alt2' has changed");
63595
63596#ifdef FREECIV_JSON_CONNECTION
63597 field_addr.name = "graphic_alt2";
63598#endif /* FREECIV_JSON_CONNECTION */
63599 e = 0;
63600
63601 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt2);
63602
63603 if (e) {
63604 log_packet_detailed("'graphic_alt2' field error detected");
63605 }
63606 }
63607
63608 if (BV_ISSET(fields, 7)) {
63609 log_packet_detailed(" field 'reqs' has changed");
63610
63611#ifdef FREECIV_JSON_CONNECTION
63612 field_addr.name = "reqs";
63613#endif /* FREECIV_JSON_CONNECTION */
63614 e = 0;
63615
63616 {
63617 int i;
63618
63619 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
63620 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
63621
63622#ifdef FREECIV_JSON_CONNECTION
63623 /* Enter array. */
63624 field_addr.sub_location = plocation_elem_new(0);
63625#endif /* FREECIV_JSON_CONNECTION */
63626
63627 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
63628#ifdef FREECIV_JSON_CONNECTION
63629 /* Next array element. */
63630 field_addr.sub_location->number = i;
63631#endif /* FREECIV_JSON_CONNECTION */
63632
63633 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
63634 }
63635
63636#ifdef FREECIV_JSON_CONNECTION
63637 /* Exit array. */
63638 FC_FREE(field_addr.sub_location);
63639#endif /* FREECIV_JSON_CONNECTION */
63640 }
63641
63642 if (e) {
63643 log_packet_detailed("'reqs' field error detected");
63644 }
63645 }
63646
63647 if (BV_ISSET(fields, 8)) {
63648 log_packet_detailed(" field 'obs_reqs' has changed");
63649
63650#ifdef FREECIV_JSON_CONNECTION
63651 field_addr.name = "obs_reqs";
63652#endif /* FREECIV_JSON_CONNECTION */
63653 e = 0;
63654
63655 {
63656 int i;
63657
63658 fc_assert(requirement_vector_size(&real_packet->obs_reqs) < MAX_UINT16);
63659 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->obs_reqs));
63660
63661#ifdef FREECIV_JSON_CONNECTION
63662 /* Enter array. */
63663 field_addr.sub_location = plocation_elem_new(0);
63664#endif /* FREECIV_JSON_CONNECTION */
63665
63666 for (i = 0; i < requirement_vector_size(&real_packet->obs_reqs); i++) {
63667#ifdef FREECIV_JSON_CONNECTION
63668 /* Next array element. */
63669 field_addr.sub_location->number = i;
63670#endif /* FREECIV_JSON_CONNECTION */
63671
63672 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->obs_reqs.p[i]);
63673 }
63674
63675#ifdef FREECIV_JSON_CONNECTION
63676 /* Exit array. */
63677 FC_FREE(field_addr.sub_location);
63678#endif /* FREECIV_JSON_CONNECTION */
63679 }
63680
63681 if (e) {
63682 log_packet_detailed("'obs_reqs' field error detected");
63683 }
63684 }
63685
63686 if (BV_ISSET(fields, 9)) {
63687 log_packet_detailed(" field 'build_cost' has changed");
63688
63689#ifdef FREECIV_JSON_CONNECTION
63690 field_addr.name = "build_cost";
63691#endif /* FREECIV_JSON_CONNECTION */
63692 e = 0;
63693
63694 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->build_cost);
63695
63696 if (e) {
63697 log_packet_detailed("'build_cost' field error detected");
63698 }
63699 }
63700
63701 if (BV_ISSET(fields, 10)) {
63702 log_packet_detailed(" field 'upkeep' has changed");
63703
63704#ifdef FREECIV_JSON_CONNECTION
63705 field_addr.name = "upkeep";
63706#endif /* FREECIV_JSON_CONNECTION */
63707 e = 0;
63708
63709 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->upkeep);
63710
63711 if (e) {
63712 log_packet_detailed("'upkeep' field error detected");
63713 }
63714 }
63715
63716 if (BV_ISSET(fields, 11)) {
63717 log_packet_detailed(" field 'sabotage' has changed");
63718
63719#ifdef FREECIV_JSON_CONNECTION
63720 field_addr.name = "sabotage";
63721#endif /* FREECIV_JSON_CONNECTION */
63722 e = 0;
63723
63724 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sabotage);
63725
63726 if (e) {
63727 log_packet_detailed("'sabotage' field error detected");
63728 }
63729 }
63730
63731 if (BV_ISSET(fields, 12)) {
63732 log_packet_detailed(" field 'flags' has changed");
63733
63734#ifdef FREECIV_JSON_CONNECTION
63735 field_addr.name = "flags";
63736#endif /* FREECIV_JSON_CONNECTION */
63737 e = 0;
63738
63739 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
63740
63741 if (e) {
63742 log_packet_detailed("'flags' field error detected");
63743 }
63744 }
63745
63746 if (BV_ISSET(fields, 13)) {
63747 log_packet_detailed(" field 'soundtag' has changed");
63748
63749#ifdef FREECIV_JSON_CONNECTION
63750 field_addr.name = "soundtag";
63751#endif /* FREECIV_JSON_CONNECTION */
63752 e = 0;
63753
63754 e |= DIO_PUT(string, &dout, &field_addr, real_packet->soundtag);
63755
63756 if (e) {
63757 log_packet_detailed("'soundtag' field error detected");
63758 }
63759 }
63760
63761 if (BV_ISSET(fields, 14)) {
63762 log_packet_detailed(" field 'soundtag_alt' has changed");
63763
63764#ifdef FREECIV_JSON_CONNECTION
63765 field_addr.name = "soundtag_alt";
63766#endif /* FREECIV_JSON_CONNECTION */
63767 e = 0;
63768
63769 e |= DIO_PUT(string, &dout, &field_addr, real_packet->soundtag_alt);
63770
63771 if (e) {
63772 log_packet_detailed("'soundtag_alt' field error detected");
63773 }
63774 }
63775
63776 if (BV_ISSET(fields, 15)) {
63777 log_packet_detailed(" field 'soundtag_alt2' has changed");
63778
63779#ifdef FREECIV_JSON_CONNECTION
63780 field_addr.name = "soundtag_alt2";
63781#endif /* FREECIV_JSON_CONNECTION */
63782 e = 0;
63783
63784 e |= DIO_PUT(string, &dout, &field_addr, real_packet->soundtag_alt2);
63785
63786 if (e) {
63787 log_packet_detailed("'soundtag_alt2' field error detected");
63788 }
63789 }
63790
63791 if (BV_ISSET(fields, 16)) {
63792 log_packet_detailed(" field 'helptext' has changed");
63793
63794#ifdef FREECIV_JSON_CONNECTION
63795 field_addr.name = "helptext";
63796#endif /* FREECIV_JSON_CONNECTION */
63797 e = 0;
63798
63799 if (!real_packet->helptext) {
63800 /* Transmit null as empty */
63801 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
63802 } else {
63803 int i;
63804
63805 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
63806 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
63807
63808#ifdef FREECIV_JSON_CONNECTION
63809 /* Enter array. */
63810 field_addr.sub_location = plocation_elem_new(0);
63811#endif /* FREECIV_JSON_CONNECTION */
63812
63813 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
63814#ifdef FREECIV_JSON_CONNECTION
63815 /* Next array element. */
63816 field_addr.sub_location->number = i;
63817#endif /* FREECIV_JSON_CONNECTION */
63818
63819 {
63820 const char *pstr = strvec_get(real_packet->helptext, i);
63821
63822 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
63823 }
63824 }
63825
63826#ifdef FREECIV_JSON_CONNECTION
63827 /* Exit array. */
63828 FC_FREE(field_addr.sub_location);
63829#endif /* FREECIV_JSON_CONNECTION */
63830 }
63831
63832 if (e) {
63833 log_packet_detailed("'helptext' field error detected");
63834 }
63835 }
63836
63837 old->id = real_packet->id;
63838 old->genus = real_packet->genus;
63839 sz_strlcpy(old->name, real_packet->name);
63840 sz_strlcpy(old->rule_name, real_packet->rule_name);
63841 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
63842 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
63843 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
63844 requirement_vector_copy(&old->reqs, &real_packet->reqs);
63845 requirement_vector_copy(&old->obs_reqs, &real_packet->obs_reqs);
63846 old->build_cost = real_packet->build_cost;
63847 old->upkeep = real_packet->upkeep;
63848 old->sabotage = real_packet->sabotage;
63849 old->flags = real_packet->flags;
63850 sz_strlcpy(old->soundtag, real_packet->soundtag);
63851 sz_strlcpy(old->soundtag_alt, real_packet->soundtag_alt);
63852 sz_strlcpy(old->soundtag_alt2, real_packet->soundtag_alt2);
63853 if (real_packet->helptext) {
63854 strvec_copy(old->helptext, real_packet->helptext);
63855 } else {
63856 strvec_clear(old->helptext);
63857 }
63858
63859#else /* FREECIV_DELTA_PROTOCOL */
63860#ifdef FREECIV_JSON_CONNECTION
63861 field_addr.name = "id";
63862#endif /* FREECIV_JSON_CONNECTION */
63863 e = 0;
63864
63865 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
63866
63867 if (e) {
63868 log_packet_detailed("'id' field error detected");
63869 }
63870
63871#ifdef FREECIV_JSON_CONNECTION
63872 field_addr.name = "genus";
63873#endif /* FREECIV_JSON_CONNECTION */
63874 e = 0;
63875
63876 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->genus);
63877
63878 if (e) {
63879 log_packet_detailed("'genus' field error detected");
63880 }
63881
63882#ifdef FREECIV_JSON_CONNECTION
63883 field_addr.name = "name";
63884#endif /* FREECIV_JSON_CONNECTION */
63885 e = 0;
63886
63887 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
63888
63889 if (e) {
63890 log_packet_detailed("'name' field error detected");
63891 }
63892
63893#ifdef FREECIV_JSON_CONNECTION
63894 field_addr.name = "rule_name";
63895#endif /* FREECIV_JSON_CONNECTION */
63896 e = 0;
63897
63898 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
63899
63900 if (e) {
63901 log_packet_detailed("'rule_name' field error detected");
63902 }
63903
63904#ifdef FREECIV_JSON_CONNECTION
63905 field_addr.name = "graphic_str";
63906#endif /* FREECIV_JSON_CONNECTION */
63907 e = 0;
63908
63909 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
63910
63911 if (e) {
63912 log_packet_detailed("'graphic_str' field error detected");
63913 }
63914
63915#ifdef FREECIV_JSON_CONNECTION
63916 field_addr.name = "graphic_alt";
63917#endif /* FREECIV_JSON_CONNECTION */
63918 e = 0;
63919
63920 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
63921
63922 if (e) {
63923 log_packet_detailed("'graphic_alt' field error detected");
63924 }
63925
63926#ifdef FREECIV_JSON_CONNECTION
63927 field_addr.name = "graphic_alt2";
63928#endif /* FREECIV_JSON_CONNECTION */
63929 e = 0;
63930
63931 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt2);
63932
63933 if (e) {
63934 log_packet_detailed("'graphic_alt2' field error detected");
63935 }
63936
63937#ifdef FREECIV_JSON_CONNECTION
63938 field_addr.name = "reqs";
63939#endif /* FREECIV_JSON_CONNECTION */
63940 e = 0;
63941
63942 {
63943 int i;
63944
63945 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
63946 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
63947
63948#ifdef FREECIV_JSON_CONNECTION
63949 /* Enter array. */
63950 field_addr.sub_location = plocation_elem_new(0);
63951#endif /* FREECIV_JSON_CONNECTION */
63952
63953 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
63954#ifdef FREECIV_JSON_CONNECTION
63955 /* Next array element. */
63956 field_addr.sub_location->number = i;
63957#endif /* FREECIV_JSON_CONNECTION */
63958
63959 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
63960 }
63961
63962#ifdef FREECIV_JSON_CONNECTION
63963 /* Exit array. */
63964 FC_FREE(field_addr.sub_location);
63965#endif /* FREECIV_JSON_CONNECTION */
63966 }
63967
63968 if (e) {
63969 log_packet_detailed("'reqs' field error detected");
63970 }
63971
63972#ifdef FREECIV_JSON_CONNECTION
63973 field_addr.name = "obs_reqs";
63974#endif /* FREECIV_JSON_CONNECTION */
63975 e = 0;
63976
63977 {
63978 int i;
63979
63980 fc_assert(requirement_vector_size(&real_packet->obs_reqs) < MAX_UINT16);
63981 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->obs_reqs));
63982
63983#ifdef FREECIV_JSON_CONNECTION
63984 /* Enter array. */
63985 field_addr.sub_location = plocation_elem_new(0);
63986#endif /* FREECIV_JSON_CONNECTION */
63987
63988 for (i = 0; i < requirement_vector_size(&real_packet->obs_reqs); i++) {
63989#ifdef FREECIV_JSON_CONNECTION
63990 /* Next array element. */
63991 field_addr.sub_location->number = i;
63992#endif /* FREECIV_JSON_CONNECTION */
63993
63994 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->obs_reqs.p[i]);
63995 }
63996
63997#ifdef FREECIV_JSON_CONNECTION
63998 /* Exit array. */
63999 FC_FREE(field_addr.sub_location);
64000#endif /* FREECIV_JSON_CONNECTION */
64001 }
64002
64003 if (e) {
64004 log_packet_detailed("'obs_reqs' field error detected");
64005 }
64006
64007#ifdef FREECIV_JSON_CONNECTION
64008 field_addr.name = "build_cost";
64009#endif /* FREECIV_JSON_CONNECTION */
64010 e = 0;
64011
64012 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->build_cost);
64013
64014 if (e) {
64015 log_packet_detailed("'build_cost' field error detected");
64016 }
64017
64018#ifdef FREECIV_JSON_CONNECTION
64019 field_addr.name = "upkeep";
64020#endif /* FREECIV_JSON_CONNECTION */
64021 e = 0;
64022
64023 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->upkeep);
64024
64025 if (e) {
64026 log_packet_detailed("'upkeep' field error detected");
64027 }
64028
64029#ifdef FREECIV_JSON_CONNECTION
64030 field_addr.name = "sabotage";
64031#endif /* FREECIV_JSON_CONNECTION */
64032 e = 0;
64033
64034 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sabotage);
64035
64036 if (e) {
64037 log_packet_detailed("'sabotage' field error detected");
64038 }
64039
64040#ifdef FREECIV_JSON_CONNECTION
64041 field_addr.name = "flags";
64042#endif /* FREECIV_JSON_CONNECTION */
64043 e = 0;
64044
64045 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
64046
64047 if (e) {
64048 log_packet_detailed("'flags' field error detected");
64049 }
64050
64051#ifdef FREECIV_JSON_CONNECTION
64052 field_addr.name = "soundtag";
64053#endif /* FREECIV_JSON_CONNECTION */
64054 e = 0;
64055
64056 e |= DIO_PUT(string, &dout, &field_addr, real_packet->soundtag);
64057
64058 if (e) {
64059 log_packet_detailed("'soundtag' field error detected");
64060 }
64061
64062#ifdef FREECIV_JSON_CONNECTION
64063 field_addr.name = "soundtag_alt";
64064#endif /* FREECIV_JSON_CONNECTION */
64065 e = 0;
64066
64067 e |= DIO_PUT(string, &dout, &field_addr, real_packet->soundtag_alt);
64068
64069 if (e) {
64070 log_packet_detailed("'soundtag_alt' field error detected");
64071 }
64072
64073#ifdef FREECIV_JSON_CONNECTION
64074 field_addr.name = "soundtag_alt2";
64075#endif /* FREECIV_JSON_CONNECTION */
64076 e = 0;
64077
64078 e |= DIO_PUT(string, &dout, &field_addr, real_packet->soundtag_alt2);
64079
64080 if (e) {
64081 log_packet_detailed("'soundtag_alt2' field error detected");
64082 }
64083
64084#ifdef FREECIV_JSON_CONNECTION
64085 field_addr.name = "helptext";
64086#endif /* FREECIV_JSON_CONNECTION */
64087 e = 0;
64088
64089 if (!real_packet->helptext) {
64090 /* Transmit null as empty */
64091 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
64092 } else {
64093 int i;
64094
64095 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
64096 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
64097
64098#ifdef FREECIV_JSON_CONNECTION
64099 /* Enter array. */
64100 field_addr.sub_location = plocation_elem_new(0);
64101#endif /* FREECIV_JSON_CONNECTION */
64102
64103 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
64104#ifdef FREECIV_JSON_CONNECTION
64105 /* Next array element. */
64106 field_addr.sub_location->number = i;
64107#endif /* FREECIV_JSON_CONNECTION */
64108
64109 {
64110 const char *pstr = strvec_get(real_packet->helptext, i);
64111
64112 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
64113 }
64114 }
64115
64116#ifdef FREECIV_JSON_CONNECTION
64117 /* Exit array. */
64118 FC_FREE(field_addr.sub_location);
64119#endif /* FREECIV_JSON_CONNECTION */
64120 }
64121
64122 if (e) {
64123 log_packet_detailed("'helptext' field error detected");
64124 }
64125#endif /* FREECIV_DELTA_PROTOCOL */
64126
64127 SEND_PACKET_END(PACKET_RULESET_BUILDING);
64128}
64129
64130 int send_packet_ruleset_building(struct connection *pc, const struct packet_ruleset_building *packet)
64131{
64132 if (!pc->used) {
64133 log_error("WARNING: trying to send data to the closed connection %s",
64134 conn_description(pc));
64135 return -1;
64136 }
64137 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_BUILDING].packet != nullptr, -1,
64138 "Handler for PACKET_RULESET_BUILDING not installed");
64139 return pc->phs.handlers->send[PACKET_RULESET_BUILDING].packet(pc, packet);
64140}
64141
64142 void lsend_packet_ruleset_building(struct conn_list *dest, const struct packet_ruleset_building *packet)
64143{
64144 conn_list_iterate(dest, pconn) {
64145 send_packet_ruleset_building(pconn, packet);
64146 } conn_list_iterate_end;
64147}
64148
64149 static inline void init_packet_ruleset_impr_flag(struct packet_ruleset_impr_flag *packet)
64150{
64151 memset(packet, 0, sizeof(*packet));
64152}
64153
64154#define free_packet_ruleset_impr_flag(_packet) (void) 0
64155#define destroy_packet_ruleset_impr_flag free
64156
64157#ifdef FREECIV_DELTA_PROTOCOL
64158#define hash_packet_ruleset_impr_flag_100 hash_const
64159#define cmp_packet_ruleset_impr_flag_100 cmp_const
64160 BV_DEFINE(packet_ruleset_impr_flag_100_fields, 3);
64161#endif /* FREECIV_DELTA_PROTOCOL */
64162
64163 static struct packet_ruleset_impr_flag *receive_packet_ruleset_impr_flag_100(struct connection *pc)
64164{
64165#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_impr_flag(_packet)
64166 RECEIVE_PACKET_START(packet_ruleset_impr_flag, real_packet);
64167
64168#ifdef FREECIV_JSON_CONNECTION
64169 struct plocation field_addr;
64170 {
64171 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
64172 field_addr = *field_addr_tmp;
64173 FC_FREE(field_addr_tmp);
64174 }
64175#endif /* FREECIV_JSON_CONNECTION */
64176
64177 log_packet_detailed("packet_ruleset_impr_flag_100: got info about ()");
64178
64179#ifdef FREECIV_DELTA_PROTOCOL
64180 packet_ruleset_impr_flag_100_fields fields;
64181 struct packet_ruleset_impr_flag *old;
64182 struct genhash **hash = pc->phs.received + PACKET_RULESET_IMPR_FLAG;
64183
64184 if (nullptr == *hash) {
64185 *hash = genhash_new_full(hash_packet_ruleset_impr_flag_100, cmp_packet_ruleset_impr_flag_100,
64186 nullptr, nullptr, nullptr, destroy_packet_ruleset_impr_flag);
64187 }
64188
64189 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
64190 *real_packet = *old;
64191 } else {
64192 /* packet is already initialized empty */
64193 log_packet_detailed(" no old info");
64194 }
64195
64196#ifdef FREECIV_JSON_CONNECTION
64197 field_addr.name = "fields";
64198#endif /* FREECIV_JSON_CONNECTION */
64199 DIO_BV_GET(&din, &field_addr, fields);
64200
64201 if (BV_ISSET(fields, 0)) {
64202 log_packet_detailed(" got field 'id'");
64203
64204#ifdef FREECIV_JSON_CONNECTION
64205 field_addr.name = "id";
64206#endif /* FREECIV_JSON_CONNECTION */
64207
64208 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
64209 RECEIVE_PACKET_FIELD_ERROR(id);
64210 }
64211 }
64212
64213 if (BV_ISSET(fields, 1)) {
64214 log_packet_detailed(" got field 'name'");
64215
64216#ifdef FREECIV_JSON_CONNECTION
64217 field_addr.name = "name";
64218#endif /* FREECIV_JSON_CONNECTION */
64219
64220 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
64221 RECEIVE_PACKET_FIELD_ERROR(name);
64222 }
64223 }
64224
64225 if (BV_ISSET(fields, 2)) {
64226 log_packet_detailed(" got field 'helptxt'");
64227
64228#ifdef FREECIV_JSON_CONNECTION
64229 field_addr.name = "helptxt";
64230#endif /* FREECIV_JSON_CONNECTION */
64231
64232 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
64233 RECEIVE_PACKET_FIELD_ERROR(helptxt);
64234 }
64235 }
64236
64237 if (nullptr == old) {
64238 old = fc_malloc(sizeof(*old));
64239 init_packet_ruleset_impr_flag(old);
64240 *old = *real_packet;
64241 genhash_insert(*hash, old, old);
64242 } else {
64243 *old = *real_packet;
64244 }
64245
64246#else /* FREECIV_DELTA_PROTOCOL */
64247#ifdef FREECIV_JSON_CONNECTION
64248 field_addr.name = "id";
64249#endif /* FREECIV_JSON_CONNECTION */
64250
64251 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
64252 RECEIVE_PACKET_FIELD_ERROR(id);
64253 }
64254
64255#ifdef FREECIV_JSON_CONNECTION
64256 field_addr.name = "name";
64257#endif /* FREECIV_JSON_CONNECTION */
64258
64259 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
64260 RECEIVE_PACKET_FIELD_ERROR(name);
64261 }
64262
64263#ifdef FREECIV_JSON_CONNECTION
64264 field_addr.name = "helptxt";
64265#endif /* FREECIV_JSON_CONNECTION */
64266
64267 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
64268 RECEIVE_PACKET_FIELD_ERROR(helptxt);
64269 }
64270#endif /* FREECIV_DELTA_PROTOCOL */
64271
64272 RECEIVE_PACKET_END(real_packet);
64273#undef FREE_PACKET_STRUCT
64274}
64275
64276 static int send_packet_ruleset_impr_flag_100(struct connection *pc, const struct packet_ruleset_impr_flag *packet)
64277{
64278 const struct packet_ruleset_impr_flag *real_packet = packet;
64279 int e;
64280 SEND_PACKET_START(PACKET_RULESET_IMPR_FLAG);
64281
64282 log_packet_detailed("packet_ruleset_impr_flag_100: sending info about ()");
64283
64284#ifdef FREECIV_DELTA_PROTOCOL
64285 packet_ruleset_impr_flag_100_fields fields;
64286 struct packet_ruleset_impr_flag *old;
64287 bool differ;
64288 struct genhash **hash = pc->phs.sent + PACKET_RULESET_IMPR_FLAG;
64289
64290 if (nullptr == *hash) {
64291 *hash = genhash_new_full(hash_packet_ruleset_impr_flag_100, cmp_packet_ruleset_impr_flag_100,
64292 nullptr, nullptr, nullptr, destroy_packet_ruleset_impr_flag);
64293 }
64294 BV_CLR_ALL(fields);
64295
64296 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
64297 old = fc_malloc(sizeof(*old));
64298 /* temporary bitcopy just to insert correctly */
64299 *old = *real_packet;
64300 genhash_insert(*hash, old, old);
64301 init_packet_ruleset_impr_flag(old);
64302 }
64303
64304 differ = (old->id != real_packet->id);
64305 if (differ) {
64306 BV_SET(fields, 0);
64307 }
64308
64309 differ = (strcmp(old->name, real_packet->name) != 0);
64310 if (differ) {
64311 BV_SET(fields, 1);
64312 }
64313
64314 differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
64315 if (differ) {
64316 BV_SET(fields, 2);
64317 }
64318#endif /* FREECIV_DELTA_PROTOCOL */
64319
64320#ifdef FREECIV_JSON_CONNECTION
64321 struct plocation field_addr;
64322 {
64323 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
64324 field_addr = *field_addr_tmp;
64325 FC_FREE(field_addr_tmp);
64326 }
64327#endif /* FREECIV_JSON_CONNECTION */
64328
64329#ifdef FREECIV_DELTA_PROTOCOL
64330#ifdef FREECIV_JSON_CONNECTION
64331 field_addr.name = "fields";
64332#endif /* FREECIV_JSON_CONNECTION */
64333 e = 0;
64334 e |= DIO_BV_PUT(&dout, &field_addr, fields);
64335 if (e) {
64336 log_packet_detailed("fields bitvector error detected");
64337 }
64338
64339 if (BV_ISSET(fields, 0)) {
64340 log_packet_detailed(" field 'id' has changed");
64341
64342#ifdef FREECIV_JSON_CONNECTION
64343 field_addr.name = "id";
64344#endif /* FREECIV_JSON_CONNECTION */
64345 e = 0;
64346
64347 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
64348
64349 if (e) {
64350 log_packet_detailed("'id' field error detected");
64351 }
64352 }
64353
64354 if (BV_ISSET(fields, 1)) {
64355 log_packet_detailed(" field 'name' has changed");
64356
64357#ifdef FREECIV_JSON_CONNECTION
64358 field_addr.name = "name";
64359#endif /* FREECIV_JSON_CONNECTION */
64360 e = 0;
64361
64362 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
64363
64364 if (e) {
64365 log_packet_detailed("'name' field error detected");
64366 }
64367 }
64368
64369 if (BV_ISSET(fields, 2)) {
64370 log_packet_detailed(" field 'helptxt' has changed");
64371
64372#ifdef FREECIV_JSON_CONNECTION
64373 field_addr.name = "helptxt";
64374#endif /* FREECIV_JSON_CONNECTION */
64375 e = 0;
64376
64377 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
64378
64379 if (e) {
64380 log_packet_detailed("'helptxt' field error detected");
64381 }
64382 }
64383
64384 *old = *real_packet;
64385
64386#else /* FREECIV_DELTA_PROTOCOL */
64387#ifdef FREECIV_JSON_CONNECTION
64388 field_addr.name = "id";
64389#endif /* FREECIV_JSON_CONNECTION */
64390 e = 0;
64391
64392 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
64393
64394 if (e) {
64395 log_packet_detailed("'id' field error detected");
64396 }
64397
64398#ifdef FREECIV_JSON_CONNECTION
64399 field_addr.name = "name";
64400#endif /* FREECIV_JSON_CONNECTION */
64401 e = 0;
64402
64403 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
64404
64405 if (e) {
64406 log_packet_detailed("'name' field error detected");
64407 }
64408
64409#ifdef FREECIV_JSON_CONNECTION
64410 field_addr.name = "helptxt";
64411#endif /* FREECIV_JSON_CONNECTION */
64412 e = 0;
64413
64414 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
64415
64416 if (e) {
64417 log_packet_detailed("'helptxt' field error detected");
64418 }
64419#endif /* FREECIV_DELTA_PROTOCOL */
64420
64421 SEND_PACKET_END(PACKET_RULESET_IMPR_FLAG);
64422}
64423
64424 int send_packet_ruleset_impr_flag(struct connection *pc, const struct packet_ruleset_impr_flag *packet)
64425{
64426 if (!pc->used) {
64427 log_error("WARNING: trying to send data to the closed connection %s",
64428 conn_description(pc));
64429 return -1;
64430 }
64431 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_IMPR_FLAG].packet != nullptr, -1,
64432 "Handler for PACKET_RULESET_IMPR_FLAG not installed");
64433 return pc->phs.handlers->send[PACKET_RULESET_IMPR_FLAG].packet(pc, packet);
64434}
64435
64436 void lsend_packet_ruleset_impr_flag(struct conn_list *dest, const struct packet_ruleset_impr_flag *packet)
64437{
64438 conn_list_iterate(dest, pconn) {
64439 send_packet_ruleset_impr_flag(pconn, packet);
64440 } conn_list_iterate_end;
64441}
64442
64443 static inline void init_packet_ruleset_terrain(struct packet_ruleset_terrain *packet)
64444{
64445 memset(packet, 0, sizeof(*packet));
64446
64447 packet->helptext = strvec_new();
64448}
64449
64450 static inline void free_packet_ruleset_terrain(struct packet_ruleset_terrain *packet)
64451{
64452 if (packet->helptext) {
64453 strvec_destroy(packet->helptext);
64454 packet->helptext = nullptr;
64455 }
64456}
64457
64458 static inline void destroy_packet_ruleset_terrain(void *packet)
64459{
64460 free_packet_ruleset_terrain((struct packet_ruleset_terrain *) packet);
64461 free(packet);
64462}
64463
64464#ifdef FREECIV_DELTA_PROTOCOL
64465#define hash_packet_ruleset_terrain_100 hash_const
64466#define cmp_packet_ruleset_terrain_100 cmp_const
64467 BV_DEFINE(packet_ruleset_terrain_100_fields, 37);
64468#endif /* FREECIV_DELTA_PROTOCOL */
64469
64470 static struct packet_ruleset_terrain *receive_packet_ruleset_terrain_100(struct connection *pc)
64471{
64472#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_terrain(_packet)
64473 RECEIVE_PACKET_START(packet_ruleset_terrain, real_packet);
64474
64475#ifdef FREECIV_JSON_CONNECTION
64476 struct plocation field_addr;
64477 {
64478 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
64479 field_addr = *field_addr_tmp;
64480 FC_FREE(field_addr_tmp);
64481 }
64482#endif /* FREECIV_JSON_CONNECTION */
64483
64484 log_packet_detailed("packet_ruleset_terrain_100: got info about ()");
64485
64486#ifdef FREECIV_DELTA_PROTOCOL
64487 packet_ruleset_terrain_100_fields fields;
64488 struct packet_ruleset_terrain *old;
64489 struct genhash **hash = pc->phs.received + PACKET_RULESET_TERRAIN;
64490
64491 if (nullptr == *hash) {
64492 *hash = genhash_new_full(hash_packet_ruleset_terrain_100, cmp_packet_ruleset_terrain_100,
64493 nullptr, nullptr, nullptr, destroy_packet_ruleset_terrain);
64494 }
64495
64496 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
64497 real_packet->id = old->id;
64498 real_packet->tclass = old->tclass;
64499 real_packet->flags = old->flags;
64500 real_packet->native_to = old->native_to;
64501 sz_strlcpy(real_packet->name, old->name);
64502 sz_strlcpy(real_packet->rule_name, old->rule_name);
64503 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
64504 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
64505 sz_strlcpy(real_packet->graphic_alt2, old->graphic_alt2);
64506 real_packet->movement_cost = old->movement_cost;
64507 real_packet->defense_bonus = old->defense_bonus;
64508 {
64509 int i;
64510
64511 for (i = 0; i < O_LAST; i++) {
64512 real_packet->output[i] = old->output[i];
64513 }
64514 }
64515 real_packet->num_resources = old->num_resources;
64516 {
64517 int i;
64518
64519 for (i = 0; i < old->num_resources; i++) {
64520 real_packet->resources[i] = old->resources[i];
64521 }
64522 }
64523 {
64524 int i;
64525
64526 for (i = 0; i < old->num_resources; i++) {
64527 real_packet->resource_freq[i] = old->resource_freq[i];
64528 }
64529 }
64530 {
64531 int i;
64532
64533 for (i = 0; i < O_LAST; i++) {
64534 real_packet->road_output_incr_pct[i] = old->road_output_incr_pct[i];
64535 }
64536 }
64537 real_packet->base_time = old->base_time;
64538 real_packet->road_time = old->road_time;
64539 real_packet->cultivate_result = old->cultivate_result;
64540 real_packet->cultivate_time = old->cultivate_time;
64541 real_packet->plant_result = old->plant_result;
64542 real_packet->plant_time = old->plant_time;
64543 real_packet->irrigation_food_incr = old->irrigation_food_incr;
64544 real_packet->irrigation_time = old->irrigation_time;
64545 real_packet->mining_shield_incr = old->mining_shield_incr;
64546 real_packet->mining_time = old->mining_time;
64547 real_packet->animal = old->animal;
64548 real_packet->transform_result = old->transform_result;
64549 real_packet->transform_time = old->transform_time;
64550 real_packet->placing_time = old->placing_time;
64551 real_packet->pillage_time = old->pillage_time;
64552 real_packet->extra_count = old->extra_count;
64553 {
64554 int i;
64555
64556 for (i = 0; i < old->extra_count; i++) {
64557 real_packet->extra_removal_times[i] = old->extra_removal_times[i];
64558 }
64559 }
64560 real_packet->color_red = old->color_red;
64561 real_packet->color_green = old->color_green;
64562 real_packet->color_blue = old->color_blue;
64563 if (old->helptext) {
64564 strvec_copy(real_packet->helptext, old->helptext);
64565 } else {
64566 strvec_clear(real_packet->helptext);
64567 }
64568 } else {
64569 /* packet is already initialized empty */
64570 log_packet_detailed(" no old info");
64571 }
64572
64573#ifdef FREECIV_JSON_CONNECTION
64574 field_addr.name = "fields";
64575#endif /* FREECIV_JSON_CONNECTION */
64576 DIO_BV_GET(&din, &field_addr, fields);
64577
64578 if (BV_ISSET(fields, 0)) {
64579 log_packet_detailed(" got field 'id'");
64580
64581#ifdef FREECIV_JSON_CONNECTION
64582 field_addr.name = "id";
64583#endif /* FREECIV_JSON_CONNECTION */
64584
64585 {
64586 int readin;
64587
64588 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
64589 RECEIVE_PACKET_FIELD_ERROR(id);
64590 }
64591 real_packet->id = readin;
64592 }
64593 }
64594
64595 if (BV_ISSET(fields, 1)) {
64596 log_packet_detailed(" got field 'tclass'");
64597
64598#ifdef FREECIV_JSON_CONNECTION
64599 field_addr.name = "tclass";
64600#endif /* FREECIV_JSON_CONNECTION */
64601
64602 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tclass)) {
64603 RECEIVE_PACKET_FIELD_ERROR(tclass);
64604 }
64605 }
64606
64607 if (BV_ISSET(fields, 2)) {
64608 log_packet_detailed(" got field 'flags'");
64609
64610#ifdef FREECIV_JSON_CONNECTION
64611 field_addr.name = "flags";
64612#endif /* FREECIV_JSON_CONNECTION */
64613
64614 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
64615 RECEIVE_PACKET_FIELD_ERROR(flags);
64616 }
64617 }
64618
64619 if (BV_ISSET(fields, 3)) {
64620 log_packet_detailed(" got field 'native_to'");
64621
64622#ifdef FREECIV_JSON_CONNECTION
64623 field_addr.name = "native_to";
64624#endif /* FREECIV_JSON_CONNECTION */
64625
64626 if (!DIO_BV_GET(&din, &field_addr, real_packet->native_to)) {
64627 RECEIVE_PACKET_FIELD_ERROR(native_to);
64628 }
64629 }
64630
64631 if (BV_ISSET(fields, 4)) {
64632 log_packet_detailed(" got field 'name'");
64633
64634#ifdef FREECIV_JSON_CONNECTION
64635 field_addr.name = "name";
64636#endif /* FREECIV_JSON_CONNECTION */
64637
64638 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
64639 RECEIVE_PACKET_FIELD_ERROR(name);
64640 }
64641 }
64642
64643 if (BV_ISSET(fields, 5)) {
64644 log_packet_detailed(" got field 'rule_name'");
64645
64646#ifdef FREECIV_JSON_CONNECTION
64647 field_addr.name = "rule_name";
64648#endif /* FREECIV_JSON_CONNECTION */
64649
64650 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
64651 RECEIVE_PACKET_FIELD_ERROR(rule_name);
64652 }
64653 }
64654
64655 if (BV_ISSET(fields, 6)) {
64656 log_packet_detailed(" got field 'graphic_str'");
64657
64658#ifdef FREECIV_JSON_CONNECTION
64659 field_addr.name = "graphic_str";
64660#endif /* FREECIV_JSON_CONNECTION */
64661
64662 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
64663 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
64664 }
64665 }
64666
64667 if (BV_ISSET(fields, 7)) {
64668 log_packet_detailed(" got field 'graphic_alt'");
64669
64670#ifdef FREECIV_JSON_CONNECTION
64671 field_addr.name = "graphic_alt";
64672#endif /* FREECIV_JSON_CONNECTION */
64673
64674 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
64675 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
64676 }
64677 }
64678
64679 if (BV_ISSET(fields, 8)) {
64680 log_packet_detailed(" got field 'graphic_alt2'");
64681
64682#ifdef FREECIV_JSON_CONNECTION
64683 field_addr.name = "graphic_alt2";
64684#endif /* FREECIV_JSON_CONNECTION */
64685
64686 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt2, sizeof(real_packet->graphic_alt2))) {
64687 RECEIVE_PACKET_FIELD_ERROR(graphic_alt2);
64688 }
64689 }
64690
64691 if (BV_ISSET(fields, 9)) {
64692 log_packet_detailed(" got field 'movement_cost'");
64693
64694#ifdef FREECIV_JSON_CONNECTION
64695 field_addr.name = "movement_cost";
64696#endif /* FREECIV_JSON_CONNECTION */
64697
64698 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->movement_cost)) {
64699 RECEIVE_PACKET_FIELD_ERROR(movement_cost);
64700 }
64701 }
64702
64703 if (BV_ISSET(fields, 10)) {
64704 log_packet_detailed(" got field 'defense_bonus'");
64705
64706#ifdef FREECIV_JSON_CONNECTION
64707 field_addr.name = "defense_bonus";
64708#endif /* FREECIV_JSON_CONNECTION */
64709
64710 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->defense_bonus)) {
64711 RECEIVE_PACKET_FIELD_ERROR(defense_bonus);
64712 }
64713 }
64714
64715 if (BV_ISSET(fields, 11)) {
64716 log_packet_detailed(" got field 'output'");
64717
64718#ifdef FREECIV_JSON_CONNECTION
64719 field_addr.name = "output";
64720#endif /* FREECIV_JSON_CONNECTION */
64721
64722 {
64723 int i;
64724
64725
64726#ifdef FREECIV_JSON_CONNECTION
64727 /* Enter array. */
64728 field_addr.sub_location = plocation_elem_new(0);
64729#endif /* FREECIV_JSON_CONNECTION */
64730
64731 for (i = 0; i < O_LAST; i++) {
64732#ifdef FREECIV_JSON_CONNECTION
64733 /* Next array element */
64734 field_addr.sub_location->number = i;
64735#endif /* FREECIV_JSON_CONNECTION */
64736
64737 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output[i])) {
64738 RECEIVE_PACKET_FIELD_ERROR(output);
64739 }
64740 }
64741
64742#ifdef FREECIV_JSON_CONNECTION
64743 /* Exit array. */
64744 FC_FREE(field_addr.sub_location);
64745#endif /* FREECIV_JSON_CONNECTION */
64746 }
64747 }
64748
64749 if (BV_ISSET(fields, 12)) {
64750 log_packet_detailed(" got field 'num_resources'");
64751
64752#ifdef FREECIV_JSON_CONNECTION
64753 field_addr.name = "num_resources";
64754#endif /* FREECIV_JSON_CONNECTION */
64755
64756 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->num_resources)) {
64757 RECEIVE_PACKET_FIELD_ERROR(num_resources);
64758 }
64759 }
64760
64761 if (BV_ISSET(fields, 13)) {
64762 log_packet_detailed(" got field 'resources'");
64763
64764#ifdef FREECIV_JSON_CONNECTION
64765 field_addr.name = "resources";
64766#endif /* FREECIV_JSON_CONNECTION */
64767
64768 {
64769 int i;
64770
64771 if (real_packet->num_resources > MAX_EXTRA_TYPES) {
64772 RECEIVE_PACKET_FIELD_ERROR(resources, ": array truncated");
64773 }
64774
64775#ifdef FREECIV_JSON_CONNECTION
64776 /* Enter array. */
64777 field_addr.sub_location = plocation_elem_new(0);
64778#endif /* FREECIV_JSON_CONNECTION */
64779
64780 for (i = 0; i < real_packet->num_resources; i++) {
64781#ifdef FREECIV_JSON_CONNECTION
64782 /* Next array element */
64783 field_addr.sub_location->number = i;
64784#endif /* FREECIV_JSON_CONNECTION */
64785
64786 {
64787 int readin;
64788
64789 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
64790 RECEIVE_PACKET_FIELD_ERROR(resources);
64791 }
64792 real_packet->resources[i] = readin;
64793 }
64794 }
64795
64796#ifdef FREECIV_JSON_CONNECTION
64797 /* Exit array. */
64798 FC_FREE(field_addr.sub_location);
64799#endif /* FREECIV_JSON_CONNECTION */
64800 }
64801 }
64802
64803 if (BV_ISSET(fields, 14)) {
64804 log_packet_detailed(" got field 'resource_freq'");
64805
64806#ifdef FREECIV_JSON_CONNECTION
64807 field_addr.name = "resource_freq";
64808#endif /* FREECIV_JSON_CONNECTION */
64809
64810 {
64811 int i;
64812
64813 if (real_packet->num_resources > MAX_EXTRA_TYPES) {
64814 RECEIVE_PACKET_FIELD_ERROR(resource_freq, ": array truncated");
64815 }
64816
64817#ifdef FREECIV_JSON_CONNECTION
64818 /* Enter array. */
64819 field_addr.sub_location = plocation_elem_new(0);
64820#endif /* FREECIV_JSON_CONNECTION */
64821
64822 for (i = 0; i < real_packet->num_resources; i++) {
64823#ifdef FREECIV_JSON_CONNECTION
64824 /* Next array element */
64825 field_addr.sub_location->number = i;
64826#endif /* FREECIV_JSON_CONNECTION */
64827
64828 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->resource_freq[i])) {
64829 RECEIVE_PACKET_FIELD_ERROR(resource_freq);
64830 }
64831 }
64832
64833#ifdef FREECIV_JSON_CONNECTION
64834 /* Exit array. */
64835 FC_FREE(field_addr.sub_location);
64836#endif /* FREECIV_JSON_CONNECTION */
64837 }
64838 }
64839
64840 if (BV_ISSET(fields, 15)) {
64841 log_packet_detailed(" got field 'road_output_incr_pct'");
64842
64843#ifdef FREECIV_JSON_CONNECTION
64844 field_addr.name = "road_output_incr_pct";
64845#endif /* FREECIV_JSON_CONNECTION */
64846
64847 {
64848 int i;
64849
64850
64851#ifdef FREECIV_JSON_CONNECTION
64852 /* Enter array. */
64853 field_addr.sub_location = plocation_elem_new(0);
64854#endif /* FREECIV_JSON_CONNECTION */
64855
64856 for (i = 0; i < O_LAST; i++) {
64857#ifdef FREECIV_JSON_CONNECTION
64858 /* Next array element */
64859 field_addr.sub_location->number = i;
64860#endif /* FREECIV_JSON_CONNECTION */
64861
64862 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->road_output_incr_pct[i])) {
64863 RECEIVE_PACKET_FIELD_ERROR(road_output_incr_pct);
64864 }
64865 }
64866
64867#ifdef FREECIV_JSON_CONNECTION
64868 /* Exit array. */
64869 FC_FREE(field_addr.sub_location);
64870#endif /* FREECIV_JSON_CONNECTION */
64871 }
64872 }
64873
64874 if (BV_ISSET(fields, 16)) {
64875 log_packet_detailed(" got field 'base_time'");
64876
64877#ifdef FREECIV_JSON_CONNECTION
64878 field_addr.name = "base_time";
64879#endif /* FREECIV_JSON_CONNECTION */
64880
64881 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->base_time)) {
64882 RECEIVE_PACKET_FIELD_ERROR(base_time);
64883 }
64884 }
64885
64886 if (BV_ISSET(fields, 17)) {
64887 log_packet_detailed(" got field 'road_time'");
64888
64889#ifdef FREECIV_JSON_CONNECTION
64890 field_addr.name = "road_time";
64891#endif /* FREECIV_JSON_CONNECTION */
64892
64893 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->road_time)) {
64894 RECEIVE_PACKET_FIELD_ERROR(road_time);
64895 }
64896 }
64897
64898 if (BV_ISSET(fields, 18)) {
64899 log_packet_detailed(" got field 'cultivate_result'");
64900
64901#ifdef FREECIV_JSON_CONNECTION
64902 field_addr.name = "cultivate_result";
64903#endif /* FREECIV_JSON_CONNECTION */
64904
64905 {
64906 int readin;
64907
64908 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
64909 RECEIVE_PACKET_FIELD_ERROR(cultivate_result);
64910 }
64911 real_packet->cultivate_result = readin;
64912 }
64913 }
64914
64915 if (BV_ISSET(fields, 19)) {
64916 log_packet_detailed(" got field 'cultivate_time'");
64917
64918#ifdef FREECIV_JSON_CONNECTION
64919 field_addr.name = "cultivate_time";
64920#endif /* FREECIV_JSON_CONNECTION */
64921
64922 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->cultivate_time)) {
64923 RECEIVE_PACKET_FIELD_ERROR(cultivate_time);
64924 }
64925 }
64926
64927 if (BV_ISSET(fields, 20)) {
64928 log_packet_detailed(" got field 'plant_result'");
64929
64930#ifdef FREECIV_JSON_CONNECTION
64931 field_addr.name = "plant_result";
64932#endif /* FREECIV_JSON_CONNECTION */
64933
64934 {
64935 int readin;
64936
64937 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
64938 RECEIVE_PACKET_FIELD_ERROR(plant_result);
64939 }
64940 real_packet->plant_result = readin;
64941 }
64942 }
64943
64944 if (BV_ISSET(fields, 21)) {
64945 log_packet_detailed(" got field 'plant_time'");
64946
64947#ifdef FREECIV_JSON_CONNECTION
64948 field_addr.name = "plant_time";
64949#endif /* FREECIV_JSON_CONNECTION */
64950
64951 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->plant_time)) {
64952 RECEIVE_PACKET_FIELD_ERROR(plant_time);
64953 }
64954 }
64955
64956 if (BV_ISSET(fields, 22)) {
64957 log_packet_detailed(" got field 'irrigation_food_incr'");
64958
64959#ifdef FREECIV_JSON_CONNECTION
64960 field_addr.name = "irrigation_food_incr";
64961#endif /* FREECIV_JSON_CONNECTION */
64962
64963 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->irrigation_food_incr)) {
64964 RECEIVE_PACKET_FIELD_ERROR(irrigation_food_incr);
64965 }
64966 }
64967
64968 if (BV_ISSET(fields, 23)) {
64969 log_packet_detailed(" got field 'irrigation_time'");
64970
64971#ifdef FREECIV_JSON_CONNECTION
64972 field_addr.name = "irrigation_time";
64973#endif /* FREECIV_JSON_CONNECTION */
64974
64975 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->irrigation_time)) {
64976 RECEIVE_PACKET_FIELD_ERROR(irrigation_time);
64977 }
64978 }
64979
64980 if (BV_ISSET(fields, 24)) {
64981 log_packet_detailed(" got field 'mining_shield_incr'");
64982
64983#ifdef FREECIV_JSON_CONNECTION
64984 field_addr.name = "mining_shield_incr";
64985#endif /* FREECIV_JSON_CONNECTION */
64986
64987 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->mining_shield_incr)) {
64988 RECEIVE_PACKET_FIELD_ERROR(mining_shield_incr);
64989 }
64990 }
64991
64992 if (BV_ISSET(fields, 25)) {
64993 log_packet_detailed(" got field 'mining_time'");
64994
64995#ifdef FREECIV_JSON_CONNECTION
64996 field_addr.name = "mining_time";
64997#endif /* FREECIV_JSON_CONNECTION */
64998
64999 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->mining_time)) {
65000 RECEIVE_PACKET_FIELD_ERROR(mining_time);
65001 }
65002 }
65003
65004 if (BV_ISSET(fields, 26)) {
65005 log_packet_detailed(" got field 'animal'");
65006
65007#ifdef FREECIV_JSON_CONNECTION
65008 field_addr.name = "animal";
65009#endif /* FREECIV_JSON_CONNECTION */
65010
65011 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->animal)) {
65012 RECEIVE_PACKET_FIELD_ERROR(animal);
65013 }
65014 }
65015
65016 if (BV_ISSET(fields, 27)) {
65017 log_packet_detailed(" got field 'transform_result'");
65018
65019#ifdef FREECIV_JSON_CONNECTION
65020 field_addr.name = "transform_result";
65021#endif /* FREECIV_JSON_CONNECTION */
65022
65023 {
65024 int readin;
65025
65026 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
65027 RECEIVE_PACKET_FIELD_ERROR(transform_result);
65028 }
65029 real_packet->transform_result = readin;
65030 }
65031 }
65032
65033 if (BV_ISSET(fields, 28)) {
65034 log_packet_detailed(" got field 'transform_time'");
65035
65036#ifdef FREECIV_JSON_CONNECTION
65037 field_addr.name = "transform_time";
65038#endif /* FREECIV_JSON_CONNECTION */
65039
65040 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->transform_time)) {
65041 RECEIVE_PACKET_FIELD_ERROR(transform_time);
65042 }
65043 }
65044
65045 if (BV_ISSET(fields, 29)) {
65046 log_packet_detailed(" got field 'placing_time'");
65047
65048#ifdef FREECIV_JSON_CONNECTION
65049 field_addr.name = "placing_time";
65050#endif /* FREECIV_JSON_CONNECTION */
65051
65052 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->placing_time)) {
65053 RECEIVE_PACKET_FIELD_ERROR(placing_time);
65054 }
65055 }
65056
65057 if (BV_ISSET(fields, 30)) {
65058 log_packet_detailed(" got field 'pillage_time'");
65059
65060#ifdef FREECIV_JSON_CONNECTION
65061 field_addr.name = "pillage_time";
65062#endif /* FREECIV_JSON_CONNECTION */
65063
65064 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->pillage_time)) {
65065 RECEIVE_PACKET_FIELD_ERROR(pillage_time);
65066 }
65067 }
65068
65069 if (BV_ISSET(fields, 31)) {
65070 log_packet_detailed(" got field 'extra_count'");
65071
65072#ifdef FREECIV_JSON_CONNECTION
65073 field_addr.name = "extra_count";
65074#endif /* FREECIV_JSON_CONNECTION */
65075
65076 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->extra_count)) {
65077 RECEIVE_PACKET_FIELD_ERROR(extra_count);
65078 }
65079 }
65080
65081 if (BV_ISSET(fields, 32)) {
65082 log_packet_detailed(" got field 'extra_removal_times'");
65083
65084#ifdef FREECIV_JSON_CONNECTION
65085 field_addr.name = "extra_removal_times";
65086#endif /* FREECIV_JSON_CONNECTION */
65087
65088 {
65089 int i;
65090
65091 if (real_packet->extra_count > MAX_EXTRA_TYPES) {
65092 RECEIVE_PACKET_FIELD_ERROR(extra_removal_times, ": array truncated");
65093 }
65094
65095#ifdef FREECIV_JSON_CONNECTION
65096 /* Enter array. */
65097 field_addr.sub_location = plocation_elem_new(0);
65098#endif /* FREECIV_JSON_CONNECTION */
65099
65100 for (i = 0; i < real_packet->extra_count; i++) {
65101#ifdef FREECIV_JSON_CONNECTION
65102 /* Next array element */
65103 field_addr.sub_location->number = i;
65104#endif /* FREECIV_JSON_CONNECTION */
65105
65106 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->extra_removal_times[i])) {
65107 RECEIVE_PACKET_FIELD_ERROR(extra_removal_times);
65108 }
65109 }
65110
65111#ifdef FREECIV_JSON_CONNECTION
65112 /* Exit array. */
65113 FC_FREE(field_addr.sub_location);
65114#endif /* FREECIV_JSON_CONNECTION */
65115 }
65116 }
65117
65118 if (BV_ISSET(fields, 33)) {
65119 log_packet_detailed(" got field 'color_red'");
65120
65121#ifdef FREECIV_JSON_CONNECTION
65122 field_addr.name = "color_red";
65123#endif /* FREECIV_JSON_CONNECTION */
65124
65125 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_red)) {
65126 RECEIVE_PACKET_FIELD_ERROR(color_red);
65127 }
65128 }
65129
65130 if (BV_ISSET(fields, 34)) {
65131 log_packet_detailed(" got field 'color_green'");
65132
65133#ifdef FREECIV_JSON_CONNECTION
65134 field_addr.name = "color_green";
65135#endif /* FREECIV_JSON_CONNECTION */
65136
65137 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_green)) {
65138 RECEIVE_PACKET_FIELD_ERROR(color_green);
65139 }
65140 }
65141
65142 if (BV_ISSET(fields, 35)) {
65143 log_packet_detailed(" got field 'color_blue'");
65144
65145#ifdef FREECIV_JSON_CONNECTION
65146 field_addr.name = "color_blue";
65147#endif /* FREECIV_JSON_CONNECTION */
65148
65149 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_blue)) {
65150 RECEIVE_PACKET_FIELD_ERROR(color_blue);
65151 }
65152 }
65153
65154 if (BV_ISSET(fields, 36)) {
65155 log_packet_detailed(" got field 'helptext'");
65156
65157#ifdef FREECIV_JSON_CONNECTION
65158 field_addr.name = "helptext";
65159#endif /* FREECIV_JSON_CONNECTION */
65160
65161 {
65162 int i;
65163
65164 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
65165 RECEIVE_PACKET_FIELD_ERROR(helptext);
65166 }
65167 strvec_reserve(real_packet->helptext, i);
65168
65169#ifdef FREECIV_JSON_CONNECTION
65170 /* Enter array. */
65171 field_addr.sub_location = plocation_elem_new(0);
65172#endif /* FREECIV_JSON_CONNECTION */
65173
65174 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
65175#ifdef FREECIV_JSON_CONNECTION
65176 /* Next array element */
65177 field_addr.sub_location->number = i;
65178#endif /* FREECIV_JSON_CONNECTION */
65179
65180 {
65181 char readin[MAX_LEN_PACKET];
65182
65183 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
65184 || !strvec_set(real_packet->helptext, i, readin)) {
65185 RECEIVE_PACKET_FIELD_ERROR(helptext);
65186 }
65187 }
65188 }
65189
65190#ifdef FREECIV_JSON_CONNECTION
65191 /* Exit array. */
65192 FC_FREE(field_addr.sub_location);
65193#endif /* FREECIV_JSON_CONNECTION */
65194 }
65195 }
65196
65197 if (nullptr == old) {
65198 old = fc_malloc(sizeof(*old));
65199 init_packet_ruleset_terrain(old);
65200 old->id = real_packet->id;
65201 old->tclass = real_packet->tclass;
65202 old->flags = real_packet->flags;
65203 old->native_to = real_packet->native_to;
65204 sz_strlcpy(old->name, real_packet->name);
65205 sz_strlcpy(old->rule_name, real_packet->rule_name);
65206 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
65207 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
65208 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
65209 old->movement_cost = real_packet->movement_cost;
65210 old->defense_bonus = real_packet->defense_bonus;
65211 {
65212 int i;
65213
65214 for (i = 0; i < O_LAST; i++) {
65215 old->output[i] = real_packet->output[i];
65216 }
65217 }
65218 old->num_resources = real_packet->num_resources;
65219 {
65220 int i;
65221
65222 for (i = 0; i < real_packet->num_resources; i++) {
65223 old->resources[i] = real_packet->resources[i];
65224 }
65225 }
65226 {
65227 int i;
65228
65229 for (i = 0; i < real_packet->num_resources; i++) {
65230 old->resource_freq[i] = real_packet->resource_freq[i];
65231 }
65232 }
65233 {
65234 int i;
65235
65236 for (i = 0; i < O_LAST; i++) {
65237 old->road_output_incr_pct[i] = real_packet->road_output_incr_pct[i];
65238 }
65239 }
65240 old->base_time = real_packet->base_time;
65241 old->road_time = real_packet->road_time;
65242 old->cultivate_result = real_packet->cultivate_result;
65243 old->cultivate_time = real_packet->cultivate_time;
65244 old->plant_result = real_packet->plant_result;
65245 old->plant_time = real_packet->plant_time;
65246 old->irrigation_food_incr = real_packet->irrigation_food_incr;
65247 old->irrigation_time = real_packet->irrigation_time;
65248 old->mining_shield_incr = real_packet->mining_shield_incr;
65249 old->mining_time = real_packet->mining_time;
65250 old->animal = real_packet->animal;
65251 old->transform_result = real_packet->transform_result;
65252 old->transform_time = real_packet->transform_time;
65253 old->placing_time = real_packet->placing_time;
65254 old->pillage_time = real_packet->pillage_time;
65255 old->extra_count = real_packet->extra_count;
65256 {
65257 int i;
65258
65259 for (i = 0; i < real_packet->extra_count; i++) {
65260 old->extra_removal_times[i] = real_packet->extra_removal_times[i];
65261 }
65262 }
65263 old->color_red = real_packet->color_red;
65264 old->color_green = real_packet->color_green;
65265 old->color_blue = real_packet->color_blue;
65266 if (real_packet->helptext) {
65267 strvec_copy(old->helptext, real_packet->helptext);
65268 } else {
65269 strvec_clear(old->helptext);
65270 }
65271 genhash_insert(*hash, old, old);
65272 } else {
65273 old->id = real_packet->id;
65274 old->tclass = real_packet->tclass;
65275 old->flags = real_packet->flags;
65276 old->native_to = real_packet->native_to;
65277 sz_strlcpy(old->name, real_packet->name);
65278 sz_strlcpy(old->rule_name, real_packet->rule_name);
65279 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
65280 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
65281 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
65282 old->movement_cost = real_packet->movement_cost;
65283 old->defense_bonus = real_packet->defense_bonus;
65284 {
65285 int i;
65286
65287 for (i = 0; i < O_LAST; i++) {
65288 old->output[i] = real_packet->output[i];
65289 }
65290 }
65291 old->num_resources = real_packet->num_resources;
65292 {
65293 int i;
65294
65295 for (i = 0; i < real_packet->num_resources; i++) {
65296 old->resources[i] = real_packet->resources[i];
65297 }
65298 }
65299 {
65300 int i;
65301
65302 for (i = 0; i < real_packet->num_resources; i++) {
65303 old->resource_freq[i] = real_packet->resource_freq[i];
65304 }
65305 }
65306 {
65307 int i;
65308
65309 for (i = 0; i < O_LAST; i++) {
65310 old->road_output_incr_pct[i] = real_packet->road_output_incr_pct[i];
65311 }
65312 }
65313 old->base_time = real_packet->base_time;
65314 old->road_time = real_packet->road_time;
65315 old->cultivate_result = real_packet->cultivate_result;
65316 old->cultivate_time = real_packet->cultivate_time;
65317 old->plant_result = real_packet->plant_result;
65318 old->plant_time = real_packet->plant_time;
65319 old->irrigation_food_incr = real_packet->irrigation_food_incr;
65320 old->irrigation_time = real_packet->irrigation_time;
65321 old->mining_shield_incr = real_packet->mining_shield_incr;
65322 old->mining_time = real_packet->mining_time;
65323 old->animal = real_packet->animal;
65324 old->transform_result = real_packet->transform_result;
65325 old->transform_time = real_packet->transform_time;
65326 old->placing_time = real_packet->placing_time;
65327 old->pillage_time = real_packet->pillage_time;
65328 old->extra_count = real_packet->extra_count;
65329 {
65330 int i;
65331
65332 for (i = 0; i < real_packet->extra_count; i++) {
65333 old->extra_removal_times[i] = real_packet->extra_removal_times[i];
65334 }
65335 }
65336 old->color_red = real_packet->color_red;
65337 old->color_green = real_packet->color_green;
65338 old->color_blue = real_packet->color_blue;
65339 if (real_packet->helptext) {
65340 strvec_copy(old->helptext, real_packet->helptext);
65341 } else {
65342 strvec_clear(old->helptext);
65343 }
65344 }
65345
65346#else /* FREECIV_DELTA_PROTOCOL */
65347#ifdef FREECIV_JSON_CONNECTION
65348 field_addr.name = "id";
65349#endif /* FREECIV_JSON_CONNECTION */
65350
65351 {
65352 int readin;
65353
65354 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
65355 RECEIVE_PACKET_FIELD_ERROR(id);
65356 }
65357 real_packet->id = readin;
65358 }
65359
65360#ifdef FREECIV_JSON_CONNECTION
65361 field_addr.name = "tclass";
65362#endif /* FREECIV_JSON_CONNECTION */
65363
65364 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tclass)) {
65365 RECEIVE_PACKET_FIELD_ERROR(tclass);
65366 }
65367
65368#ifdef FREECIV_JSON_CONNECTION
65369 field_addr.name = "flags";
65370#endif /* FREECIV_JSON_CONNECTION */
65371
65372 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
65373 RECEIVE_PACKET_FIELD_ERROR(flags);
65374 }
65375
65376#ifdef FREECIV_JSON_CONNECTION
65377 field_addr.name = "native_to";
65378#endif /* FREECIV_JSON_CONNECTION */
65379
65380 if (!DIO_BV_GET(&din, &field_addr, real_packet->native_to)) {
65381 RECEIVE_PACKET_FIELD_ERROR(native_to);
65382 }
65383
65384#ifdef FREECIV_JSON_CONNECTION
65385 field_addr.name = "name";
65386#endif /* FREECIV_JSON_CONNECTION */
65387
65388 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
65389 RECEIVE_PACKET_FIELD_ERROR(name);
65390 }
65391
65392#ifdef FREECIV_JSON_CONNECTION
65393 field_addr.name = "rule_name";
65394#endif /* FREECIV_JSON_CONNECTION */
65395
65396 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
65397 RECEIVE_PACKET_FIELD_ERROR(rule_name);
65398 }
65399
65400#ifdef FREECIV_JSON_CONNECTION
65401 field_addr.name = "graphic_str";
65402#endif /* FREECIV_JSON_CONNECTION */
65403
65404 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
65405 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
65406 }
65407
65408#ifdef FREECIV_JSON_CONNECTION
65409 field_addr.name = "graphic_alt";
65410#endif /* FREECIV_JSON_CONNECTION */
65411
65412 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
65413 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
65414 }
65415
65416#ifdef FREECIV_JSON_CONNECTION
65417 field_addr.name = "graphic_alt2";
65418#endif /* FREECIV_JSON_CONNECTION */
65419
65420 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt2, sizeof(real_packet->graphic_alt2))) {
65421 RECEIVE_PACKET_FIELD_ERROR(graphic_alt2);
65422 }
65423
65424#ifdef FREECIV_JSON_CONNECTION
65425 field_addr.name = "movement_cost";
65426#endif /* FREECIV_JSON_CONNECTION */
65427
65428 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->movement_cost)) {
65429 RECEIVE_PACKET_FIELD_ERROR(movement_cost);
65430 }
65431
65432#ifdef FREECIV_JSON_CONNECTION
65433 field_addr.name = "defense_bonus";
65434#endif /* FREECIV_JSON_CONNECTION */
65435
65436 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->defense_bonus)) {
65437 RECEIVE_PACKET_FIELD_ERROR(defense_bonus);
65438 }
65439
65440#ifdef FREECIV_JSON_CONNECTION
65441 field_addr.name = "output";
65442#endif /* FREECIV_JSON_CONNECTION */
65443
65444 {
65445 int i;
65446
65447
65448#ifdef FREECIV_JSON_CONNECTION
65449 /* Enter array. */
65450 field_addr.sub_location = plocation_elem_new(0);
65451#endif /* FREECIV_JSON_CONNECTION */
65452
65453 for (i = 0; i < O_LAST; i++) {
65454#ifdef FREECIV_JSON_CONNECTION
65455 /* Next array element */
65456 field_addr.sub_location->number = i;
65457#endif /* FREECIV_JSON_CONNECTION */
65458
65459 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output[i])) {
65460 RECEIVE_PACKET_FIELD_ERROR(output);
65461 }
65462 }
65463
65464#ifdef FREECIV_JSON_CONNECTION
65465 /* Exit array. */
65466 FC_FREE(field_addr.sub_location);
65467#endif /* FREECIV_JSON_CONNECTION */
65468 }
65469
65470#ifdef FREECIV_JSON_CONNECTION
65471 field_addr.name = "num_resources";
65472#endif /* FREECIV_JSON_CONNECTION */
65473
65474 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->num_resources)) {
65475 RECEIVE_PACKET_FIELD_ERROR(num_resources);
65476 }
65477
65478#ifdef FREECIV_JSON_CONNECTION
65479 field_addr.name = "resources";
65480#endif /* FREECIV_JSON_CONNECTION */
65481
65482 {
65483 int i;
65484
65485 if (real_packet->num_resources > MAX_EXTRA_TYPES) {
65486 RECEIVE_PACKET_FIELD_ERROR(resources, ": array truncated");
65487 }
65488
65489#ifdef FREECIV_JSON_CONNECTION
65490 /* Enter array. */
65491 field_addr.sub_location = plocation_elem_new(0);
65492#endif /* FREECIV_JSON_CONNECTION */
65493
65494 for (i = 0; i < real_packet->num_resources; i++) {
65495#ifdef FREECIV_JSON_CONNECTION
65496 /* Next array element */
65497 field_addr.sub_location->number = i;
65498#endif /* FREECIV_JSON_CONNECTION */
65499
65500 {
65501 int readin;
65502
65503 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
65504 RECEIVE_PACKET_FIELD_ERROR(resources);
65505 }
65506 real_packet->resources[i] = readin;
65507 }
65508 }
65509
65510#ifdef FREECIV_JSON_CONNECTION
65511 /* Exit array. */
65512 FC_FREE(field_addr.sub_location);
65513#endif /* FREECIV_JSON_CONNECTION */
65514 }
65515
65516#ifdef FREECIV_JSON_CONNECTION
65517 field_addr.name = "resource_freq";
65518#endif /* FREECIV_JSON_CONNECTION */
65519
65520 {
65521 int i;
65522
65523 if (real_packet->num_resources > MAX_EXTRA_TYPES) {
65524 RECEIVE_PACKET_FIELD_ERROR(resource_freq, ": array truncated");
65525 }
65526
65527#ifdef FREECIV_JSON_CONNECTION
65528 /* Enter array. */
65529 field_addr.sub_location = plocation_elem_new(0);
65530#endif /* FREECIV_JSON_CONNECTION */
65531
65532 for (i = 0; i < real_packet->num_resources; i++) {
65533#ifdef FREECIV_JSON_CONNECTION
65534 /* Next array element */
65535 field_addr.sub_location->number = i;
65536#endif /* FREECIV_JSON_CONNECTION */
65537
65538 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->resource_freq[i])) {
65539 RECEIVE_PACKET_FIELD_ERROR(resource_freq);
65540 }
65541 }
65542
65543#ifdef FREECIV_JSON_CONNECTION
65544 /* Exit array. */
65545 FC_FREE(field_addr.sub_location);
65546#endif /* FREECIV_JSON_CONNECTION */
65547 }
65548
65549#ifdef FREECIV_JSON_CONNECTION
65550 field_addr.name = "road_output_incr_pct";
65551#endif /* FREECIV_JSON_CONNECTION */
65552
65553 {
65554 int i;
65555
65556
65557#ifdef FREECIV_JSON_CONNECTION
65558 /* Enter array. */
65559 field_addr.sub_location = plocation_elem_new(0);
65560#endif /* FREECIV_JSON_CONNECTION */
65561
65562 for (i = 0; i < O_LAST; i++) {
65563#ifdef FREECIV_JSON_CONNECTION
65564 /* Next array element */
65565 field_addr.sub_location->number = i;
65566#endif /* FREECIV_JSON_CONNECTION */
65567
65568 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->road_output_incr_pct[i])) {
65569 RECEIVE_PACKET_FIELD_ERROR(road_output_incr_pct);
65570 }
65571 }
65572
65573#ifdef FREECIV_JSON_CONNECTION
65574 /* Exit array. */
65575 FC_FREE(field_addr.sub_location);
65576#endif /* FREECIV_JSON_CONNECTION */
65577 }
65578
65579#ifdef FREECIV_JSON_CONNECTION
65580 field_addr.name = "base_time";
65581#endif /* FREECIV_JSON_CONNECTION */
65582
65583 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->base_time)) {
65584 RECEIVE_PACKET_FIELD_ERROR(base_time);
65585 }
65586
65587#ifdef FREECIV_JSON_CONNECTION
65588 field_addr.name = "road_time";
65589#endif /* FREECIV_JSON_CONNECTION */
65590
65591 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->road_time)) {
65592 RECEIVE_PACKET_FIELD_ERROR(road_time);
65593 }
65594
65595#ifdef FREECIV_JSON_CONNECTION
65596 field_addr.name = "cultivate_result";
65597#endif /* FREECIV_JSON_CONNECTION */
65598
65599 {
65600 int readin;
65601
65602 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
65603 RECEIVE_PACKET_FIELD_ERROR(cultivate_result);
65604 }
65605 real_packet->cultivate_result = readin;
65606 }
65607
65608#ifdef FREECIV_JSON_CONNECTION
65609 field_addr.name = "cultivate_time";
65610#endif /* FREECIV_JSON_CONNECTION */
65611
65612 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->cultivate_time)) {
65613 RECEIVE_PACKET_FIELD_ERROR(cultivate_time);
65614 }
65615
65616#ifdef FREECIV_JSON_CONNECTION
65617 field_addr.name = "plant_result";
65618#endif /* FREECIV_JSON_CONNECTION */
65619
65620 {
65621 int readin;
65622
65623 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
65624 RECEIVE_PACKET_FIELD_ERROR(plant_result);
65625 }
65626 real_packet->plant_result = readin;
65627 }
65628
65629#ifdef FREECIV_JSON_CONNECTION
65630 field_addr.name = "plant_time";
65631#endif /* FREECIV_JSON_CONNECTION */
65632
65633 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->plant_time)) {
65634 RECEIVE_PACKET_FIELD_ERROR(plant_time);
65635 }
65636
65637#ifdef FREECIV_JSON_CONNECTION
65638 field_addr.name = "irrigation_food_incr";
65639#endif /* FREECIV_JSON_CONNECTION */
65640
65641 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->irrigation_food_incr)) {
65642 RECEIVE_PACKET_FIELD_ERROR(irrigation_food_incr);
65643 }
65644
65645#ifdef FREECIV_JSON_CONNECTION
65646 field_addr.name = "irrigation_time";
65647#endif /* FREECIV_JSON_CONNECTION */
65648
65649 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->irrigation_time)) {
65650 RECEIVE_PACKET_FIELD_ERROR(irrigation_time);
65651 }
65652
65653#ifdef FREECIV_JSON_CONNECTION
65654 field_addr.name = "mining_shield_incr";
65655#endif /* FREECIV_JSON_CONNECTION */
65656
65657 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->mining_shield_incr)) {
65658 RECEIVE_PACKET_FIELD_ERROR(mining_shield_incr);
65659 }
65660
65661#ifdef FREECIV_JSON_CONNECTION
65662 field_addr.name = "mining_time";
65663#endif /* FREECIV_JSON_CONNECTION */
65664
65665 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->mining_time)) {
65666 RECEIVE_PACKET_FIELD_ERROR(mining_time);
65667 }
65668
65669#ifdef FREECIV_JSON_CONNECTION
65670 field_addr.name = "animal";
65671#endif /* FREECIV_JSON_CONNECTION */
65672
65673 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->animal)) {
65674 RECEIVE_PACKET_FIELD_ERROR(animal);
65675 }
65676
65677#ifdef FREECIV_JSON_CONNECTION
65678 field_addr.name = "transform_result";
65679#endif /* FREECIV_JSON_CONNECTION */
65680
65681 {
65682 int readin;
65683
65684 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
65685 RECEIVE_PACKET_FIELD_ERROR(transform_result);
65686 }
65687 real_packet->transform_result = readin;
65688 }
65689
65690#ifdef FREECIV_JSON_CONNECTION
65691 field_addr.name = "transform_time";
65692#endif /* FREECIV_JSON_CONNECTION */
65693
65694 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->transform_time)) {
65695 RECEIVE_PACKET_FIELD_ERROR(transform_time);
65696 }
65697
65698#ifdef FREECIV_JSON_CONNECTION
65699 field_addr.name = "placing_time";
65700#endif /* FREECIV_JSON_CONNECTION */
65701
65702 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->placing_time)) {
65703 RECEIVE_PACKET_FIELD_ERROR(placing_time);
65704 }
65705
65706#ifdef FREECIV_JSON_CONNECTION
65707 field_addr.name = "pillage_time";
65708#endif /* FREECIV_JSON_CONNECTION */
65709
65710 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->pillage_time)) {
65711 RECEIVE_PACKET_FIELD_ERROR(pillage_time);
65712 }
65713
65714#ifdef FREECIV_JSON_CONNECTION
65715 field_addr.name = "extra_count";
65716#endif /* FREECIV_JSON_CONNECTION */
65717
65718 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->extra_count)) {
65719 RECEIVE_PACKET_FIELD_ERROR(extra_count);
65720 }
65721
65722#ifdef FREECIV_JSON_CONNECTION
65723 field_addr.name = "extra_removal_times";
65724#endif /* FREECIV_JSON_CONNECTION */
65725
65726 {
65727 int i;
65728
65729 if (real_packet->extra_count > MAX_EXTRA_TYPES) {
65730 RECEIVE_PACKET_FIELD_ERROR(extra_removal_times, ": array truncated");
65731 }
65732
65733#ifdef FREECIV_JSON_CONNECTION
65734 /* Enter array. */
65735 field_addr.sub_location = plocation_elem_new(0);
65736#endif /* FREECIV_JSON_CONNECTION */
65737
65738 for (i = 0; i < real_packet->extra_count; i++) {
65739#ifdef FREECIV_JSON_CONNECTION
65740 /* Next array element */
65741 field_addr.sub_location->number = i;
65742#endif /* FREECIV_JSON_CONNECTION */
65743
65744 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->extra_removal_times[i])) {
65745 RECEIVE_PACKET_FIELD_ERROR(extra_removal_times);
65746 }
65747 }
65748
65749#ifdef FREECIV_JSON_CONNECTION
65750 /* Exit array. */
65751 FC_FREE(field_addr.sub_location);
65752#endif /* FREECIV_JSON_CONNECTION */
65753 }
65754
65755#ifdef FREECIV_JSON_CONNECTION
65756 field_addr.name = "color_red";
65757#endif /* FREECIV_JSON_CONNECTION */
65758
65759 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_red)) {
65760 RECEIVE_PACKET_FIELD_ERROR(color_red);
65761 }
65762
65763#ifdef FREECIV_JSON_CONNECTION
65764 field_addr.name = "color_green";
65765#endif /* FREECIV_JSON_CONNECTION */
65766
65767 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_green)) {
65768 RECEIVE_PACKET_FIELD_ERROR(color_green);
65769 }
65770
65771#ifdef FREECIV_JSON_CONNECTION
65772 field_addr.name = "color_blue";
65773#endif /* FREECIV_JSON_CONNECTION */
65774
65775 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->color_blue)) {
65776 RECEIVE_PACKET_FIELD_ERROR(color_blue);
65777 }
65778
65779#ifdef FREECIV_JSON_CONNECTION
65780 field_addr.name = "helptext";
65781#endif /* FREECIV_JSON_CONNECTION */
65782
65783 {
65784 int i;
65785
65786 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
65787 RECEIVE_PACKET_FIELD_ERROR(helptext);
65788 }
65789 strvec_reserve(real_packet->helptext, i);
65790
65791#ifdef FREECIV_JSON_CONNECTION
65792 /* Enter array. */
65793 field_addr.sub_location = plocation_elem_new(0);
65794#endif /* FREECIV_JSON_CONNECTION */
65795
65796 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
65797#ifdef FREECIV_JSON_CONNECTION
65798 /* Next array element */
65799 field_addr.sub_location->number = i;
65800#endif /* FREECIV_JSON_CONNECTION */
65801
65802 {
65803 char readin[MAX_LEN_PACKET];
65804
65805 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
65806 || !strvec_set(real_packet->helptext, i, readin)) {
65807 RECEIVE_PACKET_FIELD_ERROR(helptext);
65808 }
65809 }
65810 }
65811
65812#ifdef FREECIV_JSON_CONNECTION
65813 /* Exit array. */
65814 FC_FREE(field_addr.sub_location);
65815#endif /* FREECIV_JSON_CONNECTION */
65816 }
65817#endif /* FREECIV_DELTA_PROTOCOL */
65818
65819 RECEIVE_PACKET_END(real_packet);
65820#undef FREE_PACKET_STRUCT
65821}
65822
65823 static int send_packet_ruleset_terrain_100(struct connection *pc, const struct packet_ruleset_terrain *packet)
65824{
65825 const struct packet_ruleset_terrain *real_packet = packet;
65826 int e;
65827 SEND_PACKET_START(PACKET_RULESET_TERRAIN);
65828
65829 log_packet_detailed("packet_ruleset_terrain_100: sending info about ()");
65830
65831#ifdef FREECIV_DELTA_PROTOCOL
65832 packet_ruleset_terrain_100_fields fields;
65833 struct packet_ruleset_terrain *old;
65834 bool differ;
65835 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TERRAIN;
65836
65837 if (nullptr == *hash) {
65838 *hash = genhash_new_full(hash_packet_ruleset_terrain_100, cmp_packet_ruleset_terrain_100,
65839 nullptr, nullptr, nullptr, destroy_packet_ruleset_terrain);
65840 }
65841 BV_CLR_ALL(fields);
65842
65843 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
65844 old = fc_malloc(sizeof(*old));
65845 /* temporary bitcopy just to insert correctly */
65846 *old = *real_packet;
65847 genhash_insert(*hash, old, old);
65848 init_packet_ruleset_terrain(old);
65849 }
65850
65851 differ = (old->id != real_packet->id);
65852 if (differ) {
65853 BV_SET(fields, 0);
65854 }
65855
65856 differ = (old->tclass != real_packet->tclass);
65857 if (differ) {
65858 BV_SET(fields, 1);
65859 }
65860
65861 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
65862 if (differ) {
65863 BV_SET(fields, 2);
65864 }
65865
65866 differ = !BV_ARE_EQUAL(old->native_to, real_packet->native_to);
65867 if (differ) {
65868 BV_SET(fields, 3);
65869 }
65870
65871 differ = (strcmp(old->name, real_packet->name) != 0);
65872 if (differ) {
65873 BV_SET(fields, 4);
65874 }
65875
65876 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
65877 if (differ) {
65878 BV_SET(fields, 5);
65879 }
65880
65881 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
65882 if (differ) {
65883 BV_SET(fields, 6);
65884 }
65885
65886 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
65887 if (differ) {
65888 BV_SET(fields, 7);
65889 }
65890
65891 differ = (strcmp(old->graphic_alt2, real_packet->graphic_alt2) != 0);
65892 if (differ) {
65893 BV_SET(fields, 8);
65894 }
65895
65896 differ = (old->movement_cost != real_packet->movement_cost);
65897 if (differ) {
65898 BV_SET(fields, 9);
65899 }
65900
65901 differ = (old->defense_bonus != real_packet->defense_bonus);
65902 if (differ) {
65903 BV_SET(fields, 10);
65904 }
65905
65906 differ = FALSE;
65907 {
65908 int i;
65909
65910 for (i = 0; i < O_LAST; i++) {
65911 differ = (old->output[i] != real_packet->output[i]);
65912 if (differ) {
65913 break;
65914 }
65915 }
65916 }
65917 if (differ) {
65918 BV_SET(fields, 11);
65919 }
65920
65921 differ = (old->num_resources != real_packet->num_resources);
65922 if (differ) {
65923 BV_SET(fields, 12);
65924 }
65925
65926 differ = (old->num_resources != real_packet->num_resources);
65927 if (!differ) {
65928 int i;
65929
65930 for (i = 0; i < old->num_resources; i++) {
65931 differ = (old->resources[i] != real_packet->resources[i]);
65932 if (differ) {
65933 break;
65934 }
65935 }
65936 }
65937 if (differ) {
65938 BV_SET(fields, 13);
65939 }
65940
65941 differ = (old->num_resources != real_packet->num_resources);
65942 if (!differ) {
65943 int i;
65944
65945 for (i = 0; i < old->num_resources; i++) {
65946 differ = (old->resource_freq[i] != real_packet->resource_freq[i]);
65947 if (differ) {
65948 break;
65949 }
65950 }
65951 }
65952 if (differ) {
65953 BV_SET(fields, 14);
65954 }
65955
65956 differ = FALSE;
65957 {
65958 int i;
65959
65960 for (i = 0; i < O_LAST; i++) {
65961 differ = (old->road_output_incr_pct[i] != real_packet->road_output_incr_pct[i]);
65962 if (differ) {
65963 break;
65964 }
65965 }
65966 }
65967 if (differ) {
65968 BV_SET(fields, 15);
65969 }
65970
65971 differ = (old->base_time != real_packet->base_time);
65972 if (differ) {
65973 BV_SET(fields, 16);
65974 }
65975
65976 differ = (old->road_time != real_packet->road_time);
65977 if (differ) {
65978 BV_SET(fields, 17);
65979 }
65980
65981 differ = (old->cultivate_result != real_packet->cultivate_result);
65982 if (differ) {
65983 BV_SET(fields, 18);
65984 }
65985
65986 differ = (old->cultivate_time != real_packet->cultivate_time);
65987 if (differ) {
65988 BV_SET(fields, 19);
65989 }
65990
65991 differ = (old->plant_result != real_packet->plant_result);
65992 if (differ) {
65993 BV_SET(fields, 20);
65994 }
65995
65996 differ = (old->plant_time != real_packet->plant_time);
65997 if (differ) {
65998 BV_SET(fields, 21);
65999 }
66000
66001 differ = (old->irrigation_food_incr != real_packet->irrigation_food_incr);
66002 if (differ) {
66003 BV_SET(fields, 22);
66004 }
66005
66006 differ = (old->irrigation_time != real_packet->irrigation_time);
66007 if (differ) {
66008 BV_SET(fields, 23);
66009 }
66010
66011 differ = (old->mining_shield_incr != real_packet->mining_shield_incr);
66012 if (differ) {
66013 BV_SET(fields, 24);
66014 }
66015
66016 differ = (old->mining_time != real_packet->mining_time);
66017 if (differ) {
66018 BV_SET(fields, 25);
66019 }
66020
66021 differ = (old->animal != real_packet->animal);
66022 if (differ) {
66023 BV_SET(fields, 26);
66024 }
66025
66026 differ = (old->transform_result != real_packet->transform_result);
66027 if (differ) {
66028 BV_SET(fields, 27);
66029 }
66030
66031 differ = (old->transform_time != real_packet->transform_time);
66032 if (differ) {
66033 BV_SET(fields, 28);
66034 }
66035
66036 differ = (old->placing_time != real_packet->placing_time);
66037 if (differ) {
66038 BV_SET(fields, 29);
66039 }
66040
66041 differ = (old->pillage_time != real_packet->pillage_time);
66042 if (differ) {
66043 BV_SET(fields, 30);
66044 }
66045
66046 differ = (old->extra_count != real_packet->extra_count);
66047 if (differ) {
66048 BV_SET(fields, 31);
66049 }
66050
66051 differ = (old->extra_count != real_packet->extra_count);
66052 if (!differ) {
66053 int i;
66054
66055 for (i = 0; i < old->extra_count; i++) {
66056 differ = (old->extra_removal_times[i] != real_packet->extra_removal_times[i]);
66057 if (differ) {
66058 break;
66059 }
66060 }
66061 }
66062 if (differ) {
66063 BV_SET(fields, 32);
66064 }
66065
66066 differ = (old->color_red != real_packet->color_red);
66067 if (differ) {
66068 BV_SET(fields, 33);
66069 }
66070
66071 differ = (old->color_green != real_packet->color_green);
66072 if (differ) {
66073 BV_SET(fields, 34);
66074 }
66075
66076 differ = (old->color_blue != real_packet->color_blue);
66077 if (differ) {
66078 BV_SET(fields, 35);
66079 }
66080
66081 if (real_packet->helptext) {
66082 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
66083 } else {
66084 differ = (strvec_size(old->helptext) > 0);
66085 }
66086 if (differ) {
66087 BV_SET(fields, 36);
66088 }
66089#endif /* FREECIV_DELTA_PROTOCOL */
66090
66091#ifdef FREECIV_JSON_CONNECTION
66092 struct plocation field_addr;
66093 {
66094 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
66095 field_addr = *field_addr_tmp;
66096 FC_FREE(field_addr_tmp);
66097 }
66098#endif /* FREECIV_JSON_CONNECTION */
66099
66100#ifdef FREECIV_DELTA_PROTOCOL
66101#ifdef FREECIV_JSON_CONNECTION
66102 field_addr.name = "fields";
66103#endif /* FREECIV_JSON_CONNECTION */
66104 e = 0;
66105 e |= DIO_BV_PUT(&dout, &field_addr, fields);
66106 if (e) {
66107 log_packet_detailed("fields bitvector error detected");
66108 }
66109
66110 if (BV_ISSET(fields, 0)) {
66111 log_packet_detailed(" field 'id' has changed");
66112
66113#ifdef FREECIV_JSON_CONNECTION
66114 field_addr.name = "id";
66115#endif /* FREECIV_JSON_CONNECTION */
66116 e = 0;
66117
66118 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
66119
66120 if (e) {
66121 log_packet_detailed("'id' field error detected");
66122 }
66123 }
66124
66125 if (BV_ISSET(fields, 1)) {
66126 log_packet_detailed(" field 'tclass' has changed");
66127
66128#ifdef FREECIV_JSON_CONNECTION
66129 field_addr.name = "tclass";
66130#endif /* FREECIV_JSON_CONNECTION */
66131 e = 0;
66132
66133 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tclass);
66134
66135 if (e) {
66136 log_packet_detailed("'tclass' field error detected");
66137 }
66138 }
66139
66140 if (BV_ISSET(fields, 2)) {
66141 log_packet_detailed(" field 'flags' has changed");
66142
66143#ifdef FREECIV_JSON_CONNECTION
66144 field_addr.name = "flags";
66145#endif /* FREECIV_JSON_CONNECTION */
66146 e = 0;
66147
66148 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
66149
66150 if (e) {
66151 log_packet_detailed("'flags' field error detected");
66152 }
66153 }
66154
66155 if (BV_ISSET(fields, 3)) {
66156 log_packet_detailed(" field 'native_to' has changed");
66157
66158#ifdef FREECIV_JSON_CONNECTION
66159 field_addr.name = "native_to";
66160#endif /* FREECIV_JSON_CONNECTION */
66161 e = 0;
66162
66163 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->native_to);
66164
66165 if (e) {
66166 log_packet_detailed("'native_to' field error detected");
66167 }
66168 }
66169
66170 if (BV_ISSET(fields, 4)) {
66171 log_packet_detailed(" field 'name' has changed");
66172
66173#ifdef FREECIV_JSON_CONNECTION
66174 field_addr.name = "name";
66175#endif /* FREECIV_JSON_CONNECTION */
66176 e = 0;
66177
66178 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
66179
66180 if (e) {
66181 log_packet_detailed("'name' field error detected");
66182 }
66183 }
66184
66185 if (BV_ISSET(fields, 5)) {
66186 log_packet_detailed(" field 'rule_name' has changed");
66187
66188#ifdef FREECIV_JSON_CONNECTION
66189 field_addr.name = "rule_name";
66190#endif /* FREECIV_JSON_CONNECTION */
66191 e = 0;
66192
66193 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
66194
66195 if (e) {
66196 log_packet_detailed("'rule_name' field error detected");
66197 }
66198 }
66199
66200 if (BV_ISSET(fields, 6)) {
66201 log_packet_detailed(" field 'graphic_str' has changed");
66202
66203#ifdef FREECIV_JSON_CONNECTION
66204 field_addr.name = "graphic_str";
66205#endif /* FREECIV_JSON_CONNECTION */
66206 e = 0;
66207
66208 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
66209
66210 if (e) {
66211 log_packet_detailed("'graphic_str' field error detected");
66212 }
66213 }
66214
66215 if (BV_ISSET(fields, 7)) {
66216 log_packet_detailed(" field 'graphic_alt' has changed");
66217
66218#ifdef FREECIV_JSON_CONNECTION
66219 field_addr.name = "graphic_alt";
66220#endif /* FREECIV_JSON_CONNECTION */
66221 e = 0;
66222
66223 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
66224
66225 if (e) {
66226 log_packet_detailed("'graphic_alt' field error detected");
66227 }
66228 }
66229
66230 if (BV_ISSET(fields, 8)) {
66231 log_packet_detailed(" field 'graphic_alt2' has changed");
66232
66233#ifdef FREECIV_JSON_CONNECTION
66234 field_addr.name = "graphic_alt2";
66235#endif /* FREECIV_JSON_CONNECTION */
66236 e = 0;
66237
66238 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt2);
66239
66240 if (e) {
66241 log_packet_detailed("'graphic_alt2' field error detected");
66242 }
66243 }
66244
66245 if (BV_ISSET(fields, 9)) {
66246 log_packet_detailed(" field 'movement_cost' has changed");
66247
66248#ifdef FREECIV_JSON_CONNECTION
66249 field_addr.name = "movement_cost";
66250#endif /* FREECIV_JSON_CONNECTION */
66251 e = 0;
66252
66253 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->movement_cost);
66254
66255 if (e) {
66256 log_packet_detailed("'movement_cost' field error detected");
66257 }
66258 }
66259
66260 if (BV_ISSET(fields, 10)) {
66261 log_packet_detailed(" field 'defense_bonus' has changed");
66262
66263#ifdef FREECIV_JSON_CONNECTION
66264 field_addr.name = "defense_bonus";
66265#endif /* FREECIV_JSON_CONNECTION */
66266 e = 0;
66267
66268 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->defense_bonus);
66269
66270 if (e) {
66271 log_packet_detailed("'defense_bonus' field error detected");
66272 }
66273 }
66274
66275 if (BV_ISSET(fields, 11)) {
66276 log_packet_detailed(" field 'output' has changed");
66277
66278#ifdef FREECIV_JSON_CONNECTION
66279 field_addr.name = "output";
66280#endif /* FREECIV_JSON_CONNECTION */
66281 e = 0;
66282
66283 {
66284 int i;
66285
66286#ifdef FREECIV_JSON_CONNECTION
66287 /* Create the array. */
66288 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
66289
66290 /* Enter array. */
66291 field_addr.sub_location = plocation_elem_new(0);
66292#endif /* FREECIV_JSON_CONNECTION */
66293
66294 for (i = 0; i < O_LAST; i++) {
66295#ifdef FREECIV_JSON_CONNECTION
66296 /* Next array element. */
66297 field_addr.sub_location->number = i;
66298#endif /* FREECIV_JSON_CONNECTION */
66299
66300 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output[i]);
66301 }
66302
66303#ifdef FREECIV_JSON_CONNECTION
66304 /* Exit array. */
66305 FC_FREE(field_addr.sub_location);
66306#endif /* FREECIV_JSON_CONNECTION */
66307 }
66308
66309 if (e) {
66310 log_packet_detailed("'output' field error detected");
66311 }
66312 }
66313
66314 if (BV_ISSET(fields, 12)) {
66315 log_packet_detailed(" field 'num_resources' has changed");
66316
66317#ifdef FREECIV_JSON_CONNECTION
66318 field_addr.name = "num_resources";
66319#endif /* FREECIV_JSON_CONNECTION */
66320 e = 0;
66321
66322 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->num_resources);
66323
66324 if (e) {
66325 log_packet_detailed("'num_resources' field error detected");
66326 }
66327 }
66328
66329 if (BV_ISSET(fields, 13)) {
66330 log_packet_detailed(" field 'resources' has changed");
66331
66332#ifdef FREECIV_JSON_CONNECTION
66333 field_addr.name = "resources";
66334#endif /* FREECIV_JSON_CONNECTION */
66335 e = 0;
66336
66337 {
66338 int i;
66339
66340#ifdef FREECIV_JSON_CONNECTION
66341 /* Create the array. */
66342 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->num_resources);
66343
66344 /* Enter array. */
66345 field_addr.sub_location = plocation_elem_new(0);
66346#endif /* FREECIV_JSON_CONNECTION */
66347
66348 for (i = 0; i < real_packet->num_resources; i++) {
66349#ifdef FREECIV_JSON_CONNECTION
66350 /* Next array element. */
66351 field_addr.sub_location->number = i;
66352#endif /* FREECIV_JSON_CONNECTION */
66353
66354 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resources[i]);
66355 }
66356
66357#ifdef FREECIV_JSON_CONNECTION
66358 /* Exit array. */
66359 FC_FREE(field_addr.sub_location);
66360#endif /* FREECIV_JSON_CONNECTION */
66361 }
66362
66363 if (e) {
66364 log_packet_detailed("'resources' field error detected");
66365 }
66366 }
66367
66368 if (BV_ISSET(fields, 14)) {
66369 log_packet_detailed(" field 'resource_freq' has changed");
66370
66371#ifdef FREECIV_JSON_CONNECTION
66372 field_addr.name = "resource_freq";
66373#endif /* FREECIV_JSON_CONNECTION */
66374 e = 0;
66375
66376 {
66377 int i;
66378
66379#ifdef FREECIV_JSON_CONNECTION
66380 /* Create the array. */
66381 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->num_resources);
66382
66383 /* Enter array. */
66384 field_addr.sub_location = plocation_elem_new(0);
66385#endif /* FREECIV_JSON_CONNECTION */
66386
66387 for (i = 0; i < real_packet->num_resources; i++) {
66388#ifdef FREECIV_JSON_CONNECTION
66389 /* Next array element. */
66390 field_addr.sub_location->number = i;
66391#endif /* FREECIV_JSON_CONNECTION */
66392
66393 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resource_freq[i]);
66394 }
66395
66396#ifdef FREECIV_JSON_CONNECTION
66397 /* Exit array. */
66398 FC_FREE(field_addr.sub_location);
66399#endif /* FREECIV_JSON_CONNECTION */
66400 }
66401
66402 if (e) {
66403 log_packet_detailed("'resource_freq' field error detected");
66404 }
66405 }
66406
66407 if (BV_ISSET(fields, 15)) {
66408 log_packet_detailed(" field 'road_output_incr_pct' has changed");
66409
66410#ifdef FREECIV_JSON_CONNECTION
66411 field_addr.name = "road_output_incr_pct";
66412#endif /* FREECIV_JSON_CONNECTION */
66413 e = 0;
66414
66415 {
66416 int i;
66417
66418#ifdef FREECIV_JSON_CONNECTION
66419 /* Create the array. */
66420 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
66421
66422 /* Enter array. */
66423 field_addr.sub_location = plocation_elem_new(0);
66424#endif /* FREECIV_JSON_CONNECTION */
66425
66426 for (i = 0; i < O_LAST; i++) {
66427#ifdef FREECIV_JSON_CONNECTION
66428 /* Next array element. */
66429 field_addr.sub_location->number = i;
66430#endif /* FREECIV_JSON_CONNECTION */
66431
66432 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->road_output_incr_pct[i]);
66433 }
66434
66435#ifdef FREECIV_JSON_CONNECTION
66436 /* Exit array. */
66437 FC_FREE(field_addr.sub_location);
66438#endif /* FREECIV_JSON_CONNECTION */
66439 }
66440
66441 if (e) {
66442 log_packet_detailed("'road_output_incr_pct' field error detected");
66443 }
66444 }
66445
66446 if (BV_ISSET(fields, 16)) {
66447 log_packet_detailed(" field 'base_time' has changed");
66448
66449#ifdef FREECIV_JSON_CONNECTION
66450 field_addr.name = "base_time";
66451#endif /* FREECIV_JSON_CONNECTION */
66452 e = 0;
66453
66454 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->base_time);
66455
66456 if (e) {
66457 log_packet_detailed("'base_time' field error detected");
66458 }
66459 }
66460
66461 if (BV_ISSET(fields, 17)) {
66462 log_packet_detailed(" field 'road_time' has changed");
66463
66464#ifdef FREECIV_JSON_CONNECTION
66465 field_addr.name = "road_time";
66466#endif /* FREECIV_JSON_CONNECTION */
66467 e = 0;
66468
66469 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->road_time);
66470
66471 if (e) {
66472 log_packet_detailed("'road_time' field error detected");
66473 }
66474 }
66475
66476 if (BV_ISSET(fields, 18)) {
66477 log_packet_detailed(" field 'cultivate_result' has changed");
66478
66479#ifdef FREECIV_JSON_CONNECTION
66480 field_addr.name = "cultivate_result";
66481#endif /* FREECIV_JSON_CONNECTION */
66482 e = 0;
66483
66484 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cultivate_result);
66485
66486 if (e) {
66487 log_packet_detailed("'cultivate_result' field error detected");
66488 }
66489 }
66490
66491 if (BV_ISSET(fields, 19)) {
66492 log_packet_detailed(" field 'cultivate_time' has changed");
66493
66494#ifdef FREECIV_JSON_CONNECTION
66495 field_addr.name = "cultivate_time";
66496#endif /* FREECIV_JSON_CONNECTION */
66497 e = 0;
66498
66499 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cultivate_time);
66500
66501 if (e) {
66502 log_packet_detailed("'cultivate_time' field error detected");
66503 }
66504 }
66505
66506 if (BV_ISSET(fields, 20)) {
66507 log_packet_detailed(" field 'plant_result' has changed");
66508
66509#ifdef FREECIV_JSON_CONNECTION
66510 field_addr.name = "plant_result";
66511#endif /* FREECIV_JSON_CONNECTION */
66512 e = 0;
66513
66514 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->plant_result);
66515
66516 if (e) {
66517 log_packet_detailed("'plant_result' field error detected");
66518 }
66519 }
66520
66521 if (BV_ISSET(fields, 21)) {
66522 log_packet_detailed(" field 'plant_time' has changed");
66523
66524#ifdef FREECIV_JSON_CONNECTION
66525 field_addr.name = "plant_time";
66526#endif /* FREECIV_JSON_CONNECTION */
66527 e = 0;
66528
66529 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->plant_time);
66530
66531 if (e) {
66532 log_packet_detailed("'plant_time' field error detected");
66533 }
66534 }
66535
66536 if (BV_ISSET(fields, 22)) {
66537 log_packet_detailed(" field 'irrigation_food_incr' has changed");
66538
66539#ifdef FREECIV_JSON_CONNECTION
66540 field_addr.name = "irrigation_food_incr";
66541#endif /* FREECIV_JSON_CONNECTION */
66542 e = 0;
66543
66544 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->irrigation_food_incr);
66545
66546 if (e) {
66547 log_packet_detailed("'irrigation_food_incr' field error detected");
66548 }
66549 }
66550
66551 if (BV_ISSET(fields, 23)) {
66552 log_packet_detailed(" field 'irrigation_time' has changed");
66553
66554#ifdef FREECIV_JSON_CONNECTION
66555 field_addr.name = "irrigation_time";
66556#endif /* FREECIV_JSON_CONNECTION */
66557 e = 0;
66558
66559 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->irrigation_time);
66560
66561 if (e) {
66562 log_packet_detailed("'irrigation_time' field error detected");
66563 }
66564 }
66565
66566 if (BV_ISSET(fields, 24)) {
66567 log_packet_detailed(" field 'mining_shield_incr' has changed");
66568
66569#ifdef FREECIV_JSON_CONNECTION
66570 field_addr.name = "mining_shield_incr";
66571#endif /* FREECIV_JSON_CONNECTION */
66572 e = 0;
66573
66574 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->mining_shield_incr);
66575
66576 if (e) {
66577 log_packet_detailed("'mining_shield_incr' field error detected");
66578 }
66579 }
66580
66581 if (BV_ISSET(fields, 25)) {
66582 log_packet_detailed(" field 'mining_time' has changed");
66583
66584#ifdef FREECIV_JSON_CONNECTION
66585 field_addr.name = "mining_time";
66586#endif /* FREECIV_JSON_CONNECTION */
66587 e = 0;
66588
66589 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->mining_time);
66590
66591 if (e) {
66592 log_packet_detailed("'mining_time' field error detected");
66593 }
66594 }
66595
66596 if (BV_ISSET(fields, 26)) {
66597 log_packet_detailed(" field 'animal' has changed");
66598
66599#ifdef FREECIV_JSON_CONNECTION
66600 field_addr.name = "animal";
66601#endif /* FREECIV_JSON_CONNECTION */
66602 e = 0;
66603
66604 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->animal);
66605
66606 if (e) {
66607 log_packet_detailed("'animal' field error detected");
66608 }
66609 }
66610
66611 if (BV_ISSET(fields, 27)) {
66612 log_packet_detailed(" field 'transform_result' has changed");
66613
66614#ifdef FREECIV_JSON_CONNECTION
66615 field_addr.name = "transform_result";
66616#endif /* FREECIV_JSON_CONNECTION */
66617 e = 0;
66618
66619 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->transform_result);
66620
66621 if (e) {
66622 log_packet_detailed("'transform_result' field error detected");
66623 }
66624 }
66625
66626 if (BV_ISSET(fields, 28)) {
66627 log_packet_detailed(" field 'transform_time' has changed");
66628
66629#ifdef FREECIV_JSON_CONNECTION
66630 field_addr.name = "transform_time";
66631#endif /* FREECIV_JSON_CONNECTION */
66632 e = 0;
66633
66634 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->transform_time);
66635
66636 if (e) {
66637 log_packet_detailed("'transform_time' field error detected");
66638 }
66639 }
66640
66641 if (BV_ISSET(fields, 29)) {
66642 log_packet_detailed(" field 'placing_time' has changed");
66643
66644#ifdef FREECIV_JSON_CONNECTION
66645 field_addr.name = "placing_time";
66646#endif /* FREECIV_JSON_CONNECTION */
66647 e = 0;
66648
66649 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->placing_time);
66650
66651 if (e) {
66652 log_packet_detailed("'placing_time' field error detected");
66653 }
66654 }
66655
66656 if (BV_ISSET(fields, 30)) {
66657 log_packet_detailed(" field 'pillage_time' has changed");
66658
66659#ifdef FREECIV_JSON_CONNECTION
66660 field_addr.name = "pillage_time";
66661#endif /* FREECIV_JSON_CONNECTION */
66662 e = 0;
66663
66664 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->pillage_time);
66665
66666 if (e) {
66667 log_packet_detailed("'pillage_time' field error detected");
66668 }
66669 }
66670
66671 if (BV_ISSET(fields, 31)) {
66672 log_packet_detailed(" field 'extra_count' has changed");
66673
66674#ifdef FREECIV_JSON_CONNECTION
66675 field_addr.name = "extra_count";
66676#endif /* FREECIV_JSON_CONNECTION */
66677 e = 0;
66678
66679 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->extra_count);
66680
66681 if (e) {
66682 log_packet_detailed("'extra_count' field error detected");
66683 }
66684 }
66685
66686 if (BV_ISSET(fields, 32)) {
66687 log_packet_detailed(" field 'extra_removal_times' has changed");
66688
66689#ifdef FREECIV_JSON_CONNECTION
66690 field_addr.name = "extra_removal_times";
66691#endif /* FREECIV_JSON_CONNECTION */
66692 e = 0;
66693
66694 {
66695 int i;
66696
66697#ifdef FREECIV_JSON_CONNECTION
66698 /* Create the array. */
66699 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->extra_count);
66700
66701 /* Enter array. */
66702 field_addr.sub_location = plocation_elem_new(0);
66703#endif /* FREECIV_JSON_CONNECTION */
66704
66705 for (i = 0; i < real_packet->extra_count; i++) {
66706#ifdef FREECIV_JSON_CONNECTION
66707 /* Next array element. */
66708 field_addr.sub_location->number = i;
66709#endif /* FREECIV_JSON_CONNECTION */
66710
66711 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->extra_removal_times[i]);
66712 }
66713
66714#ifdef FREECIV_JSON_CONNECTION
66715 /* Exit array. */
66716 FC_FREE(field_addr.sub_location);
66717#endif /* FREECIV_JSON_CONNECTION */
66718 }
66719
66720 if (e) {
66721 log_packet_detailed("'extra_removal_times' field error detected");
66722 }
66723 }
66724
66725 if (BV_ISSET(fields, 33)) {
66726 log_packet_detailed(" field 'color_red' has changed");
66727
66728#ifdef FREECIV_JSON_CONNECTION
66729 field_addr.name = "color_red";
66730#endif /* FREECIV_JSON_CONNECTION */
66731 e = 0;
66732
66733 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_red);
66734
66735 if (e) {
66736 log_packet_detailed("'color_red' field error detected");
66737 }
66738 }
66739
66740 if (BV_ISSET(fields, 34)) {
66741 log_packet_detailed(" field 'color_green' has changed");
66742
66743#ifdef FREECIV_JSON_CONNECTION
66744 field_addr.name = "color_green";
66745#endif /* FREECIV_JSON_CONNECTION */
66746 e = 0;
66747
66748 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_green);
66749
66750 if (e) {
66751 log_packet_detailed("'color_green' field error detected");
66752 }
66753 }
66754
66755 if (BV_ISSET(fields, 35)) {
66756 log_packet_detailed(" field 'color_blue' has changed");
66757
66758#ifdef FREECIV_JSON_CONNECTION
66759 field_addr.name = "color_blue";
66760#endif /* FREECIV_JSON_CONNECTION */
66761 e = 0;
66762
66763 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_blue);
66764
66765 if (e) {
66766 log_packet_detailed("'color_blue' field error detected");
66767 }
66768 }
66769
66770 if (BV_ISSET(fields, 36)) {
66771 log_packet_detailed(" field 'helptext' has changed");
66772
66773#ifdef FREECIV_JSON_CONNECTION
66774 field_addr.name = "helptext";
66775#endif /* FREECIV_JSON_CONNECTION */
66776 e = 0;
66777
66778 if (!real_packet->helptext) {
66779 /* Transmit null as empty */
66780 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
66781 } else {
66782 int i;
66783
66784 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
66785 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
66786
66787#ifdef FREECIV_JSON_CONNECTION
66788 /* Enter array. */
66789 field_addr.sub_location = plocation_elem_new(0);
66790#endif /* FREECIV_JSON_CONNECTION */
66791
66792 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
66793#ifdef FREECIV_JSON_CONNECTION
66794 /* Next array element. */
66795 field_addr.sub_location->number = i;
66796#endif /* FREECIV_JSON_CONNECTION */
66797
66798 {
66799 const char *pstr = strvec_get(real_packet->helptext, i);
66800
66801 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
66802 }
66803 }
66804
66805#ifdef FREECIV_JSON_CONNECTION
66806 /* Exit array. */
66807 FC_FREE(field_addr.sub_location);
66808#endif /* FREECIV_JSON_CONNECTION */
66809 }
66810
66811 if (e) {
66812 log_packet_detailed("'helptext' field error detected");
66813 }
66814 }
66815
66816 old->id = real_packet->id;
66817 old->tclass = real_packet->tclass;
66818 old->flags = real_packet->flags;
66819 old->native_to = real_packet->native_to;
66820 sz_strlcpy(old->name, real_packet->name);
66821 sz_strlcpy(old->rule_name, real_packet->rule_name);
66822 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
66823 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
66824 sz_strlcpy(old->graphic_alt2, real_packet->graphic_alt2);
66825 old->movement_cost = real_packet->movement_cost;
66826 old->defense_bonus = real_packet->defense_bonus;
66827 {
66828 int i;
66829
66830 for (i = 0; i < O_LAST; i++) {
66831 old->output[i] = real_packet->output[i];
66832 }
66833 }
66834 old->num_resources = real_packet->num_resources;
66835 {
66836 int i;
66837
66838 for (i = 0; i < real_packet->num_resources; i++) {
66839 old->resources[i] = real_packet->resources[i];
66840 }
66841 }
66842 {
66843 int i;
66844
66845 for (i = 0; i < real_packet->num_resources; i++) {
66846 old->resource_freq[i] = real_packet->resource_freq[i];
66847 }
66848 }
66849 {
66850 int i;
66851
66852 for (i = 0; i < O_LAST; i++) {
66853 old->road_output_incr_pct[i] = real_packet->road_output_incr_pct[i];
66854 }
66855 }
66856 old->base_time = real_packet->base_time;
66857 old->road_time = real_packet->road_time;
66858 old->cultivate_result = real_packet->cultivate_result;
66859 old->cultivate_time = real_packet->cultivate_time;
66860 old->plant_result = real_packet->plant_result;
66861 old->plant_time = real_packet->plant_time;
66862 old->irrigation_food_incr = real_packet->irrigation_food_incr;
66863 old->irrigation_time = real_packet->irrigation_time;
66864 old->mining_shield_incr = real_packet->mining_shield_incr;
66865 old->mining_time = real_packet->mining_time;
66866 old->animal = real_packet->animal;
66867 old->transform_result = real_packet->transform_result;
66868 old->transform_time = real_packet->transform_time;
66869 old->placing_time = real_packet->placing_time;
66870 old->pillage_time = real_packet->pillage_time;
66871 old->extra_count = real_packet->extra_count;
66872 {
66873 int i;
66874
66875 for (i = 0; i < real_packet->extra_count; i++) {
66876 old->extra_removal_times[i] = real_packet->extra_removal_times[i];
66877 }
66878 }
66879 old->color_red = real_packet->color_red;
66880 old->color_green = real_packet->color_green;
66881 old->color_blue = real_packet->color_blue;
66882 if (real_packet->helptext) {
66883 strvec_copy(old->helptext, real_packet->helptext);
66884 } else {
66885 strvec_clear(old->helptext);
66886 }
66887
66888#else /* FREECIV_DELTA_PROTOCOL */
66889#ifdef FREECIV_JSON_CONNECTION
66890 field_addr.name = "id";
66891#endif /* FREECIV_JSON_CONNECTION */
66892 e = 0;
66893
66894 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
66895
66896 if (e) {
66897 log_packet_detailed("'id' field error detected");
66898 }
66899
66900#ifdef FREECIV_JSON_CONNECTION
66901 field_addr.name = "tclass";
66902#endif /* FREECIV_JSON_CONNECTION */
66903 e = 0;
66904
66905 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tclass);
66906
66907 if (e) {
66908 log_packet_detailed("'tclass' field error detected");
66909 }
66910
66911#ifdef FREECIV_JSON_CONNECTION
66912 field_addr.name = "flags";
66913#endif /* FREECIV_JSON_CONNECTION */
66914 e = 0;
66915
66916 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
66917
66918 if (e) {
66919 log_packet_detailed("'flags' field error detected");
66920 }
66921
66922#ifdef FREECIV_JSON_CONNECTION
66923 field_addr.name = "native_to";
66924#endif /* FREECIV_JSON_CONNECTION */
66925 e = 0;
66926
66927 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->native_to);
66928
66929 if (e) {
66930 log_packet_detailed("'native_to' field error detected");
66931 }
66932
66933#ifdef FREECIV_JSON_CONNECTION
66934 field_addr.name = "name";
66935#endif /* FREECIV_JSON_CONNECTION */
66936 e = 0;
66937
66938 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
66939
66940 if (e) {
66941 log_packet_detailed("'name' field error detected");
66942 }
66943
66944#ifdef FREECIV_JSON_CONNECTION
66945 field_addr.name = "rule_name";
66946#endif /* FREECIV_JSON_CONNECTION */
66947 e = 0;
66948
66949 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
66950
66951 if (e) {
66952 log_packet_detailed("'rule_name' field error detected");
66953 }
66954
66955#ifdef FREECIV_JSON_CONNECTION
66956 field_addr.name = "graphic_str";
66957#endif /* FREECIV_JSON_CONNECTION */
66958 e = 0;
66959
66960 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
66961
66962 if (e) {
66963 log_packet_detailed("'graphic_str' field error detected");
66964 }
66965
66966#ifdef FREECIV_JSON_CONNECTION
66967 field_addr.name = "graphic_alt";
66968#endif /* FREECIV_JSON_CONNECTION */
66969 e = 0;
66970
66971 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
66972
66973 if (e) {
66974 log_packet_detailed("'graphic_alt' field error detected");
66975 }
66976
66977#ifdef FREECIV_JSON_CONNECTION
66978 field_addr.name = "graphic_alt2";
66979#endif /* FREECIV_JSON_CONNECTION */
66980 e = 0;
66981
66982 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt2);
66983
66984 if (e) {
66985 log_packet_detailed("'graphic_alt2' field error detected");
66986 }
66987
66988#ifdef FREECIV_JSON_CONNECTION
66989 field_addr.name = "movement_cost";
66990#endif /* FREECIV_JSON_CONNECTION */
66991 e = 0;
66992
66993 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->movement_cost);
66994
66995 if (e) {
66996 log_packet_detailed("'movement_cost' field error detected");
66997 }
66998
66999#ifdef FREECIV_JSON_CONNECTION
67000 field_addr.name = "defense_bonus";
67001#endif /* FREECIV_JSON_CONNECTION */
67002 e = 0;
67003
67004 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->defense_bonus);
67005
67006 if (e) {
67007 log_packet_detailed("'defense_bonus' field error detected");
67008 }
67009
67010#ifdef FREECIV_JSON_CONNECTION
67011 field_addr.name = "output";
67012#endif /* FREECIV_JSON_CONNECTION */
67013 e = 0;
67014
67015 {
67016 int i;
67017
67018#ifdef FREECIV_JSON_CONNECTION
67019 /* Create the array. */
67020 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
67021
67022 /* Enter array. */
67023 field_addr.sub_location = plocation_elem_new(0);
67024#endif /* FREECIV_JSON_CONNECTION */
67025
67026 for (i = 0; i < O_LAST; i++) {
67027#ifdef FREECIV_JSON_CONNECTION
67028 /* Next array element. */
67029 field_addr.sub_location->number = i;
67030#endif /* FREECIV_JSON_CONNECTION */
67031
67032 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output[i]);
67033 }
67034
67035#ifdef FREECIV_JSON_CONNECTION
67036 /* Exit array. */
67037 FC_FREE(field_addr.sub_location);
67038#endif /* FREECIV_JSON_CONNECTION */
67039 }
67040
67041 if (e) {
67042 log_packet_detailed("'output' field error detected");
67043 }
67044
67045#ifdef FREECIV_JSON_CONNECTION
67046 field_addr.name = "num_resources";
67047#endif /* FREECIV_JSON_CONNECTION */
67048 e = 0;
67049
67050 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->num_resources);
67051
67052 if (e) {
67053 log_packet_detailed("'num_resources' field error detected");
67054 }
67055
67056#ifdef FREECIV_JSON_CONNECTION
67057 field_addr.name = "resources";
67058#endif /* FREECIV_JSON_CONNECTION */
67059 e = 0;
67060
67061 {
67062 int i;
67063
67064#ifdef FREECIV_JSON_CONNECTION
67065 /* Create the array. */
67066 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->num_resources);
67067
67068 /* Enter array. */
67069 field_addr.sub_location = plocation_elem_new(0);
67070#endif /* FREECIV_JSON_CONNECTION */
67071
67072 for (i = 0; i < real_packet->num_resources; i++) {
67073#ifdef FREECIV_JSON_CONNECTION
67074 /* Next array element. */
67075 field_addr.sub_location->number = i;
67076#endif /* FREECIV_JSON_CONNECTION */
67077
67078 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resources[i]);
67079 }
67080
67081#ifdef FREECIV_JSON_CONNECTION
67082 /* Exit array. */
67083 FC_FREE(field_addr.sub_location);
67084#endif /* FREECIV_JSON_CONNECTION */
67085 }
67086
67087 if (e) {
67088 log_packet_detailed("'resources' field error detected");
67089 }
67090
67091#ifdef FREECIV_JSON_CONNECTION
67092 field_addr.name = "resource_freq";
67093#endif /* FREECIV_JSON_CONNECTION */
67094 e = 0;
67095
67096 {
67097 int i;
67098
67099#ifdef FREECIV_JSON_CONNECTION
67100 /* Create the array. */
67101 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->num_resources);
67102
67103 /* Enter array. */
67104 field_addr.sub_location = plocation_elem_new(0);
67105#endif /* FREECIV_JSON_CONNECTION */
67106
67107 for (i = 0; i < real_packet->num_resources; i++) {
67108#ifdef FREECIV_JSON_CONNECTION
67109 /* Next array element. */
67110 field_addr.sub_location->number = i;
67111#endif /* FREECIV_JSON_CONNECTION */
67112
67113 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resource_freq[i]);
67114 }
67115
67116#ifdef FREECIV_JSON_CONNECTION
67117 /* Exit array. */
67118 FC_FREE(field_addr.sub_location);
67119#endif /* FREECIV_JSON_CONNECTION */
67120 }
67121
67122 if (e) {
67123 log_packet_detailed("'resource_freq' field error detected");
67124 }
67125
67126#ifdef FREECIV_JSON_CONNECTION
67127 field_addr.name = "road_output_incr_pct";
67128#endif /* FREECIV_JSON_CONNECTION */
67129 e = 0;
67130
67131 {
67132 int i;
67133
67134#ifdef FREECIV_JSON_CONNECTION
67135 /* Create the array. */
67136 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
67137
67138 /* Enter array. */
67139 field_addr.sub_location = plocation_elem_new(0);
67140#endif /* FREECIV_JSON_CONNECTION */
67141
67142 for (i = 0; i < O_LAST; i++) {
67143#ifdef FREECIV_JSON_CONNECTION
67144 /* Next array element. */
67145 field_addr.sub_location->number = i;
67146#endif /* FREECIV_JSON_CONNECTION */
67147
67148 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->road_output_incr_pct[i]);
67149 }
67150
67151#ifdef FREECIV_JSON_CONNECTION
67152 /* Exit array. */
67153 FC_FREE(field_addr.sub_location);
67154#endif /* FREECIV_JSON_CONNECTION */
67155 }
67156
67157 if (e) {
67158 log_packet_detailed("'road_output_incr_pct' field error detected");
67159 }
67160
67161#ifdef FREECIV_JSON_CONNECTION
67162 field_addr.name = "base_time";
67163#endif /* FREECIV_JSON_CONNECTION */
67164 e = 0;
67165
67166 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->base_time);
67167
67168 if (e) {
67169 log_packet_detailed("'base_time' field error detected");
67170 }
67171
67172#ifdef FREECIV_JSON_CONNECTION
67173 field_addr.name = "road_time";
67174#endif /* FREECIV_JSON_CONNECTION */
67175 e = 0;
67176
67177 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->road_time);
67178
67179 if (e) {
67180 log_packet_detailed("'road_time' field error detected");
67181 }
67182
67183#ifdef FREECIV_JSON_CONNECTION
67184 field_addr.name = "cultivate_result";
67185#endif /* FREECIV_JSON_CONNECTION */
67186 e = 0;
67187
67188 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cultivate_result);
67189
67190 if (e) {
67191 log_packet_detailed("'cultivate_result' field error detected");
67192 }
67193
67194#ifdef FREECIV_JSON_CONNECTION
67195 field_addr.name = "cultivate_time";
67196#endif /* FREECIV_JSON_CONNECTION */
67197 e = 0;
67198
67199 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cultivate_time);
67200
67201 if (e) {
67202 log_packet_detailed("'cultivate_time' field error detected");
67203 }
67204
67205#ifdef FREECIV_JSON_CONNECTION
67206 field_addr.name = "plant_result";
67207#endif /* FREECIV_JSON_CONNECTION */
67208 e = 0;
67209
67210 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->plant_result);
67211
67212 if (e) {
67213 log_packet_detailed("'plant_result' field error detected");
67214 }
67215
67216#ifdef FREECIV_JSON_CONNECTION
67217 field_addr.name = "plant_time";
67218#endif /* FREECIV_JSON_CONNECTION */
67219 e = 0;
67220
67221 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->plant_time);
67222
67223 if (e) {
67224 log_packet_detailed("'plant_time' field error detected");
67225 }
67226
67227#ifdef FREECIV_JSON_CONNECTION
67228 field_addr.name = "irrigation_food_incr";
67229#endif /* FREECIV_JSON_CONNECTION */
67230 e = 0;
67231
67232 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->irrigation_food_incr);
67233
67234 if (e) {
67235 log_packet_detailed("'irrigation_food_incr' field error detected");
67236 }
67237
67238#ifdef FREECIV_JSON_CONNECTION
67239 field_addr.name = "irrigation_time";
67240#endif /* FREECIV_JSON_CONNECTION */
67241 e = 0;
67242
67243 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->irrigation_time);
67244
67245 if (e) {
67246 log_packet_detailed("'irrigation_time' field error detected");
67247 }
67248
67249#ifdef FREECIV_JSON_CONNECTION
67250 field_addr.name = "mining_shield_incr";
67251#endif /* FREECIV_JSON_CONNECTION */
67252 e = 0;
67253
67254 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->mining_shield_incr);
67255
67256 if (e) {
67257 log_packet_detailed("'mining_shield_incr' field error detected");
67258 }
67259
67260#ifdef FREECIV_JSON_CONNECTION
67261 field_addr.name = "mining_time";
67262#endif /* FREECIV_JSON_CONNECTION */
67263 e = 0;
67264
67265 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->mining_time);
67266
67267 if (e) {
67268 log_packet_detailed("'mining_time' field error detected");
67269 }
67270
67271#ifdef FREECIV_JSON_CONNECTION
67272 field_addr.name = "animal";
67273#endif /* FREECIV_JSON_CONNECTION */
67274 e = 0;
67275
67276 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->animal);
67277
67278 if (e) {
67279 log_packet_detailed("'animal' field error detected");
67280 }
67281
67282#ifdef FREECIV_JSON_CONNECTION
67283 field_addr.name = "transform_result";
67284#endif /* FREECIV_JSON_CONNECTION */
67285 e = 0;
67286
67287 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->transform_result);
67288
67289 if (e) {
67290 log_packet_detailed("'transform_result' field error detected");
67291 }
67292
67293#ifdef FREECIV_JSON_CONNECTION
67294 field_addr.name = "transform_time";
67295#endif /* FREECIV_JSON_CONNECTION */
67296 e = 0;
67297
67298 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->transform_time);
67299
67300 if (e) {
67301 log_packet_detailed("'transform_time' field error detected");
67302 }
67303
67304#ifdef FREECIV_JSON_CONNECTION
67305 field_addr.name = "placing_time";
67306#endif /* FREECIV_JSON_CONNECTION */
67307 e = 0;
67308
67309 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->placing_time);
67310
67311 if (e) {
67312 log_packet_detailed("'placing_time' field error detected");
67313 }
67314
67315#ifdef FREECIV_JSON_CONNECTION
67316 field_addr.name = "pillage_time";
67317#endif /* FREECIV_JSON_CONNECTION */
67318 e = 0;
67319
67320 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->pillage_time);
67321
67322 if (e) {
67323 log_packet_detailed("'pillage_time' field error detected");
67324 }
67325
67326#ifdef FREECIV_JSON_CONNECTION
67327 field_addr.name = "extra_count";
67328#endif /* FREECIV_JSON_CONNECTION */
67329 e = 0;
67330
67331 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->extra_count);
67332
67333 if (e) {
67334 log_packet_detailed("'extra_count' field error detected");
67335 }
67336
67337#ifdef FREECIV_JSON_CONNECTION
67338 field_addr.name = "extra_removal_times";
67339#endif /* FREECIV_JSON_CONNECTION */
67340 e = 0;
67341
67342 {
67343 int i;
67344
67345#ifdef FREECIV_JSON_CONNECTION
67346 /* Create the array. */
67347 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->extra_count);
67348
67349 /* Enter array. */
67350 field_addr.sub_location = plocation_elem_new(0);
67351#endif /* FREECIV_JSON_CONNECTION */
67352
67353 for (i = 0; i < real_packet->extra_count; i++) {
67354#ifdef FREECIV_JSON_CONNECTION
67355 /* Next array element. */
67356 field_addr.sub_location->number = i;
67357#endif /* FREECIV_JSON_CONNECTION */
67358
67359 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->extra_removal_times[i]);
67360 }
67361
67362#ifdef FREECIV_JSON_CONNECTION
67363 /* Exit array. */
67364 FC_FREE(field_addr.sub_location);
67365#endif /* FREECIV_JSON_CONNECTION */
67366 }
67367
67368 if (e) {
67369 log_packet_detailed("'extra_removal_times' field error detected");
67370 }
67371
67372#ifdef FREECIV_JSON_CONNECTION
67373 field_addr.name = "color_red";
67374#endif /* FREECIV_JSON_CONNECTION */
67375 e = 0;
67376
67377 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_red);
67378
67379 if (e) {
67380 log_packet_detailed("'color_red' field error detected");
67381 }
67382
67383#ifdef FREECIV_JSON_CONNECTION
67384 field_addr.name = "color_green";
67385#endif /* FREECIV_JSON_CONNECTION */
67386 e = 0;
67387
67388 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_green);
67389
67390 if (e) {
67391 log_packet_detailed("'color_green' field error detected");
67392 }
67393
67394#ifdef FREECIV_JSON_CONNECTION
67395 field_addr.name = "color_blue";
67396#endif /* FREECIV_JSON_CONNECTION */
67397 e = 0;
67398
67399 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->color_blue);
67400
67401 if (e) {
67402 log_packet_detailed("'color_blue' field error detected");
67403 }
67404
67405#ifdef FREECIV_JSON_CONNECTION
67406 field_addr.name = "helptext";
67407#endif /* FREECIV_JSON_CONNECTION */
67408 e = 0;
67409
67410 if (!real_packet->helptext) {
67411 /* Transmit null as empty */
67412 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
67413 } else {
67414 int i;
67415
67416 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
67417 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
67418
67419#ifdef FREECIV_JSON_CONNECTION
67420 /* Enter array. */
67421 field_addr.sub_location = plocation_elem_new(0);
67422#endif /* FREECIV_JSON_CONNECTION */
67423
67424 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
67425#ifdef FREECIV_JSON_CONNECTION
67426 /* Next array element. */
67427 field_addr.sub_location->number = i;
67428#endif /* FREECIV_JSON_CONNECTION */
67429
67430 {
67431 const char *pstr = strvec_get(real_packet->helptext, i);
67432
67433 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
67434 }
67435 }
67436
67437#ifdef FREECIV_JSON_CONNECTION
67438 /* Exit array. */
67439 FC_FREE(field_addr.sub_location);
67440#endif /* FREECIV_JSON_CONNECTION */
67441 }
67442
67443 if (e) {
67444 log_packet_detailed("'helptext' field error detected");
67445 }
67446#endif /* FREECIV_DELTA_PROTOCOL */
67447
67448 SEND_PACKET_END(PACKET_RULESET_TERRAIN);
67449}
67450
67451 int send_packet_ruleset_terrain(struct connection *pc, const struct packet_ruleset_terrain *packet)
67452{
67453 if (!pc->used) {
67454 log_error("WARNING: trying to send data to the closed connection %s",
67455 conn_description(pc));
67456 return -1;
67457 }
67458 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TERRAIN].packet != nullptr, -1,
67459 "Handler for PACKET_RULESET_TERRAIN not installed");
67460 return pc->phs.handlers->send[PACKET_RULESET_TERRAIN].packet(pc, packet);
67461}
67462
67463 void lsend_packet_ruleset_terrain(struct conn_list *dest, const struct packet_ruleset_terrain *packet)
67464{
67465 conn_list_iterate(dest, pconn) {
67466 send_packet_ruleset_terrain(pconn, packet);
67467 } conn_list_iterate_end;
67468}
67469
67470 static inline void init_packet_ruleset_terrain_flag(struct packet_ruleset_terrain_flag *packet)
67471{
67472 memset(packet, 0, sizeof(*packet));
67473}
67474
67475#define free_packet_ruleset_terrain_flag(_packet) (void) 0
67476#define destroy_packet_ruleset_terrain_flag free
67477
67478#ifdef FREECIV_DELTA_PROTOCOL
67479#define hash_packet_ruleset_terrain_flag_100 hash_const
67480#define cmp_packet_ruleset_terrain_flag_100 cmp_const
67481 BV_DEFINE(packet_ruleset_terrain_flag_100_fields, 3);
67482#endif /* FREECIV_DELTA_PROTOCOL */
67483
67484 static struct packet_ruleset_terrain_flag *receive_packet_ruleset_terrain_flag_100(struct connection *pc)
67485{
67486#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_terrain_flag(_packet)
67487 RECEIVE_PACKET_START(packet_ruleset_terrain_flag, real_packet);
67488
67489#ifdef FREECIV_JSON_CONNECTION
67490 struct plocation field_addr;
67491 {
67492 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
67493 field_addr = *field_addr_tmp;
67494 FC_FREE(field_addr_tmp);
67495 }
67496#endif /* FREECIV_JSON_CONNECTION */
67497
67498 log_packet_detailed("packet_ruleset_terrain_flag_100: got info about ()");
67499
67500#ifdef FREECIV_DELTA_PROTOCOL
67501 packet_ruleset_terrain_flag_100_fields fields;
67502 struct packet_ruleset_terrain_flag *old;
67503 struct genhash **hash = pc->phs.received + PACKET_RULESET_TERRAIN_FLAG;
67504
67505 if (nullptr == *hash) {
67506 *hash = genhash_new_full(hash_packet_ruleset_terrain_flag_100, cmp_packet_ruleset_terrain_flag_100,
67507 nullptr, nullptr, nullptr, destroy_packet_ruleset_terrain_flag);
67508 }
67509
67510 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
67511 *real_packet = *old;
67512 } else {
67513 /* packet is already initialized empty */
67514 log_packet_detailed(" no old info");
67515 }
67516
67517#ifdef FREECIV_JSON_CONNECTION
67518 field_addr.name = "fields";
67519#endif /* FREECIV_JSON_CONNECTION */
67520 DIO_BV_GET(&din, &field_addr, fields);
67521
67522 if (BV_ISSET(fields, 0)) {
67523 log_packet_detailed(" got field 'id'");
67524
67525#ifdef FREECIV_JSON_CONNECTION
67526 field_addr.name = "id";
67527#endif /* FREECIV_JSON_CONNECTION */
67528
67529 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
67530 RECEIVE_PACKET_FIELD_ERROR(id);
67531 }
67532 }
67533
67534 if (BV_ISSET(fields, 1)) {
67535 log_packet_detailed(" got field 'name'");
67536
67537#ifdef FREECIV_JSON_CONNECTION
67538 field_addr.name = "name";
67539#endif /* FREECIV_JSON_CONNECTION */
67540
67541 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
67542 RECEIVE_PACKET_FIELD_ERROR(name);
67543 }
67544 }
67545
67546 if (BV_ISSET(fields, 2)) {
67547 log_packet_detailed(" got field 'helptxt'");
67548
67549#ifdef FREECIV_JSON_CONNECTION
67550 field_addr.name = "helptxt";
67551#endif /* FREECIV_JSON_CONNECTION */
67552
67553 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
67554 RECEIVE_PACKET_FIELD_ERROR(helptxt);
67555 }
67556 }
67557
67558 if (nullptr == old) {
67559 old = fc_malloc(sizeof(*old));
67560 init_packet_ruleset_terrain_flag(old);
67561 *old = *real_packet;
67562 genhash_insert(*hash, old, old);
67563 } else {
67564 *old = *real_packet;
67565 }
67566
67567#else /* FREECIV_DELTA_PROTOCOL */
67568#ifdef FREECIV_JSON_CONNECTION
67569 field_addr.name = "id";
67570#endif /* FREECIV_JSON_CONNECTION */
67571
67572 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
67573 RECEIVE_PACKET_FIELD_ERROR(id);
67574 }
67575
67576#ifdef FREECIV_JSON_CONNECTION
67577 field_addr.name = "name";
67578#endif /* FREECIV_JSON_CONNECTION */
67579
67580 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
67581 RECEIVE_PACKET_FIELD_ERROR(name);
67582 }
67583
67584#ifdef FREECIV_JSON_CONNECTION
67585 field_addr.name = "helptxt";
67586#endif /* FREECIV_JSON_CONNECTION */
67587
67588 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
67589 RECEIVE_PACKET_FIELD_ERROR(helptxt);
67590 }
67591#endif /* FREECIV_DELTA_PROTOCOL */
67592
67593 RECEIVE_PACKET_END(real_packet);
67594#undef FREE_PACKET_STRUCT
67595}
67596
67597 static int send_packet_ruleset_terrain_flag_100(struct connection *pc, const struct packet_ruleset_terrain_flag *packet)
67598{
67599 const struct packet_ruleset_terrain_flag *real_packet = packet;
67600 int e;
67601 SEND_PACKET_START(PACKET_RULESET_TERRAIN_FLAG);
67602
67603 log_packet_detailed("packet_ruleset_terrain_flag_100: sending info about ()");
67604
67605#ifdef FREECIV_DELTA_PROTOCOL
67606 packet_ruleset_terrain_flag_100_fields fields;
67607 struct packet_ruleset_terrain_flag *old;
67608 bool differ;
67609 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TERRAIN_FLAG;
67610
67611 if (nullptr == *hash) {
67612 *hash = genhash_new_full(hash_packet_ruleset_terrain_flag_100, cmp_packet_ruleset_terrain_flag_100,
67613 nullptr, nullptr, nullptr, destroy_packet_ruleset_terrain_flag);
67614 }
67615 BV_CLR_ALL(fields);
67616
67617 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
67618 old = fc_malloc(sizeof(*old));
67619 /* temporary bitcopy just to insert correctly */
67620 *old = *real_packet;
67621 genhash_insert(*hash, old, old);
67622 init_packet_ruleset_terrain_flag(old);
67623 }
67624
67625 differ = (old->id != real_packet->id);
67626 if (differ) {
67627 BV_SET(fields, 0);
67628 }
67629
67630 differ = (strcmp(old->name, real_packet->name) != 0);
67631 if (differ) {
67632 BV_SET(fields, 1);
67633 }
67634
67635 differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
67636 if (differ) {
67637 BV_SET(fields, 2);
67638 }
67639#endif /* FREECIV_DELTA_PROTOCOL */
67640
67641#ifdef FREECIV_JSON_CONNECTION
67642 struct plocation field_addr;
67643 {
67644 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
67645 field_addr = *field_addr_tmp;
67646 FC_FREE(field_addr_tmp);
67647 }
67648#endif /* FREECIV_JSON_CONNECTION */
67649
67650#ifdef FREECIV_DELTA_PROTOCOL
67651#ifdef FREECIV_JSON_CONNECTION
67652 field_addr.name = "fields";
67653#endif /* FREECIV_JSON_CONNECTION */
67654 e = 0;
67655 e |= DIO_BV_PUT(&dout, &field_addr, fields);
67656 if (e) {
67657 log_packet_detailed("fields bitvector error detected");
67658 }
67659
67660 if (BV_ISSET(fields, 0)) {
67661 log_packet_detailed(" field 'id' has changed");
67662
67663#ifdef FREECIV_JSON_CONNECTION
67664 field_addr.name = "id";
67665#endif /* FREECIV_JSON_CONNECTION */
67666 e = 0;
67667
67668 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
67669
67670 if (e) {
67671 log_packet_detailed("'id' field error detected");
67672 }
67673 }
67674
67675 if (BV_ISSET(fields, 1)) {
67676 log_packet_detailed(" field 'name' has changed");
67677
67678#ifdef FREECIV_JSON_CONNECTION
67679 field_addr.name = "name";
67680#endif /* FREECIV_JSON_CONNECTION */
67681 e = 0;
67682
67683 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
67684
67685 if (e) {
67686 log_packet_detailed("'name' field error detected");
67687 }
67688 }
67689
67690 if (BV_ISSET(fields, 2)) {
67691 log_packet_detailed(" field 'helptxt' has changed");
67692
67693#ifdef FREECIV_JSON_CONNECTION
67694 field_addr.name = "helptxt";
67695#endif /* FREECIV_JSON_CONNECTION */
67696 e = 0;
67697
67698 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
67699
67700 if (e) {
67701 log_packet_detailed("'helptxt' field error detected");
67702 }
67703 }
67704
67705 *old = *real_packet;
67706
67707#else /* FREECIV_DELTA_PROTOCOL */
67708#ifdef FREECIV_JSON_CONNECTION
67709 field_addr.name = "id";
67710#endif /* FREECIV_JSON_CONNECTION */
67711 e = 0;
67712
67713 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
67714
67715 if (e) {
67716 log_packet_detailed("'id' field error detected");
67717 }
67718
67719#ifdef FREECIV_JSON_CONNECTION
67720 field_addr.name = "name";
67721#endif /* FREECIV_JSON_CONNECTION */
67722 e = 0;
67723
67724 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
67725
67726 if (e) {
67727 log_packet_detailed("'name' field error detected");
67728 }
67729
67730#ifdef FREECIV_JSON_CONNECTION
67731 field_addr.name = "helptxt";
67732#endif /* FREECIV_JSON_CONNECTION */
67733 e = 0;
67734
67735 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
67736
67737 if (e) {
67738 log_packet_detailed("'helptxt' field error detected");
67739 }
67740#endif /* FREECIV_DELTA_PROTOCOL */
67741
67742 SEND_PACKET_END(PACKET_RULESET_TERRAIN_FLAG);
67743}
67744
67745 int send_packet_ruleset_terrain_flag(struct connection *pc, const struct packet_ruleset_terrain_flag *packet)
67746{
67747 if (!pc->used) {
67748 log_error("WARNING: trying to send data to the closed connection %s",
67749 conn_description(pc));
67750 return -1;
67751 }
67752 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TERRAIN_FLAG].packet != nullptr, -1,
67753 "Handler for PACKET_RULESET_TERRAIN_FLAG not installed");
67754 return pc->phs.handlers->send[PACKET_RULESET_TERRAIN_FLAG].packet(pc, packet);
67755}
67756
67757 void lsend_packet_ruleset_terrain_flag(struct conn_list *dest, const struct packet_ruleset_terrain_flag *packet)
67758{
67759 conn_list_iterate(dest, pconn) {
67760 send_packet_ruleset_terrain_flag(pconn, packet);
67761 } conn_list_iterate_end;
67762}
67763
67764 static inline void init_packet_ruleset_unit_class(struct packet_ruleset_unit_class *packet)
67765{
67766 memset(packet, 0, sizeof(*packet));
67767
67768 packet->helptext = strvec_new();
67769}
67770
67771 static inline void free_packet_ruleset_unit_class(struct packet_ruleset_unit_class *packet)
67772{
67773 if (packet->helptext) {
67774 strvec_destroy(packet->helptext);
67775 packet->helptext = nullptr;
67776 }
67777}
67778
67779 static inline void destroy_packet_ruleset_unit_class(void *packet)
67780{
67781 free_packet_ruleset_unit_class((struct packet_ruleset_unit_class *) packet);
67782 free(packet);
67783}
67784
67785#ifdef FREECIV_DELTA_PROTOCOL
67786#define hash_packet_ruleset_unit_class_100 hash_const
67787#define cmp_packet_ruleset_unit_class_100 cmp_const
67788 BV_DEFINE(packet_ruleset_unit_class_100_fields, 8);
67789#endif /* FREECIV_DELTA_PROTOCOL */
67790
67791 static struct packet_ruleset_unit_class *receive_packet_ruleset_unit_class_100(struct connection *pc)
67792{
67793#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_unit_class(_packet)
67794 RECEIVE_PACKET_START(packet_ruleset_unit_class, real_packet);
67795
67796#ifdef FREECIV_JSON_CONNECTION
67797 struct plocation field_addr;
67798 {
67799 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
67800 field_addr = *field_addr_tmp;
67801 FC_FREE(field_addr_tmp);
67802 }
67803#endif /* FREECIV_JSON_CONNECTION */
67804
67805 log_packet_detailed("packet_ruleset_unit_class_100: got info about ()");
67806
67807#ifdef FREECIV_DELTA_PROTOCOL
67808 packet_ruleset_unit_class_100_fields fields;
67809 struct packet_ruleset_unit_class *old;
67810 struct genhash **hash = pc->phs.received + PACKET_RULESET_UNIT_CLASS;
67811
67812 if (nullptr == *hash) {
67813 *hash = genhash_new_full(hash_packet_ruleset_unit_class_100, cmp_packet_ruleset_unit_class_100,
67814 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_class);
67815 }
67816
67817 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
67818 real_packet->id = old->id;
67819 sz_strlcpy(real_packet->name, old->name);
67820 sz_strlcpy(real_packet->rule_name, old->rule_name);
67821 real_packet->min_speed = old->min_speed;
67822 real_packet->hp_loss_pct = old->hp_loss_pct;
67823 real_packet->non_native_def_pct = old->non_native_def_pct;
67824 real_packet->flags = old->flags;
67825 if (old->helptext) {
67826 strvec_copy(real_packet->helptext, old->helptext);
67827 } else {
67828 strvec_clear(real_packet->helptext);
67829 }
67830 } else {
67831 /* packet is already initialized empty */
67832 log_packet_detailed(" no old info");
67833 }
67834
67835#ifdef FREECIV_JSON_CONNECTION
67836 field_addr.name = "fields";
67837#endif /* FREECIV_JSON_CONNECTION */
67838 DIO_BV_GET(&din, &field_addr, fields);
67839
67840 if (BV_ISSET(fields, 0)) {
67841 log_packet_detailed(" got field 'id'");
67842
67843#ifdef FREECIV_JSON_CONNECTION
67844 field_addr.name = "id";
67845#endif /* FREECIV_JSON_CONNECTION */
67846
67847 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
67848 RECEIVE_PACKET_FIELD_ERROR(id);
67849 }
67850 }
67851
67852 if (BV_ISSET(fields, 1)) {
67853 log_packet_detailed(" got field 'name'");
67854
67855#ifdef FREECIV_JSON_CONNECTION
67856 field_addr.name = "name";
67857#endif /* FREECIV_JSON_CONNECTION */
67858
67859 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
67860 RECEIVE_PACKET_FIELD_ERROR(name);
67861 }
67862 }
67863
67864 if (BV_ISSET(fields, 2)) {
67865 log_packet_detailed(" got field 'rule_name'");
67866
67867#ifdef FREECIV_JSON_CONNECTION
67868 field_addr.name = "rule_name";
67869#endif /* FREECIV_JSON_CONNECTION */
67870
67871 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
67872 RECEIVE_PACKET_FIELD_ERROR(rule_name);
67873 }
67874 }
67875
67876 if (BV_ISSET(fields, 3)) {
67877 log_packet_detailed(" got field 'min_speed'");
67878
67879#ifdef FREECIV_JSON_CONNECTION
67880 field_addr.name = "min_speed";
67881#endif /* FREECIV_JSON_CONNECTION */
67882
67883 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->min_speed)) {
67884 RECEIVE_PACKET_FIELD_ERROR(min_speed);
67885 }
67886 }
67887
67888 if (BV_ISSET(fields, 4)) {
67889 log_packet_detailed(" got field 'hp_loss_pct'");
67890
67891#ifdef FREECIV_JSON_CONNECTION
67892 field_addr.name = "hp_loss_pct";
67893#endif /* FREECIV_JSON_CONNECTION */
67894
67895 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp_loss_pct)) {
67896 RECEIVE_PACKET_FIELD_ERROR(hp_loss_pct);
67897 }
67898 }
67899
67900 if (BV_ISSET(fields, 5)) {
67901 log_packet_detailed(" got field 'non_native_def_pct'");
67902
67903#ifdef FREECIV_JSON_CONNECTION
67904 field_addr.name = "non_native_def_pct";
67905#endif /* FREECIV_JSON_CONNECTION */
67906
67907 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->non_native_def_pct)) {
67908 RECEIVE_PACKET_FIELD_ERROR(non_native_def_pct);
67909 }
67910 }
67911
67912 if (BV_ISSET(fields, 6)) {
67913 log_packet_detailed(" got field 'flags'");
67914
67915#ifdef FREECIV_JSON_CONNECTION
67916 field_addr.name = "flags";
67917#endif /* FREECIV_JSON_CONNECTION */
67918
67919 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
67920 RECEIVE_PACKET_FIELD_ERROR(flags);
67921 }
67922 }
67923
67924 if (BV_ISSET(fields, 7)) {
67925 log_packet_detailed(" got field 'helptext'");
67926
67927#ifdef FREECIV_JSON_CONNECTION
67928 field_addr.name = "helptext";
67929#endif /* FREECIV_JSON_CONNECTION */
67930
67931 {
67932 int i;
67933
67934 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
67935 RECEIVE_PACKET_FIELD_ERROR(helptext);
67936 }
67937 strvec_reserve(real_packet->helptext, i);
67938
67939#ifdef FREECIV_JSON_CONNECTION
67940 /* Enter array. */
67941 field_addr.sub_location = plocation_elem_new(0);
67942#endif /* FREECIV_JSON_CONNECTION */
67943
67944 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
67945#ifdef FREECIV_JSON_CONNECTION
67946 /* Next array element */
67947 field_addr.sub_location->number = i;
67948#endif /* FREECIV_JSON_CONNECTION */
67949
67950 {
67951 char readin[MAX_LEN_PACKET];
67952
67953 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
67954 || !strvec_set(real_packet->helptext, i, readin)) {
67955 RECEIVE_PACKET_FIELD_ERROR(helptext);
67956 }
67957 }
67958 }
67959
67960#ifdef FREECIV_JSON_CONNECTION
67961 /* Exit array. */
67962 FC_FREE(field_addr.sub_location);
67963#endif /* FREECIV_JSON_CONNECTION */
67964 }
67965 }
67966
67967 if (nullptr == old) {
67968 old = fc_malloc(sizeof(*old));
67969 init_packet_ruleset_unit_class(old);
67970 old->id = real_packet->id;
67971 sz_strlcpy(old->name, real_packet->name);
67972 sz_strlcpy(old->rule_name, real_packet->rule_name);
67973 old->min_speed = real_packet->min_speed;
67974 old->hp_loss_pct = real_packet->hp_loss_pct;
67975 old->non_native_def_pct = real_packet->non_native_def_pct;
67976 old->flags = real_packet->flags;
67977 if (real_packet->helptext) {
67978 strvec_copy(old->helptext, real_packet->helptext);
67979 } else {
67980 strvec_clear(old->helptext);
67981 }
67982 genhash_insert(*hash, old, old);
67983 } else {
67984 old->id = real_packet->id;
67985 sz_strlcpy(old->name, real_packet->name);
67986 sz_strlcpy(old->rule_name, real_packet->rule_name);
67987 old->min_speed = real_packet->min_speed;
67988 old->hp_loss_pct = real_packet->hp_loss_pct;
67989 old->non_native_def_pct = real_packet->non_native_def_pct;
67990 old->flags = real_packet->flags;
67991 if (real_packet->helptext) {
67992 strvec_copy(old->helptext, real_packet->helptext);
67993 } else {
67994 strvec_clear(old->helptext);
67995 }
67996 }
67997
67998#else /* FREECIV_DELTA_PROTOCOL */
67999#ifdef FREECIV_JSON_CONNECTION
68000 field_addr.name = "id";
68001#endif /* FREECIV_JSON_CONNECTION */
68002
68003 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
68004 RECEIVE_PACKET_FIELD_ERROR(id);
68005 }
68006
68007#ifdef FREECIV_JSON_CONNECTION
68008 field_addr.name = "name";
68009#endif /* FREECIV_JSON_CONNECTION */
68010
68011 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
68012 RECEIVE_PACKET_FIELD_ERROR(name);
68013 }
68014
68015#ifdef FREECIV_JSON_CONNECTION
68016 field_addr.name = "rule_name";
68017#endif /* FREECIV_JSON_CONNECTION */
68018
68019 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
68020 RECEIVE_PACKET_FIELD_ERROR(rule_name);
68021 }
68022
68023#ifdef FREECIV_JSON_CONNECTION
68024 field_addr.name = "min_speed";
68025#endif /* FREECIV_JSON_CONNECTION */
68026
68027 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->min_speed)) {
68028 RECEIVE_PACKET_FIELD_ERROR(min_speed);
68029 }
68030
68031#ifdef FREECIV_JSON_CONNECTION
68032 field_addr.name = "hp_loss_pct";
68033#endif /* FREECIV_JSON_CONNECTION */
68034
68035 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp_loss_pct)) {
68036 RECEIVE_PACKET_FIELD_ERROR(hp_loss_pct);
68037 }
68038
68039#ifdef FREECIV_JSON_CONNECTION
68040 field_addr.name = "non_native_def_pct";
68041#endif /* FREECIV_JSON_CONNECTION */
68042
68043 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->non_native_def_pct)) {
68044 RECEIVE_PACKET_FIELD_ERROR(non_native_def_pct);
68045 }
68046
68047#ifdef FREECIV_JSON_CONNECTION
68048 field_addr.name = "flags";
68049#endif /* FREECIV_JSON_CONNECTION */
68050
68051 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
68052 RECEIVE_PACKET_FIELD_ERROR(flags);
68053 }
68054
68055#ifdef FREECIV_JSON_CONNECTION
68056 field_addr.name = "helptext";
68057#endif /* FREECIV_JSON_CONNECTION */
68058
68059 {
68060 int i;
68061
68062 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
68063 RECEIVE_PACKET_FIELD_ERROR(helptext);
68064 }
68065 strvec_reserve(real_packet->helptext, i);
68066
68067#ifdef FREECIV_JSON_CONNECTION
68068 /* Enter array. */
68069 field_addr.sub_location = plocation_elem_new(0);
68070#endif /* FREECIV_JSON_CONNECTION */
68071
68072 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
68073#ifdef FREECIV_JSON_CONNECTION
68074 /* Next array element */
68075 field_addr.sub_location->number = i;
68076#endif /* FREECIV_JSON_CONNECTION */
68077
68078 {
68079 char readin[MAX_LEN_PACKET];
68080
68081 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
68082 || !strvec_set(real_packet->helptext, i, readin)) {
68083 RECEIVE_PACKET_FIELD_ERROR(helptext);
68084 }
68085 }
68086 }
68087
68088#ifdef FREECIV_JSON_CONNECTION
68089 /* Exit array. */
68090 FC_FREE(field_addr.sub_location);
68091#endif /* FREECIV_JSON_CONNECTION */
68092 }
68093#endif /* FREECIV_DELTA_PROTOCOL */
68094
68095 RECEIVE_PACKET_END(real_packet);
68096#undef FREE_PACKET_STRUCT
68097}
68098
68099 static int send_packet_ruleset_unit_class_100(struct connection *pc, const struct packet_ruleset_unit_class *packet)
68100{
68101 const struct packet_ruleset_unit_class *real_packet = packet;
68102 int e;
68103 SEND_PACKET_START(PACKET_RULESET_UNIT_CLASS);
68104
68105 log_packet_detailed("packet_ruleset_unit_class_100: sending info about ()");
68106
68107#ifdef FREECIV_DELTA_PROTOCOL
68108 packet_ruleset_unit_class_100_fields fields;
68109 struct packet_ruleset_unit_class *old;
68110 bool differ;
68111 struct genhash **hash = pc->phs.sent + PACKET_RULESET_UNIT_CLASS;
68112
68113 if (nullptr == *hash) {
68114 *hash = genhash_new_full(hash_packet_ruleset_unit_class_100, cmp_packet_ruleset_unit_class_100,
68115 nullptr, nullptr, nullptr, destroy_packet_ruleset_unit_class);
68116 }
68117 BV_CLR_ALL(fields);
68118
68119 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
68120 old = fc_malloc(sizeof(*old));
68121 /* temporary bitcopy just to insert correctly */
68122 *old = *real_packet;
68123 genhash_insert(*hash, old, old);
68124 init_packet_ruleset_unit_class(old);
68125 }
68126
68127 differ = (old->id != real_packet->id);
68128 if (differ) {
68129 BV_SET(fields, 0);
68130 }
68131
68132 differ = (strcmp(old->name, real_packet->name) != 0);
68133 if (differ) {
68134 BV_SET(fields, 1);
68135 }
68136
68137 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
68138 if (differ) {
68139 BV_SET(fields, 2);
68140 }
68141
68142 differ = (old->min_speed != real_packet->min_speed);
68143 if (differ) {
68144 BV_SET(fields, 3);
68145 }
68146
68147 differ = (old->hp_loss_pct != real_packet->hp_loss_pct);
68148 if (differ) {
68149 BV_SET(fields, 4);
68150 }
68151
68152 differ = (old->non_native_def_pct != real_packet->non_native_def_pct);
68153 if (differ) {
68154 BV_SET(fields, 5);
68155 }
68156
68157 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
68158 if (differ) {
68159 BV_SET(fields, 6);
68160 }
68161
68162 if (real_packet->helptext) {
68163 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
68164 } else {
68165 differ = (strvec_size(old->helptext) > 0);
68166 }
68167 if (differ) {
68168 BV_SET(fields, 7);
68169 }
68170#endif /* FREECIV_DELTA_PROTOCOL */
68171
68172#ifdef FREECIV_JSON_CONNECTION
68173 struct plocation field_addr;
68174 {
68175 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
68176 field_addr = *field_addr_tmp;
68177 FC_FREE(field_addr_tmp);
68178 }
68179#endif /* FREECIV_JSON_CONNECTION */
68180
68181#ifdef FREECIV_DELTA_PROTOCOL
68182#ifdef FREECIV_JSON_CONNECTION
68183 field_addr.name = "fields";
68184#endif /* FREECIV_JSON_CONNECTION */
68185 e = 0;
68186 e |= DIO_BV_PUT(&dout, &field_addr, fields);
68187 if (e) {
68188 log_packet_detailed("fields bitvector error detected");
68189 }
68190
68191 if (BV_ISSET(fields, 0)) {
68192 log_packet_detailed(" field 'id' has changed");
68193
68194#ifdef FREECIV_JSON_CONNECTION
68195 field_addr.name = "id";
68196#endif /* FREECIV_JSON_CONNECTION */
68197 e = 0;
68198
68199 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
68200
68201 if (e) {
68202 log_packet_detailed("'id' field error detected");
68203 }
68204 }
68205
68206 if (BV_ISSET(fields, 1)) {
68207 log_packet_detailed(" field 'name' has changed");
68208
68209#ifdef FREECIV_JSON_CONNECTION
68210 field_addr.name = "name";
68211#endif /* FREECIV_JSON_CONNECTION */
68212 e = 0;
68213
68214 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
68215
68216 if (e) {
68217 log_packet_detailed("'name' field error detected");
68218 }
68219 }
68220
68221 if (BV_ISSET(fields, 2)) {
68222 log_packet_detailed(" field 'rule_name' has changed");
68223
68224#ifdef FREECIV_JSON_CONNECTION
68225 field_addr.name = "rule_name";
68226#endif /* FREECIV_JSON_CONNECTION */
68227 e = 0;
68228
68229 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
68230
68231 if (e) {
68232 log_packet_detailed("'rule_name' field error detected");
68233 }
68234 }
68235
68236 if (BV_ISSET(fields, 3)) {
68237 log_packet_detailed(" field 'min_speed' has changed");
68238
68239#ifdef FREECIV_JSON_CONNECTION
68240 field_addr.name = "min_speed";
68241#endif /* FREECIV_JSON_CONNECTION */
68242 e = 0;
68243
68244 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->min_speed);
68245
68246 if (e) {
68247 log_packet_detailed("'min_speed' field error detected");
68248 }
68249 }
68250
68251 if (BV_ISSET(fields, 4)) {
68252 log_packet_detailed(" field 'hp_loss_pct' has changed");
68253
68254#ifdef FREECIV_JSON_CONNECTION
68255 field_addr.name = "hp_loss_pct";
68256#endif /* FREECIV_JSON_CONNECTION */
68257 e = 0;
68258
68259 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp_loss_pct);
68260
68261 if (e) {
68262 log_packet_detailed("'hp_loss_pct' field error detected");
68263 }
68264 }
68265
68266 if (BV_ISSET(fields, 5)) {
68267 log_packet_detailed(" field 'non_native_def_pct' has changed");
68268
68269#ifdef FREECIV_JSON_CONNECTION
68270 field_addr.name = "non_native_def_pct";
68271#endif /* FREECIV_JSON_CONNECTION */
68272 e = 0;
68273
68274 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->non_native_def_pct);
68275
68276 if (e) {
68277 log_packet_detailed("'non_native_def_pct' field error detected");
68278 }
68279 }
68280
68281 if (BV_ISSET(fields, 6)) {
68282 log_packet_detailed(" field 'flags' has changed");
68283
68284#ifdef FREECIV_JSON_CONNECTION
68285 field_addr.name = "flags";
68286#endif /* FREECIV_JSON_CONNECTION */
68287 e = 0;
68288
68289 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
68290
68291 if (e) {
68292 log_packet_detailed("'flags' field error detected");
68293 }
68294 }
68295
68296 if (BV_ISSET(fields, 7)) {
68297 log_packet_detailed(" field 'helptext' has changed");
68298
68299#ifdef FREECIV_JSON_CONNECTION
68300 field_addr.name = "helptext";
68301#endif /* FREECIV_JSON_CONNECTION */
68302 e = 0;
68303
68304 if (!real_packet->helptext) {
68305 /* Transmit null as empty */
68306 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
68307 } else {
68308 int i;
68309
68310 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
68311 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
68312
68313#ifdef FREECIV_JSON_CONNECTION
68314 /* Enter array. */
68315 field_addr.sub_location = plocation_elem_new(0);
68316#endif /* FREECIV_JSON_CONNECTION */
68317
68318 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
68319#ifdef FREECIV_JSON_CONNECTION
68320 /* Next array element. */
68321 field_addr.sub_location->number = i;
68322#endif /* FREECIV_JSON_CONNECTION */
68323
68324 {
68325 const char *pstr = strvec_get(real_packet->helptext, i);
68326
68327 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
68328 }
68329 }
68330
68331#ifdef FREECIV_JSON_CONNECTION
68332 /* Exit array. */
68333 FC_FREE(field_addr.sub_location);
68334#endif /* FREECIV_JSON_CONNECTION */
68335 }
68336
68337 if (e) {
68338 log_packet_detailed("'helptext' field error detected");
68339 }
68340 }
68341
68342 old->id = real_packet->id;
68343 sz_strlcpy(old->name, real_packet->name);
68344 sz_strlcpy(old->rule_name, real_packet->rule_name);
68345 old->min_speed = real_packet->min_speed;
68346 old->hp_loss_pct = real_packet->hp_loss_pct;
68347 old->non_native_def_pct = real_packet->non_native_def_pct;
68348 old->flags = real_packet->flags;
68349 if (real_packet->helptext) {
68350 strvec_copy(old->helptext, real_packet->helptext);
68351 } else {
68352 strvec_clear(old->helptext);
68353 }
68354
68355#else /* FREECIV_DELTA_PROTOCOL */
68356#ifdef FREECIV_JSON_CONNECTION
68357 field_addr.name = "id";
68358#endif /* FREECIV_JSON_CONNECTION */
68359 e = 0;
68360
68361 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
68362
68363 if (e) {
68364 log_packet_detailed("'id' field error detected");
68365 }
68366
68367#ifdef FREECIV_JSON_CONNECTION
68368 field_addr.name = "name";
68369#endif /* FREECIV_JSON_CONNECTION */
68370 e = 0;
68371
68372 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
68373
68374 if (e) {
68375 log_packet_detailed("'name' field error detected");
68376 }
68377
68378#ifdef FREECIV_JSON_CONNECTION
68379 field_addr.name = "rule_name";
68380#endif /* FREECIV_JSON_CONNECTION */
68381 e = 0;
68382
68383 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
68384
68385 if (e) {
68386 log_packet_detailed("'rule_name' field error detected");
68387 }
68388
68389#ifdef FREECIV_JSON_CONNECTION
68390 field_addr.name = "min_speed";
68391#endif /* FREECIV_JSON_CONNECTION */
68392 e = 0;
68393
68394 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->min_speed);
68395
68396 if (e) {
68397 log_packet_detailed("'min_speed' field error detected");
68398 }
68399
68400#ifdef FREECIV_JSON_CONNECTION
68401 field_addr.name = "hp_loss_pct";
68402#endif /* FREECIV_JSON_CONNECTION */
68403 e = 0;
68404
68405 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp_loss_pct);
68406
68407 if (e) {
68408 log_packet_detailed("'hp_loss_pct' field error detected");
68409 }
68410
68411#ifdef FREECIV_JSON_CONNECTION
68412 field_addr.name = "non_native_def_pct";
68413#endif /* FREECIV_JSON_CONNECTION */
68414 e = 0;
68415
68416 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->non_native_def_pct);
68417
68418 if (e) {
68419 log_packet_detailed("'non_native_def_pct' field error detected");
68420 }
68421
68422#ifdef FREECIV_JSON_CONNECTION
68423 field_addr.name = "flags";
68424#endif /* FREECIV_JSON_CONNECTION */
68425 e = 0;
68426
68427 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
68428
68429 if (e) {
68430 log_packet_detailed("'flags' field error detected");
68431 }
68432
68433#ifdef FREECIV_JSON_CONNECTION
68434 field_addr.name = "helptext";
68435#endif /* FREECIV_JSON_CONNECTION */
68436 e = 0;
68437
68438 if (!real_packet->helptext) {
68439 /* Transmit null as empty */
68440 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
68441 } else {
68442 int i;
68443
68444 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
68445 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
68446
68447#ifdef FREECIV_JSON_CONNECTION
68448 /* Enter array. */
68449 field_addr.sub_location = plocation_elem_new(0);
68450#endif /* FREECIV_JSON_CONNECTION */
68451
68452 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
68453#ifdef FREECIV_JSON_CONNECTION
68454 /* Next array element. */
68455 field_addr.sub_location->number = i;
68456#endif /* FREECIV_JSON_CONNECTION */
68457
68458 {
68459 const char *pstr = strvec_get(real_packet->helptext, i);
68460
68461 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
68462 }
68463 }
68464
68465#ifdef FREECIV_JSON_CONNECTION
68466 /* Exit array. */
68467 FC_FREE(field_addr.sub_location);
68468#endif /* FREECIV_JSON_CONNECTION */
68469 }
68470
68471 if (e) {
68472 log_packet_detailed("'helptext' field error detected");
68473 }
68474#endif /* FREECIV_DELTA_PROTOCOL */
68475
68476 SEND_PACKET_END(PACKET_RULESET_UNIT_CLASS);
68477}
68478
68479 int send_packet_ruleset_unit_class(struct connection *pc, const struct packet_ruleset_unit_class *packet)
68480{
68481 if (!pc->used) {
68482 log_error("WARNING: trying to send data to the closed connection %s",
68483 conn_description(pc));
68484 return -1;
68485 }
68486 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_UNIT_CLASS].packet != nullptr, -1,
68487 "Handler for PACKET_RULESET_UNIT_CLASS not installed");
68488 return pc->phs.handlers->send[PACKET_RULESET_UNIT_CLASS].packet(pc, packet);
68489}
68490
68491 void lsend_packet_ruleset_unit_class(struct conn_list *dest, const struct packet_ruleset_unit_class *packet)
68492{
68493 conn_list_iterate(dest, pconn) {
68494 send_packet_ruleset_unit_class(pconn, packet);
68495 } conn_list_iterate_end;
68496}
68497
68498 static inline void init_packet_ruleset_extra(struct packet_ruleset_extra *packet)
68499{
68500 memset(packet, 0, sizeof(*packet));
68501
68502 requirement_vector_init(&packet->reqs);
68503 requirement_vector_init(&packet->rmreqs);
68504 requirement_vector_init(&packet->appearance_reqs);
68505 requirement_vector_init(&packet->disappearance_reqs);
68506 packet->helptext = strvec_new();
68507}
68508
68509 static inline void free_packet_ruleset_extra(struct packet_ruleset_extra *packet)
68510{
68511 if (packet->helptext) {
68512 strvec_destroy(packet->helptext);
68513 packet->helptext = nullptr;
68514 }
68515 requirement_vector_free(&packet->disappearance_reqs);
68516 requirement_vector_free(&packet->appearance_reqs);
68517 requirement_vector_free(&packet->rmreqs);
68518 requirement_vector_free(&packet->reqs);
68519}
68520
68521 static inline void destroy_packet_ruleset_extra(void *packet)
68522{
68523 free_packet_ruleset_extra((struct packet_ruleset_extra *) packet);
68524 free(packet);
68525}
68526
68527#ifdef FREECIV_DELTA_PROTOCOL
68528#define hash_packet_ruleset_extra_100 hash_const
68529#define cmp_packet_ruleset_extra_100 cmp_const
68530 BV_DEFINE(packet_ruleset_extra_100_fields, 37);
68531#endif /* FREECIV_DELTA_PROTOCOL */
68532
68533 static struct packet_ruleset_extra *receive_packet_ruleset_extra_100(struct connection *pc)
68534{
68535#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_extra(_packet)
68536 RECEIVE_PACKET_START(packet_ruleset_extra, real_packet);
68537
68538#ifdef FREECIV_JSON_CONNECTION
68539 struct plocation field_addr;
68540 {
68541 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
68542 field_addr = *field_addr_tmp;
68543 FC_FREE(field_addr_tmp);
68544 }
68545#endif /* FREECIV_JSON_CONNECTION */
68546
68547 log_packet_detailed("packet_ruleset_extra_100: got info about ()");
68548
68549#ifdef FREECIV_DELTA_PROTOCOL
68550 packet_ruleset_extra_100_fields fields;
68551 struct packet_ruleset_extra *old;
68552 struct genhash **hash = pc->phs.received + PACKET_RULESET_EXTRA;
68553
68554 if (nullptr == *hash) {
68555 *hash = genhash_new_full(hash_packet_ruleset_extra_100, cmp_packet_ruleset_extra_100,
68556 nullptr, nullptr, nullptr, destroy_packet_ruleset_extra);
68557 }
68558
68559 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
68560 real_packet->id = old->id;
68561 sz_strlcpy(real_packet->name, old->name);
68562 sz_strlcpy(real_packet->rule_name, old->rule_name);
68563 real_packet->category = old->category;
68564 real_packet->causes = old->causes;
68565 real_packet->rmcauses = old->rmcauses;
68566 sz_strlcpy(real_packet->activity_gfx, old->activity_gfx);
68567 sz_strlcpy(real_packet->act_gfx_alt, old->act_gfx_alt);
68568 sz_strlcpy(real_packet->act_gfx_alt2, old->act_gfx_alt2);
68569 sz_strlcpy(real_packet->rmact_gfx, old->rmact_gfx);
68570 sz_strlcpy(real_packet->rmact_gfx_alt, old->rmact_gfx_alt);
68571 sz_strlcpy(real_packet->rmact_gfx_alt2, old->rmact_gfx_alt2);
68572 sz_strlcpy(real_packet->graphic_str, old->graphic_str);
68573 sz_strlcpy(real_packet->graphic_alt, old->graphic_alt);
68574 requirement_vector_copy(&real_packet->reqs, &old->reqs);
68575 requirement_vector_copy(&real_packet->rmreqs, &old->rmreqs);
68576 real_packet->appearance_chance = old->appearance_chance;
68577 requirement_vector_copy(&real_packet->appearance_reqs, &old->appearance_reqs);
68578 real_packet->disappearance_chance = old->disappearance_chance;
68579 requirement_vector_copy(&real_packet->disappearance_reqs, &old->disappearance_reqs);
68580 real_packet->visibility_req = old->visibility_req;
68581 real_packet->buildable = old->buildable;
68582 real_packet->generated = old->generated;
68583 real_packet->build_time = old->build_time;
68584 real_packet->build_time_factor = old->build_time_factor;
68585 real_packet->removal_time = old->removal_time;
68586 real_packet->removal_time_factor = old->removal_time_factor;
68587 real_packet->infracost = old->infracost;
68588 real_packet->defense_bonus = old->defense_bonus;
68589 real_packet->eus = old->eus;
68590 real_packet->native_to = old->native_to;
68591 real_packet->flags = old->flags;
68592 real_packet->hidden_by = old->hidden_by;
68593 real_packet->bridged_over = old->bridged_over;
68594 real_packet->conflicts = old->conflicts;
68595 real_packet->no_aggr_near_city = old->no_aggr_near_city;
68596 if (old->helptext) {
68597 strvec_copy(real_packet->helptext, old->helptext);
68598 } else {
68599 strvec_clear(real_packet->helptext);
68600 }
68601 } else {
68602 /* packet is already initialized empty */
68603 log_packet_detailed(" no old info");
68604 }
68605
68606#ifdef FREECIV_JSON_CONNECTION
68607 field_addr.name = "fields";
68608#endif /* FREECIV_JSON_CONNECTION */
68609 DIO_BV_GET(&din, &field_addr, fields);
68610
68611 if (BV_ISSET(fields, 0)) {
68612 log_packet_detailed(" got field 'id'");
68613
68614#ifdef FREECIV_JSON_CONNECTION
68615 field_addr.name = "id";
68616#endif /* FREECIV_JSON_CONNECTION */
68617
68618 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
68619 RECEIVE_PACKET_FIELD_ERROR(id);
68620 }
68621 }
68622
68623 if (BV_ISSET(fields, 1)) {
68624 log_packet_detailed(" got field 'name'");
68625
68626#ifdef FREECIV_JSON_CONNECTION
68627 field_addr.name = "name";
68628#endif /* FREECIV_JSON_CONNECTION */
68629
68630 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
68631 RECEIVE_PACKET_FIELD_ERROR(name);
68632 }
68633 }
68634
68635 if (BV_ISSET(fields, 2)) {
68636 log_packet_detailed(" got field 'rule_name'");
68637
68638#ifdef FREECIV_JSON_CONNECTION
68639 field_addr.name = "rule_name";
68640#endif /* FREECIV_JSON_CONNECTION */
68641
68642 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
68643 RECEIVE_PACKET_FIELD_ERROR(rule_name);
68644 }
68645 }
68646
68647 if (BV_ISSET(fields, 3)) {
68648 log_packet_detailed(" got field 'category'");
68649
68650#ifdef FREECIV_JSON_CONNECTION
68651 field_addr.name = "category";
68652#endif /* FREECIV_JSON_CONNECTION */
68653
68654 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->category)) {
68655 RECEIVE_PACKET_FIELD_ERROR(category);
68656 }
68657 }
68658
68659 if (BV_ISSET(fields, 4)) {
68660 log_packet_detailed(" got field 'causes'");
68661
68662#ifdef FREECIV_JSON_CONNECTION
68663 field_addr.name = "causes";
68664#endif /* FREECIV_JSON_CONNECTION */
68665
68666 if (!DIO_BV_GET(&din, &field_addr, real_packet->causes)) {
68667 RECEIVE_PACKET_FIELD_ERROR(causes);
68668 }
68669 }
68670
68671 if (BV_ISSET(fields, 5)) {
68672 log_packet_detailed(" got field 'rmcauses'");
68673
68674#ifdef FREECIV_JSON_CONNECTION
68675 field_addr.name = "rmcauses";
68676#endif /* FREECIV_JSON_CONNECTION */
68677
68678 if (!DIO_BV_GET(&din, &field_addr, real_packet->rmcauses)) {
68679 RECEIVE_PACKET_FIELD_ERROR(rmcauses);
68680 }
68681 }
68682
68683 if (BV_ISSET(fields, 6)) {
68684 log_packet_detailed(" got field 'activity_gfx'");
68685
68686#ifdef FREECIV_JSON_CONNECTION
68687 field_addr.name = "activity_gfx";
68688#endif /* FREECIV_JSON_CONNECTION */
68689
68690 if (!DIO_GET(string, &din, &field_addr, real_packet->activity_gfx, sizeof(real_packet->activity_gfx))) {
68691 RECEIVE_PACKET_FIELD_ERROR(activity_gfx);
68692 }
68693 }
68694
68695 if (BV_ISSET(fields, 7)) {
68696 log_packet_detailed(" got field 'act_gfx_alt'");
68697
68698#ifdef FREECIV_JSON_CONNECTION
68699 field_addr.name = "act_gfx_alt";
68700#endif /* FREECIV_JSON_CONNECTION */
68701
68702 if (!DIO_GET(string, &din, &field_addr, real_packet->act_gfx_alt, sizeof(real_packet->act_gfx_alt))) {
68703 RECEIVE_PACKET_FIELD_ERROR(act_gfx_alt);
68704 }
68705 }
68706
68707 if (BV_ISSET(fields, 8)) {
68708 log_packet_detailed(" got field 'act_gfx_alt2'");
68709
68710#ifdef FREECIV_JSON_CONNECTION
68711 field_addr.name = "act_gfx_alt2";
68712#endif /* FREECIV_JSON_CONNECTION */
68713
68714 if (!DIO_GET(string, &din, &field_addr, real_packet->act_gfx_alt2, sizeof(real_packet->act_gfx_alt2))) {
68715 RECEIVE_PACKET_FIELD_ERROR(act_gfx_alt2);
68716 }
68717 }
68718
68719 if (BV_ISSET(fields, 9)) {
68720 log_packet_detailed(" got field 'rmact_gfx'");
68721
68722#ifdef FREECIV_JSON_CONNECTION
68723 field_addr.name = "rmact_gfx";
68724#endif /* FREECIV_JSON_CONNECTION */
68725
68726 if (!DIO_GET(string, &din, &field_addr, real_packet->rmact_gfx, sizeof(real_packet->rmact_gfx))) {
68727 RECEIVE_PACKET_FIELD_ERROR(rmact_gfx);
68728 }
68729 }
68730
68731 if (BV_ISSET(fields, 10)) {
68732 log_packet_detailed(" got field 'rmact_gfx_alt'");
68733
68734#ifdef FREECIV_JSON_CONNECTION
68735 field_addr.name = "rmact_gfx_alt";
68736#endif /* FREECIV_JSON_CONNECTION */
68737
68738 if (!DIO_GET(string, &din, &field_addr, real_packet->rmact_gfx_alt, sizeof(real_packet->rmact_gfx_alt))) {
68739 RECEIVE_PACKET_FIELD_ERROR(rmact_gfx_alt);
68740 }
68741 }
68742
68743 if (BV_ISSET(fields, 11)) {
68744 log_packet_detailed(" got field 'rmact_gfx_alt2'");
68745
68746#ifdef FREECIV_JSON_CONNECTION
68747 field_addr.name = "rmact_gfx_alt2";
68748#endif /* FREECIV_JSON_CONNECTION */
68749
68750 if (!DIO_GET(string, &din, &field_addr, real_packet->rmact_gfx_alt2, sizeof(real_packet->rmact_gfx_alt2))) {
68751 RECEIVE_PACKET_FIELD_ERROR(rmact_gfx_alt2);
68752 }
68753 }
68754
68755 if (BV_ISSET(fields, 12)) {
68756 log_packet_detailed(" got field 'graphic_str'");
68757
68758#ifdef FREECIV_JSON_CONNECTION
68759 field_addr.name = "graphic_str";
68760#endif /* FREECIV_JSON_CONNECTION */
68761
68762 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
68763 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
68764 }
68765 }
68766
68767 if (BV_ISSET(fields, 13)) {
68768 log_packet_detailed(" got field 'graphic_alt'");
68769
68770#ifdef FREECIV_JSON_CONNECTION
68771 field_addr.name = "graphic_alt";
68772#endif /* FREECIV_JSON_CONNECTION */
68773
68774 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
68775 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
68776 }
68777 }
68778
68779 if (BV_ISSET(fields, 14)) {
68780 log_packet_detailed(" got field 'reqs'");
68781
68782#ifdef FREECIV_JSON_CONNECTION
68783 field_addr.name = "reqs";
68784#endif /* FREECIV_JSON_CONNECTION */
68785
68786 {
68787 int i;
68788
68789 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
68790 RECEIVE_PACKET_FIELD_ERROR(reqs);
68791 }
68792 requirement_vector_reserve(&real_packet->reqs, i);
68793
68794#ifdef FREECIV_JSON_CONNECTION
68795 /* Enter array. */
68796 field_addr.sub_location = plocation_elem_new(0);
68797#endif /* FREECIV_JSON_CONNECTION */
68798
68799 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
68800#ifdef FREECIV_JSON_CONNECTION
68801 /* Next array element */
68802 field_addr.sub_location->number = i;
68803#endif /* FREECIV_JSON_CONNECTION */
68804
68805 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
68806 RECEIVE_PACKET_FIELD_ERROR(reqs);
68807 }
68808 }
68809
68810#ifdef FREECIV_JSON_CONNECTION
68811 /* Exit array. */
68812 FC_FREE(field_addr.sub_location);
68813#endif /* FREECIV_JSON_CONNECTION */
68814 }
68815 }
68816
68817 if (BV_ISSET(fields, 15)) {
68818 log_packet_detailed(" got field 'rmreqs'");
68819
68820#ifdef FREECIV_JSON_CONNECTION
68821 field_addr.name = "rmreqs";
68822#endif /* FREECIV_JSON_CONNECTION */
68823
68824 {
68825 int i;
68826
68827 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
68828 RECEIVE_PACKET_FIELD_ERROR(rmreqs);
68829 }
68830 requirement_vector_reserve(&real_packet->rmreqs, i);
68831
68832#ifdef FREECIV_JSON_CONNECTION
68833 /* Enter array. */
68834 field_addr.sub_location = plocation_elem_new(0);
68835#endif /* FREECIV_JSON_CONNECTION */
68836
68837 for (i = 0; i < requirement_vector_size(&real_packet->rmreqs); i++) {
68838#ifdef FREECIV_JSON_CONNECTION
68839 /* Next array element */
68840 field_addr.sub_location->number = i;
68841#endif /* FREECIV_JSON_CONNECTION */
68842
68843 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->rmreqs.p[i])) {
68844 RECEIVE_PACKET_FIELD_ERROR(rmreqs);
68845 }
68846 }
68847
68848#ifdef FREECIV_JSON_CONNECTION
68849 /* Exit array. */
68850 FC_FREE(field_addr.sub_location);
68851#endif /* FREECIV_JSON_CONNECTION */
68852 }
68853 }
68854
68855 if (BV_ISSET(fields, 16)) {
68856 log_packet_detailed(" got field 'appearance_chance'");
68857
68858#ifdef FREECIV_JSON_CONNECTION
68859 field_addr.name = "appearance_chance";
68860#endif /* FREECIV_JSON_CONNECTION */
68861
68862 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->appearance_chance)) {
68863 RECEIVE_PACKET_FIELD_ERROR(appearance_chance);
68864 }
68865 }
68866
68867 if (BV_ISSET(fields, 17)) {
68868 log_packet_detailed(" got field 'appearance_reqs'");
68869
68870#ifdef FREECIV_JSON_CONNECTION
68871 field_addr.name = "appearance_reqs";
68872#endif /* FREECIV_JSON_CONNECTION */
68873
68874 {
68875 int i;
68876
68877 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
68878 RECEIVE_PACKET_FIELD_ERROR(appearance_reqs);
68879 }
68880 requirement_vector_reserve(&real_packet->appearance_reqs, i);
68881
68882#ifdef FREECIV_JSON_CONNECTION
68883 /* Enter array. */
68884 field_addr.sub_location = plocation_elem_new(0);
68885#endif /* FREECIV_JSON_CONNECTION */
68886
68887 for (i = 0; i < requirement_vector_size(&real_packet->appearance_reqs); i++) {
68888#ifdef FREECIV_JSON_CONNECTION
68889 /* Next array element */
68890 field_addr.sub_location->number = i;
68891#endif /* FREECIV_JSON_CONNECTION */
68892
68893 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->appearance_reqs.p[i])) {
68894 RECEIVE_PACKET_FIELD_ERROR(appearance_reqs);
68895 }
68896 }
68897
68898#ifdef FREECIV_JSON_CONNECTION
68899 /* Exit array. */
68900 FC_FREE(field_addr.sub_location);
68901#endif /* FREECIV_JSON_CONNECTION */
68902 }
68903 }
68904
68905 if (BV_ISSET(fields, 18)) {
68906 log_packet_detailed(" got field 'disappearance_chance'");
68907
68908#ifdef FREECIV_JSON_CONNECTION
68909 field_addr.name = "disappearance_chance";
68910#endif /* FREECIV_JSON_CONNECTION */
68911
68912 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->disappearance_chance)) {
68913 RECEIVE_PACKET_FIELD_ERROR(disappearance_chance);
68914 }
68915 }
68916
68917 if (BV_ISSET(fields, 19)) {
68918 log_packet_detailed(" got field 'disappearance_reqs'");
68919
68920#ifdef FREECIV_JSON_CONNECTION
68921 field_addr.name = "disappearance_reqs";
68922#endif /* FREECIV_JSON_CONNECTION */
68923
68924 {
68925 int i;
68926
68927 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
68928 RECEIVE_PACKET_FIELD_ERROR(disappearance_reqs);
68929 }
68930 requirement_vector_reserve(&real_packet->disappearance_reqs, i);
68931
68932#ifdef FREECIV_JSON_CONNECTION
68933 /* Enter array. */
68934 field_addr.sub_location = plocation_elem_new(0);
68935#endif /* FREECIV_JSON_CONNECTION */
68936
68937 for (i = 0; i < requirement_vector_size(&real_packet->disappearance_reqs); i++) {
68938#ifdef FREECIV_JSON_CONNECTION
68939 /* Next array element */
68940 field_addr.sub_location->number = i;
68941#endif /* FREECIV_JSON_CONNECTION */
68942
68943 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->disappearance_reqs.p[i])) {
68944 RECEIVE_PACKET_FIELD_ERROR(disappearance_reqs);
68945 }
68946 }
68947
68948#ifdef FREECIV_JSON_CONNECTION
68949 /* Exit array. */
68950 FC_FREE(field_addr.sub_location);
68951#endif /* FREECIV_JSON_CONNECTION */
68952 }
68953 }
68954
68955 if (BV_ISSET(fields, 20)) {
68956 log_packet_detailed(" got field 'visibility_req'");
68957
68958#ifdef FREECIV_JSON_CONNECTION
68959 field_addr.name = "visibility_req";
68960#endif /* FREECIV_JSON_CONNECTION */
68961
68962 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->visibility_req)) {
68963 RECEIVE_PACKET_FIELD_ERROR(visibility_req);
68964 }
68965 }
68966
68967 real_packet->buildable = BV_ISSET(fields, 21);
68968
68969 real_packet->generated = BV_ISSET(fields, 22);
68970
68971 if (BV_ISSET(fields, 23)) {
68972 log_packet_detailed(" got field 'build_time'");
68973
68974#ifdef FREECIV_JSON_CONNECTION
68975 field_addr.name = "build_time";
68976#endif /* FREECIV_JSON_CONNECTION */
68977
68978 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->build_time)) {
68979 RECEIVE_PACKET_FIELD_ERROR(build_time);
68980 }
68981 }
68982
68983 if (BV_ISSET(fields, 24)) {
68984 log_packet_detailed(" got field 'build_time_factor'");
68985
68986#ifdef FREECIV_JSON_CONNECTION
68987 field_addr.name = "build_time_factor";
68988#endif /* FREECIV_JSON_CONNECTION */
68989
68990 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->build_time_factor)) {
68991 RECEIVE_PACKET_FIELD_ERROR(build_time_factor);
68992 }
68993 }
68994
68995 if (BV_ISSET(fields, 25)) {
68996 log_packet_detailed(" got field 'removal_time'");
68997
68998#ifdef FREECIV_JSON_CONNECTION
68999 field_addr.name = "removal_time";
69000#endif /* FREECIV_JSON_CONNECTION */
69001
69002 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->removal_time)) {
69003 RECEIVE_PACKET_FIELD_ERROR(removal_time);
69004 }
69005 }
69006
69007 if (BV_ISSET(fields, 26)) {
69008 log_packet_detailed(" got field 'removal_time_factor'");
69009
69010#ifdef FREECIV_JSON_CONNECTION
69011 field_addr.name = "removal_time_factor";
69012#endif /* FREECIV_JSON_CONNECTION */
69013
69014 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->removal_time_factor)) {
69015 RECEIVE_PACKET_FIELD_ERROR(removal_time_factor);
69016 }
69017 }
69018
69019 if (BV_ISSET(fields, 27)) {
69020 log_packet_detailed(" got field 'infracost'");
69021
69022#ifdef FREECIV_JSON_CONNECTION
69023 field_addr.name = "infracost";
69024#endif /* FREECIV_JSON_CONNECTION */
69025
69026 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->infracost)) {
69027 RECEIVE_PACKET_FIELD_ERROR(infracost);
69028 }
69029 }
69030
69031 if (BV_ISSET(fields, 28)) {
69032 log_packet_detailed(" got field 'defense_bonus'");
69033
69034#ifdef FREECIV_JSON_CONNECTION
69035 field_addr.name = "defense_bonus";
69036#endif /* FREECIV_JSON_CONNECTION */
69037
69038 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->defense_bonus)) {
69039 RECEIVE_PACKET_FIELD_ERROR(defense_bonus);
69040 }
69041 }
69042
69043 if (BV_ISSET(fields, 29)) {
69044 log_packet_detailed(" got field 'eus'");
69045
69046#ifdef FREECIV_JSON_CONNECTION
69047 field_addr.name = "eus";
69048#endif /* FREECIV_JSON_CONNECTION */
69049
69050 {
69051 int readin;
69052
69053 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
69054 RECEIVE_PACKET_FIELD_ERROR(eus);
69055 }
69056 real_packet->eus = readin;
69057 }
69058 }
69059
69060 if (BV_ISSET(fields, 30)) {
69061 log_packet_detailed(" got field 'native_to'");
69062
69063#ifdef FREECIV_JSON_CONNECTION
69064 field_addr.name = "native_to";
69065#endif /* FREECIV_JSON_CONNECTION */
69066
69067 if (!DIO_BV_GET(&din, &field_addr, real_packet->native_to)) {
69068 RECEIVE_PACKET_FIELD_ERROR(native_to);
69069 }
69070 }
69071
69072 if (BV_ISSET(fields, 31)) {
69073 log_packet_detailed(" got field 'flags'");
69074
69075#ifdef FREECIV_JSON_CONNECTION
69076 field_addr.name = "flags";
69077#endif /* FREECIV_JSON_CONNECTION */
69078
69079 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
69080 RECEIVE_PACKET_FIELD_ERROR(flags);
69081 }
69082 }
69083
69084 if (BV_ISSET(fields, 32)) {
69085 log_packet_detailed(" got field 'hidden_by'");
69086
69087#ifdef FREECIV_JSON_CONNECTION
69088 field_addr.name = "hidden_by";
69089#endif /* FREECIV_JSON_CONNECTION */
69090
69091 if (!DIO_BV_GET(&din, &field_addr, real_packet->hidden_by)) {
69092 RECEIVE_PACKET_FIELD_ERROR(hidden_by);
69093 }
69094 }
69095
69096 if (BV_ISSET(fields, 33)) {
69097 log_packet_detailed(" got field 'bridged_over'");
69098
69099#ifdef FREECIV_JSON_CONNECTION
69100 field_addr.name = "bridged_over";
69101#endif /* FREECIV_JSON_CONNECTION */
69102
69103 if (!DIO_BV_GET(&din, &field_addr, real_packet->bridged_over)) {
69104 RECEIVE_PACKET_FIELD_ERROR(bridged_over);
69105 }
69106 }
69107
69108 if (BV_ISSET(fields, 34)) {
69109 log_packet_detailed(" got field 'conflicts'");
69110
69111#ifdef FREECIV_JSON_CONNECTION
69112 field_addr.name = "conflicts";
69113#endif /* FREECIV_JSON_CONNECTION */
69114
69115 if (!DIO_BV_GET(&din, &field_addr, real_packet->conflicts)) {
69116 RECEIVE_PACKET_FIELD_ERROR(conflicts);
69117 }
69118 }
69119
69120 if (BV_ISSET(fields, 35)) {
69121 log_packet_detailed(" got field 'no_aggr_near_city'");
69122
69123#ifdef FREECIV_JSON_CONNECTION
69124 field_addr.name = "no_aggr_near_city";
69125#endif /* FREECIV_JSON_CONNECTION */
69126
69127 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->no_aggr_near_city)) {
69128 RECEIVE_PACKET_FIELD_ERROR(no_aggr_near_city);
69129 }
69130 }
69131
69132 if (BV_ISSET(fields, 36)) {
69133 log_packet_detailed(" got field 'helptext'");
69134
69135#ifdef FREECIV_JSON_CONNECTION
69136 field_addr.name = "helptext";
69137#endif /* FREECIV_JSON_CONNECTION */
69138
69139 {
69140 int i;
69141
69142 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
69143 RECEIVE_PACKET_FIELD_ERROR(helptext);
69144 }
69145 strvec_reserve(real_packet->helptext, i);
69146
69147#ifdef FREECIV_JSON_CONNECTION
69148 /* Enter array. */
69149 field_addr.sub_location = plocation_elem_new(0);
69150#endif /* FREECIV_JSON_CONNECTION */
69151
69152 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
69153#ifdef FREECIV_JSON_CONNECTION
69154 /* Next array element */
69155 field_addr.sub_location->number = i;
69156#endif /* FREECIV_JSON_CONNECTION */
69157
69158 {
69159 char readin[MAX_LEN_PACKET];
69160
69161 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
69162 || !strvec_set(real_packet->helptext, i, readin)) {
69163 RECEIVE_PACKET_FIELD_ERROR(helptext);
69164 }
69165 }
69166 }
69167
69168#ifdef FREECIV_JSON_CONNECTION
69169 /* Exit array. */
69170 FC_FREE(field_addr.sub_location);
69171#endif /* FREECIV_JSON_CONNECTION */
69172 }
69173 }
69174
69175 if (nullptr == old) {
69176 old = fc_malloc(sizeof(*old));
69177 init_packet_ruleset_extra(old);
69178 old->id = real_packet->id;
69179 sz_strlcpy(old->name, real_packet->name);
69180 sz_strlcpy(old->rule_name, real_packet->rule_name);
69181 old->category = real_packet->category;
69182 old->causes = real_packet->causes;
69183 old->rmcauses = real_packet->rmcauses;
69184 sz_strlcpy(old->activity_gfx, real_packet->activity_gfx);
69185 sz_strlcpy(old->act_gfx_alt, real_packet->act_gfx_alt);
69186 sz_strlcpy(old->act_gfx_alt2, real_packet->act_gfx_alt2);
69187 sz_strlcpy(old->rmact_gfx, real_packet->rmact_gfx);
69188 sz_strlcpy(old->rmact_gfx_alt, real_packet->rmact_gfx_alt);
69189 sz_strlcpy(old->rmact_gfx_alt2, real_packet->rmact_gfx_alt2);
69190 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
69191 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
69192 requirement_vector_copy(&old->reqs, &real_packet->reqs);
69193 requirement_vector_copy(&old->rmreqs, &real_packet->rmreqs);
69194 old->appearance_chance = real_packet->appearance_chance;
69195 requirement_vector_copy(&old->appearance_reqs, &real_packet->appearance_reqs);
69196 old->disappearance_chance = real_packet->disappearance_chance;
69197 requirement_vector_copy(&old->disappearance_reqs, &real_packet->disappearance_reqs);
69198 old->visibility_req = real_packet->visibility_req;
69199 old->buildable = real_packet->buildable;
69200 old->generated = real_packet->generated;
69201 old->build_time = real_packet->build_time;
69202 old->build_time_factor = real_packet->build_time_factor;
69203 old->removal_time = real_packet->removal_time;
69204 old->removal_time_factor = real_packet->removal_time_factor;
69205 old->infracost = real_packet->infracost;
69206 old->defense_bonus = real_packet->defense_bonus;
69207 old->eus = real_packet->eus;
69208 old->native_to = real_packet->native_to;
69209 old->flags = real_packet->flags;
69210 old->hidden_by = real_packet->hidden_by;
69211 old->bridged_over = real_packet->bridged_over;
69212 old->conflicts = real_packet->conflicts;
69213 old->no_aggr_near_city = real_packet->no_aggr_near_city;
69214 if (real_packet->helptext) {
69215 strvec_copy(old->helptext, real_packet->helptext);
69216 } else {
69217 strvec_clear(old->helptext);
69218 }
69219 genhash_insert(*hash, old, old);
69220 } else {
69221 old->id = real_packet->id;
69222 sz_strlcpy(old->name, real_packet->name);
69223 sz_strlcpy(old->rule_name, real_packet->rule_name);
69224 old->category = real_packet->category;
69225 old->causes = real_packet->causes;
69226 old->rmcauses = real_packet->rmcauses;
69227 sz_strlcpy(old->activity_gfx, real_packet->activity_gfx);
69228 sz_strlcpy(old->act_gfx_alt, real_packet->act_gfx_alt);
69229 sz_strlcpy(old->act_gfx_alt2, real_packet->act_gfx_alt2);
69230 sz_strlcpy(old->rmact_gfx, real_packet->rmact_gfx);
69231 sz_strlcpy(old->rmact_gfx_alt, real_packet->rmact_gfx_alt);
69232 sz_strlcpy(old->rmact_gfx_alt2, real_packet->rmact_gfx_alt2);
69233 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
69234 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
69235 requirement_vector_copy(&old->reqs, &real_packet->reqs);
69236 requirement_vector_copy(&old->rmreqs, &real_packet->rmreqs);
69237 old->appearance_chance = real_packet->appearance_chance;
69238 requirement_vector_copy(&old->appearance_reqs, &real_packet->appearance_reqs);
69239 old->disappearance_chance = real_packet->disappearance_chance;
69240 requirement_vector_copy(&old->disappearance_reqs, &real_packet->disappearance_reqs);
69241 old->visibility_req = real_packet->visibility_req;
69242 old->buildable = real_packet->buildable;
69243 old->generated = real_packet->generated;
69244 old->build_time = real_packet->build_time;
69245 old->build_time_factor = real_packet->build_time_factor;
69246 old->removal_time = real_packet->removal_time;
69247 old->removal_time_factor = real_packet->removal_time_factor;
69248 old->infracost = real_packet->infracost;
69249 old->defense_bonus = real_packet->defense_bonus;
69250 old->eus = real_packet->eus;
69251 old->native_to = real_packet->native_to;
69252 old->flags = real_packet->flags;
69253 old->hidden_by = real_packet->hidden_by;
69254 old->bridged_over = real_packet->bridged_over;
69255 old->conflicts = real_packet->conflicts;
69256 old->no_aggr_near_city = real_packet->no_aggr_near_city;
69257 if (real_packet->helptext) {
69258 strvec_copy(old->helptext, real_packet->helptext);
69259 } else {
69260 strvec_clear(old->helptext);
69261 }
69262 }
69263
69264#else /* FREECIV_DELTA_PROTOCOL */
69265#ifdef FREECIV_JSON_CONNECTION
69266 field_addr.name = "id";
69267#endif /* FREECIV_JSON_CONNECTION */
69268
69269 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
69270 RECEIVE_PACKET_FIELD_ERROR(id);
69271 }
69272
69273#ifdef FREECIV_JSON_CONNECTION
69274 field_addr.name = "name";
69275#endif /* FREECIV_JSON_CONNECTION */
69276
69277 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
69278 RECEIVE_PACKET_FIELD_ERROR(name);
69279 }
69280
69281#ifdef FREECIV_JSON_CONNECTION
69282 field_addr.name = "rule_name";
69283#endif /* FREECIV_JSON_CONNECTION */
69284
69285 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
69286 RECEIVE_PACKET_FIELD_ERROR(rule_name);
69287 }
69288
69289#ifdef FREECIV_JSON_CONNECTION
69290 field_addr.name = "category";
69291#endif /* FREECIV_JSON_CONNECTION */
69292
69293 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->category)) {
69294 RECEIVE_PACKET_FIELD_ERROR(category);
69295 }
69296
69297#ifdef FREECIV_JSON_CONNECTION
69298 field_addr.name = "causes";
69299#endif /* FREECIV_JSON_CONNECTION */
69300
69301 if (!DIO_BV_GET(&din, &field_addr, real_packet->causes)) {
69302 RECEIVE_PACKET_FIELD_ERROR(causes);
69303 }
69304
69305#ifdef FREECIV_JSON_CONNECTION
69306 field_addr.name = "rmcauses";
69307#endif /* FREECIV_JSON_CONNECTION */
69308
69309 if (!DIO_BV_GET(&din, &field_addr, real_packet->rmcauses)) {
69310 RECEIVE_PACKET_FIELD_ERROR(rmcauses);
69311 }
69312
69313#ifdef FREECIV_JSON_CONNECTION
69314 field_addr.name = "activity_gfx";
69315#endif /* FREECIV_JSON_CONNECTION */
69316
69317 if (!DIO_GET(string, &din, &field_addr, real_packet->activity_gfx, sizeof(real_packet->activity_gfx))) {
69318 RECEIVE_PACKET_FIELD_ERROR(activity_gfx);
69319 }
69320
69321#ifdef FREECIV_JSON_CONNECTION
69322 field_addr.name = "act_gfx_alt";
69323#endif /* FREECIV_JSON_CONNECTION */
69324
69325 if (!DIO_GET(string, &din, &field_addr, real_packet->act_gfx_alt, sizeof(real_packet->act_gfx_alt))) {
69326 RECEIVE_PACKET_FIELD_ERROR(act_gfx_alt);
69327 }
69328
69329#ifdef FREECIV_JSON_CONNECTION
69330 field_addr.name = "act_gfx_alt2";
69331#endif /* FREECIV_JSON_CONNECTION */
69332
69333 if (!DIO_GET(string, &din, &field_addr, real_packet->act_gfx_alt2, sizeof(real_packet->act_gfx_alt2))) {
69334 RECEIVE_PACKET_FIELD_ERROR(act_gfx_alt2);
69335 }
69336
69337#ifdef FREECIV_JSON_CONNECTION
69338 field_addr.name = "rmact_gfx";
69339#endif /* FREECIV_JSON_CONNECTION */
69340
69341 if (!DIO_GET(string, &din, &field_addr, real_packet->rmact_gfx, sizeof(real_packet->rmact_gfx))) {
69342 RECEIVE_PACKET_FIELD_ERROR(rmact_gfx);
69343 }
69344
69345#ifdef FREECIV_JSON_CONNECTION
69346 field_addr.name = "rmact_gfx_alt";
69347#endif /* FREECIV_JSON_CONNECTION */
69348
69349 if (!DIO_GET(string, &din, &field_addr, real_packet->rmact_gfx_alt, sizeof(real_packet->rmact_gfx_alt))) {
69350 RECEIVE_PACKET_FIELD_ERROR(rmact_gfx_alt);
69351 }
69352
69353#ifdef FREECIV_JSON_CONNECTION
69354 field_addr.name = "rmact_gfx_alt2";
69355#endif /* FREECIV_JSON_CONNECTION */
69356
69357 if (!DIO_GET(string, &din, &field_addr, real_packet->rmact_gfx_alt2, sizeof(real_packet->rmact_gfx_alt2))) {
69358 RECEIVE_PACKET_FIELD_ERROR(rmact_gfx_alt2);
69359 }
69360
69361#ifdef FREECIV_JSON_CONNECTION
69362 field_addr.name = "graphic_str";
69363#endif /* FREECIV_JSON_CONNECTION */
69364
69365 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_str, sizeof(real_packet->graphic_str))) {
69366 RECEIVE_PACKET_FIELD_ERROR(graphic_str);
69367 }
69368
69369#ifdef FREECIV_JSON_CONNECTION
69370 field_addr.name = "graphic_alt";
69371#endif /* FREECIV_JSON_CONNECTION */
69372
69373 if (!DIO_GET(string, &din, &field_addr, real_packet->graphic_alt, sizeof(real_packet->graphic_alt))) {
69374 RECEIVE_PACKET_FIELD_ERROR(graphic_alt);
69375 }
69376
69377#ifdef FREECIV_JSON_CONNECTION
69378 field_addr.name = "reqs";
69379#endif /* FREECIV_JSON_CONNECTION */
69380
69381 {
69382 int i;
69383
69384 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
69385 RECEIVE_PACKET_FIELD_ERROR(reqs);
69386 }
69387 requirement_vector_reserve(&real_packet->reqs, i);
69388
69389#ifdef FREECIV_JSON_CONNECTION
69390 /* Enter array. */
69391 field_addr.sub_location = plocation_elem_new(0);
69392#endif /* FREECIV_JSON_CONNECTION */
69393
69394 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
69395#ifdef FREECIV_JSON_CONNECTION
69396 /* Next array element */
69397 field_addr.sub_location->number = i;
69398#endif /* FREECIV_JSON_CONNECTION */
69399
69400 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
69401 RECEIVE_PACKET_FIELD_ERROR(reqs);
69402 }
69403 }
69404
69405#ifdef FREECIV_JSON_CONNECTION
69406 /* Exit array. */
69407 FC_FREE(field_addr.sub_location);
69408#endif /* FREECIV_JSON_CONNECTION */
69409 }
69410
69411#ifdef FREECIV_JSON_CONNECTION
69412 field_addr.name = "rmreqs";
69413#endif /* FREECIV_JSON_CONNECTION */
69414
69415 {
69416 int i;
69417
69418 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
69419 RECEIVE_PACKET_FIELD_ERROR(rmreqs);
69420 }
69421 requirement_vector_reserve(&real_packet->rmreqs, i);
69422
69423#ifdef FREECIV_JSON_CONNECTION
69424 /* Enter array. */
69425 field_addr.sub_location = plocation_elem_new(0);
69426#endif /* FREECIV_JSON_CONNECTION */
69427
69428 for (i = 0; i < requirement_vector_size(&real_packet->rmreqs); i++) {
69429#ifdef FREECIV_JSON_CONNECTION
69430 /* Next array element */
69431 field_addr.sub_location->number = i;
69432#endif /* FREECIV_JSON_CONNECTION */
69433
69434 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->rmreqs.p[i])) {
69435 RECEIVE_PACKET_FIELD_ERROR(rmreqs);
69436 }
69437 }
69438
69439#ifdef FREECIV_JSON_CONNECTION
69440 /* Exit array. */
69441 FC_FREE(field_addr.sub_location);
69442#endif /* FREECIV_JSON_CONNECTION */
69443 }
69444
69445#ifdef FREECIV_JSON_CONNECTION
69446 field_addr.name = "appearance_chance";
69447#endif /* FREECIV_JSON_CONNECTION */
69448
69449 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->appearance_chance)) {
69450 RECEIVE_PACKET_FIELD_ERROR(appearance_chance);
69451 }
69452
69453#ifdef FREECIV_JSON_CONNECTION
69454 field_addr.name = "appearance_reqs";
69455#endif /* FREECIV_JSON_CONNECTION */
69456
69457 {
69458 int i;
69459
69460 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
69461 RECEIVE_PACKET_FIELD_ERROR(appearance_reqs);
69462 }
69463 requirement_vector_reserve(&real_packet->appearance_reqs, i);
69464
69465#ifdef FREECIV_JSON_CONNECTION
69466 /* Enter array. */
69467 field_addr.sub_location = plocation_elem_new(0);
69468#endif /* FREECIV_JSON_CONNECTION */
69469
69470 for (i = 0; i < requirement_vector_size(&real_packet->appearance_reqs); i++) {
69471#ifdef FREECIV_JSON_CONNECTION
69472 /* Next array element */
69473 field_addr.sub_location->number = i;
69474#endif /* FREECIV_JSON_CONNECTION */
69475
69476 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->appearance_reqs.p[i])) {
69477 RECEIVE_PACKET_FIELD_ERROR(appearance_reqs);
69478 }
69479 }
69480
69481#ifdef FREECIV_JSON_CONNECTION
69482 /* Exit array. */
69483 FC_FREE(field_addr.sub_location);
69484#endif /* FREECIV_JSON_CONNECTION */
69485 }
69486
69487#ifdef FREECIV_JSON_CONNECTION
69488 field_addr.name = "disappearance_chance";
69489#endif /* FREECIV_JSON_CONNECTION */
69490
69491 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->disappearance_chance)) {
69492 RECEIVE_PACKET_FIELD_ERROR(disappearance_chance);
69493 }
69494
69495#ifdef FREECIV_JSON_CONNECTION
69496 field_addr.name = "disappearance_reqs";
69497#endif /* FREECIV_JSON_CONNECTION */
69498
69499 {
69500 int i;
69501
69502 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
69503 RECEIVE_PACKET_FIELD_ERROR(disappearance_reqs);
69504 }
69505 requirement_vector_reserve(&real_packet->disappearance_reqs, i);
69506
69507#ifdef FREECIV_JSON_CONNECTION
69508 /* Enter array. */
69509 field_addr.sub_location = plocation_elem_new(0);
69510#endif /* FREECIV_JSON_CONNECTION */
69511
69512 for (i = 0; i < requirement_vector_size(&real_packet->disappearance_reqs); i++) {
69513#ifdef FREECIV_JSON_CONNECTION
69514 /* Next array element */
69515 field_addr.sub_location->number = i;
69516#endif /* FREECIV_JSON_CONNECTION */
69517
69518 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->disappearance_reqs.p[i])) {
69519 RECEIVE_PACKET_FIELD_ERROR(disappearance_reqs);
69520 }
69521 }
69522
69523#ifdef FREECIV_JSON_CONNECTION
69524 /* Exit array. */
69525 FC_FREE(field_addr.sub_location);
69526#endif /* FREECIV_JSON_CONNECTION */
69527 }
69528
69529#ifdef FREECIV_JSON_CONNECTION
69530 field_addr.name = "visibility_req";
69531#endif /* FREECIV_JSON_CONNECTION */
69532
69533 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->visibility_req)) {
69534 RECEIVE_PACKET_FIELD_ERROR(visibility_req);
69535 }
69536
69537#ifdef FREECIV_JSON_CONNECTION
69538 field_addr.name = "buildable";
69539#endif /* FREECIV_JSON_CONNECTION */
69540
69541 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->buildable)) {
69542 RECEIVE_PACKET_FIELD_ERROR(buildable);
69543 }
69544
69545#ifdef FREECIV_JSON_CONNECTION
69546 field_addr.name = "generated";
69547#endif /* FREECIV_JSON_CONNECTION */
69548
69549 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->generated)) {
69550 RECEIVE_PACKET_FIELD_ERROR(generated);
69551 }
69552
69553#ifdef FREECIV_JSON_CONNECTION
69554 field_addr.name = "build_time";
69555#endif /* FREECIV_JSON_CONNECTION */
69556
69557 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->build_time)) {
69558 RECEIVE_PACKET_FIELD_ERROR(build_time);
69559 }
69560
69561#ifdef FREECIV_JSON_CONNECTION
69562 field_addr.name = "build_time_factor";
69563#endif /* FREECIV_JSON_CONNECTION */
69564
69565 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->build_time_factor)) {
69566 RECEIVE_PACKET_FIELD_ERROR(build_time_factor);
69567 }
69568
69569#ifdef FREECIV_JSON_CONNECTION
69570 field_addr.name = "removal_time";
69571#endif /* FREECIV_JSON_CONNECTION */
69572
69573 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->removal_time)) {
69574 RECEIVE_PACKET_FIELD_ERROR(removal_time);
69575 }
69576
69577#ifdef FREECIV_JSON_CONNECTION
69578 field_addr.name = "removal_time_factor";
69579#endif /* FREECIV_JSON_CONNECTION */
69580
69581 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->removal_time_factor)) {
69582 RECEIVE_PACKET_FIELD_ERROR(removal_time_factor);
69583 }
69584
69585#ifdef FREECIV_JSON_CONNECTION
69586 field_addr.name = "infracost";
69587#endif /* FREECIV_JSON_CONNECTION */
69588
69589 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->infracost)) {
69590 RECEIVE_PACKET_FIELD_ERROR(infracost);
69591 }
69592
69593#ifdef FREECIV_JSON_CONNECTION
69594 field_addr.name = "defense_bonus";
69595#endif /* FREECIV_JSON_CONNECTION */
69596
69597 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->defense_bonus)) {
69598 RECEIVE_PACKET_FIELD_ERROR(defense_bonus);
69599 }
69600
69601#ifdef FREECIV_JSON_CONNECTION
69602 field_addr.name = "eus";
69603#endif /* FREECIV_JSON_CONNECTION */
69604
69605 {
69606 int readin;
69607
69608 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
69609 RECEIVE_PACKET_FIELD_ERROR(eus);
69610 }
69611 real_packet->eus = readin;
69612 }
69613
69614#ifdef FREECIV_JSON_CONNECTION
69615 field_addr.name = "native_to";
69616#endif /* FREECIV_JSON_CONNECTION */
69617
69618 if (!DIO_BV_GET(&din, &field_addr, real_packet->native_to)) {
69619 RECEIVE_PACKET_FIELD_ERROR(native_to);
69620 }
69621
69622#ifdef FREECIV_JSON_CONNECTION
69623 field_addr.name = "flags";
69624#endif /* FREECIV_JSON_CONNECTION */
69625
69626 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
69627 RECEIVE_PACKET_FIELD_ERROR(flags);
69628 }
69629
69630#ifdef FREECIV_JSON_CONNECTION
69631 field_addr.name = "hidden_by";
69632#endif /* FREECIV_JSON_CONNECTION */
69633
69634 if (!DIO_BV_GET(&din, &field_addr, real_packet->hidden_by)) {
69635 RECEIVE_PACKET_FIELD_ERROR(hidden_by);
69636 }
69637
69638#ifdef FREECIV_JSON_CONNECTION
69639 field_addr.name = "bridged_over";
69640#endif /* FREECIV_JSON_CONNECTION */
69641
69642 if (!DIO_BV_GET(&din, &field_addr, real_packet->bridged_over)) {
69643 RECEIVE_PACKET_FIELD_ERROR(bridged_over);
69644 }
69645
69646#ifdef FREECIV_JSON_CONNECTION
69647 field_addr.name = "conflicts";
69648#endif /* FREECIV_JSON_CONNECTION */
69649
69650 if (!DIO_BV_GET(&din, &field_addr, real_packet->conflicts)) {
69651 RECEIVE_PACKET_FIELD_ERROR(conflicts);
69652 }
69653
69654#ifdef FREECIV_JSON_CONNECTION
69655 field_addr.name = "no_aggr_near_city";
69656#endif /* FREECIV_JSON_CONNECTION */
69657
69658 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->no_aggr_near_city)) {
69659 RECEIVE_PACKET_FIELD_ERROR(no_aggr_near_city);
69660 }
69661
69662#ifdef FREECIV_JSON_CONNECTION
69663 field_addr.name = "helptext";
69664#endif /* FREECIV_JSON_CONNECTION */
69665
69666 {
69667 int i;
69668
69669 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
69670 RECEIVE_PACKET_FIELD_ERROR(helptext);
69671 }
69672 strvec_reserve(real_packet->helptext, i);
69673
69674#ifdef FREECIV_JSON_CONNECTION
69675 /* Enter array. */
69676 field_addr.sub_location = plocation_elem_new(0);
69677#endif /* FREECIV_JSON_CONNECTION */
69678
69679 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
69680#ifdef FREECIV_JSON_CONNECTION
69681 /* Next array element */
69682 field_addr.sub_location->number = i;
69683#endif /* FREECIV_JSON_CONNECTION */
69684
69685 {
69686 char readin[MAX_LEN_PACKET];
69687
69688 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
69689 || !strvec_set(real_packet->helptext, i, readin)) {
69690 RECEIVE_PACKET_FIELD_ERROR(helptext);
69691 }
69692 }
69693 }
69694
69695#ifdef FREECIV_JSON_CONNECTION
69696 /* Exit array. */
69697 FC_FREE(field_addr.sub_location);
69698#endif /* FREECIV_JSON_CONNECTION */
69699 }
69700#endif /* FREECIV_DELTA_PROTOCOL */
69701
69702 RECEIVE_PACKET_END(real_packet);
69703#undef FREE_PACKET_STRUCT
69704}
69705
69706 static int send_packet_ruleset_extra_100(struct connection *pc, const struct packet_ruleset_extra *packet)
69707{
69708 const struct packet_ruleset_extra *real_packet = packet;
69709 int e;
69710 SEND_PACKET_START(PACKET_RULESET_EXTRA);
69711
69712 log_packet_detailed("packet_ruleset_extra_100: sending info about ()");
69713
69714#ifdef FREECIV_DELTA_PROTOCOL
69715 packet_ruleset_extra_100_fields fields;
69716 struct packet_ruleset_extra *old;
69717 bool differ;
69718 struct genhash **hash = pc->phs.sent + PACKET_RULESET_EXTRA;
69719
69720 if (nullptr == *hash) {
69721 *hash = genhash_new_full(hash_packet_ruleset_extra_100, cmp_packet_ruleset_extra_100,
69722 nullptr, nullptr, nullptr, destroy_packet_ruleset_extra);
69723 }
69724 BV_CLR_ALL(fields);
69725
69726 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
69727 old = fc_malloc(sizeof(*old));
69728 /* temporary bitcopy just to insert correctly */
69729 *old = *real_packet;
69730 genhash_insert(*hash, old, old);
69731 init_packet_ruleset_extra(old);
69732 }
69733
69734 differ = (old->id != real_packet->id);
69735 if (differ) {
69736 BV_SET(fields, 0);
69737 }
69738
69739 differ = (strcmp(old->name, real_packet->name) != 0);
69740 if (differ) {
69741 BV_SET(fields, 1);
69742 }
69743
69744 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
69745 if (differ) {
69746 BV_SET(fields, 2);
69747 }
69748
69749 differ = (old->category != real_packet->category);
69750 if (differ) {
69751 BV_SET(fields, 3);
69752 }
69753
69754 differ = !BV_ARE_EQUAL(old->causes, real_packet->causes);
69755 if (differ) {
69756 BV_SET(fields, 4);
69757 }
69758
69759 differ = !BV_ARE_EQUAL(old->rmcauses, real_packet->rmcauses);
69760 if (differ) {
69761 BV_SET(fields, 5);
69762 }
69763
69764 differ = (strcmp(old->activity_gfx, real_packet->activity_gfx) != 0);
69765 if (differ) {
69766 BV_SET(fields, 6);
69767 }
69768
69769 differ = (strcmp(old->act_gfx_alt, real_packet->act_gfx_alt) != 0);
69770 if (differ) {
69771 BV_SET(fields, 7);
69772 }
69773
69774 differ = (strcmp(old->act_gfx_alt2, real_packet->act_gfx_alt2) != 0);
69775 if (differ) {
69776 BV_SET(fields, 8);
69777 }
69778
69779 differ = (strcmp(old->rmact_gfx, real_packet->rmact_gfx) != 0);
69780 if (differ) {
69781 BV_SET(fields, 9);
69782 }
69783
69784 differ = (strcmp(old->rmact_gfx_alt, real_packet->rmact_gfx_alt) != 0);
69785 if (differ) {
69786 BV_SET(fields, 10);
69787 }
69788
69789 differ = (strcmp(old->rmact_gfx_alt2, real_packet->rmact_gfx_alt2) != 0);
69790 if (differ) {
69791 BV_SET(fields, 11);
69792 }
69793
69794 differ = (strcmp(old->graphic_str, real_packet->graphic_str) != 0);
69795 if (differ) {
69796 BV_SET(fields, 12);
69797 }
69798
69799 differ = (strcmp(old->graphic_alt, real_packet->graphic_alt) != 0);
69800 if (differ) {
69801 BV_SET(fields, 13);
69802 }
69803
69804 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
69805 if (!differ) {
69806 int i;
69807
69808 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
69809 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
69810 if (differ) {
69811 break;
69812 }
69813 }
69814 }
69815 if (differ) {
69816 BV_SET(fields, 14);
69817 }
69818
69819 differ = (requirement_vector_size(&old->rmreqs) != requirement_vector_size(&real_packet->rmreqs));
69820 if (!differ) {
69821 int i;
69822
69823 for (i = 0; i < requirement_vector_size(&old->rmreqs); i++) {
69824 differ = !are_requirements_equal(&old->rmreqs.p[i], &real_packet->rmreqs.p[i]);
69825 if (differ) {
69826 break;
69827 }
69828 }
69829 }
69830 if (differ) {
69831 BV_SET(fields, 15);
69832 }
69833
69834 differ = (old->appearance_chance != real_packet->appearance_chance);
69835 if (differ) {
69836 BV_SET(fields, 16);
69837 }
69838
69839 differ = (requirement_vector_size(&old->appearance_reqs) != requirement_vector_size(&real_packet->appearance_reqs));
69840 if (!differ) {
69841 int i;
69842
69843 for (i = 0; i < requirement_vector_size(&old->appearance_reqs); i++) {
69844 differ = !are_requirements_equal(&old->appearance_reqs.p[i], &real_packet->appearance_reqs.p[i]);
69845 if (differ) {
69846 break;
69847 }
69848 }
69849 }
69850 if (differ) {
69851 BV_SET(fields, 17);
69852 }
69853
69854 differ = (old->disappearance_chance != real_packet->disappearance_chance);
69855 if (differ) {
69856 BV_SET(fields, 18);
69857 }
69858
69859 differ = (requirement_vector_size(&old->disappearance_reqs) != requirement_vector_size(&real_packet->disappearance_reqs));
69860 if (!differ) {
69861 int i;
69862
69863 for (i = 0; i < requirement_vector_size(&old->disappearance_reqs); i++) {
69864 differ = !are_requirements_equal(&old->disappearance_reqs.p[i], &real_packet->disappearance_reqs.p[i]);
69865 if (differ) {
69866 break;
69867 }
69868 }
69869 }
69870 if (differ) {
69871 BV_SET(fields, 19);
69872 }
69873
69874 differ = (old->visibility_req != real_packet->visibility_req);
69875 if (differ) {
69876 BV_SET(fields, 20);
69877 }
69878
69879 /* folded into head */
69880 if (real_packet->buildable) {
69881 BV_SET(fields, 21);
69882 }
69883
69884 /* folded into head */
69885 if (real_packet->generated) {
69886 BV_SET(fields, 22);
69887 }
69888
69889 differ = (old->build_time != real_packet->build_time);
69890 if (differ) {
69891 BV_SET(fields, 23);
69892 }
69893
69894 differ = (old->build_time_factor != real_packet->build_time_factor);
69895 if (differ) {
69896 BV_SET(fields, 24);
69897 }
69898
69899 differ = (old->removal_time != real_packet->removal_time);
69900 if (differ) {
69901 BV_SET(fields, 25);
69902 }
69903
69904 differ = (old->removal_time_factor != real_packet->removal_time_factor);
69905 if (differ) {
69906 BV_SET(fields, 26);
69907 }
69908
69909 differ = (old->infracost != real_packet->infracost);
69910 if (differ) {
69911 BV_SET(fields, 27);
69912 }
69913
69914 differ = (old->defense_bonus != real_packet->defense_bonus);
69915 if (differ) {
69916 BV_SET(fields, 28);
69917 }
69918
69919 differ = (old->eus != real_packet->eus);
69920 if (differ) {
69921 BV_SET(fields, 29);
69922 }
69923
69924 differ = !BV_ARE_EQUAL(old->native_to, real_packet->native_to);
69925 if (differ) {
69926 BV_SET(fields, 30);
69927 }
69928
69929 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
69930 if (differ) {
69931 BV_SET(fields, 31);
69932 }
69933
69934 differ = !BV_ARE_EQUAL(old->hidden_by, real_packet->hidden_by);
69935 if (differ) {
69936 BV_SET(fields, 32);
69937 }
69938
69939 differ = !BV_ARE_EQUAL(old->bridged_over, real_packet->bridged_over);
69940 if (differ) {
69941 BV_SET(fields, 33);
69942 }
69943
69944 differ = !BV_ARE_EQUAL(old->conflicts, real_packet->conflicts);
69945 if (differ) {
69946 BV_SET(fields, 34);
69947 }
69948
69949 differ = (old->no_aggr_near_city != real_packet->no_aggr_near_city);
69950 if (differ) {
69951 BV_SET(fields, 35);
69952 }
69953
69954 if (real_packet->helptext) {
69955 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
69956 } else {
69957 differ = (strvec_size(old->helptext) > 0);
69958 }
69959 if (differ) {
69960 BV_SET(fields, 36);
69961 }
69962#endif /* FREECIV_DELTA_PROTOCOL */
69963
69964#ifdef FREECIV_JSON_CONNECTION
69965 struct plocation field_addr;
69966 {
69967 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
69968 field_addr = *field_addr_tmp;
69969 FC_FREE(field_addr_tmp);
69970 }
69971#endif /* FREECIV_JSON_CONNECTION */
69972
69973#ifdef FREECIV_DELTA_PROTOCOL
69974#ifdef FREECIV_JSON_CONNECTION
69975 field_addr.name = "fields";
69976#endif /* FREECIV_JSON_CONNECTION */
69977 e = 0;
69978 e |= DIO_BV_PUT(&dout, &field_addr, fields);
69979 if (e) {
69980 log_packet_detailed("fields bitvector error detected");
69981 }
69982
69983 if (BV_ISSET(fields, 0)) {
69984 log_packet_detailed(" field 'id' has changed");
69985
69986#ifdef FREECIV_JSON_CONNECTION
69987 field_addr.name = "id";
69988#endif /* FREECIV_JSON_CONNECTION */
69989 e = 0;
69990
69991 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
69992
69993 if (e) {
69994 log_packet_detailed("'id' field error detected");
69995 }
69996 }
69997
69998 if (BV_ISSET(fields, 1)) {
69999 log_packet_detailed(" field 'name' has changed");
70000
70001#ifdef FREECIV_JSON_CONNECTION
70002 field_addr.name = "name";
70003#endif /* FREECIV_JSON_CONNECTION */
70004 e = 0;
70005
70006 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
70007
70008 if (e) {
70009 log_packet_detailed("'name' field error detected");
70010 }
70011 }
70012
70013 if (BV_ISSET(fields, 2)) {
70014 log_packet_detailed(" field 'rule_name' has changed");
70015
70016#ifdef FREECIV_JSON_CONNECTION
70017 field_addr.name = "rule_name";
70018#endif /* FREECIV_JSON_CONNECTION */
70019 e = 0;
70020
70021 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
70022
70023 if (e) {
70024 log_packet_detailed("'rule_name' field error detected");
70025 }
70026 }
70027
70028 if (BV_ISSET(fields, 3)) {
70029 log_packet_detailed(" field 'category' has changed");
70030
70031#ifdef FREECIV_JSON_CONNECTION
70032 field_addr.name = "category";
70033#endif /* FREECIV_JSON_CONNECTION */
70034 e = 0;
70035
70036 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->category);
70037
70038 if (e) {
70039 log_packet_detailed("'category' field error detected");
70040 }
70041 }
70042
70043 if (BV_ISSET(fields, 4)) {
70044 log_packet_detailed(" field 'causes' has changed");
70045
70046#ifdef FREECIV_JSON_CONNECTION
70047 field_addr.name = "causes";
70048#endif /* FREECIV_JSON_CONNECTION */
70049 e = 0;
70050
70051 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->causes);
70052
70053 if (e) {
70054 log_packet_detailed("'causes' field error detected");
70055 }
70056 }
70057
70058 if (BV_ISSET(fields, 5)) {
70059 log_packet_detailed(" field 'rmcauses' has changed");
70060
70061#ifdef FREECIV_JSON_CONNECTION
70062 field_addr.name = "rmcauses";
70063#endif /* FREECIV_JSON_CONNECTION */
70064 e = 0;
70065
70066 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->rmcauses);
70067
70068 if (e) {
70069 log_packet_detailed("'rmcauses' field error detected");
70070 }
70071 }
70072
70073 if (BV_ISSET(fields, 6)) {
70074 log_packet_detailed(" field 'activity_gfx' has changed");
70075
70076#ifdef FREECIV_JSON_CONNECTION
70077 field_addr.name = "activity_gfx";
70078#endif /* FREECIV_JSON_CONNECTION */
70079 e = 0;
70080
70081 e |= DIO_PUT(string, &dout, &field_addr, real_packet->activity_gfx);
70082
70083 if (e) {
70084 log_packet_detailed("'activity_gfx' field error detected");
70085 }
70086 }
70087
70088 if (BV_ISSET(fields, 7)) {
70089 log_packet_detailed(" field 'act_gfx_alt' has changed");
70090
70091#ifdef FREECIV_JSON_CONNECTION
70092 field_addr.name = "act_gfx_alt";
70093#endif /* FREECIV_JSON_CONNECTION */
70094 e = 0;
70095
70096 e |= DIO_PUT(string, &dout, &field_addr, real_packet->act_gfx_alt);
70097
70098 if (e) {
70099 log_packet_detailed("'act_gfx_alt' field error detected");
70100 }
70101 }
70102
70103 if (BV_ISSET(fields, 8)) {
70104 log_packet_detailed(" field 'act_gfx_alt2' has changed");
70105
70106#ifdef FREECIV_JSON_CONNECTION
70107 field_addr.name = "act_gfx_alt2";
70108#endif /* FREECIV_JSON_CONNECTION */
70109 e = 0;
70110
70111 e |= DIO_PUT(string, &dout, &field_addr, real_packet->act_gfx_alt2);
70112
70113 if (e) {
70114 log_packet_detailed("'act_gfx_alt2' field error detected");
70115 }
70116 }
70117
70118 if (BV_ISSET(fields, 9)) {
70119 log_packet_detailed(" field 'rmact_gfx' has changed");
70120
70121#ifdef FREECIV_JSON_CONNECTION
70122 field_addr.name = "rmact_gfx";
70123#endif /* FREECIV_JSON_CONNECTION */
70124 e = 0;
70125
70126 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rmact_gfx);
70127
70128 if (e) {
70129 log_packet_detailed("'rmact_gfx' field error detected");
70130 }
70131 }
70132
70133 if (BV_ISSET(fields, 10)) {
70134 log_packet_detailed(" field 'rmact_gfx_alt' has changed");
70135
70136#ifdef FREECIV_JSON_CONNECTION
70137 field_addr.name = "rmact_gfx_alt";
70138#endif /* FREECIV_JSON_CONNECTION */
70139 e = 0;
70140
70141 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rmact_gfx_alt);
70142
70143 if (e) {
70144 log_packet_detailed("'rmact_gfx_alt' field error detected");
70145 }
70146 }
70147
70148 if (BV_ISSET(fields, 11)) {
70149 log_packet_detailed(" field 'rmact_gfx_alt2' has changed");
70150
70151#ifdef FREECIV_JSON_CONNECTION
70152 field_addr.name = "rmact_gfx_alt2";
70153#endif /* FREECIV_JSON_CONNECTION */
70154 e = 0;
70155
70156 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rmact_gfx_alt2);
70157
70158 if (e) {
70159 log_packet_detailed("'rmact_gfx_alt2' field error detected");
70160 }
70161 }
70162
70163 if (BV_ISSET(fields, 12)) {
70164 log_packet_detailed(" field 'graphic_str' has changed");
70165
70166#ifdef FREECIV_JSON_CONNECTION
70167 field_addr.name = "graphic_str";
70168#endif /* FREECIV_JSON_CONNECTION */
70169 e = 0;
70170
70171 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
70172
70173 if (e) {
70174 log_packet_detailed("'graphic_str' field error detected");
70175 }
70176 }
70177
70178 if (BV_ISSET(fields, 13)) {
70179 log_packet_detailed(" field 'graphic_alt' has changed");
70180
70181#ifdef FREECIV_JSON_CONNECTION
70182 field_addr.name = "graphic_alt";
70183#endif /* FREECIV_JSON_CONNECTION */
70184 e = 0;
70185
70186 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
70187
70188 if (e) {
70189 log_packet_detailed("'graphic_alt' field error detected");
70190 }
70191 }
70192
70193 if (BV_ISSET(fields, 14)) {
70194 log_packet_detailed(" field 'reqs' has changed");
70195
70196#ifdef FREECIV_JSON_CONNECTION
70197 field_addr.name = "reqs";
70198#endif /* FREECIV_JSON_CONNECTION */
70199 e = 0;
70200
70201 {
70202 int i;
70203
70204 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
70205 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
70206
70207#ifdef FREECIV_JSON_CONNECTION
70208 /* Enter array. */
70209 field_addr.sub_location = plocation_elem_new(0);
70210#endif /* FREECIV_JSON_CONNECTION */
70211
70212 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
70213#ifdef FREECIV_JSON_CONNECTION
70214 /* Next array element. */
70215 field_addr.sub_location->number = i;
70216#endif /* FREECIV_JSON_CONNECTION */
70217
70218 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
70219 }
70220
70221#ifdef FREECIV_JSON_CONNECTION
70222 /* Exit array. */
70223 FC_FREE(field_addr.sub_location);
70224#endif /* FREECIV_JSON_CONNECTION */
70225 }
70226
70227 if (e) {
70228 log_packet_detailed("'reqs' field error detected");
70229 }
70230 }
70231
70232 if (BV_ISSET(fields, 15)) {
70233 log_packet_detailed(" field 'rmreqs' has changed");
70234
70235#ifdef FREECIV_JSON_CONNECTION
70236 field_addr.name = "rmreqs";
70237#endif /* FREECIV_JSON_CONNECTION */
70238 e = 0;
70239
70240 {
70241 int i;
70242
70243 fc_assert(requirement_vector_size(&real_packet->rmreqs) < MAX_UINT16);
70244 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->rmreqs));
70245
70246#ifdef FREECIV_JSON_CONNECTION
70247 /* Enter array. */
70248 field_addr.sub_location = plocation_elem_new(0);
70249#endif /* FREECIV_JSON_CONNECTION */
70250
70251 for (i = 0; i < requirement_vector_size(&real_packet->rmreqs); i++) {
70252#ifdef FREECIV_JSON_CONNECTION
70253 /* Next array element. */
70254 field_addr.sub_location->number = i;
70255#endif /* FREECIV_JSON_CONNECTION */
70256
70257 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->rmreqs.p[i]);
70258 }
70259
70260#ifdef FREECIV_JSON_CONNECTION
70261 /* Exit array. */
70262 FC_FREE(field_addr.sub_location);
70263#endif /* FREECIV_JSON_CONNECTION */
70264 }
70265
70266 if (e) {
70267 log_packet_detailed("'rmreqs' field error detected");
70268 }
70269 }
70270
70271 if (BV_ISSET(fields, 16)) {
70272 log_packet_detailed(" field 'appearance_chance' has changed");
70273
70274#ifdef FREECIV_JSON_CONNECTION
70275 field_addr.name = "appearance_chance";
70276#endif /* FREECIV_JSON_CONNECTION */
70277 e = 0;
70278
70279 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->appearance_chance);
70280
70281 if (e) {
70282 log_packet_detailed("'appearance_chance' field error detected");
70283 }
70284 }
70285
70286 if (BV_ISSET(fields, 17)) {
70287 log_packet_detailed(" field 'appearance_reqs' has changed");
70288
70289#ifdef FREECIV_JSON_CONNECTION
70290 field_addr.name = "appearance_reqs";
70291#endif /* FREECIV_JSON_CONNECTION */
70292 e = 0;
70293
70294 {
70295 int i;
70296
70297 fc_assert(requirement_vector_size(&real_packet->appearance_reqs) < MAX_UINT16);
70298 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->appearance_reqs));
70299
70300#ifdef FREECIV_JSON_CONNECTION
70301 /* Enter array. */
70302 field_addr.sub_location = plocation_elem_new(0);
70303#endif /* FREECIV_JSON_CONNECTION */
70304
70305 for (i = 0; i < requirement_vector_size(&real_packet->appearance_reqs); i++) {
70306#ifdef FREECIV_JSON_CONNECTION
70307 /* Next array element. */
70308 field_addr.sub_location->number = i;
70309#endif /* FREECIV_JSON_CONNECTION */
70310
70311 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->appearance_reqs.p[i]);
70312 }
70313
70314#ifdef FREECIV_JSON_CONNECTION
70315 /* Exit array. */
70316 FC_FREE(field_addr.sub_location);
70317#endif /* FREECIV_JSON_CONNECTION */
70318 }
70319
70320 if (e) {
70321 log_packet_detailed("'appearance_reqs' field error detected");
70322 }
70323 }
70324
70325 if (BV_ISSET(fields, 18)) {
70326 log_packet_detailed(" field 'disappearance_chance' has changed");
70327
70328#ifdef FREECIV_JSON_CONNECTION
70329 field_addr.name = "disappearance_chance";
70330#endif /* FREECIV_JSON_CONNECTION */
70331 e = 0;
70332
70333 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->disappearance_chance);
70334
70335 if (e) {
70336 log_packet_detailed("'disappearance_chance' field error detected");
70337 }
70338 }
70339
70340 if (BV_ISSET(fields, 19)) {
70341 log_packet_detailed(" field 'disappearance_reqs' has changed");
70342
70343#ifdef FREECIV_JSON_CONNECTION
70344 field_addr.name = "disappearance_reqs";
70345#endif /* FREECIV_JSON_CONNECTION */
70346 e = 0;
70347
70348 {
70349 int i;
70350
70351 fc_assert(requirement_vector_size(&real_packet->disappearance_reqs) < MAX_UINT16);
70352 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->disappearance_reqs));
70353
70354#ifdef FREECIV_JSON_CONNECTION
70355 /* Enter array. */
70356 field_addr.sub_location = plocation_elem_new(0);
70357#endif /* FREECIV_JSON_CONNECTION */
70358
70359 for (i = 0; i < requirement_vector_size(&real_packet->disappearance_reqs); i++) {
70360#ifdef FREECIV_JSON_CONNECTION
70361 /* Next array element. */
70362 field_addr.sub_location->number = i;
70363#endif /* FREECIV_JSON_CONNECTION */
70364
70365 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->disappearance_reqs.p[i]);
70366 }
70367
70368#ifdef FREECIV_JSON_CONNECTION
70369 /* Exit array. */
70370 FC_FREE(field_addr.sub_location);
70371#endif /* FREECIV_JSON_CONNECTION */
70372 }
70373
70374 if (e) {
70375 log_packet_detailed("'disappearance_reqs' field error detected");
70376 }
70377 }
70378
70379 if (BV_ISSET(fields, 20)) {
70380 log_packet_detailed(" field 'visibility_req' has changed");
70381
70382#ifdef FREECIV_JSON_CONNECTION
70383 field_addr.name = "visibility_req";
70384#endif /* FREECIV_JSON_CONNECTION */
70385 e = 0;
70386
70387 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->visibility_req);
70388
70389 if (e) {
70390 log_packet_detailed("'visibility_req' field error detected");
70391 }
70392 }
70393
70394 /* field 21 is folded into the header */
70395
70396 /* field 22 is folded into the header */
70397
70398 if (BV_ISSET(fields, 23)) {
70399 log_packet_detailed(" field 'build_time' has changed");
70400
70401#ifdef FREECIV_JSON_CONNECTION
70402 field_addr.name = "build_time";
70403#endif /* FREECIV_JSON_CONNECTION */
70404 e = 0;
70405
70406 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->build_time);
70407
70408 if (e) {
70409 log_packet_detailed("'build_time' field error detected");
70410 }
70411 }
70412
70413 if (BV_ISSET(fields, 24)) {
70414 log_packet_detailed(" field 'build_time_factor' has changed");
70415
70416#ifdef FREECIV_JSON_CONNECTION
70417 field_addr.name = "build_time_factor";
70418#endif /* FREECIV_JSON_CONNECTION */
70419 e = 0;
70420
70421 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->build_time_factor);
70422
70423 if (e) {
70424 log_packet_detailed("'build_time_factor' field error detected");
70425 }
70426 }
70427
70428 if (BV_ISSET(fields, 25)) {
70429 log_packet_detailed(" field 'removal_time' has changed");
70430
70431#ifdef FREECIV_JSON_CONNECTION
70432 field_addr.name = "removal_time";
70433#endif /* FREECIV_JSON_CONNECTION */
70434 e = 0;
70435
70436 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->removal_time);
70437
70438 if (e) {
70439 log_packet_detailed("'removal_time' field error detected");
70440 }
70441 }
70442
70443 if (BV_ISSET(fields, 26)) {
70444 log_packet_detailed(" field 'removal_time_factor' has changed");
70445
70446#ifdef FREECIV_JSON_CONNECTION
70447 field_addr.name = "removal_time_factor";
70448#endif /* FREECIV_JSON_CONNECTION */
70449 e = 0;
70450
70451 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->removal_time_factor);
70452
70453 if (e) {
70454 log_packet_detailed("'removal_time_factor' field error detected");
70455 }
70456 }
70457
70458 if (BV_ISSET(fields, 27)) {
70459 log_packet_detailed(" field 'infracost' has changed");
70460
70461#ifdef FREECIV_JSON_CONNECTION
70462 field_addr.name = "infracost";
70463#endif /* FREECIV_JSON_CONNECTION */
70464 e = 0;
70465
70466 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->infracost);
70467
70468 if (e) {
70469 log_packet_detailed("'infracost' field error detected");
70470 }
70471 }
70472
70473 if (BV_ISSET(fields, 28)) {
70474 log_packet_detailed(" field 'defense_bonus' has changed");
70475
70476#ifdef FREECIV_JSON_CONNECTION
70477 field_addr.name = "defense_bonus";
70478#endif /* FREECIV_JSON_CONNECTION */
70479 e = 0;
70480
70481 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->defense_bonus);
70482
70483 if (e) {
70484 log_packet_detailed("'defense_bonus' field error detected");
70485 }
70486 }
70487
70488 if (BV_ISSET(fields, 29)) {
70489 log_packet_detailed(" field 'eus' has changed");
70490
70491#ifdef FREECIV_JSON_CONNECTION
70492 field_addr.name = "eus";
70493#endif /* FREECIV_JSON_CONNECTION */
70494 e = 0;
70495
70496 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->eus);
70497
70498 if (e) {
70499 log_packet_detailed("'eus' field error detected");
70500 }
70501 }
70502
70503 if (BV_ISSET(fields, 30)) {
70504 log_packet_detailed(" field 'native_to' has changed");
70505
70506#ifdef FREECIV_JSON_CONNECTION
70507 field_addr.name = "native_to";
70508#endif /* FREECIV_JSON_CONNECTION */
70509 e = 0;
70510
70511 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->native_to);
70512
70513 if (e) {
70514 log_packet_detailed("'native_to' field error detected");
70515 }
70516 }
70517
70518 if (BV_ISSET(fields, 31)) {
70519 log_packet_detailed(" field 'flags' has changed");
70520
70521#ifdef FREECIV_JSON_CONNECTION
70522 field_addr.name = "flags";
70523#endif /* FREECIV_JSON_CONNECTION */
70524 e = 0;
70525
70526 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
70527
70528 if (e) {
70529 log_packet_detailed("'flags' field error detected");
70530 }
70531 }
70532
70533 if (BV_ISSET(fields, 32)) {
70534 log_packet_detailed(" field 'hidden_by' has changed");
70535
70536#ifdef FREECIV_JSON_CONNECTION
70537 field_addr.name = "hidden_by";
70538#endif /* FREECIV_JSON_CONNECTION */
70539 e = 0;
70540
70541 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->hidden_by);
70542
70543 if (e) {
70544 log_packet_detailed("'hidden_by' field error detected");
70545 }
70546 }
70547
70548 if (BV_ISSET(fields, 33)) {
70549 log_packet_detailed(" field 'bridged_over' has changed");
70550
70551#ifdef FREECIV_JSON_CONNECTION
70552 field_addr.name = "bridged_over";
70553#endif /* FREECIV_JSON_CONNECTION */
70554 e = 0;
70555
70556 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->bridged_over);
70557
70558 if (e) {
70559 log_packet_detailed("'bridged_over' field error detected");
70560 }
70561 }
70562
70563 if (BV_ISSET(fields, 34)) {
70564 log_packet_detailed(" field 'conflicts' has changed");
70565
70566#ifdef FREECIV_JSON_CONNECTION
70567 field_addr.name = "conflicts";
70568#endif /* FREECIV_JSON_CONNECTION */
70569 e = 0;
70570
70571 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->conflicts);
70572
70573 if (e) {
70574 log_packet_detailed("'conflicts' field error detected");
70575 }
70576 }
70577
70578 if (BV_ISSET(fields, 35)) {
70579 log_packet_detailed(" field 'no_aggr_near_city' has changed");
70580
70581#ifdef FREECIV_JSON_CONNECTION
70582 field_addr.name = "no_aggr_near_city";
70583#endif /* FREECIV_JSON_CONNECTION */
70584 e = 0;
70585
70586 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->no_aggr_near_city);
70587
70588 if (e) {
70589 log_packet_detailed("'no_aggr_near_city' field error detected");
70590 }
70591 }
70592
70593 if (BV_ISSET(fields, 36)) {
70594 log_packet_detailed(" field 'helptext' has changed");
70595
70596#ifdef FREECIV_JSON_CONNECTION
70597 field_addr.name = "helptext";
70598#endif /* FREECIV_JSON_CONNECTION */
70599 e = 0;
70600
70601 if (!real_packet->helptext) {
70602 /* Transmit null as empty */
70603 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
70604 } else {
70605 int i;
70606
70607 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
70608 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
70609
70610#ifdef FREECIV_JSON_CONNECTION
70611 /* Enter array. */
70612 field_addr.sub_location = plocation_elem_new(0);
70613#endif /* FREECIV_JSON_CONNECTION */
70614
70615 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
70616#ifdef FREECIV_JSON_CONNECTION
70617 /* Next array element. */
70618 field_addr.sub_location->number = i;
70619#endif /* FREECIV_JSON_CONNECTION */
70620
70621 {
70622 const char *pstr = strvec_get(real_packet->helptext, i);
70623
70624 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
70625 }
70626 }
70627
70628#ifdef FREECIV_JSON_CONNECTION
70629 /* Exit array. */
70630 FC_FREE(field_addr.sub_location);
70631#endif /* FREECIV_JSON_CONNECTION */
70632 }
70633
70634 if (e) {
70635 log_packet_detailed("'helptext' field error detected");
70636 }
70637 }
70638
70639 old->id = real_packet->id;
70640 sz_strlcpy(old->name, real_packet->name);
70641 sz_strlcpy(old->rule_name, real_packet->rule_name);
70642 old->category = real_packet->category;
70643 old->causes = real_packet->causes;
70644 old->rmcauses = real_packet->rmcauses;
70645 sz_strlcpy(old->activity_gfx, real_packet->activity_gfx);
70646 sz_strlcpy(old->act_gfx_alt, real_packet->act_gfx_alt);
70647 sz_strlcpy(old->act_gfx_alt2, real_packet->act_gfx_alt2);
70648 sz_strlcpy(old->rmact_gfx, real_packet->rmact_gfx);
70649 sz_strlcpy(old->rmact_gfx_alt, real_packet->rmact_gfx_alt);
70650 sz_strlcpy(old->rmact_gfx_alt2, real_packet->rmact_gfx_alt2);
70651 sz_strlcpy(old->graphic_str, real_packet->graphic_str);
70652 sz_strlcpy(old->graphic_alt, real_packet->graphic_alt);
70653 requirement_vector_copy(&old->reqs, &real_packet->reqs);
70654 requirement_vector_copy(&old->rmreqs, &real_packet->rmreqs);
70655 old->appearance_chance = real_packet->appearance_chance;
70656 requirement_vector_copy(&old->appearance_reqs, &real_packet->appearance_reqs);
70657 old->disappearance_chance = real_packet->disappearance_chance;
70658 requirement_vector_copy(&old->disappearance_reqs, &real_packet->disappearance_reqs);
70659 old->visibility_req = real_packet->visibility_req;
70660 old->buildable = real_packet->buildable;
70661 old->generated = real_packet->generated;
70662 old->build_time = real_packet->build_time;
70663 old->build_time_factor = real_packet->build_time_factor;
70664 old->removal_time = real_packet->removal_time;
70665 old->removal_time_factor = real_packet->removal_time_factor;
70666 old->infracost = real_packet->infracost;
70667 old->defense_bonus = real_packet->defense_bonus;
70668 old->eus = real_packet->eus;
70669 old->native_to = real_packet->native_to;
70670 old->flags = real_packet->flags;
70671 old->hidden_by = real_packet->hidden_by;
70672 old->bridged_over = real_packet->bridged_over;
70673 old->conflicts = real_packet->conflicts;
70674 old->no_aggr_near_city = real_packet->no_aggr_near_city;
70675 if (real_packet->helptext) {
70676 strvec_copy(old->helptext, real_packet->helptext);
70677 } else {
70678 strvec_clear(old->helptext);
70679 }
70680
70681#else /* FREECIV_DELTA_PROTOCOL */
70682#ifdef FREECIV_JSON_CONNECTION
70683 field_addr.name = "id";
70684#endif /* FREECIV_JSON_CONNECTION */
70685 e = 0;
70686
70687 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
70688
70689 if (e) {
70690 log_packet_detailed("'id' field error detected");
70691 }
70692
70693#ifdef FREECIV_JSON_CONNECTION
70694 field_addr.name = "name";
70695#endif /* FREECIV_JSON_CONNECTION */
70696 e = 0;
70697
70698 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
70699
70700 if (e) {
70701 log_packet_detailed("'name' field error detected");
70702 }
70703
70704#ifdef FREECIV_JSON_CONNECTION
70705 field_addr.name = "rule_name";
70706#endif /* FREECIV_JSON_CONNECTION */
70707 e = 0;
70708
70709 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
70710
70711 if (e) {
70712 log_packet_detailed("'rule_name' field error detected");
70713 }
70714
70715#ifdef FREECIV_JSON_CONNECTION
70716 field_addr.name = "category";
70717#endif /* FREECIV_JSON_CONNECTION */
70718 e = 0;
70719
70720 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->category);
70721
70722 if (e) {
70723 log_packet_detailed("'category' field error detected");
70724 }
70725
70726#ifdef FREECIV_JSON_CONNECTION
70727 field_addr.name = "causes";
70728#endif /* FREECIV_JSON_CONNECTION */
70729 e = 0;
70730
70731 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->causes);
70732
70733 if (e) {
70734 log_packet_detailed("'causes' field error detected");
70735 }
70736
70737#ifdef FREECIV_JSON_CONNECTION
70738 field_addr.name = "rmcauses";
70739#endif /* FREECIV_JSON_CONNECTION */
70740 e = 0;
70741
70742 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->rmcauses);
70743
70744 if (e) {
70745 log_packet_detailed("'rmcauses' field error detected");
70746 }
70747
70748#ifdef FREECIV_JSON_CONNECTION
70749 field_addr.name = "activity_gfx";
70750#endif /* FREECIV_JSON_CONNECTION */
70751 e = 0;
70752
70753 e |= DIO_PUT(string, &dout, &field_addr, real_packet->activity_gfx);
70754
70755 if (e) {
70756 log_packet_detailed("'activity_gfx' field error detected");
70757 }
70758
70759#ifdef FREECIV_JSON_CONNECTION
70760 field_addr.name = "act_gfx_alt";
70761#endif /* FREECIV_JSON_CONNECTION */
70762 e = 0;
70763
70764 e |= DIO_PUT(string, &dout, &field_addr, real_packet->act_gfx_alt);
70765
70766 if (e) {
70767 log_packet_detailed("'act_gfx_alt' field error detected");
70768 }
70769
70770#ifdef FREECIV_JSON_CONNECTION
70771 field_addr.name = "act_gfx_alt2";
70772#endif /* FREECIV_JSON_CONNECTION */
70773 e = 0;
70774
70775 e |= DIO_PUT(string, &dout, &field_addr, real_packet->act_gfx_alt2);
70776
70777 if (e) {
70778 log_packet_detailed("'act_gfx_alt2' field error detected");
70779 }
70780
70781#ifdef FREECIV_JSON_CONNECTION
70782 field_addr.name = "rmact_gfx";
70783#endif /* FREECIV_JSON_CONNECTION */
70784 e = 0;
70785
70786 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rmact_gfx);
70787
70788 if (e) {
70789 log_packet_detailed("'rmact_gfx' field error detected");
70790 }
70791
70792#ifdef FREECIV_JSON_CONNECTION
70793 field_addr.name = "rmact_gfx_alt";
70794#endif /* FREECIV_JSON_CONNECTION */
70795 e = 0;
70796
70797 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rmact_gfx_alt);
70798
70799 if (e) {
70800 log_packet_detailed("'rmact_gfx_alt' field error detected");
70801 }
70802
70803#ifdef FREECIV_JSON_CONNECTION
70804 field_addr.name = "rmact_gfx_alt2";
70805#endif /* FREECIV_JSON_CONNECTION */
70806 e = 0;
70807
70808 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rmact_gfx_alt2);
70809
70810 if (e) {
70811 log_packet_detailed("'rmact_gfx_alt2' field error detected");
70812 }
70813
70814#ifdef FREECIV_JSON_CONNECTION
70815 field_addr.name = "graphic_str";
70816#endif /* FREECIV_JSON_CONNECTION */
70817 e = 0;
70818
70819 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_str);
70820
70821 if (e) {
70822 log_packet_detailed("'graphic_str' field error detected");
70823 }
70824
70825#ifdef FREECIV_JSON_CONNECTION
70826 field_addr.name = "graphic_alt";
70827#endif /* FREECIV_JSON_CONNECTION */
70828 e = 0;
70829
70830 e |= DIO_PUT(string, &dout, &field_addr, real_packet->graphic_alt);
70831
70832 if (e) {
70833 log_packet_detailed("'graphic_alt' field error detected");
70834 }
70835
70836#ifdef FREECIV_JSON_CONNECTION
70837 field_addr.name = "reqs";
70838#endif /* FREECIV_JSON_CONNECTION */
70839 e = 0;
70840
70841 {
70842 int i;
70843
70844 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
70845 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
70846
70847#ifdef FREECIV_JSON_CONNECTION
70848 /* Enter array. */
70849 field_addr.sub_location = plocation_elem_new(0);
70850#endif /* FREECIV_JSON_CONNECTION */
70851
70852 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
70853#ifdef FREECIV_JSON_CONNECTION
70854 /* Next array element. */
70855 field_addr.sub_location->number = i;
70856#endif /* FREECIV_JSON_CONNECTION */
70857
70858 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
70859 }
70860
70861#ifdef FREECIV_JSON_CONNECTION
70862 /* Exit array. */
70863 FC_FREE(field_addr.sub_location);
70864#endif /* FREECIV_JSON_CONNECTION */
70865 }
70866
70867 if (e) {
70868 log_packet_detailed("'reqs' field error detected");
70869 }
70870
70871#ifdef FREECIV_JSON_CONNECTION
70872 field_addr.name = "rmreqs";
70873#endif /* FREECIV_JSON_CONNECTION */
70874 e = 0;
70875
70876 {
70877 int i;
70878
70879 fc_assert(requirement_vector_size(&real_packet->rmreqs) < MAX_UINT16);
70880 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->rmreqs));
70881
70882#ifdef FREECIV_JSON_CONNECTION
70883 /* Enter array. */
70884 field_addr.sub_location = plocation_elem_new(0);
70885#endif /* FREECIV_JSON_CONNECTION */
70886
70887 for (i = 0; i < requirement_vector_size(&real_packet->rmreqs); i++) {
70888#ifdef FREECIV_JSON_CONNECTION
70889 /* Next array element. */
70890 field_addr.sub_location->number = i;
70891#endif /* FREECIV_JSON_CONNECTION */
70892
70893 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->rmreqs.p[i]);
70894 }
70895
70896#ifdef FREECIV_JSON_CONNECTION
70897 /* Exit array. */
70898 FC_FREE(field_addr.sub_location);
70899#endif /* FREECIV_JSON_CONNECTION */
70900 }
70901
70902 if (e) {
70903 log_packet_detailed("'rmreqs' field error detected");
70904 }
70905
70906#ifdef FREECIV_JSON_CONNECTION
70907 field_addr.name = "appearance_chance";
70908#endif /* FREECIV_JSON_CONNECTION */
70909 e = 0;
70910
70911 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->appearance_chance);
70912
70913 if (e) {
70914 log_packet_detailed("'appearance_chance' field error detected");
70915 }
70916
70917#ifdef FREECIV_JSON_CONNECTION
70918 field_addr.name = "appearance_reqs";
70919#endif /* FREECIV_JSON_CONNECTION */
70920 e = 0;
70921
70922 {
70923 int i;
70924
70925 fc_assert(requirement_vector_size(&real_packet->appearance_reqs) < MAX_UINT16);
70926 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->appearance_reqs));
70927
70928#ifdef FREECIV_JSON_CONNECTION
70929 /* Enter array. */
70930 field_addr.sub_location = plocation_elem_new(0);
70931#endif /* FREECIV_JSON_CONNECTION */
70932
70933 for (i = 0; i < requirement_vector_size(&real_packet->appearance_reqs); i++) {
70934#ifdef FREECIV_JSON_CONNECTION
70935 /* Next array element. */
70936 field_addr.sub_location->number = i;
70937#endif /* FREECIV_JSON_CONNECTION */
70938
70939 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->appearance_reqs.p[i]);
70940 }
70941
70942#ifdef FREECIV_JSON_CONNECTION
70943 /* Exit array. */
70944 FC_FREE(field_addr.sub_location);
70945#endif /* FREECIV_JSON_CONNECTION */
70946 }
70947
70948 if (e) {
70949 log_packet_detailed("'appearance_reqs' field error detected");
70950 }
70951
70952#ifdef FREECIV_JSON_CONNECTION
70953 field_addr.name = "disappearance_chance";
70954#endif /* FREECIV_JSON_CONNECTION */
70955 e = 0;
70956
70957 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->disappearance_chance);
70958
70959 if (e) {
70960 log_packet_detailed("'disappearance_chance' field error detected");
70961 }
70962
70963#ifdef FREECIV_JSON_CONNECTION
70964 field_addr.name = "disappearance_reqs";
70965#endif /* FREECIV_JSON_CONNECTION */
70966 e = 0;
70967
70968 {
70969 int i;
70970
70971 fc_assert(requirement_vector_size(&real_packet->disappearance_reqs) < MAX_UINT16);
70972 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->disappearance_reqs));
70973
70974#ifdef FREECIV_JSON_CONNECTION
70975 /* Enter array. */
70976 field_addr.sub_location = plocation_elem_new(0);
70977#endif /* FREECIV_JSON_CONNECTION */
70978
70979 for (i = 0; i < requirement_vector_size(&real_packet->disappearance_reqs); i++) {
70980#ifdef FREECIV_JSON_CONNECTION
70981 /* Next array element. */
70982 field_addr.sub_location->number = i;
70983#endif /* FREECIV_JSON_CONNECTION */
70984
70985 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->disappearance_reqs.p[i]);
70986 }
70987
70988#ifdef FREECIV_JSON_CONNECTION
70989 /* Exit array. */
70990 FC_FREE(field_addr.sub_location);
70991#endif /* FREECIV_JSON_CONNECTION */
70992 }
70993
70994 if (e) {
70995 log_packet_detailed("'disappearance_reqs' field error detected");
70996 }
70997
70998#ifdef FREECIV_JSON_CONNECTION
70999 field_addr.name = "visibility_req";
71000#endif /* FREECIV_JSON_CONNECTION */
71001 e = 0;
71002
71003 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->visibility_req);
71004
71005 if (e) {
71006 log_packet_detailed("'visibility_req' field error detected");
71007 }
71008
71009#ifdef FREECIV_JSON_CONNECTION
71010 field_addr.name = "buildable";
71011#endif /* FREECIV_JSON_CONNECTION */
71012 e = 0;
71013
71014 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->buildable);
71015
71016 if (e) {
71017 log_packet_detailed("'buildable' field error detected");
71018 }
71019
71020#ifdef FREECIV_JSON_CONNECTION
71021 field_addr.name = "generated";
71022#endif /* FREECIV_JSON_CONNECTION */
71023 e = 0;
71024
71025 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->generated);
71026
71027 if (e) {
71028 log_packet_detailed("'generated' field error detected");
71029 }
71030
71031#ifdef FREECIV_JSON_CONNECTION
71032 field_addr.name = "build_time";
71033#endif /* FREECIV_JSON_CONNECTION */
71034 e = 0;
71035
71036 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->build_time);
71037
71038 if (e) {
71039 log_packet_detailed("'build_time' field error detected");
71040 }
71041
71042#ifdef FREECIV_JSON_CONNECTION
71043 field_addr.name = "build_time_factor";
71044#endif /* FREECIV_JSON_CONNECTION */
71045 e = 0;
71046
71047 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->build_time_factor);
71048
71049 if (e) {
71050 log_packet_detailed("'build_time_factor' field error detected");
71051 }
71052
71053#ifdef FREECIV_JSON_CONNECTION
71054 field_addr.name = "removal_time";
71055#endif /* FREECIV_JSON_CONNECTION */
71056 e = 0;
71057
71058 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->removal_time);
71059
71060 if (e) {
71061 log_packet_detailed("'removal_time' field error detected");
71062 }
71063
71064#ifdef FREECIV_JSON_CONNECTION
71065 field_addr.name = "removal_time_factor";
71066#endif /* FREECIV_JSON_CONNECTION */
71067 e = 0;
71068
71069 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->removal_time_factor);
71070
71071 if (e) {
71072 log_packet_detailed("'removal_time_factor' field error detected");
71073 }
71074
71075#ifdef FREECIV_JSON_CONNECTION
71076 field_addr.name = "infracost";
71077#endif /* FREECIV_JSON_CONNECTION */
71078 e = 0;
71079
71080 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->infracost);
71081
71082 if (e) {
71083 log_packet_detailed("'infracost' field error detected");
71084 }
71085
71086#ifdef FREECIV_JSON_CONNECTION
71087 field_addr.name = "defense_bonus";
71088#endif /* FREECIV_JSON_CONNECTION */
71089 e = 0;
71090
71091 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->defense_bonus);
71092
71093 if (e) {
71094 log_packet_detailed("'defense_bonus' field error detected");
71095 }
71096
71097#ifdef FREECIV_JSON_CONNECTION
71098 field_addr.name = "eus";
71099#endif /* FREECIV_JSON_CONNECTION */
71100 e = 0;
71101
71102 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->eus);
71103
71104 if (e) {
71105 log_packet_detailed("'eus' field error detected");
71106 }
71107
71108#ifdef FREECIV_JSON_CONNECTION
71109 field_addr.name = "native_to";
71110#endif /* FREECIV_JSON_CONNECTION */
71111 e = 0;
71112
71113 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->native_to);
71114
71115 if (e) {
71116 log_packet_detailed("'native_to' field error detected");
71117 }
71118
71119#ifdef FREECIV_JSON_CONNECTION
71120 field_addr.name = "flags";
71121#endif /* FREECIV_JSON_CONNECTION */
71122 e = 0;
71123
71124 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
71125
71126 if (e) {
71127 log_packet_detailed("'flags' field error detected");
71128 }
71129
71130#ifdef FREECIV_JSON_CONNECTION
71131 field_addr.name = "hidden_by";
71132#endif /* FREECIV_JSON_CONNECTION */
71133 e = 0;
71134
71135 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->hidden_by);
71136
71137 if (e) {
71138 log_packet_detailed("'hidden_by' field error detected");
71139 }
71140
71141#ifdef FREECIV_JSON_CONNECTION
71142 field_addr.name = "bridged_over";
71143#endif /* FREECIV_JSON_CONNECTION */
71144 e = 0;
71145
71146 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->bridged_over);
71147
71148 if (e) {
71149 log_packet_detailed("'bridged_over' field error detected");
71150 }
71151
71152#ifdef FREECIV_JSON_CONNECTION
71153 field_addr.name = "conflicts";
71154#endif /* FREECIV_JSON_CONNECTION */
71155 e = 0;
71156
71157 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->conflicts);
71158
71159 if (e) {
71160 log_packet_detailed("'conflicts' field error detected");
71161 }
71162
71163#ifdef FREECIV_JSON_CONNECTION
71164 field_addr.name = "no_aggr_near_city";
71165#endif /* FREECIV_JSON_CONNECTION */
71166 e = 0;
71167
71168 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->no_aggr_near_city);
71169
71170 if (e) {
71171 log_packet_detailed("'no_aggr_near_city' field error detected");
71172 }
71173
71174#ifdef FREECIV_JSON_CONNECTION
71175 field_addr.name = "helptext";
71176#endif /* FREECIV_JSON_CONNECTION */
71177 e = 0;
71178
71179 if (!real_packet->helptext) {
71180 /* Transmit null as empty */
71181 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
71182 } else {
71183 int i;
71184
71185 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
71186 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
71187
71188#ifdef FREECIV_JSON_CONNECTION
71189 /* Enter array. */
71190 field_addr.sub_location = plocation_elem_new(0);
71191#endif /* FREECIV_JSON_CONNECTION */
71192
71193 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
71194#ifdef FREECIV_JSON_CONNECTION
71195 /* Next array element. */
71196 field_addr.sub_location->number = i;
71197#endif /* FREECIV_JSON_CONNECTION */
71198
71199 {
71200 const char *pstr = strvec_get(real_packet->helptext, i);
71201
71202 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
71203 }
71204 }
71205
71206#ifdef FREECIV_JSON_CONNECTION
71207 /* Exit array. */
71208 FC_FREE(field_addr.sub_location);
71209#endif /* FREECIV_JSON_CONNECTION */
71210 }
71211
71212 if (e) {
71213 log_packet_detailed("'helptext' field error detected");
71214 }
71215#endif /* FREECIV_DELTA_PROTOCOL */
71216
71217 SEND_PACKET_END(PACKET_RULESET_EXTRA);
71218}
71219
71220 int send_packet_ruleset_extra(struct connection *pc, const struct packet_ruleset_extra *packet)
71221{
71222 if (!pc->used) {
71223 log_error("WARNING: trying to send data to the closed connection %s",
71224 conn_description(pc));
71225 return -1;
71226 }
71227 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_EXTRA].packet != nullptr, -1,
71228 "Handler for PACKET_RULESET_EXTRA not installed");
71229 return pc->phs.handlers->send[PACKET_RULESET_EXTRA].packet(pc, packet);
71230}
71231
71232 void lsend_packet_ruleset_extra(struct conn_list *dest, const struct packet_ruleset_extra *packet)
71233{
71234 conn_list_iterate(dest, pconn) {
71235 send_packet_ruleset_extra(pconn, packet);
71236 } conn_list_iterate_end;
71237}
71238
71239 static inline void init_packet_ruleset_extra_flag(struct packet_ruleset_extra_flag *packet)
71240{
71241 memset(packet, 0, sizeof(*packet));
71242}
71243
71244#define free_packet_ruleset_extra_flag(_packet) (void) 0
71245#define destroy_packet_ruleset_extra_flag free
71246
71247#ifdef FREECIV_DELTA_PROTOCOL
71248#define hash_packet_ruleset_extra_flag_100 hash_const
71249#define cmp_packet_ruleset_extra_flag_100 cmp_const
71250 BV_DEFINE(packet_ruleset_extra_flag_100_fields, 3);
71251#endif /* FREECIV_DELTA_PROTOCOL */
71252
71253 static struct packet_ruleset_extra_flag *receive_packet_ruleset_extra_flag_100(struct connection *pc)
71254{
71255#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_extra_flag(_packet)
71256 RECEIVE_PACKET_START(packet_ruleset_extra_flag, real_packet);
71257
71258#ifdef FREECIV_JSON_CONNECTION
71259 struct plocation field_addr;
71260 {
71261 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
71262 field_addr = *field_addr_tmp;
71263 FC_FREE(field_addr_tmp);
71264 }
71265#endif /* FREECIV_JSON_CONNECTION */
71266
71267 log_packet_detailed("packet_ruleset_extra_flag_100: got info about ()");
71268
71269#ifdef FREECIV_DELTA_PROTOCOL
71270 packet_ruleset_extra_flag_100_fields fields;
71271 struct packet_ruleset_extra_flag *old;
71272 struct genhash **hash = pc->phs.received + PACKET_RULESET_EXTRA_FLAG;
71273
71274 if (nullptr == *hash) {
71275 *hash = genhash_new_full(hash_packet_ruleset_extra_flag_100, cmp_packet_ruleset_extra_flag_100,
71276 nullptr, nullptr, nullptr, destroy_packet_ruleset_extra_flag);
71277 }
71278
71279 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
71280 *real_packet = *old;
71281 } else {
71282 /* packet is already initialized empty */
71283 log_packet_detailed(" no old info");
71284 }
71285
71286#ifdef FREECIV_JSON_CONNECTION
71287 field_addr.name = "fields";
71288#endif /* FREECIV_JSON_CONNECTION */
71289 DIO_BV_GET(&din, &field_addr, fields);
71290
71291 if (BV_ISSET(fields, 0)) {
71292 log_packet_detailed(" got field 'id'");
71293
71294#ifdef FREECIV_JSON_CONNECTION
71295 field_addr.name = "id";
71296#endif /* FREECIV_JSON_CONNECTION */
71297
71298 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
71299 RECEIVE_PACKET_FIELD_ERROR(id);
71300 }
71301 }
71302
71303 if (BV_ISSET(fields, 1)) {
71304 log_packet_detailed(" got field 'name'");
71305
71306#ifdef FREECIV_JSON_CONNECTION
71307 field_addr.name = "name";
71308#endif /* FREECIV_JSON_CONNECTION */
71309
71310 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
71311 RECEIVE_PACKET_FIELD_ERROR(name);
71312 }
71313 }
71314
71315 if (BV_ISSET(fields, 2)) {
71316 log_packet_detailed(" got field 'helptxt'");
71317
71318#ifdef FREECIV_JSON_CONNECTION
71319 field_addr.name = "helptxt";
71320#endif /* FREECIV_JSON_CONNECTION */
71321
71322 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
71323 RECEIVE_PACKET_FIELD_ERROR(helptxt);
71324 }
71325 }
71326
71327 if (nullptr == old) {
71328 old = fc_malloc(sizeof(*old));
71329 init_packet_ruleset_extra_flag(old);
71330 *old = *real_packet;
71331 genhash_insert(*hash, old, old);
71332 } else {
71333 *old = *real_packet;
71334 }
71335
71336#else /* FREECIV_DELTA_PROTOCOL */
71337#ifdef FREECIV_JSON_CONNECTION
71338 field_addr.name = "id";
71339#endif /* FREECIV_JSON_CONNECTION */
71340
71341 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
71342 RECEIVE_PACKET_FIELD_ERROR(id);
71343 }
71344
71345#ifdef FREECIV_JSON_CONNECTION
71346 field_addr.name = "name";
71347#endif /* FREECIV_JSON_CONNECTION */
71348
71349 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
71350 RECEIVE_PACKET_FIELD_ERROR(name);
71351 }
71352
71353#ifdef FREECIV_JSON_CONNECTION
71354 field_addr.name = "helptxt";
71355#endif /* FREECIV_JSON_CONNECTION */
71356
71357 if (!DIO_GET(string, &din, &field_addr, real_packet->helptxt, sizeof(real_packet->helptxt))) {
71358 RECEIVE_PACKET_FIELD_ERROR(helptxt);
71359 }
71360#endif /* FREECIV_DELTA_PROTOCOL */
71361
71362 RECEIVE_PACKET_END(real_packet);
71363#undef FREE_PACKET_STRUCT
71364}
71365
71366 static int send_packet_ruleset_extra_flag_100(struct connection *pc, const struct packet_ruleset_extra_flag *packet)
71367{
71368 const struct packet_ruleset_extra_flag *real_packet = packet;
71369 int e;
71370 SEND_PACKET_START(PACKET_RULESET_EXTRA_FLAG);
71371
71372 log_packet_detailed("packet_ruleset_extra_flag_100: sending info about ()");
71373
71374#ifdef FREECIV_DELTA_PROTOCOL
71375 packet_ruleset_extra_flag_100_fields fields;
71376 struct packet_ruleset_extra_flag *old;
71377 bool differ;
71378 struct genhash **hash = pc->phs.sent + PACKET_RULESET_EXTRA_FLAG;
71379
71380 if (nullptr == *hash) {
71381 *hash = genhash_new_full(hash_packet_ruleset_extra_flag_100, cmp_packet_ruleset_extra_flag_100,
71382 nullptr, nullptr, nullptr, destroy_packet_ruleset_extra_flag);
71383 }
71384 BV_CLR_ALL(fields);
71385
71386 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
71387 old = fc_malloc(sizeof(*old));
71388 /* temporary bitcopy just to insert correctly */
71389 *old = *real_packet;
71390 genhash_insert(*hash, old, old);
71391 init_packet_ruleset_extra_flag(old);
71392 }
71393
71394 differ = (old->id != real_packet->id);
71395 if (differ) {
71396 BV_SET(fields, 0);
71397 }
71398
71399 differ = (strcmp(old->name, real_packet->name) != 0);
71400 if (differ) {
71401 BV_SET(fields, 1);
71402 }
71403
71404 differ = (strcmp(old->helptxt, real_packet->helptxt) != 0);
71405 if (differ) {
71406 BV_SET(fields, 2);
71407 }
71408#endif /* FREECIV_DELTA_PROTOCOL */
71409
71410#ifdef FREECIV_JSON_CONNECTION
71411 struct plocation field_addr;
71412 {
71413 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
71414 field_addr = *field_addr_tmp;
71415 FC_FREE(field_addr_tmp);
71416 }
71417#endif /* FREECIV_JSON_CONNECTION */
71418
71419#ifdef FREECIV_DELTA_PROTOCOL
71420#ifdef FREECIV_JSON_CONNECTION
71421 field_addr.name = "fields";
71422#endif /* FREECIV_JSON_CONNECTION */
71423 e = 0;
71424 e |= DIO_BV_PUT(&dout, &field_addr, fields);
71425 if (e) {
71426 log_packet_detailed("fields bitvector error detected");
71427 }
71428
71429 if (BV_ISSET(fields, 0)) {
71430 log_packet_detailed(" field 'id' has changed");
71431
71432#ifdef FREECIV_JSON_CONNECTION
71433 field_addr.name = "id";
71434#endif /* FREECIV_JSON_CONNECTION */
71435 e = 0;
71436
71437 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
71438
71439 if (e) {
71440 log_packet_detailed("'id' field error detected");
71441 }
71442 }
71443
71444 if (BV_ISSET(fields, 1)) {
71445 log_packet_detailed(" field 'name' has changed");
71446
71447#ifdef FREECIV_JSON_CONNECTION
71448 field_addr.name = "name";
71449#endif /* FREECIV_JSON_CONNECTION */
71450 e = 0;
71451
71452 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
71453
71454 if (e) {
71455 log_packet_detailed("'name' field error detected");
71456 }
71457 }
71458
71459 if (BV_ISSET(fields, 2)) {
71460 log_packet_detailed(" field 'helptxt' has changed");
71461
71462#ifdef FREECIV_JSON_CONNECTION
71463 field_addr.name = "helptxt";
71464#endif /* FREECIV_JSON_CONNECTION */
71465 e = 0;
71466
71467 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
71468
71469 if (e) {
71470 log_packet_detailed("'helptxt' field error detected");
71471 }
71472 }
71473
71474 *old = *real_packet;
71475
71476#else /* FREECIV_DELTA_PROTOCOL */
71477#ifdef FREECIV_JSON_CONNECTION
71478 field_addr.name = "id";
71479#endif /* FREECIV_JSON_CONNECTION */
71480 e = 0;
71481
71482 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
71483
71484 if (e) {
71485 log_packet_detailed("'id' field error detected");
71486 }
71487
71488#ifdef FREECIV_JSON_CONNECTION
71489 field_addr.name = "name";
71490#endif /* FREECIV_JSON_CONNECTION */
71491 e = 0;
71492
71493 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
71494
71495 if (e) {
71496 log_packet_detailed("'name' field error detected");
71497 }
71498
71499#ifdef FREECIV_JSON_CONNECTION
71500 field_addr.name = "helptxt";
71501#endif /* FREECIV_JSON_CONNECTION */
71502 e = 0;
71503
71504 e |= DIO_PUT(string, &dout, &field_addr, real_packet->helptxt);
71505
71506 if (e) {
71507 log_packet_detailed("'helptxt' field error detected");
71508 }
71509#endif /* FREECIV_DELTA_PROTOCOL */
71510
71511 SEND_PACKET_END(PACKET_RULESET_EXTRA_FLAG);
71512}
71513
71514 int send_packet_ruleset_extra_flag(struct connection *pc, const struct packet_ruleset_extra_flag *packet)
71515{
71516 if (!pc->used) {
71517 log_error("WARNING: trying to send data to the closed connection %s",
71518 conn_description(pc));
71519 return -1;
71520 }
71521 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_EXTRA_FLAG].packet != nullptr, -1,
71522 "Handler for PACKET_RULESET_EXTRA_FLAG not installed");
71523 return pc->phs.handlers->send[PACKET_RULESET_EXTRA_FLAG].packet(pc, packet);
71524}
71525
71526 void lsend_packet_ruleset_extra_flag(struct conn_list *dest, const struct packet_ruleset_extra_flag *packet)
71527{
71528 conn_list_iterate(dest, pconn) {
71529 send_packet_ruleset_extra_flag(pconn, packet);
71530 } conn_list_iterate_end;
71531}
71532
71533 static inline void init_packet_ruleset_base(struct packet_ruleset_base *packet)
71534{
71535 memset(packet, 0, sizeof(*packet));
71536}
71537
71538#define free_packet_ruleset_base(_packet) (void) 0
71539#define destroy_packet_ruleset_base free
71540
71541#ifdef FREECIV_DELTA_PROTOCOL
71542#define hash_packet_ruleset_base_100 hash_const
71543#define cmp_packet_ruleset_base_100 cmp_const
71544 BV_DEFINE(packet_ruleset_base_100_fields, 6);
71545#endif /* FREECIV_DELTA_PROTOCOL */
71546
71547 static struct packet_ruleset_base *receive_packet_ruleset_base_100(struct connection *pc)
71548{
71549#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_base(_packet)
71550 RECEIVE_PACKET_START(packet_ruleset_base, real_packet);
71551
71552#ifdef FREECIV_JSON_CONNECTION
71553 struct plocation field_addr;
71554 {
71555 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
71556 field_addr = *field_addr_tmp;
71557 FC_FREE(field_addr_tmp);
71558 }
71559#endif /* FREECIV_JSON_CONNECTION */
71560
71561 log_packet_detailed("packet_ruleset_base_100: got info about ()");
71562
71563#ifdef FREECIV_DELTA_PROTOCOL
71564 packet_ruleset_base_100_fields fields;
71565 struct packet_ruleset_base *old;
71566 struct genhash **hash = pc->phs.received + PACKET_RULESET_BASE;
71567
71568 if (nullptr == *hash) {
71569 *hash = genhash_new_full(hash_packet_ruleset_base_100, cmp_packet_ruleset_base_100,
71570 nullptr, nullptr, nullptr, destroy_packet_ruleset_base);
71571 }
71572
71573 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
71574 *real_packet = *old;
71575 } else {
71576 /* packet is already initialized empty */
71577 log_packet_detailed(" no old info");
71578 }
71579
71580#ifdef FREECIV_JSON_CONNECTION
71581 field_addr.name = "fields";
71582#endif /* FREECIV_JSON_CONNECTION */
71583 DIO_BV_GET(&din, &field_addr, fields);
71584
71585 if (BV_ISSET(fields, 0)) {
71586 log_packet_detailed(" got field 'id'");
71587
71588#ifdef FREECIV_JSON_CONNECTION
71589 field_addr.name = "id";
71590#endif /* FREECIV_JSON_CONNECTION */
71591
71592 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
71593 RECEIVE_PACKET_FIELD_ERROR(id);
71594 }
71595 }
71596
71597 if (BV_ISSET(fields, 1)) {
71598 log_packet_detailed(" got field 'gui_type'");
71599
71600#ifdef FREECIV_JSON_CONNECTION
71601 field_addr.name = "gui_type";
71602#endif /* FREECIV_JSON_CONNECTION */
71603
71604 {
71605 int readin;
71606
71607 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
71608 RECEIVE_PACKET_FIELD_ERROR(gui_type);
71609 }
71610 real_packet->gui_type = readin;
71611 }
71612 }
71613
71614 if (BV_ISSET(fields, 2)) {
71615 log_packet_detailed(" got field 'border_sq'");
71616
71617#ifdef FREECIV_JSON_CONNECTION
71618 field_addr.name = "border_sq";
71619#endif /* FREECIV_JSON_CONNECTION */
71620
71621 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->border_sq)) {
71622 RECEIVE_PACKET_FIELD_ERROR(border_sq);
71623 }
71624 }
71625
71626 if (BV_ISSET(fields, 3)) {
71627 log_packet_detailed(" got field 'vision_main_sq'");
71628
71629#ifdef FREECIV_JSON_CONNECTION
71630 field_addr.name = "vision_main_sq";
71631#endif /* FREECIV_JSON_CONNECTION */
71632
71633 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->vision_main_sq)) {
71634 RECEIVE_PACKET_FIELD_ERROR(vision_main_sq);
71635 }
71636 }
71637
71638 if (BV_ISSET(fields, 4)) {
71639 log_packet_detailed(" got field 'vision_invis_sq'");
71640
71641#ifdef FREECIV_JSON_CONNECTION
71642 field_addr.name = "vision_invis_sq";
71643#endif /* FREECIV_JSON_CONNECTION */
71644
71645 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->vision_invis_sq)) {
71646 RECEIVE_PACKET_FIELD_ERROR(vision_invis_sq);
71647 }
71648 }
71649
71650 if (BV_ISSET(fields, 5)) {
71651 log_packet_detailed(" got field 'vision_subs_sq'");
71652
71653#ifdef FREECIV_JSON_CONNECTION
71654 field_addr.name = "vision_subs_sq";
71655#endif /* FREECIV_JSON_CONNECTION */
71656
71657 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->vision_subs_sq)) {
71658 RECEIVE_PACKET_FIELD_ERROR(vision_subs_sq);
71659 }
71660 }
71661
71662 if (nullptr == old) {
71663 old = fc_malloc(sizeof(*old));
71664 init_packet_ruleset_base(old);
71665 *old = *real_packet;
71666 genhash_insert(*hash, old, old);
71667 } else {
71668 *old = *real_packet;
71669 }
71670
71671#else /* FREECIV_DELTA_PROTOCOL */
71672#ifdef FREECIV_JSON_CONNECTION
71673 field_addr.name = "id";
71674#endif /* FREECIV_JSON_CONNECTION */
71675
71676 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
71677 RECEIVE_PACKET_FIELD_ERROR(id);
71678 }
71679
71680#ifdef FREECIV_JSON_CONNECTION
71681 field_addr.name = "gui_type";
71682#endif /* FREECIV_JSON_CONNECTION */
71683
71684 {
71685 int readin;
71686
71687 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
71688 RECEIVE_PACKET_FIELD_ERROR(gui_type);
71689 }
71690 real_packet->gui_type = readin;
71691 }
71692
71693#ifdef FREECIV_JSON_CONNECTION
71694 field_addr.name = "border_sq";
71695#endif /* FREECIV_JSON_CONNECTION */
71696
71697 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->border_sq)) {
71698 RECEIVE_PACKET_FIELD_ERROR(border_sq);
71699 }
71700
71701#ifdef FREECIV_JSON_CONNECTION
71702 field_addr.name = "vision_main_sq";
71703#endif /* FREECIV_JSON_CONNECTION */
71704
71705 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->vision_main_sq)) {
71706 RECEIVE_PACKET_FIELD_ERROR(vision_main_sq);
71707 }
71708
71709#ifdef FREECIV_JSON_CONNECTION
71710 field_addr.name = "vision_invis_sq";
71711#endif /* FREECIV_JSON_CONNECTION */
71712
71713 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->vision_invis_sq)) {
71714 RECEIVE_PACKET_FIELD_ERROR(vision_invis_sq);
71715 }
71716
71717#ifdef FREECIV_JSON_CONNECTION
71718 field_addr.name = "vision_subs_sq";
71719#endif /* FREECIV_JSON_CONNECTION */
71720
71721 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->vision_subs_sq)) {
71722 RECEIVE_PACKET_FIELD_ERROR(vision_subs_sq);
71723 }
71724#endif /* FREECIV_DELTA_PROTOCOL */
71725
71726 RECEIVE_PACKET_END(real_packet);
71727#undef FREE_PACKET_STRUCT
71728}
71729
71730 static int send_packet_ruleset_base_100(struct connection *pc, const struct packet_ruleset_base *packet)
71731{
71732 const struct packet_ruleset_base *real_packet = packet;
71733 int e;
71734 SEND_PACKET_START(PACKET_RULESET_BASE);
71735
71736 log_packet_detailed("packet_ruleset_base_100: sending info about ()");
71737
71738#ifdef FREECIV_DELTA_PROTOCOL
71739 packet_ruleset_base_100_fields fields;
71740 struct packet_ruleset_base *old;
71741 bool differ;
71742 struct genhash **hash = pc->phs.sent + PACKET_RULESET_BASE;
71743
71744 if (nullptr == *hash) {
71745 *hash = genhash_new_full(hash_packet_ruleset_base_100, cmp_packet_ruleset_base_100,
71746 nullptr, nullptr, nullptr, destroy_packet_ruleset_base);
71747 }
71748 BV_CLR_ALL(fields);
71749
71750 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
71751 old = fc_malloc(sizeof(*old));
71752 /* temporary bitcopy just to insert correctly */
71753 *old = *real_packet;
71754 genhash_insert(*hash, old, old);
71755 init_packet_ruleset_base(old);
71756 }
71757
71758 differ = (old->id != real_packet->id);
71759 if (differ) {
71760 BV_SET(fields, 0);
71761 }
71762
71763 differ = (old->gui_type != real_packet->gui_type);
71764 if (differ) {
71765 BV_SET(fields, 1);
71766 }
71767
71768 differ = (old->border_sq != real_packet->border_sq);
71769 if (differ) {
71770 BV_SET(fields, 2);
71771 }
71772
71773 differ = (old->vision_main_sq != real_packet->vision_main_sq);
71774 if (differ) {
71775 BV_SET(fields, 3);
71776 }
71777
71778 differ = (old->vision_invis_sq != real_packet->vision_invis_sq);
71779 if (differ) {
71780 BV_SET(fields, 4);
71781 }
71782
71783 differ = (old->vision_subs_sq != real_packet->vision_subs_sq);
71784 if (differ) {
71785 BV_SET(fields, 5);
71786 }
71787#endif /* FREECIV_DELTA_PROTOCOL */
71788
71789#ifdef FREECIV_JSON_CONNECTION
71790 struct plocation field_addr;
71791 {
71792 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
71793 field_addr = *field_addr_tmp;
71794 FC_FREE(field_addr_tmp);
71795 }
71796#endif /* FREECIV_JSON_CONNECTION */
71797
71798#ifdef FREECIV_DELTA_PROTOCOL
71799#ifdef FREECIV_JSON_CONNECTION
71800 field_addr.name = "fields";
71801#endif /* FREECIV_JSON_CONNECTION */
71802 e = 0;
71803 e |= DIO_BV_PUT(&dout, &field_addr, fields);
71804 if (e) {
71805 log_packet_detailed("fields bitvector error detected");
71806 }
71807
71808 if (BV_ISSET(fields, 0)) {
71809 log_packet_detailed(" field 'id' has changed");
71810
71811#ifdef FREECIV_JSON_CONNECTION
71812 field_addr.name = "id";
71813#endif /* FREECIV_JSON_CONNECTION */
71814 e = 0;
71815
71816 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
71817
71818 if (e) {
71819 log_packet_detailed("'id' field error detected");
71820 }
71821 }
71822
71823 if (BV_ISSET(fields, 1)) {
71824 log_packet_detailed(" field 'gui_type' has changed");
71825
71826#ifdef FREECIV_JSON_CONNECTION
71827 field_addr.name = "gui_type";
71828#endif /* FREECIV_JSON_CONNECTION */
71829 e = 0;
71830
71831 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gui_type);
71832
71833 if (e) {
71834 log_packet_detailed("'gui_type' field error detected");
71835 }
71836 }
71837
71838 if (BV_ISSET(fields, 2)) {
71839 log_packet_detailed(" field 'border_sq' has changed");
71840
71841#ifdef FREECIV_JSON_CONNECTION
71842 field_addr.name = "border_sq";
71843#endif /* FREECIV_JSON_CONNECTION */
71844 e = 0;
71845
71846 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->border_sq);
71847
71848 if (e) {
71849 log_packet_detailed("'border_sq' field error detected");
71850 }
71851 }
71852
71853 if (BV_ISSET(fields, 3)) {
71854 log_packet_detailed(" field 'vision_main_sq' has changed");
71855
71856#ifdef FREECIV_JSON_CONNECTION
71857 field_addr.name = "vision_main_sq";
71858#endif /* FREECIV_JSON_CONNECTION */
71859 e = 0;
71860
71861 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->vision_main_sq);
71862
71863 if (e) {
71864 log_packet_detailed("'vision_main_sq' field error detected");
71865 }
71866 }
71867
71868 if (BV_ISSET(fields, 4)) {
71869 log_packet_detailed(" field 'vision_invis_sq' has changed");
71870
71871#ifdef FREECIV_JSON_CONNECTION
71872 field_addr.name = "vision_invis_sq";
71873#endif /* FREECIV_JSON_CONNECTION */
71874 e = 0;
71875
71876 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->vision_invis_sq);
71877
71878 if (e) {
71879 log_packet_detailed("'vision_invis_sq' field error detected");
71880 }
71881 }
71882
71883 if (BV_ISSET(fields, 5)) {
71884 log_packet_detailed(" field 'vision_subs_sq' has changed");
71885
71886#ifdef FREECIV_JSON_CONNECTION
71887 field_addr.name = "vision_subs_sq";
71888#endif /* FREECIV_JSON_CONNECTION */
71889 e = 0;
71890
71891 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->vision_subs_sq);
71892
71893 if (e) {
71894 log_packet_detailed("'vision_subs_sq' field error detected");
71895 }
71896 }
71897
71898 *old = *real_packet;
71899
71900#else /* FREECIV_DELTA_PROTOCOL */
71901#ifdef FREECIV_JSON_CONNECTION
71902 field_addr.name = "id";
71903#endif /* FREECIV_JSON_CONNECTION */
71904 e = 0;
71905
71906 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
71907
71908 if (e) {
71909 log_packet_detailed("'id' field error detected");
71910 }
71911
71912#ifdef FREECIV_JSON_CONNECTION
71913 field_addr.name = "gui_type";
71914#endif /* FREECIV_JSON_CONNECTION */
71915 e = 0;
71916
71917 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gui_type);
71918
71919 if (e) {
71920 log_packet_detailed("'gui_type' field error detected");
71921 }
71922
71923#ifdef FREECIV_JSON_CONNECTION
71924 field_addr.name = "border_sq";
71925#endif /* FREECIV_JSON_CONNECTION */
71926 e = 0;
71927
71928 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->border_sq);
71929
71930 if (e) {
71931 log_packet_detailed("'border_sq' field error detected");
71932 }
71933
71934#ifdef FREECIV_JSON_CONNECTION
71935 field_addr.name = "vision_main_sq";
71936#endif /* FREECIV_JSON_CONNECTION */
71937 e = 0;
71938
71939 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->vision_main_sq);
71940
71941 if (e) {
71942 log_packet_detailed("'vision_main_sq' field error detected");
71943 }
71944
71945#ifdef FREECIV_JSON_CONNECTION
71946 field_addr.name = "vision_invis_sq";
71947#endif /* FREECIV_JSON_CONNECTION */
71948 e = 0;
71949
71950 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->vision_invis_sq);
71951
71952 if (e) {
71953 log_packet_detailed("'vision_invis_sq' field error detected");
71954 }
71955
71956#ifdef FREECIV_JSON_CONNECTION
71957 field_addr.name = "vision_subs_sq";
71958#endif /* FREECIV_JSON_CONNECTION */
71959 e = 0;
71960
71961 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->vision_subs_sq);
71962
71963 if (e) {
71964 log_packet_detailed("'vision_subs_sq' field error detected");
71965 }
71966#endif /* FREECIV_DELTA_PROTOCOL */
71967
71968 SEND_PACKET_END(PACKET_RULESET_BASE);
71969}
71970
71971 int send_packet_ruleset_base(struct connection *pc, const struct packet_ruleset_base *packet)
71972{
71973 if (!pc->used) {
71974 log_error("WARNING: trying to send data to the closed connection %s",
71975 conn_description(pc));
71976 return -1;
71977 }
71978 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_BASE].packet != nullptr, -1,
71979 "Handler for PACKET_RULESET_BASE not installed");
71980 return pc->phs.handlers->send[PACKET_RULESET_BASE].packet(pc, packet);
71981}
71982
71983 void lsend_packet_ruleset_base(struct conn_list *dest, const struct packet_ruleset_base *packet)
71984{
71985 conn_list_iterate(dest, pconn) {
71986 send_packet_ruleset_base(pconn, packet);
71987 } conn_list_iterate_end;
71988}
71989
71990 static inline void init_packet_ruleset_road(struct packet_ruleset_road *packet)
71991{
71992 memset(packet, 0, sizeof(*packet));
71993
71994 requirement_vector_init(&packet->first_reqs);
71995}
71996
71997 static inline void free_packet_ruleset_road(struct packet_ruleset_road *packet)
71998{
71999 requirement_vector_free(&packet->first_reqs);
72000}
72001
72002 static inline void destroy_packet_ruleset_road(void *packet)
72003{
72004 free_packet_ruleset_road((struct packet_ruleset_road *) packet);
72005 free(packet);
72006}
72007
72008#ifdef FREECIV_DELTA_PROTOCOL
72009#define hash_packet_ruleset_road_100 hash_const
72010#define cmp_packet_ruleset_road_100 cmp_const
72011 BV_DEFINE(packet_ruleset_road_100_fields, 11);
72012#endif /* FREECIV_DELTA_PROTOCOL */
72013
72014 static struct packet_ruleset_road *receive_packet_ruleset_road_100(struct connection *pc)
72015{
72016#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_road(_packet)
72017 RECEIVE_PACKET_START(packet_ruleset_road, real_packet);
72018
72019#ifdef FREECIV_JSON_CONNECTION
72020 struct plocation field_addr;
72021 {
72022 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
72023 field_addr = *field_addr_tmp;
72024 FC_FREE(field_addr_tmp);
72025 }
72026#endif /* FREECIV_JSON_CONNECTION */
72027
72028 log_packet_detailed("packet_ruleset_road_100: got info about ()");
72029
72030#ifdef FREECIV_DELTA_PROTOCOL
72031 packet_ruleset_road_100_fields fields;
72032 struct packet_ruleset_road *old;
72033 struct genhash **hash = pc->phs.received + PACKET_RULESET_ROAD;
72034
72035 if (nullptr == *hash) {
72036 *hash = genhash_new_full(hash_packet_ruleset_road_100, cmp_packet_ruleset_road_100,
72037 nullptr, nullptr, nullptr, destroy_packet_ruleset_road);
72038 }
72039
72040 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
72041 real_packet->id = old->id;
72042 real_packet->gui_type = old->gui_type;
72043 requirement_vector_copy(&real_packet->first_reqs, &old->first_reqs);
72044 real_packet->move_cost = old->move_cost;
72045 real_packet->move_mode = old->move_mode;
72046 {
72047 int i;
72048
72049 for (i = 0; i < O_LAST; i++) {
72050 real_packet->tile_incr_const[i] = old->tile_incr_const[i];
72051 }
72052 }
72053 {
72054 int i;
72055
72056 for (i = 0; i < O_LAST; i++) {
72057 real_packet->tile_incr[i] = old->tile_incr[i];
72058 }
72059 }
72060 {
72061 int i;
72062
72063 for (i = 0; i < O_LAST; i++) {
72064 real_packet->tile_bonus[i] = old->tile_bonus[i];
72065 }
72066 }
72067 real_packet->compat = old->compat;
72068 real_packet->integrates = old->integrates;
72069 real_packet->flags = old->flags;
72070 } else {
72071 /* packet is already initialized empty */
72072 log_packet_detailed(" no old info");
72073 }
72074
72075#ifdef FREECIV_JSON_CONNECTION
72076 field_addr.name = "fields";
72077#endif /* FREECIV_JSON_CONNECTION */
72078 DIO_BV_GET(&din, &field_addr, fields);
72079
72080 if (BV_ISSET(fields, 0)) {
72081 log_packet_detailed(" got field 'id'");
72082
72083#ifdef FREECIV_JSON_CONNECTION
72084 field_addr.name = "id";
72085#endif /* FREECIV_JSON_CONNECTION */
72086
72087 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
72088 RECEIVE_PACKET_FIELD_ERROR(id);
72089 }
72090 }
72091
72092 if (BV_ISSET(fields, 1)) {
72093 log_packet_detailed(" got field 'gui_type'");
72094
72095#ifdef FREECIV_JSON_CONNECTION
72096 field_addr.name = "gui_type";
72097#endif /* FREECIV_JSON_CONNECTION */
72098
72099 {
72100 int readin;
72101
72102 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
72103 RECEIVE_PACKET_FIELD_ERROR(gui_type);
72104 }
72105 real_packet->gui_type = readin;
72106 }
72107 }
72108
72109 if (BV_ISSET(fields, 2)) {
72110 log_packet_detailed(" got field 'first_reqs'");
72111
72112#ifdef FREECIV_JSON_CONNECTION
72113 field_addr.name = "first_reqs";
72114#endif /* FREECIV_JSON_CONNECTION */
72115
72116 {
72117 int i;
72118
72119 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
72120 RECEIVE_PACKET_FIELD_ERROR(first_reqs);
72121 }
72122 requirement_vector_reserve(&real_packet->first_reqs, i);
72123
72124#ifdef FREECIV_JSON_CONNECTION
72125 /* Enter array. */
72126 field_addr.sub_location = plocation_elem_new(0);
72127#endif /* FREECIV_JSON_CONNECTION */
72128
72129 for (i = 0; i < requirement_vector_size(&real_packet->first_reqs); i++) {
72130#ifdef FREECIV_JSON_CONNECTION
72131 /* Next array element */
72132 field_addr.sub_location->number = i;
72133#endif /* FREECIV_JSON_CONNECTION */
72134
72135 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->first_reqs.p[i])) {
72136 RECEIVE_PACKET_FIELD_ERROR(first_reqs);
72137 }
72138 }
72139
72140#ifdef FREECIV_JSON_CONNECTION
72141 /* Exit array. */
72142 FC_FREE(field_addr.sub_location);
72143#endif /* FREECIV_JSON_CONNECTION */
72144 }
72145 }
72146
72147 if (BV_ISSET(fields, 3)) {
72148 log_packet_detailed(" got field 'move_cost'");
72149
72150#ifdef FREECIV_JSON_CONNECTION
72151 field_addr.name = "move_cost";
72152#endif /* FREECIV_JSON_CONNECTION */
72153
72154 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->move_cost)) {
72155 RECEIVE_PACKET_FIELD_ERROR(move_cost);
72156 }
72157 }
72158
72159 if (BV_ISSET(fields, 4)) {
72160 log_packet_detailed(" got field 'move_mode'");
72161
72162#ifdef FREECIV_JSON_CONNECTION
72163 field_addr.name = "move_mode";
72164#endif /* FREECIV_JSON_CONNECTION */
72165
72166 {
72167 int readin;
72168
72169 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
72170 RECEIVE_PACKET_FIELD_ERROR(move_mode);
72171 }
72172 real_packet->move_mode = readin;
72173 }
72174 }
72175
72176 if (BV_ISSET(fields, 5)) {
72177 log_packet_detailed(" got field 'tile_incr_const'");
72178
72179#ifdef FREECIV_JSON_CONNECTION
72180 field_addr.name = "tile_incr_const";
72181#endif /* FREECIV_JSON_CONNECTION */
72182
72183 {
72184 int i;
72185
72186
72187#ifdef FREECIV_JSON_CONNECTION
72188 /* Enter array. */
72189 field_addr.sub_location = plocation_elem_new(0);
72190#endif /* FREECIV_JSON_CONNECTION */
72191
72192 for (i = 0; i < O_LAST; i++) {
72193#ifdef FREECIV_JSON_CONNECTION
72194 /* Next array element */
72195 field_addr.sub_location->number = i;
72196#endif /* FREECIV_JSON_CONNECTION */
72197
72198 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tile_incr_const[i])) {
72199 RECEIVE_PACKET_FIELD_ERROR(tile_incr_const);
72200 }
72201 }
72202
72203#ifdef FREECIV_JSON_CONNECTION
72204 /* Exit array. */
72205 FC_FREE(field_addr.sub_location);
72206#endif /* FREECIV_JSON_CONNECTION */
72207 }
72208 }
72209
72210 if (BV_ISSET(fields, 6)) {
72211 log_packet_detailed(" got field 'tile_incr'");
72212
72213#ifdef FREECIV_JSON_CONNECTION
72214 field_addr.name = "tile_incr";
72215#endif /* FREECIV_JSON_CONNECTION */
72216
72217 {
72218 int i;
72219
72220
72221#ifdef FREECIV_JSON_CONNECTION
72222 /* Enter array. */
72223 field_addr.sub_location = plocation_elem_new(0);
72224#endif /* FREECIV_JSON_CONNECTION */
72225
72226 for (i = 0; i < O_LAST; i++) {
72227#ifdef FREECIV_JSON_CONNECTION
72228 /* Next array element */
72229 field_addr.sub_location->number = i;
72230#endif /* FREECIV_JSON_CONNECTION */
72231
72232 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tile_incr[i])) {
72233 RECEIVE_PACKET_FIELD_ERROR(tile_incr);
72234 }
72235 }
72236
72237#ifdef FREECIV_JSON_CONNECTION
72238 /* Exit array. */
72239 FC_FREE(field_addr.sub_location);
72240#endif /* FREECIV_JSON_CONNECTION */
72241 }
72242 }
72243
72244 if (BV_ISSET(fields, 7)) {
72245 log_packet_detailed(" got field 'tile_bonus'");
72246
72247#ifdef FREECIV_JSON_CONNECTION
72248 field_addr.name = "tile_bonus";
72249#endif /* FREECIV_JSON_CONNECTION */
72250
72251 {
72252 int i;
72253
72254
72255#ifdef FREECIV_JSON_CONNECTION
72256 /* Enter array. */
72257 field_addr.sub_location = plocation_elem_new(0);
72258#endif /* FREECIV_JSON_CONNECTION */
72259
72260 for (i = 0; i < O_LAST; i++) {
72261#ifdef FREECIV_JSON_CONNECTION
72262 /* Next array element */
72263 field_addr.sub_location->number = i;
72264#endif /* FREECIV_JSON_CONNECTION */
72265
72266 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tile_bonus[i])) {
72267 RECEIVE_PACKET_FIELD_ERROR(tile_bonus);
72268 }
72269 }
72270
72271#ifdef FREECIV_JSON_CONNECTION
72272 /* Exit array. */
72273 FC_FREE(field_addr.sub_location);
72274#endif /* FREECIV_JSON_CONNECTION */
72275 }
72276 }
72277
72278 if (BV_ISSET(fields, 8)) {
72279 log_packet_detailed(" got field 'compat'");
72280
72281#ifdef FREECIV_JSON_CONNECTION
72282 field_addr.name = "compat";
72283#endif /* FREECIV_JSON_CONNECTION */
72284
72285 {
72286 int readin;
72287
72288 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
72289 RECEIVE_PACKET_FIELD_ERROR(compat);
72290 }
72291 real_packet->compat = readin;
72292 }
72293 }
72294
72295 if (BV_ISSET(fields, 9)) {
72296 log_packet_detailed(" got field 'integrates'");
72297
72298#ifdef FREECIV_JSON_CONNECTION
72299 field_addr.name = "integrates";
72300#endif /* FREECIV_JSON_CONNECTION */
72301
72302 if (!DIO_BV_GET(&din, &field_addr, real_packet->integrates)) {
72303 RECEIVE_PACKET_FIELD_ERROR(integrates);
72304 }
72305 }
72306
72307 if (BV_ISSET(fields, 10)) {
72308 log_packet_detailed(" got field 'flags'");
72309
72310#ifdef FREECIV_JSON_CONNECTION
72311 field_addr.name = "flags";
72312#endif /* FREECIV_JSON_CONNECTION */
72313
72314 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
72315 RECEIVE_PACKET_FIELD_ERROR(flags);
72316 }
72317 }
72318
72319 if (nullptr == old) {
72320 old = fc_malloc(sizeof(*old));
72321 init_packet_ruleset_road(old);
72322 old->id = real_packet->id;
72323 old->gui_type = real_packet->gui_type;
72324 requirement_vector_copy(&old->first_reqs, &real_packet->first_reqs);
72325 old->move_cost = real_packet->move_cost;
72326 old->move_mode = real_packet->move_mode;
72327 {
72328 int i;
72329
72330 for (i = 0; i < O_LAST; i++) {
72331 old->tile_incr_const[i] = real_packet->tile_incr_const[i];
72332 }
72333 }
72334 {
72335 int i;
72336
72337 for (i = 0; i < O_LAST; i++) {
72338 old->tile_incr[i] = real_packet->tile_incr[i];
72339 }
72340 }
72341 {
72342 int i;
72343
72344 for (i = 0; i < O_LAST; i++) {
72345 old->tile_bonus[i] = real_packet->tile_bonus[i];
72346 }
72347 }
72348 old->compat = real_packet->compat;
72349 old->integrates = real_packet->integrates;
72350 old->flags = real_packet->flags;
72351 genhash_insert(*hash, old, old);
72352 } else {
72353 old->id = real_packet->id;
72354 old->gui_type = real_packet->gui_type;
72355 requirement_vector_copy(&old->first_reqs, &real_packet->first_reqs);
72356 old->move_cost = real_packet->move_cost;
72357 old->move_mode = real_packet->move_mode;
72358 {
72359 int i;
72360
72361 for (i = 0; i < O_LAST; i++) {
72362 old->tile_incr_const[i] = real_packet->tile_incr_const[i];
72363 }
72364 }
72365 {
72366 int i;
72367
72368 for (i = 0; i < O_LAST; i++) {
72369 old->tile_incr[i] = real_packet->tile_incr[i];
72370 }
72371 }
72372 {
72373 int i;
72374
72375 for (i = 0; i < O_LAST; i++) {
72376 old->tile_bonus[i] = real_packet->tile_bonus[i];
72377 }
72378 }
72379 old->compat = real_packet->compat;
72380 old->integrates = real_packet->integrates;
72381 old->flags = real_packet->flags;
72382 }
72383
72384#else /* FREECIV_DELTA_PROTOCOL */
72385#ifdef FREECIV_JSON_CONNECTION
72386 field_addr.name = "id";
72387#endif /* FREECIV_JSON_CONNECTION */
72388
72389 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
72390 RECEIVE_PACKET_FIELD_ERROR(id);
72391 }
72392
72393#ifdef FREECIV_JSON_CONNECTION
72394 field_addr.name = "gui_type";
72395#endif /* FREECIV_JSON_CONNECTION */
72396
72397 {
72398 int readin;
72399
72400 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
72401 RECEIVE_PACKET_FIELD_ERROR(gui_type);
72402 }
72403 real_packet->gui_type = readin;
72404 }
72405
72406#ifdef FREECIV_JSON_CONNECTION
72407 field_addr.name = "first_reqs";
72408#endif /* FREECIV_JSON_CONNECTION */
72409
72410 {
72411 int i;
72412
72413 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
72414 RECEIVE_PACKET_FIELD_ERROR(first_reqs);
72415 }
72416 requirement_vector_reserve(&real_packet->first_reqs, i);
72417
72418#ifdef FREECIV_JSON_CONNECTION
72419 /* Enter array. */
72420 field_addr.sub_location = plocation_elem_new(0);
72421#endif /* FREECIV_JSON_CONNECTION */
72422
72423 for (i = 0; i < requirement_vector_size(&real_packet->first_reqs); i++) {
72424#ifdef FREECIV_JSON_CONNECTION
72425 /* Next array element */
72426 field_addr.sub_location->number = i;
72427#endif /* FREECIV_JSON_CONNECTION */
72428
72429 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->first_reqs.p[i])) {
72430 RECEIVE_PACKET_FIELD_ERROR(first_reqs);
72431 }
72432 }
72433
72434#ifdef FREECIV_JSON_CONNECTION
72435 /* Exit array. */
72436 FC_FREE(field_addr.sub_location);
72437#endif /* FREECIV_JSON_CONNECTION */
72438 }
72439
72440#ifdef FREECIV_JSON_CONNECTION
72441 field_addr.name = "move_cost";
72442#endif /* FREECIV_JSON_CONNECTION */
72443
72444 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->move_cost)) {
72445 RECEIVE_PACKET_FIELD_ERROR(move_cost);
72446 }
72447
72448#ifdef FREECIV_JSON_CONNECTION
72449 field_addr.name = "move_mode";
72450#endif /* FREECIV_JSON_CONNECTION */
72451
72452 {
72453 int readin;
72454
72455 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
72456 RECEIVE_PACKET_FIELD_ERROR(move_mode);
72457 }
72458 real_packet->move_mode = readin;
72459 }
72460
72461#ifdef FREECIV_JSON_CONNECTION
72462 field_addr.name = "tile_incr_const";
72463#endif /* FREECIV_JSON_CONNECTION */
72464
72465 {
72466 int i;
72467
72468
72469#ifdef FREECIV_JSON_CONNECTION
72470 /* Enter array. */
72471 field_addr.sub_location = plocation_elem_new(0);
72472#endif /* FREECIV_JSON_CONNECTION */
72473
72474 for (i = 0; i < O_LAST; i++) {
72475#ifdef FREECIV_JSON_CONNECTION
72476 /* Next array element */
72477 field_addr.sub_location->number = i;
72478#endif /* FREECIV_JSON_CONNECTION */
72479
72480 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tile_incr_const[i])) {
72481 RECEIVE_PACKET_FIELD_ERROR(tile_incr_const);
72482 }
72483 }
72484
72485#ifdef FREECIV_JSON_CONNECTION
72486 /* Exit array. */
72487 FC_FREE(field_addr.sub_location);
72488#endif /* FREECIV_JSON_CONNECTION */
72489 }
72490
72491#ifdef FREECIV_JSON_CONNECTION
72492 field_addr.name = "tile_incr";
72493#endif /* FREECIV_JSON_CONNECTION */
72494
72495 {
72496 int i;
72497
72498
72499#ifdef FREECIV_JSON_CONNECTION
72500 /* Enter array. */
72501 field_addr.sub_location = plocation_elem_new(0);
72502#endif /* FREECIV_JSON_CONNECTION */
72503
72504 for (i = 0; i < O_LAST; i++) {
72505#ifdef FREECIV_JSON_CONNECTION
72506 /* Next array element */
72507 field_addr.sub_location->number = i;
72508#endif /* FREECIV_JSON_CONNECTION */
72509
72510 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tile_incr[i])) {
72511 RECEIVE_PACKET_FIELD_ERROR(tile_incr);
72512 }
72513 }
72514
72515#ifdef FREECIV_JSON_CONNECTION
72516 /* Exit array. */
72517 FC_FREE(field_addr.sub_location);
72518#endif /* FREECIV_JSON_CONNECTION */
72519 }
72520
72521#ifdef FREECIV_JSON_CONNECTION
72522 field_addr.name = "tile_bonus";
72523#endif /* FREECIV_JSON_CONNECTION */
72524
72525 {
72526 int i;
72527
72528
72529#ifdef FREECIV_JSON_CONNECTION
72530 /* Enter array. */
72531 field_addr.sub_location = plocation_elem_new(0);
72532#endif /* FREECIV_JSON_CONNECTION */
72533
72534 for (i = 0; i < O_LAST; i++) {
72535#ifdef FREECIV_JSON_CONNECTION
72536 /* Next array element */
72537 field_addr.sub_location->number = i;
72538#endif /* FREECIV_JSON_CONNECTION */
72539
72540 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->tile_bonus[i])) {
72541 RECEIVE_PACKET_FIELD_ERROR(tile_bonus);
72542 }
72543 }
72544
72545#ifdef FREECIV_JSON_CONNECTION
72546 /* Exit array. */
72547 FC_FREE(field_addr.sub_location);
72548#endif /* FREECIV_JSON_CONNECTION */
72549 }
72550
72551#ifdef FREECIV_JSON_CONNECTION
72552 field_addr.name = "compat";
72553#endif /* FREECIV_JSON_CONNECTION */
72554
72555 {
72556 int readin;
72557
72558 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
72559 RECEIVE_PACKET_FIELD_ERROR(compat);
72560 }
72561 real_packet->compat = readin;
72562 }
72563
72564#ifdef FREECIV_JSON_CONNECTION
72565 field_addr.name = "integrates";
72566#endif /* FREECIV_JSON_CONNECTION */
72567
72568 if (!DIO_BV_GET(&din, &field_addr, real_packet->integrates)) {
72569 RECEIVE_PACKET_FIELD_ERROR(integrates);
72570 }
72571
72572#ifdef FREECIV_JSON_CONNECTION
72573 field_addr.name = "flags";
72574#endif /* FREECIV_JSON_CONNECTION */
72575
72576 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
72577 RECEIVE_PACKET_FIELD_ERROR(flags);
72578 }
72579#endif /* FREECIV_DELTA_PROTOCOL */
72580
72581 RECEIVE_PACKET_END(real_packet);
72582#undef FREE_PACKET_STRUCT
72583}
72584
72585 static int send_packet_ruleset_road_100(struct connection *pc, const struct packet_ruleset_road *packet)
72586{
72587 const struct packet_ruleset_road *real_packet = packet;
72588 int e;
72589 SEND_PACKET_START(PACKET_RULESET_ROAD);
72590
72591 log_packet_detailed("packet_ruleset_road_100: sending info about ()");
72592
72593#ifdef FREECIV_DELTA_PROTOCOL
72594 packet_ruleset_road_100_fields fields;
72595 struct packet_ruleset_road *old;
72596 bool differ;
72597 struct genhash **hash = pc->phs.sent + PACKET_RULESET_ROAD;
72598
72599 if (nullptr == *hash) {
72600 *hash = genhash_new_full(hash_packet_ruleset_road_100, cmp_packet_ruleset_road_100,
72601 nullptr, nullptr, nullptr, destroy_packet_ruleset_road);
72602 }
72603 BV_CLR_ALL(fields);
72604
72605 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
72606 old = fc_malloc(sizeof(*old));
72607 /* temporary bitcopy just to insert correctly */
72608 *old = *real_packet;
72609 genhash_insert(*hash, old, old);
72610 init_packet_ruleset_road(old);
72611 }
72612
72613 differ = (old->id != real_packet->id);
72614 if (differ) {
72615 BV_SET(fields, 0);
72616 }
72617
72618 differ = (old->gui_type != real_packet->gui_type);
72619 if (differ) {
72620 BV_SET(fields, 1);
72621 }
72622
72623 differ = (requirement_vector_size(&old->first_reqs) != requirement_vector_size(&real_packet->first_reqs));
72624 if (!differ) {
72625 int i;
72626
72627 for (i = 0; i < requirement_vector_size(&old->first_reqs); i++) {
72628 differ = !are_requirements_equal(&old->first_reqs.p[i], &real_packet->first_reqs.p[i]);
72629 if (differ) {
72630 break;
72631 }
72632 }
72633 }
72634 if (differ) {
72635 BV_SET(fields, 2);
72636 }
72637
72638 differ = (old->move_cost != real_packet->move_cost);
72639 if (differ) {
72640 BV_SET(fields, 3);
72641 }
72642
72643 differ = (old->move_mode != real_packet->move_mode);
72644 if (differ) {
72645 BV_SET(fields, 4);
72646 }
72647
72648 differ = FALSE;
72649 {
72650 int i;
72651
72652 for (i = 0; i < O_LAST; i++) {
72653 differ = (old->tile_incr_const[i] != real_packet->tile_incr_const[i]);
72654 if (differ) {
72655 break;
72656 }
72657 }
72658 }
72659 if (differ) {
72660 BV_SET(fields, 5);
72661 }
72662
72663 differ = FALSE;
72664 {
72665 int i;
72666
72667 for (i = 0; i < O_LAST; i++) {
72668 differ = (old->tile_incr[i] != real_packet->tile_incr[i]);
72669 if (differ) {
72670 break;
72671 }
72672 }
72673 }
72674 if (differ) {
72675 BV_SET(fields, 6);
72676 }
72677
72678 differ = FALSE;
72679 {
72680 int i;
72681
72682 for (i = 0; i < O_LAST; i++) {
72683 differ = (old->tile_bonus[i] != real_packet->tile_bonus[i]);
72684 if (differ) {
72685 break;
72686 }
72687 }
72688 }
72689 if (differ) {
72690 BV_SET(fields, 7);
72691 }
72692
72693 differ = (old->compat != real_packet->compat);
72694 if (differ) {
72695 BV_SET(fields, 8);
72696 }
72697
72698 differ = !BV_ARE_EQUAL(old->integrates, real_packet->integrates);
72699 if (differ) {
72700 BV_SET(fields, 9);
72701 }
72702
72703 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
72704 if (differ) {
72705 BV_SET(fields, 10);
72706 }
72707#endif /* FREECIV_DELTA_PROTOCOL */
72708
72709#ifdef FREECIV_JSON_CONNECTION
72710 struct plocation field_addr;
72711 {
72712 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
72713 field_addr = *field_addr_tmp;
72714 FC_FREE(field_addr_tmp);
72715 }
72716#endif /* FREECIV_JSON_CONNECTION */
72717
72718#ifdef FREECIV_DELTA_PROTOCOL
72719#ifdef FREECIV_JSON_CONNECTION
72720 field_addr.name = "fields";
72721#endif /* FREECIV_JSON_CONNECTION */
72722 e = 0;
72723 e |= DIO_BV_PUT(&dout, &field_addr, fields);
72724 if (e) {
72725 log_packet_detailed("fields bitvector error detected");
72726 }
72727
72728 if (BV_ISSET(fields, 0)) {
72729 log_packet_detailed(" field 'id' has changed");
72730
72731#ifdef FREECIV_JSON_CONNECTION
72732 field_addr.name = "id";
72733#endif /* FREECIV_JSON_CONNECTION */
72734 e = 0;
72735
72736 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
72737
72738 if (e) {
72739 log_packet_detailed("'id' field error detected");
72740 }
72741 }
72742
72743 if (BV_ISSET(fields, 1)) {
72744 log_packet_detailed(" field 'gui_type' has changed");
72745
72746#ifdef FREECIV_JSON_CONNECTION
72747 field_addr.name = "gui_type";
72748#endif /* FREECIV_JSON_CONNECTION */
72749 e = 0;
72750
72751 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gui_type);
72752
72753 if (e) {
72754 log_packet_detailed("'gui_type' field error detected");
72755 }
72756 }
72757
72758 if (BV_ISSET(fields, 2)) {
72759 log_packet_detailed(" field 'first_reqs' has changed");
72760
72761#ifdef FREECIV_JSON_CONNECTION
72762 field_addr.name = "first_reqs";
72763#endif /* FREECIV_JSON_CONNECTION */
72764 e = 0;
72765
72766 {
72767 int i;
72768
72769 fc_assert(requirement_vector_size(&real_packet->first_reqs) < MAX_UINT16);
72770 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->first_reqs));
72771
72772#ifdef FREECIV_JSON_CONNECTION
72773 /* Enter array. */
72774 field_addr.sub_location = plocation_elem_new(0);
72775#endif /* FREECIV_JSON_CONNECTION */
72776
72777 for (i = 0; i < requirement_vector_size(&real_packet->first_reqs); i++) {
72778#ifdef FREECIV_JSON_CONNECTION
72779 /* Next array element. */
72780 field_addr.sub_location->number = i;
72781#endif /* FREECIV_JSON_CONNECTION */
72782
72783 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->first_reqs.p[i]);
72784 }
72785
72786#ifdef FREECIV_JSON_CONNECTION
72787 /* Exit array. */
72788 FC_FREE(field_addr.sub_location);
72789#endif /* FREECIV_JSON_CONNECTION */
72790 }
72791
72792 if (e) {
72793 log_packet_detailed("'first_reqs' field error detected");
72794 }
72795 }
72796
72797 if (BV_ISSET(fields, 3)) {
72798 log_packet_detailed(" field 'move_cost' has changed");
72799
72800#ifdef FREECIV_JSON_CONNECTION
72801 field_addr.name = "move_cost";
72802#endif /* FREECIV_JSON_CONNECTION */
72803 e = 0;
72804
72805 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->move_cost);
72806
72807 if (e) {
72808 log_packet_detailed("'move_cost' field error detected");
72809 }
72810 }
72811
72812 if (BV_ISSET(fields, 4)) {
72813 log_packet_detailed(" field 'move_mode' has changed");
72814
72815#ifdef FREECIV_JSON_CONNECTION
72816 field_addr.name = "move_mode";
72817#endif /* FREECIV_JSON_CONNECTION */
72818 e = 0;
72819
72820 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->move_mode);
72821
72822 if (e) {
72823 log_packet_detailed("'move_mode' field error detected");
72824 }
72825 }
72826
72827 if (BV_ISSET(fields, 5)) {
72828 log_packet_detailed(" field 'tile_incr_const' has changed");
72829
72830#ifdef FREECIV_JSON_CONNECTION
72831 field_addr.name = "tile_incr_const";
72832#endif /* FREECIV_JSON_CONNECTION */
72833 e = 0;
72834
72835 {
72836 int i;
72837
72838#ifdef FREECIV_JSON_CONNECTION
72839 /* Create the array. */
72840 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
72841
72842 /* Enter array. */
72843 field_addr.sub_location = plocation_elem_new(0);
72844#endif /* FREECIV_JSON_CONNECTION */
72845
72846 for (i = 0; i < O_LAST; i++) {
72847#ifdef FREECIV_JSON_CONNECTION
72848 /* Next array element. */
72849 field_addr.sub_location->number = i;
72850#endif /* FREECIV_JSON_CONNECTION */
72851
72852 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tile_incr_const[i]);
72853 }
72854
72855#ifdef FREECIV_JSON_CONNECTION
72856 /* Exit array. */
72857 FC_FREE(field_addr.sub_location);
72858#endif /* FREECIV_JSON_CONNECTION */
72859 }
72860
72861 if (e) {
72862 log_packet_detailed("'tile_incr_const' field error detected");
72863 }
72864 }
72865
72866 if (BV_ISSET(fields, 6)) {
72867 log_packet_detailed(" field 'tile_incr' has changed");
72868
72869#ifdef FREECIV_JSON_CONNECTION
72870 field_addr.name = "tile_incr";
72871#endif /* FREECIV_JSON_CONNECTION */
72872 e = 0;
72873
72874 {
72875 int i;
72876
72877#ifdef FREECIV_JSON_CONNECTION
72878 /* Create the array. */
72879 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
72880
72881 /* Enter array. */
72882 field_addr.sub_location = plocation_elem_new(0);
72883#endif /* FREECIV_JSON_CONNECTION */
72884
72885 for (i = 0; i < O_LAST; i++) {
72886#ifdef FREECIV_JSON_CONNECTION
72887 /* Next array element. */
72888 field_addr.sub_location->number = i;
72889#endif /* FREECIV_JSON_CONNECTION */
72890
72891 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tile_incr[i]);
72892 }
72893
72894#ifdef FREECIV_JSON_CONNECTION
72895 /* Exit array. */
72896 FC_FREE(field_addr.sub_location);
72897#endif /* FREECIV_JSON_CONNECTION */
72898 }
72899
72900 if (e) {
72901 log_packet_detailed("'tile_incr' field error detected");
72902 }
72903 }
72904
72905 if (BV_ISSET(fields, 7)) {
72906 log_packet_detailed(" field 'tile_bonus' has changed");
72907
72908#ifdef FREECIV_JSON_CONNECTION
72909 field_addr.name = "tile_bonus";
72910#endif /* FREECIV_JSON_CONNECTION */
72911 e = 0;
72912
72913 {
72914 int i;
72915
72916#ifdef FREECIV_JSON_CONNECTION
72917 /* Create the array. */
72918 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
72919
72920 /* Enter array. */
72921 field_addr.sub_location = plocation_elem_new(0);
72922#endif /* FREECIV_JSON_CONNECTION */
72923
72924 for (i = 0; i < O_LAST; i++) {
72925#ifdef FREECIV_JSON_CONNECTION
72926 /* Next array element. */
72927 field_addr.sub_location->number = i;
72928#endif /* FREECIV_JSON_CONNECTION */
72929
72930 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tile_bonus[i]);
72931 }
72932
72933#ifdef FREECIV_JSON_CONNECTION
72934 /* Exit array. */
72935 FC_FREE(field_addr.sub_location);
72936#endif /* FREECIV_JSON_CONNECTION */
72937 }
72938
72939 if (e) {
72940 log_packet_detailed("'tile_bonus' field error detected");
72941 }
72942 }
72943
72944 if (BV_ISSET(fields, 8)) {
72945 log_packet_detailed(" field 'compat' has changed");
72946
72947#ifdef FREECIV_JSON_CONNECTION
72948 field_addr.name = "compat";
72949#endif /* FREECIV_JSON_CONNECTION */
72950 e = 0;
72951
72952 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->compat);
72953
72954 if (e) {
72955 log_packet_detailed("'compat' field error detected");
72956 }
72957 }
72958
72959 if (BV_ISSET(fields, 9)) {
72960 log_packet_detailed(" field 'integrates' has changed");
72961
72962#ifdef FREECIV_JSON_CONNECTION
72963 field_addr.name = "integrates";
72964#endif /* FREECIV_JSON_CONNECTION */
72965 e = 0;
72966
72967 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->integrates);
72968
72969 if (e) {
72970 log_packet_detailed("'integrates' field error detected");
72971 }
72972 }
72973
72974 if (BV_ISSET(fields, 10)) {
72975 log_packet_detailed(" field 'flags' has changed");
72976
72977#ifdef FREECIV_JSON_CONNECTION
72978 field_addr.name = "flags";
72979#endif /* FREECIV_JSON_CONNECTION */
72980 e = 0;
72981
72982 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
72983
72984 if (e) {
72985 log_packet_detailed("'flags' field error detected");
72986 }
72987 }
72988
72989 old->id = real_packet->id;
72990 old->gui_type = real_packet->gui_type;
72991 requirement_vector_copy(&old->first_reqs, &real_packet->first_reqs);
72992 old->move_cost = real_packet->move_cost;
72993 old->move_mode = real_packet->move_mode;
72994 {
72995 int i;
72996
72997 for (i = 0; i < O_LAST; i++) {
72998 old->tile_incr_const[i] = real_packet->tile_incr_const[i];
72999 }
73000 }
73001 {
73002 int i;
73003
73004 for (i = 0; i < O_LAST; i++) {
73005 old->tile_incr[i] = real_packet->tile_incr[i];
73006 }
73007 }
73008 {
73009 int i;
73010
73011 for (i = 0; i < O_LAST; i++) {
73012 old->tile_bonus[i] = real_packet->tile_bonus[i];
73013 }
73014 }
73015 old->compat = real_packet->compat;
73016 old->integrates = real_packet->integrates;
73017 old->flags = real_packet->flags;
73018
73019#else /* FREECIV_DELTA_PROTOCOL */
73020#ifdef FREECIV_JSON_CONNECTION
73021 field_addr.name = "id";
73022#endif /* FREECIV_JSON_CONNECTION */
73023 e = 0;
73024
73025 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
73026
73027 if (e) {
73028 log_packet_detailed("'id' field error detected");
73029 }
73030
73031#ifdef FREECIV_JSON_CONNECTION
73032 field_addr.name = "gui_type";
73033#endif /* FREECIV_JSON_CONNECTION */
73034 e = 0;
73035
73036 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->gui_type);
73037
73038 if (e) {
73039 log_packet_detailed("'gui_type' field error detected");
73040 }
73041
73042#ifdef FREECIV_JSON_CONNECTION
73043 field_addr.name = "first_reqs";
73044#endif /* FREECIV_JSON_CONNECTION */
73045 e = 0;
73046
73047 {
73048 int i;
73049
73050 fc_assert(requirement_vector_size(&real_packet->first_reqs) < MAX_UINT16);
73051 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->first_reqs));
73052
73053#ifdef FREECIV_JSON_CONNECTION
73054 /* Enter array. */
73055 field_addr.sub_location = plocation_elem_new(0);
73056#endif /* FREECIV_JSON_CONNECTION */
73057
73058 for (i = 0; i < requirement_vector_size(&real_packet->first_reqs); i++) {
73059#ifdef FREECIV_JSON_CONNECTION
73060 /* Next array element. */
73061 field_addr.sub_location->number = i;
73062#endif /* FREECIV_JSON_CONNECTION */
73063
73064 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->first_reqs.p[i]);
73065 }
73066
73067#ifdef FREECIV_JSON_CONNECTION
73068 /* Exit array. */
73069 FC_FREE(field_addr.sub_location);
73070#endif /* FREECIV_JSON_CONNECTION */
73071 }
73072
73073 if (e) {
73074 log_packet_detailed("'first_reqs' field error detected");
73075 }
73076
73077#ifdef FREECIV_JSON_CONNECTION
73078 field_addr.name = "move_cost";
73079#endif /* FREECIV_JSON_CONNECTION */
73080 e = 0;
73081
73082 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->move_cost);
73083
73084 if (e) {
73085 log_packet_detailed("'move_cost' field error detected");
73086 }
73087
73088#ifdef FREECIV_JSON_CONNECTION
73089 field_addr.name = "move_mode";
73090#endif /* FREECIV_JSON_CONNECTION */
73091 e = 0;
73092
73093 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->move_mode);
73094
73095 if (e) {
73096 log_packet_detailed("'move_mode' field error detected");
73097 }
73098
73099#ifdef FREECIV_JSON_CONNECTION
73100 field_addr.name = "tile_incr_const";
73101#endif /* FREECIV_JSON_CONNECTION */
73102 e = 0;
73103
73104 {
73105 int i;
73106
73107#ifdef FREECIV_JSON_CONNECTION
73108 /* Create the array. */
73109 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
73110
73111 /* Enter array. */
73112 field_addr.sub_location = plocation_elem_new(0);
73113#endif /* FREECIV_JSON_CONNECTION */
73114
73115 for (i = 0; i < O_LAST; i++) {
73116#ifdef FREECIV_JSON_CONNECTION
73117 /* Next array element. */
73118 field_addr.sub_location->number = i;
73119#endif /* FREECIV_JSON_CONNECTION */
73120
73121 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tile_incr_const[i]);
73122 }
73123
73124#ifdef FREECIV_JSON_CONNECTION
73125 /* Exit array. */
73126 FC_FREE(field_addr.sub_location);
73127#endif /* FREECIV_JSON_CONNECTION */
73128 }
73129
73130 if (e) {
73131 log_packet_detailed("'tile_incr_const' field error detected");
73132 }
73133
73134#ifdef FREECIV_JSON_CONNECTION
73135 field_addr.name = "tile_incr";
73136#endif /* FREECIV_JSON_CONNECTION */
73137 e = 0;
73138
73139 {
73140 int i;
73141
73142#ifdef FREECIV_JSON_CONNECTION
73143 /* Create the array. */
73144 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
73145
73146 /* Enter array. */
73147 field_addr.sub_location = plocation_elem_new(0);
73148#endif /* FREECIV_JSON_CONNECTION */
73149
73150 for (i = 0; i < O_LAST; i++) {
73151#ifdef FREECIV_JSON_CONNECTION
73152 /* Next array element. */
73153 field_addr.sub_location->number = i;
73154#endif /* FREECIV_JSON_CONNECTION */
73155
73156 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tile_incr[i]);
73157 }
73158
73159#ifdef FREECIV_JSON_CONNECTION
73160 /* Exit array. */
73161 FC_FREE(field_addr.sub_location);
73162#endif /* FREECIV_JSON_CONNECTION */
73163 }
73164
73165 if (e) {
73166 log_packet_detailed("'tile_incr' field error detected");
73167 }
73168
73169#ifdef FREECIV_JSON_CONNECTION
73170 field_addr.name = "tile_bonus";
73171#endif /* FREECIV_JSON_CONNECTION */
73172 e = 0;
73173
73174 {
73175 int i;
73176
73177#ifdef FREECIV_JSON_CONNECTION
73178 /* Create the array. */
73179 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
73180
73181 /* Enter array. */
73182 field_addr.sub_location = plocation_elem_new(0);
73183#endif /* FREECIV_JSON_CONNECTION */
73184
73185 for (i = 0; i < O_LAST; i++) {
73186#ifdef FREECIV_JSON_CONNECTION
73187 /* Next array element. */
73188 field_addr.sub_location->number = i;
73189#endif /* FREECIV_JSON_CONNECTION */
73190
73191 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->tile_bonus[i]);
73192 }
73193
73194#ifdef FREECIV_JSON_CONNECTION
73195 /* Exit array. */
73196 FC_FREE(field_addr.sub_location);
73197#endif /* FREECIV_JSON_CONNECTION */
73198 }
73199
73200 if (e) {
73201 log_packet_detailed("'tile_bonus' field error detected");
73202 }
73203
73204#ifdef FREECIV_JSON_CONNECTION
73205 field_addr.name = "compat";
73206#endif /* FREECIV_JSON_CONNECTION */
73207 e = 0;
73208
73209 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->compat);
73210
73211 if (e) {
73212 log_packet_detailed("'compat' field error detected");
73213 }
73214
73215#ifdef FREECIV_JSON_CONNECTION
73216 field_addr.name = "integrates";
73217#endif /* FREECIV_JSON_CONNECTION */
73218 e = 0;
73219
73220 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->integrates);
73221
73222 if (e) {
73223 log_packet_detailed("'integrates' field error detected");
73224 }
73225
73226#ifdef FREECIV_JSON_CONNECTION
73227 field_addr.name = "flags";
73228#endif /* FREECIV_JSON_CONNECTION */
73229 e = 0;
73230
73231 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
73232
73233 if (e) {
73234 log_packet_detailed("'flags' field error detected");
73235 }
73236#endif /* FREECIV_DELTA_PROTOCOL */
73237
73238 SEND_PACKET_END(PACKET_RULESET_ROAD);
73239}
73240
73241 int send_packet_ruleset_road(struct connection *pc, const struct packet_ruleset_road *packet)
73242{
73243 if (!pc->used) {
73244 log_error("WARNING: trying to send data to the closed connection %s",
73245 conn_description(pc));
73246 return -1;
73247 }
73248 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ROAD].packet != nullptr, -1,
73249 "Handler for PACKET_RULESET_ROAD not installed");
73250 return pc->phs.handlers->send[PACKET_RULESET_ROAD].packet(pc, packet);
73251}
73252
73253 void lsend_packet_ruleset_road(struct conn_list *dest, const struct packet_ruleset_road *packet)
73254{
73255 conn_list_iterate(dest, pconn) {
73256 send_packet_ruleset_road(pconn, packet);
73257 } conn_list_iterate_end;
73258}
73259
73260 static inline void init_packet_ruleset_goods(struct packet_ruleset_goods *packet)
73261{
73262 memset(packet, 0, sizeof(*packet));
73263
73264 requirement_vector_init(&packet->reqs);
73265 packet->helptext = strvec_new();
73266}
73267
73268 static inline void free_packet_ruleset_goods(struct packet_ruleset_goods *packet)
73269{
73270 if (packet->helptext) {
73271 strvec_destroy(packet->helptext);
73272 packet->helptext = nullptr;
73273 }
73274 requirement_vector_free(&packet->reqs);
73275}
73276
73277 static inline void destroy_packet_ruleset_goods(void *packet)
73278{
73279 free_packet_ruleset_goods((struct packet_ruleset_goods *) packet);
73280 free(packet);
73281}
73282
73283#ifdef FREECIV_DELTA_PROTOCOL
73284#define hash_packet_ruleset_goods_100 hash_const
73285#define cmp_packet_ruleset_goods_100 cmp_const
73286 BV_DEFINE(packet_ruleset_goods_100_fields, 10);
73287#endif /* FREECIV_DELTA_PROTOCOL */
73288
73289 static struct packet_ruleset_goods *receive_packet_ruleset_goods_100(struct connection *pc)
73290{
73291#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_goods(_packet)
73292 RECEIVE_PACKET_START(packet_ruleset_goods, real_packet);
73293
73294#ifdef FREECIV_JSON_CONNECTION
73295 struct plocation field_addr;
73296 {
73297 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
73298 field_addr = *field_addr_tmp;
73299 FC_FREE(field_addr_tmp);
73300 }
73301#endif /* FREECIV_JSON_CONNECTION */
73302
73303 log_packet_detailed("packet_ruleset_goods_100: got info about ()");
73304
73305#ifdef FREECIV_DELTA_PROTOCOL
73306 packet_ruleset_goods_100_fields fields;
73307 struct packet_ruleset_goods *old;
73308 struct genhash **hash = pc->phs.received + PACKET_RULESET_GOODS;
73309
73310 if (nullptr == *hash) {
73311 *hash = genhash_new_full(hash_packet_ruleset_goods_100, cmp_packet_ruleset_goods_100,
73312 nullptr, nullptr, nullptr, destroy_packet_ruleset_goods);
73313 }
73314
73315 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
73316 real_packet->id = old->id;
73317 sz_strlcpy(real_packet->name, old->name);
73318 sz_strlcpy(real_packet->rule_name, old->rule_name);
73319 requirement_vector_copy(&real_packet->reqs, &old->reqs);
73320 real_packet->from_pct = old->from_pct;
73321 real_packet->to_pct = old->to_pct;
73322 real_packet->onetime_pct = old->onetime_pct;
73323 real_packet->select_priority = old->select_priority;
73324 real_packet->flags = old->flags;
73325 if (old->helptext) {
73326 strvec_copy(real_packet->helptext, old->helptext);
73327 } else {
73328 strvec_clear(real_packet->helptext);
73329 }
73330 } else {
73331 /* packet is already initialized empty */
73332 log_packet_detailed(" no old info");
73333 }
73334
73335#ifdef FREECIV_JSON_CONNECTION
73336 field_addr.name = "fields";
73337#endif /* FREECIV_JSON_CONNECTION */
73338 DIO_BV_GET(&din, &field_addr, fields);
73339
73340 if (BV_ISSET(fields, 0)) {
73341 log_packet_detailed(" got field 'id'");
73342
73343#ifdef FREECIV_JSON_CONNECTION
73344 field_addr.name = "id";
73345#endif /* FREECIV_JSON_CONNECTION */
73346
73347 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
73348 RECEIVE_PACKET_FIELD_ERROR(id);
73349 }
73350 }
73351
73352 if (BV_ISSET(fields, 1)) {
73353 log_packet_detailed(" got field 'name'");
73354
73355#ifdef FREECIV_JSON_CONNECTION
73356 field_addr.name = "name";
73357#endif /* FREECIV_JSON_CONNECTION */
73358
73359 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
73360 RECEIVE_PACKET_FIELD_ERROR(name);
73361 }
73362 }
73363
73364 if (BV_ISSET(fields, 2)) {
73365 log_packet_detailed(" got field 'rule_name'");
73366
73367#ifdef FREECIV_JSON_CONNECTION
73368 field_addr.name = "rule_name";
73369#endif /* FREECIV_JSON_CONNECTION */
73370
73371 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
73372 RECEIVE_PACKET_FIELD_ERROR(rule_name);
73373 }
73374 }
73375
73376 if (BV_ISSET(fields, 3)) {
73377 log_packet_detailed(" got field 'reqs'");
73378
73379#ifdef FREECIV_JSON_CONNECTION
73380 field_addr.name = "reqs";
73381#endif /* FREECIV_JSON_CONNECTION */
73382
73383 {
73384 int i;
73385
73386 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
73387 RECEIVE_PACKET_FIELD_ERROR(reqs);
73388 }
73389 requirement_vector_reserve(&real_packet->reqs, i);
73390
73391#ifdef FREECIV_JSON_CONNECTION
73392 /* Enter array. */
73393 field_addr.sub_location = plocation_elem_new(0);
73394#endif /* FREECIV_JSON_CONNECTION */
73395
73396 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
73397#ifdef FREECIV_JSON_CONNECTION
73398 /* Next array element */
73399 field_addr.sub_location->number = i;
73400#endif /* FREECIV_JSON_CONNECTION */
73401
73402 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
73403 RECEIVE_PACKET_FIELD_ERROR(reqs);
73404 }
73405 }
73406
73407#ifdef FREECIV_JSON_CONNECTION
73408 /* Exit array. */
73409 FC_FREE(field_addr.sub_location);
73410#endif /* FREECIV_JSON_CONNECTION */
73411 }
73412 }
73413
73414 if (BV_ISSET(fields, 4)) {
73415 log_packet_detailed(" got field 'from_pct'");
73416
73417#ifdef FREECIV_JSON_CONNECTION
73418 field_addr.name = "from_pct";
73419#endif /* FREECIV_JSON_CONNECTION */
73420
73421 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->from_pct)) {
73422 RECEIVE_PACKET_FIELD_ERROR(from_pct);
73423 }
73424 }
73425
73426 if (BV_ISSET(fields, 5)) {
73427 log_packet_detailed(" got field 'to_pct'");
73428
73429#ifdef FREECIV_JSON_CONNECTION
73430 field_addr.name = "to_pct";
73431#endif /* FREECIV_JSON_CONNECTION */
73432
73433 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->to_pct)) {
73434 RECEIVE_PACKET_FIELD_ERROR(to_pct);
73435 }
73436 }
73437
73438 if (BV_ISSET(fields, 6)) {
73439 log_packet_detailed(" got field 'onetime_pct'");
73440
73441#ifdef FREECIV_JSON_CONNECTION
73442 field_addr.name = "onetime_pct";
73443#endif /* FREECIV_JSON_CONNECTION */
73444
73445 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->onetime_pct)) {
73446 RECEIVE_PACKET_FIELD_ERROR(onetime_pct);
73447 }
73448 }
73449
73450 if (BV_ISSET(fields, 7)) {
73451 log_packet_detailed(" got field 'select_priority'");
73452
73453#ifdef FREECIV_JSON_CONNECTION
73454 field_addr.name = "select_priority";
73455#endif /* FREECIV_JSON_CONNECTION */
73456
73457 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->select_priority)) {
73458 RECEIVE_PACKET_FIELD_ERROR(select_priority);
73459 }
73460 }
73461
73462 if (BV_ISSET(fields, 8)) {
73463 log_packet_detailed(" got field 'flags'");
73464
73465#ifdef FREECIV_JSON_CONNECTION
73466 field_addr.name = "flags";
73467#endif /* FREECIV_JSON_CONNECTION */
73468
73469 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
73470 RECEIVE_PACKET_FIELD_ERROR(flags);
73471 }
73472 }
73473
73474 if (BV_ISSET(fields, 9)) {
73475 log_packet_detailed(" got field 'helptext'");
73476
73477#ifdef FREECIV_JSON_CONNECTION
73478 field_addr.name = "helptext";
73479#endif /* FREECIV_JSON_CONNECTION */
73480
73481 {
73482 int i;
73483
73484 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
73485 RECEIVE_PACKET_FIELD_ERROR(helptext);
73486 }
73487 strvec_reserve(real_packet->helptext, i);
73488
73489#ifdef FREECIV_JSON_CONNECTION
73490 /* Enter array. */
73491 field_addr.sub_location = plocation_elem_new(0);
73492#endif /* FREECIV_JSON_CONNECTION */
73493
73494 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
73495#ifdef FREECIV_JSON_CONNECTION
73496 /* Next array element */
73497 field_addr.sub_location->number = i;
73498#endif /* FREECIV_JSON_CONNECTION */
73499
73500 {
73501 char readin[MAX_LEN_PACKET];
73502
73503 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
73504 || !strvec_set(real_packet->helptext, i, readin)) {
73505 RECEIVE_PACKET_FIELD_ERROR(helptext);
73506 }
73507 }
73508 }
73509
73510#ifdef FREECIV_JSON_CONNECTION
73511 /* Exit array. */
73512 FC_FREE(field_addr.sub_location);
73513#endif /* FREECIV_JSON_CONNECTION */
73514 }
73515 }
73516
73517 if (nullptr == old) {
73518 old = fc_malloc(sizeof(*old));
73519 init_packet_ruleset_goods(old);
73520 old->id = real_packet->id;
73521 sz_strlcpy(old->name, real_packet->name);
73522 sz_strlcpy(old->rule_name, real_packet->rule_name);
73523 requirement_vector_copy(&old->reqs, &real_packet->reqs);
73524 old->from_pct = real_packet->from_pct;
73525 old->to_pct = real_packet->to_pct;
73526 old->onetime_pct = real_packet->onetime_pct;
73527 old->select_priority = real_packet->select_priority;
73528 old->flags = real_packet->flags;
73529 if (real_packet->helptext) {
73530 strvec_copy(old->helptext, real_packet->helptext);
73531 } else {
73532 strvec_clear(old->helptext);
73533 }
73534 genhash_insert(*hash, old, old);
73535 } else {
73536 old->id = real_packet->id;
73537 sz_strlcpy(old->name, real_packet->name);
73538 sz_strlcpy(old->rule_name, real_packet->rule_name);
73539 requirement_vector_copy(&old->reqs, &real_packet->reqs);
73540 old->from_pct = real_packet->from_pct;
73541 old->to_pct = real_packet->to_pct;
73542 old->onetime_pct = real_packet->onetime_pct;
73543 old->select_priority = real_packet->select_priority;
73544 old->flags = real_packet->flags;
73545 if (real_packet->helptext) {
73546 strvec_copy(old->helptext, real_packet->helptext);
73547 } else {
73548 strvec_clear(old->helptext);
73549 }
73550 }
73551
73552#else /* FREECIV_DELTA_PROTOCOL */
73553#ifdef FREECIV_JSON_CONNECTION
73554 field_addr.name = "id";
73555#endif /* FREECIV_JSON_CONNECTION */
73556
73557 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
73558 RECEIVE_PACKET_FIELD_ERROR(id);
73559 }
73560
73561#ifdef FREECIV_JSON_CONNECTION
73562 field_addr.name = "name";
73563#endif /* FREECIV_JSON_CONNECTION */
73564
73565 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
73566 RECEIVE_PACKET_FIELD_ERROR(name);
73567 }
73568
73569#ifdef FREECIV_JSON_CONNECTION
73570 field_addr.name = "rule_name";
73571#endif /* FREECIV_JSON_CONNECTION */
73572
73573 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
73574 RECEIVE_PACKET_FIELD_ERROR(rule_name);
73575 }
73576
73577#ifdef FREECIV_JSON_CONNECTION
73578 field_addr.name = "reqs";
73579#endif /* FREECIV_JSON_CONNECTION */
73580
73581 {
73582 int i;
73583
73584 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
73585 RECEIVE_PACKET_FIELD_ERROR(reqs);
73586 }
73587 requirement_vector_reserve(&real_packet->reqs, i);
73588
73589#ifdef FREECIV_JSON_CONNECTION
73590 /* Enter array. */
73591 field_addr.sub_location = plocation_elem_new(0);
73592#endif /* FREECIV_JSON_CONNECTION */
73593
73594 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
73595#ifdef FREECIV_JSON_CONNECTION
73596 /* Next array element */
73597 field_addr.sub_location->number = i;
73598#endif /* FREECIV_JSON_CONNECTION */
73599
73600 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
73601 RECEIVE_PACKET_FIELD_ERROR(reqs);
73602 }
73603 }
73604
73605#ifdef FREECIV_JSON_CONNECTION
73606 /* Exit array. */
73607 FC_FREE(field_addr.sub_location);
73608#endif /* FREECIV_JSON_CONNECTION */
73609 }
73610
73611#ifdef FREECIV_JSON_CONNECTION
73612 field_addr.name = "from_pct";
73613#endif /* FREECIV_JSON_CONNECTION */
73614
73615 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->from_pct)) {
73616 RECEIVE_PACKET_FIELD_ERROR(from_pct);
73617 }
73618
73619#ifdef FREECIV_JSON_CONNECTION
73620 field_addr.name = "to_pct";
73621#endif /* FREECIV_JSON_CONNECTION */
73622
73623 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->to_pct)) {
73624 RECEIVE_PACKET_FIELD_ERROR(to_pct);
73625 }
73626
73627#ifdef FREECIV_JSON_CONNECTION
73628 field_addr.name = "onetime_pct";
73629#endif /* FREECIV_JSON_CONNECTION */
73630
73631 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->onetime_pct)) {
73632 RECEIVE_PACKET_FIELD_ERROR(onetime_pct);
73633 }
73634
73635#ifdef FREECIV_JSON_CONNECTION
73636 field_addr.name = "select_priority";
73637#endif /* FREECIV_JSON_CONNECTION */
73638
73639 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->select_priority)) {
73640 RECEIVE_PACKET_FIELD_ERROR(select_priority);
73641 }
73642
73643#ifdef FREECIV_JSON_CONNECTION
73644 field_addr.name = "flags";
73645#endif /* FREECIV_JSON_CONNECTION */
73646
73647 if (!DIO_BV_GET(&din, &field_addr, real_packet->flags)) {
73648 RECEIVE_PACKET_FIELD_ERROR(flags);
73649 }
73650
73651#ifdef FREECIV_JSON_CONNECTION
73652 field_addr.name = "helptext";
73653#endif /* FREECIV_JSON_CONNECTION */
73654
73655 {
73656 int i;
73657
73658 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
73659 RECEIVE_PACKET_FIELD_ERROR(helptext);
73660 }
73661 strvec_reserve(real_packet->helptext, i);
73662
73663#ifdef FREECIV_JSON_CONNECTION
73664 /* Enter array. */
73665 field_addr.sub_location = plocation_elem_new(0);
73666#endif /* FREECIV_JSON_CONNECTION */
73667
73668 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
73669#ifdef FREECIV_JSON_CONNECTION
73670 /* Next array element */
73671 field_addr.sub_location->number = i;
73672#endif /* FREECIV_JSON_CONNECTION */
73673
73674 {
73675 char readin[MAX_LEN_PACKET];
73676
73677 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
73678 || !strvec_set(real_packet->helptext, i, readin)) {
73679 RECEIVE_PACKET_FIELD_ERROR(helptext);
73680 }
73681 }
73682 }
73683
73684#ifdef FREECIV_JSON_CONNECTION
73685 /* Exit array. */
73686 FC_FREE(field_addr.sub_location);
73687#endif /* FREECIV_JSON_CONNECTION */
73688 }
73689#endif /* FREECIV_DELTA_PROTOCOL */
73690
73691 RECEIVE_PACKET_END(real_packet);
73692#undef FREE_PACKET_STRUCT
73693}
73694
73695 static int send_packet_ruleset_goods_100(struct connection *pc, const struct packet_ruleset_goods *packet)
73696{
73697 const struct packet_ruleset_goods *real_packet = packet;
73698 int e;
73699 SEND_PACKET_START(PACKET_RULESET_GOODS);
73700
73701 log_packet_detailed("packet_ruleset_goods_100: sending info about ()");
73702
73703#ifdef FREECIV_DELTA_PROTOCOL
73704 packet_ruleset_goods_100_fields fields;
73705 struct packet_ruleset_goods *old;
73706 bool differ;
73707 struct genhash **hash = pc->phs.sent + PACKET_RULESET_GOODS;
73708
73709 if (nullptr == *hash) {
73710 *hash = genhash_new_full(hash_packet_ruleset_goods_100, cmp_packet_ruleset_goods_100,
73711 nullptr, nullptr, nullptr, destroy_packet_ruleset_goods);
73712 }
73713 BV_CLR_ALL(fields);
73714
73715 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
73716 old = fc_malloc(sizeof(*old));
73717 /* temporary bitcopy just to insert correctly */
73718 *old = *real_packet;
73719 genhash_insert(*hash, old, old);
73720 init_packet_ruleset_goods(old);
73721 }
73722
73723 differ = (old->id != real_packet->id);
73724 if (differ) {
73725 BV_SET(fields, 0);
73726 }
73727
73728 differ = (strcmp(old->name, real_packet->name) != 0);
73729 if (differ) {
73730 BV_SET(fields, 1);
73731 }
73732
73733 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
73734 if (differ) {
73735 BV_SET(fields, 2);
73736 }
73737
73738 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
73739 if (!differ) {
73740 int i;
73741
73742 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
73743 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
73744 if (differ) {
73745 break;
73746 }
73747 }
73748 }
73749 if (differ) {
73750 BV_SET(fields, 3);
73751 }
73752
73753 differ = (old->from_pct != real_packet->from_pct);
73754 if (differ) {
73755 BV_SET(fields, 4);
73756 }
73757
73758 differ = (old->to_pct != real_packet->to_pct);
73759 if (differ) {
73760 BV_SET(fields, 5);
73761 }
73762
73763 differ = (old->onetime_pct != real_packet->onetime_pct);
73764 if (differ) {
73765 BV_SET(fields, 6);
73766 }
73767
73768 differ = (old->select_priority != real_packet->select_priority);
73769 if (differ) {
73770 BV_SET(fields, 7);
73771 }
73772
73773 differ = !BV_ARE_EQUAL(old->flags, real_packet->flags);
73774 if (differ) {
73775 BV_SET(fields, 8);
73776 }
73777
73778 if (real_packet->helptext) {
73779 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
73780 } else {
73781 differ = (strvec_size(old->helptext) > 0);
73782 }
73783 if (differ) {
73784 BV_SET(fields, 9);
73785 }
73786#endif /* FREECIV_DELTA_PROTOCOL */
73787
73788#ifdef FREECIV_JSON_CONNECTION
73789 struct plocation field_addr;
73790 {
73791 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
73792 field_addr = *field_addr_tmp;
73793 FC_FREE(field_addr_tmp);
73794 }
73795#endif /* FREECIV_JSON_CONNECTION */
73796
73797#ifdef FREECIV_DELTA_PROTOCOL
73798#ifdef FREECIV_JSON_CONNECTION
73799 field_addr.name = "fields";
73800#endif /* FREECIV_JSON_CONNECTION */
73801 e = 0;
73802 e |= DIO_BV_PUT(&dout, &field_addr, fields);
73803 if (e) {
73804 log_packet_detailed("fields bitvector error detected");
73805 }
73806
73807 if (BV_ISSET(fields, 0)) {
73808 log_packet_detailed(" field 'id' has changed");
73809
73810#ifdef FREECIV_JSON_CONNECTION
73811 field_addr.name = "id";
73812#endif /* FREECIV_JSON_CONNECTION */
73813 e = 0;
73814
73815 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
73816
73817 if (e) {
73818 log_packet_detailed("'id' field error detected");
73819 }
73820 }
73821
73822 if (BV_ISSET(fields, 1)) {
73823 log_packet_detailed(" field 'name' has changed");
73824
73825#ifdef FREECIV_JSON_CONNECTION
73826 field_addr.name = "name";
73827#endif /* FREECIV_JSON_CONNECTION */
73828 e = 0;
73829
73830 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
73831
73832 if (e) {
73833 log_packet_detailed("'name' field error detected");
73834 }
73835 }
73836
73837 if (BV_ISSET(fields, 2)) {
73838 log_packet_detailed(" field 'rule_name' has changed");
73839
73840#ifdef FREECIV_JSON_CONNECTION
73841 field_addr.name = "rule_name";
73842#endif /* FREECIV_JSON_CONNECTION */
73843 e = 0;
73844
73845 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
73846
73847 if (e) {
73848 log_packet_detailed("'rule_name' field error detected");
73849 }
73850 }
73851
73852 if (BV_ISSET(fields, 3)) {
73853 log_packet_detailed(" field 'reqs' has changed");
73854
73855#ifdef FREECIV_JSON_CONNECTION
73856 field_addr.name = "reqs";
73857#endif /* FREECIV_JSON_CONNECTION */
73858 e = 0;
73859
73860 {
73861 int i;
73862
73863 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
73864 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
73865
73866#ifdef FREECIV_JSON_CONNECTION
73867 /* Enter array. */
73868 field_addr.sub_location = plocation_elem_new(0);
73869#endif /* FREECIV_JSON_CONNECTION */
73870
73871 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
73872#ifdef FREECIV_JSON_CONNECTION
73873 /* Next array element. */
73874 field_addr.sub_location->number = i;
73875#endif /* FREECIV_JSON_CONNECTION */
73876
73877 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
73878 }
73879
73880#ifdef FREECIV_JSON_CONNECTION
73881 /* Exit array. */
73882 FC_FREE(field_addr.sub_location);
73883#endif /* FREECIV_JSON_CONNECTION */
73884 }
73885
73886 if (e) {
73887 log_packet_detailed("'reqs' field error detected");
73888 }
73889 }
73890
73891 if (BV_ISSET(fields, 4)) {
73892 log_packet_detailed(" field 'from_pct' has changed");
73893
73894#ifdef FREECIV_JSON_CONNECTION
73895 field_addr.name = "from_pct";
73896#endif /* FREECIV_JSON_CONNECTION */
73897 e = 0;
73898
73899 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->from_pct);
73900
73901 if (e) {
73902 log_packet_detailed("'from_pct' field error detected");
73903 }
73904 }
73905
73906 if (BV_ISSET(fields, 5)) {
73907 log_packet_detailed(" field 'to_pct' has changed");
73908
73909#ifdef FREECIV_JSON_CONNECTION
73910 field_addr.name = "to_pct";
73911#endif /* FREECIV_JSON_CONNECTION */
73912 e = 0;
73913
73914 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->to_pct);
73915
73916 if (e) {
73917 log_packet_detailed("'to_pct' field error detected");
73918 }
73919 }
73920
73921 if (BV_ISSET(fields, 6)) {
73922 log_packet_detailed(" field 'onetime_pct' has changed");
73923
73924#ifdef FREECIV_JSON_CONNECTION
73925 field_addr.name = "onetime_pct";
73926#endif /* FREECIV_JSON_CONNECTION */
73927 e = 0;
73928
73929 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->onetime_pct);
73930
73931 if (e) {
73932 log_packet_detailed("'onetime_pct' field error detected");
73933 }
73934 }
73935
73936 if (BV_ISSET(fields, 7)) {
73937 log_packet_detailed(" field 'select_priority' has changed");
73938
73939#ifdef FREECIV_JSON_CONNECTION
73940 field_addr.name = "select_priority";
73941#endif /* FREECIV_JSON_CONNECTION */
73942 e = 0;
73943
73944 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->select_priority);
73945
73946 if (e) {
73947 log_packet_detailed("'select_priority' field error detected");
73948 }
73949 }
73950
73951 if (BV_ISSET(fields, 8)) {
73952 log_packet_detailed(" field 'flags' has changed");
73953
73954#ifdef FREECIV_JSON_CONNECTION
73955 field_addr.name = "flags";
73956#endif /* FREECIV_JSON_CONNECTION */
73957 e = 0;
73958
73959 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
73960
73961 if (e) {
73962 log_packet_detailed("'flags' field error detected");
73963 }
73964 }
73965
73966 if (BV_ISSET(fields, 9)) {
73967 log_packet_detailed(" field 'helptext' has changed");
73968
73969#ifdef FREECIV_JSON_CONNECTION
73970 field_addr.name = "helptext";
73971#endif /* FREECIV_JSON_CONNECTION */
73972 e = 0;
73973
73974 if (!real_packet->helptext) {
73975 /* Transmit null as empty */
73976 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
73977 } else {
73978 int i;
73979
73980 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
73981 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
73982
73983#ifdef FREECIV_JSON_CONNECTION
73984 /* Enter array. */
73985 field_addr.sub_location = plocation_elem_new(0);
73986#endif /* FREECIV_JSON_CONNECTION */
73987
73988 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
73989#ifdef FREECIV_JSON_CONNECTION
73990 /* Next array element. */
73991 field_addr.sub_location->number = i;
73992#endif /* FREECIV_JSON_CONNECTION */
73993
73994 {
73995 const char *pstr = strvec_get(real_packet->helptext, i);
73996
73997 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
73998 }
73999 }
74000
74001#ifdef FREECIV_JSON_CONNECTION
74002 /* Exit array. */
74003 FC_FREE(field_addr.sub_location);
74004#endif /* FREECIV_JSON_CONNECTION */
74005 }
74006
74007 if (e) {
74008 log_packet_detailed("'helptext' field error detected");
74009 }
74010 }
74011
74012 old->id = real_packet->id;
74013 sz_strlcpy(old->name, real_packet->name);
74014 sz_strlcpy(old->rule_name, real_packet->rule_name);
74015 requirement_vector_copy(&old->reqs, &real_packet->reqs);
74016 old->from_pct = real_packet->from_pct;
74017 old->to_pct = real_packet->to_pct;
74018 old->onetime_pct = real_packet->onetime_pct;
74019 old->select_priority = real_packet->select_priority;
74020 old->flags = real_packet->flags;
74021 if (real_packet->helptext) {
74022 strvec_copy(old->helptext, real_packet->helptext);
74023 } else {
74024 strvec_clear(old->helptext);
74025 }
74026
74027#else /* FREECIV_DELTA_PROTOCOL */
74028#ifdef FREECIV_JSON_CONNECTION
74029 field_addr.name = "id";
74030#endif /* FREECIV_JSON_CONNECTION */
74031 e = 0;
74032
74033 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
74034
74035 if (e) {
74036 log_packet_detailed("'id' field error detected");
74037 }
74038
74039#ifdef FREECIV_JSON_CONNECTION
74040 field_addr.name = "name";
74041#endif /* FREECIV_JSON_CONNECTION */
74042 e = 0;
74043
74044 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
74045
74046 if (e) {
74047 log_packet_detailed("'name' field error detected");
74048 }
74049
74050#ifdef FREECIV_JSON_CONNECTION
74051 field_addr.name = "rule_name";
74052#endif /* FREECIV_JSON_CONNECTION */
74053 e = 0;
74054
74055 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
74056
74057 if (e) {
74058 log_packet_detailed("'rule_name' field error detected");
74059 }
74060
74061#ifdef FREECIV_JSON_CONNECTION
74062 field_addr.name = "reqs";
74063#endif /* FREECIV_JSON_CONNECTION */
74064 e = 0;
74065
74066 {
74067 int i;
74068
74069 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
74070 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
74071
74072#ifdef FREECIV_JSON_CONNECTION
74073 /* Enter array. */
74074 field_addr.sub_location = plocation_elem_new(0);
74075#endif /* FREECIV_JSON_CONNECTION */
74076
74077 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
74078#ifdef FREECIV_JSON_CONNECTION
74079 /* Next array element. */
74080 field_addr.sub_location->number = i;
74081#endif /* FREECIV_JSON_CONNECTION */
74082
74083 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
74084 }
74085
74086#ifdef FREECIV_JSON_CONNECTION
74087 /* Exit array. */
74088 FC_FREE(field_addr.sub_location);
74089#endif /* FREECIV_JSON_CONNECTION */
74090 }
74091
74092 if (e) {
74093 log_packet_detailed("'reqs' field error detected");
74094 }
74095
74096#ifdef FREECIV_JSON_CONNECTION
74097 field_addr.name = "from_pct";
74098#endif /* FREECIV_JSON_CONNECTION */
74099 e = 0;
74100
74101 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->from_pct);
74102
74103 if (e) {
74104 log_packet_detailed("'from_pct' field error detected");
74105 }
74106
74107#ifdef FREECIV_JSON_CONNECTION
74108 field_addr.name = "to_pct";
74109#endif /* FREECIV_JSON_CONNECTION */
74110 e = 0;
74111
74112 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->to_pct);
74113
74114 if (e) {
74115 log_packet_detailed("'to_pct' field error detected");
74116 }
74117
74118#ifdef FREECIV_JSON_CONNECTION
74119 field_addr.name = "onetime_pct";
74120#endif /* FREECIV_JSON_CONNECTION */
74121 e = 0;
74122
74123 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->onetime_pct);
74124
74125 if (e) {
74126 log_packet_detailed("'onetime_pct' field error detected");
74127 }
74128
74129#ifdef FREECIV_JSON_CONNECTION
74130 field_addr.name = "select_priority";
74131#endif /* FREECIV_JSON_CONNECTION */
74132 e = 0;
74133
74134 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->select_priority);
74135
74136 if (e) {
74137 log_packet_detailed("'select_priority' field error detected");
74138 }
74139
74140#ifdef FREECIV_JSON_CONNECTION
74141 field_addr.name = "flags";
74142#endif /* FREECIV_JSON_CONNECTION */
74143 e = 0;
74144
74145 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->flags);
74146
74147 if (e) {
74148 log_packet_detailed("'flags' field error detected");
74149 }
74150
74151#ifdef FREECIV_JSON_CONNECTION
74152 field_addr.name = "helptext";
74153#endif /* FREECIV_JSON_CONNECTION */
74154 e = 0;
74155
74156 if (!real_packet->helptext) {
74157 /* Transmit null as empty */
74158 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
74159 } else {
74160 int i;
74161
74162 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
74163 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
74164
74165#ifdef FREECIV_JSON_CONNECTION
74166 /* Enter array. */
74167 field_addr.sub_location = plocation_elem_new(0);
74168#endif /* FREECIV_JSON_CONNECTION */
74169
74170 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
74171#ifdef FREECIV_JSON_CONNECTION
74172 /* Next array element. */
74173 field_addr.sub_location->number = i;
74174#endif /* FREECIV_JSON_CONNECTION */
74175
74176 {
74177 const char *pstr = strvec_get(real_packet->helptext, i);
74178
74179 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
74180 }
74181 }
74182
74183#ifdef FREECIV_JSON_CONNECTION
74184 /* Exit array. */
74185 FC_FREE(field_addr.sub_location);
74186#endif /* FREECIV_JSON_CONNECTION */
74187 }
74188
74189 if (e) {
74190 log_packet_detailed("'helptext' field error detected");
74191 }
74192#endif /* FREECIV_DELTA_PROTOCOL */
74193
74194 SEND_PACKET_END(PACKET_RULESET_GOODS);
74195}
74196
74197 int send_packet_ruleset_goods(struct connection *pc, const struct packet_ruleset_goods *packet)
74198{
74199 if (!pc->used) {
74200 log_error("WARNING: trying to send data to the closed connection %s",
74201 conn_description(pc));
74202 return -1;
74203 }
74204 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_GOODS].packet != nullptr, -1,
74205 "Handler for PACKET_RULESET_GOODS not installed");
74206 return pc->phs.handlers->send[PACKET_RULESET_GOODS].packet(pc, packet);
74207}
74208
74209 void lsend_packet_ruleset_goods(struct conn_list *dest, const struct packet_ruleset_goods *packet)
74210{
74211 conn_list_iterate(dest, pconn) {
74212 send_packet_ruleset_goods(pconn, packet);
74213 } conn_list_iterate_end;
74214}
74215
74216 static inline void init_packet_ruleset_disaster(struct packet_ruleset_disaster *packet)
74217{
74218 memset(packet, 0, sizeof(*packet));
74219
74220 requirement_vector_init(&packet->reqs);
74221}
74222
74223 static inline void free_packet_ruleset_disaster(struct packet_ruleset_disaster *packet)
74224{
74225 requirement_vector_free(&packet->reqs);
74226}
74227
74228 static inline void destroy_packet_ruleset_disaster(void *packet)
74229{
74230 free_packet_ruleset_disaster((struct packet_ruleset_disaster *) packet);
74231 free(packet);
74232}
74233
74234#ifdef FREECIV_DELTA_PROTOCOL
74235#define hash_packet_ruleset_disaster_100 hash_const
74236#define cmp_packet_ruleset_disaster_100 cmp_const
74237 BV_DEFINE(packet_ruleset_disaster_100_fields, 6);
74238#endif /* FREECIV_DELTA_PROTOCOL */
74239
74240 static struct packet_ruleset_disaster *receive_packet_ruleset_disaster_100(struct connection *pc)
74241{
74242#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_disaster(_packet)
74243 RECEIVE_PACKET_START(packet_ruleset_disaster, real_packet);
74244
74245#ifdef FREECIV_JSON_CONNECTION
74246 struct plocation field_addr;
74247 {
74248 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
74249 field_addr = *field_addr_tmp;
74250 FC_FREE(field_addr_tmp);
74251 }
74252#endif /* FREECIV_JSON_CONNECTION */
74253
74254 log_packet_detailed("packet_ruleset_disaster_100: got info about ()");
74255
74256#ifdef FREECIV_DELTA_PROTOCOL
74257 packet_ruleset_disaster_100_fields fields;
74258 struct packet_ruleset_disaster *old;
74259 struct genhash **hash = pc->phs.received + PACKET_RULESET_DISASTER;
74260
74261 if (nullptr == *hash) {
74262 *hash = genhash_new_full(hash_packet_ruleset_disaster_100, cmp_packet_ruleset_disaster_100,
74263 nullptr, nullptr, nullptr, destroy_packet_ruleset_disaster);
74264 }
74265
74266 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
74267 real_packet->id = old->id;
74268 sz_strlcpy(real_packet->name, old->name);
74269 sz_strlcpy(real_packet->rule_name, old->rule_name);
74270 requirement_vector_copy(&real_packet->reqs, &old->reqs);
74271 real_packet->frequency = old->frequency;
74272 real_packet->effects = old->effects;
74273 } else {
74274 /* packet is already initialized empty */
74275 log_packet_detailed(" no old info");
74276 }
74277
74278#ifdef FREECIV_JSON_CONNECTION
74279 field_addr.name = "fields";
74280#endif /* FREECIV_JSON_CONNECTION */
74281 DIO_BV_GET(&din, &field_addr, fields);
74282
74283 if (BV_ISSET(fields, 0)) {
74284 log_packet_detailed(" got field 'id'");
74285
74286#ifdef FREECIV_JSON_CONNECTION
74287 field_addr.name = "id";
74288#endif /* FREECIV_JSON_CONNECTION */
74289
74290 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
74291 RECEIVE_PACKET_FIELD_ERROR(id);
74292 }
74293 }
74294
74295 if (BV_ISSET(fields, 1)) {
74296 log_packet_detailed(" got field 'name'");
74297
74298#ifdef FREECIV_JSON_CONNECTION
74299 field_addr.name = "name";
74300#endif /* FREECIV_JSON_CONNECTION */
74301
74302 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
74303 RECEIVE_PACKET_FIELD_ERROR(name);
74304 }
74305 }
74306
74307 if (BV_ISSET(fields, 2)) {
74308 log_packet_detailed(" got field 'rule_name'");
74309
74310#ifdef FREECIV_JSON_CONNECTION
74311 field_addr.name = "rule_name";
74312#endif /* FREECIV_JSON_CONNECTION */
74313
74314 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
74315 RECEIVE_PACKET_FIELD_ERROR(rule_name);
74316 }
74317 }
74318
74319 if (BV_ISSET(fields, 3)) {
74320 log_packet_detailed(" got field 'reqs'");
74321
74322#ifdef FREECIV_JSON_CONNECTION
74323 field_addr.name = "reqs";
74324#endif /* FREECIV_JSON_CONNECTION */
74325
74326 {
74327 int i;
74328
74329 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
74330 RECEIVE_PACKET_FIELD_ERROR(reqs);
74331 }
74332 requirement_vector_reserve(&real_packet->reqs, i);
74333
74334#ifdef FREECIV_JSON_CONNECTION
74335 /* Enter array. */
74336 field_addr.sub_location = plocation_elem_new(0);
74337#endif /* FREECIV_JSON_CONNECTION */
74338
74339 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
74340#ifdef FREECIV_JSON_CONNECTION
74341 /* Next array element */
74342 field_addr.sub_location->number = i;
74343#endif /* FREECIV_JSON_CONNECTION */
74344
74345 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
74346 RECEIVE_PACKET_FIELD_ERROR(reqs);
74347 }
74348 }
74349
74350#ifdef FREECIV_JSON_CONNECTION
74351 /* Exit array. */
74352 FC_FREE(field_addr.sub_location);
74353#endif /* FREECIV_JSON_CONNECTION */
74354 }
74355 }
74356
74357 if (BV_ISSET(fields, 4)) {
74358 log_packet_detailed(" got field 'frequency'");
74359
74360#ifdef FREECIV_JSON_CONNECTION
74361 field_addr.name = "frequency";
74362#endif /* FREECIV_JSON_CONNECTION */
74363
74364 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->frequency)) {
74365 RECEIVE_PACKET_FIELD_ERROR(frequency);
74366 }
74367 }
74368
74369 if (BV_ISSET(fields, 5)) {
74370 log_packet_detailed(" got field 'effects'");
74371
74372#ifdef FREECIV_JSON_CONNECTION
74373 field_addr.name = "effects";
74374#endif /* FREECIV_JSON_CONNECTION */
74375
74376 if (!DIO_BV_GET(&din, &field_addr, real_packet->effects)) {
74377 RECEIVE_PACKET_FIELD_ERROR(effects);
74378 }
74379 }
74380
74381 if (nullptr == old) {
74382 old = fc_malloc(sizeof(*old));
74383 init_packet_ruleset_disaster(old);
74384 old->id = real_packet->id;
74385 sz_strlcpy(old->name, real_packet->name);
74386 sz_strlcpy(old->rule_name, real_packet->rule_name);
74387 requirement_vector_copy(&old->reqs, &real_packet->reqs);
74388 old->frequency = real_packet->frequency;
74389 old->effects = real_packet->effects;
74390 genhash_insert(*hash, old, old);
74391 } else {
74392 old->id = real_packet->id;
74393 sz_strlcpy(old->name, real_packet->name);
74394 sz_strlcpy(old->rule_name, real_packet->rule_name);
74395 requirement_vector_copy(&old->reqs, &real_packet->reqs);
74396 old->frequency = real_packet->frequency;
74397 old->effects = real_packet->effects;
74398 }
74399
74400#else /* FREECIV_DELTA_PROTOCOL */
74401#ifdef FREECIV_JSON_CONNECTION
74402 field_addr.name = "id";
74403#endif /* FREECIV_JSON_CONNECTION */
74404
74405 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
74406 RECEIVE_PACKET_FIELD_ERROR(id);
74407 }
74408
74409#ifdef FREECIV_JSON_CONNECTION
74410 field_addr.name = "name";
74411#endif /* FREECIV_JSON_CONNECTION */
74412
74413 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
74414 RECEIVE_PACKET_FIELD_ERROR(name);
74415 }
74416
74417#ifdef FREECIV_JSON_CONNECTION
74418 field_addr.name = "rule_name";
74419#endif /* FREECIV_JSON_CONNECTION */
74420
74421 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
74422 RECEIVE_PACKET_FIELD_ERROR(rule_name);
74423 }
74424
74425#ifdef FREECIV_JSON_CONNECTION
74426 field_addr.name = "reqs";
74427#endif /* FREECIV_JSON_CONNECTION */
74428
74429 {
74430 int i;
74431
74432 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
74433 RECEIVE_PACKET_FIELD_ERROR(reqs);
74434 }
74435 requirement_vector_reserve(&real_packet->reqs, i);
74436
74437#ifdef FREECIV_JSON_CONNECTION
74438 /* Enter array. */
74439 field_addr.sub_location = plocation_elem_new(0);
74440#endif /* FREECIV_JSON_CONNECTION */
74441
74442 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
74443#ifdef FREECIV_JSON_CONNECTION
74444 /* Next array element */
74445 field_addr.sub_location->number = i;
74446#endif /* FREECIV_JSON_CONNECTION */
74447
74448 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
74449 RECEIVE_PACKET_FIELD_ERROR(reqs);
74450 }
74451 }
74452
74453#ifdef FREECIV_JSON_CONNECTION
74454 /* Exit array. */
74455 FC_FREE(field_addr.sub_location);
74456#endif /* FREECIV_JSON_CONNECTION */
74457 }
74458
74459#ifdef FREECIV_JSON_CONNECTION
74460 field_addr.name = "frequency";
74461#endif /* FREECIV_JSON_CONNECTION */
74462
74463 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->frequency)) {
74464 RECEIVE_PACKET_FIELD_ERROR(frequency);
74465 }
74466
74467#ifdef FREECIV_JSON_CONNECTION
74468 field_addr.name = "effects";
74469#endif /* FREECIV_JSON_CONNECTION */
74470
74471 if (!DIO_BV_GET(&din, &field_addr, real_packet->effects)) {
74472 RECEIVE_PACKET_FIELD_ERROR(effects);
74473 }
74474#endif /* FREECIV_DELTA_PROTOCOL */
74475
74476 RECEIVE_PACKET_END(real_packet);
74477#undef FREE_PACKET_STRUCT
74478}
74479
74480 static int send_packet_ruleset_disaster_100(struct connection *pc, const struct packet_ruleset_disaster *packet)
74481{
74482 const struct packet_ruleset_disaster *real_packet = packet;
74483 int e;
74484 SEND_PACKET_START(PACKET_RULESET_DISASTER);
74485
74486 log_packet_detailed("packet_ruleset_disaster_100: sending info about ()");
74487
74488#ifdef FREECIV_DELTA_PROTOCOL
74489 packet_ruleset_disaster_100_fields fields;
74490 struct packet_ruleset_disaster *old;
74491 bool differ;
74492 struct genhash **hash = pc->phs.sent + PACKET_RULESET_DISASTER;
74493
74494 if (nullptr == *hash) {
74495 *hash = genhash_new_full(hash_packet_ruleset_disaster_100, cmp_packet_ruleset_disaster_100,
74496 nullptr, nullptr, nullptr, destroy_packet_ruleset_disaster);
74497 }
74498 BV_CLR_ALL(fields);
74499
74500 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
74501 old = fc_malloc(sizeof(*old));
74502 /* temporary bitcopy just to insert correctly */
74503 *old = *real_packet;
74504 genhash_insert(*hash, old, old);
74505 init_packet_ruleset_disaster(old);
74506 }
74507
74508 differ = (old->id != real_packet->id);
74509 if (differ) {
74510 BV_SET(fields, 0);
74511 }
74512
74513 differ = (strcmp(old->name, real_packet->name) != 0);
74514 if (differ) {
74515 BV_SET(fields, 1);
74516 }
74517
74518 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
74519 if (differ) {
74520 BV_SET(fields, 2);
74521 }
74522
74523 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
74524 if (!differ) {
74525 int i;
74526
74527 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
74528 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
74529 if (differ) {
74530 break;
74531 }
74532 }
74533 }
74534 if (differ) {
74535 BV_SET(fields, 3);
74536 }
74537
74538 differ = (old->frequency != real_packet->frequency);
74539 if (differ) {
74540 BV_SET(fields, 4);
74541 }
74542
74543 differ = !BV_ARE_EQUAL(old->effects, real_packet->effects);
74544 if (differ) {
74545 BV_SET(fields, 5);
74546 }
74547#endif /* FREECIV_DELTA_PROTOCOL */
74548
74549#ifdef FREECIV_JSON_CONNECTION
74550 struct plocation field_addr;
74551 {
74552 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
74553 field_addr = *field_addr_tmp;
74554 FC_FREE(field_addr_tmp);
74555 }
74556#endif /* FREECIV_JSON_CONNECTION */
74557
74558#ifdef FREECIV_DELTA_PROTOCOL
74559#ifdef FREECIV_JSON_CONNECTION
74560 field_addr.name = "fields";
74561#endif /* FREECIV_JSON_CONNECTION */
74562 e = 0;
74563 e |= DIO_BV_PUT(&dout, &field_addr, fields);
74564 if (e) {
74565 log_packet_detailed("fields bitvector error detected");
74566 }
74567
74568 if (BV_ISSET(fields, 0)) {
74569 log_packet_detailed(" field 'id' has changed");
74570
74571#ifdef FREECIV_JSON_CONNECTION
74572 field_addr.name = "id";
74573#endif /* FREECIV_JSON_CONNECTION */
74574 e = 0;
74575
74576 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
74577
74578 if (e) {
74579 log_packet_detailed("'id' field error detected");
74580 }
74581 }
74582
74583 if (BV_ISSET(fields, 1)) {
74584 log_packet_detailed(" field 'name' has changed");
74585
74586#ifdef FREECIV_JSON_CONNECTION
74587 field_addr.name = "name";
74588#endif /* FREECIV_JSON_CONNECTION */
74589 e = 0;
74590
74591 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
74592
74593 if (e) {
74594 log_packet_detailed("'name' field error detected");
74595 }
74596 }
74597
74598 if (BV_ISSET(fields, 2)) {
74599 log_packet_detailed(" field 'rule_name' has changed");
74600
74601#ifdef FREECIV_JSON_CONNECTION
74602 field_addr.name = "rule_name";
74603#endif /* FREECIV_JSON_CONNECTION */
74604 e = 0;
74605
74606 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
74607
74608 if (e) {
74609 log_packet_detailed("'rule_name' field error detected");
74610 }
74611 }
74612
74613 if (BV_ISSET(fields, 3)) {
74614 log_packet_detailed(" field 'reqs' has changed");
74615
74616#ifdef FREECIV_JSON_CONNECTION
74617 field_addr.name = "reqs";
74618#endif /* FREECIV_JSON_CONNECTION */
74619 e = 0;
74620
74621 {
74622 int i;
74623
74624 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
74625 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
74626
74627#ifdef FREECIV_JSON_CONNECTION
74628 /* Enter array. */
74629 field_addr.sub_location = plocation_elem_new(0);
74630#endif /* FREECIV_JSON_CONNECTION */
74631
74632 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
74633#ifdef FREECIV_JSON_CONNECTION
74634 /* Next array element. */
74635 field_addr.sub_location->number = i;
74636#endif /* FREECIV_JSON_CONNECTION */
74637
74638 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
74639 }
74640
74641#ifdef FREECIV_JSON_CONNECTION
74642 /* Exit array. */
74643 FC_FREE(field_addr.sub_location);
74644#endif /* FREECIV_JSON_CONNECTION */
74645 }
74646
74647 if (e) {
74648 log_packet_detailed("'reqs' field error detected");
74649 }
74650 }
74651
74652 if (BV_ISSET(fields, 4)) {
74653 log_packet_detailed(" field 'frequency' has changed");
74654
74655#ifdef FREECIV_JSON_CONNECTION
74656 field_addr.name = "frequency";
74657#endif /* FREECIV_JSON_CONNECTION */
74658 e = 0;
74659
74660 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->frequency);
74661
74662 if (e) {
74663 log_packet_detailed("'frequency' field error detected");
74664 }
74665 }
74666
74667 if (BV_ISSET(fields, 5)) {
74668 log_packet_detailed(" field 'effects' has changed");
74669
74670#ifdef FREECIV_JSON_CONNECTION
74671 field_addr.name = "effects";
74672#endif /* FREECIV_JSON_CONNECTION */
74673 e = 0;
74674
74675 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->effects);
74676
74677 if (e) {
74678 log_packet_detailed("'effects' field error detected");
74679 }
74680 }
74681
74682 old->id = real_packet->id;
74683 sz_strlcpy(old->name, real_packet->name);
74684 sz_strlcpy(old->rule_name, real_packet->rule_name);
74685 requirement_vector_copy(&old->reqs, &real_packet->reqs);
74686 old->frequency = real_packet->frequency;
74687 old->effects = real_packet->effects;
74688
74689#else /* FREECIV_DELTA_PROTOCOL */
74690#ifdef FREECIV_JSON_CONNECTION
74691 field_addr.name = "id";
74692#endif /* FREECIV_JSON_CONNECTION */
74693 e = 0;
74694
74695 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
74696
74697 if (e) {
74698 log_packet_detailed("'id' field error detected");
74699 }
74700
74701#ifdef FREECIV_JSON_CONNECTION
74702 field_addr.name = "name";
74703#endif /* FREECIV_JSON_CONNECTION */
74704 e = 0;
74705
74706 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
74707
74708 if (e) {
74709 log_packet_detailed("'name' field error detected");
74710 }
74711
74712#ifdef FREECIV_JSON_CONNECTION
74713 field_addr.name = "rule_name";
74714#endif /* FREECIV_JSON_CONNECTION */
74715 e = 0;
74716
74717 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
74718
74719 if (e) {
74720 log_packet_detailed("'rule_name' field error detected");
74721 }
74722
74723#ifdef FREECIV_JSON_CONNECTION
74724 field_addr.name = "reqs";
74725#endif /* FREECIV_JSON_CONNECTION */
74726 e = 0;
74727
74728 {
74729 int i;
74730
74731 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
74732 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
74733
74734#ifdef FREECIV_JSON_CONNECTION
74735 /* Enter array. */
74736 field_addr.sub_location = plocation_elem_new(0);
74737#endif /* FREECIV_JSON_CONNECTION */
74738
74739 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
74740#ifdef FREECIV_JSON_CONNECTION
74741 /* Next array element. */
74742 field_addr.sub_location->number = i;
74743#endif /* FREECIV_JSON_CONNECTION */
74744
74745 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
74746 }
74747
74748#ifdef FREECIV_JSON_CONNECTION
74749 /* Exit array. */
74750 FC_FREE(field_addr.sub_location);
74751#endif /* FREECIV_JSON_CONNECTION */
74752 }
74753
74754 if (e) {
74755 log_packet_detailed("'reqs' field error detected");
74756 }
74757
74758#ifdef FREECIV_JSON_CONNECTION
74759 field_addr.name = "frequency";
74760#endif /* FREECIV_JSON_CONNECTION */
74761 e = 0;
74762
74763 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->frequency);
74764
74765 if (e) {
74766 log_packet_detailed("'frequency' field error detected");
74767 }
74768
74769#ifdef FREECIV_JSON_CONNECTION
74770 field_addr.name = "effects";
74771#endif /* FREECIV_JSON_CONNECTION */
74772 e = 0;
74773
74774 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->effects);
74775
74776 if (e) {
74777 log_packet_detailed("'effects' field error detected");
74778 }
74779#endif /* FREECIV_DELTA_PROTOCOL */
74780
74781 SEND_PACKET_END(PACKET_RULESET_DISASTER);
74782}
74783
74784 int send_packet_ruleset_disaster(struct connection *pc, const struct packet_ruleset_disaster *packet)
74785{
74786 if (!pc->used) {
74787 log_error("WARNING: trying to send data to the closed connection %s",
74788 conn_description(pc));
74789 return -1;
74790 }
74791 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_DISASTER].packet != nullptr, -1,
74792 "Handler for PACKET_RULESET_DISASTER not installed");
74793 return pc->phs.handlers->send[PACKET_RULESET_DISASTER].packet(pc, packet);
74794}
74795
74796 void lsend_packet_ruleset_disaster(struct conn_list *dest, const struct packet_ruleset_disaster *packet)
74797{
74798 conn_list_iterate(dest, pconn) {
74799 send_packet_ruleset_disaster(pconn, packet);
74800 } conn_list_iterate_end;
74801}
74802
74803 static inline void init_packet_ruleset_achievement(struct packet_ruleset_achievement *packet)
74804{
74805 memset(packet, 0, sizeof(*packet));
74806}
74807
74808#define free_packet_ruleset_achievement(_packet) (void) 0
74809#define destroy_packet_ruleset_achievement free
74810
74811#ifdef FREECIV_DELTA_PROTOCOL
74812#define hash_packet_ruleset_achievement_100 hash_const
74813#define cmp_packet_ruleset_achievement_100 cmp_const
74814 BV_DEFINE(packet_ruleset_achievement_100_fields, 6);
74815#endif /* FREECIV_DELTA_PROTOCOL */
74816
74817 static struct packet_ruleset_achievement *receive_packet_ruleset_achievement_100(struct connection *pc)
74818{
74819#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_achievement(_packet)
74820 RECEIVE_PACKET_START(packet_ruleset_achievement, real_packet);
74821
74822#ifdef FREECIV_JSON_CONNECTION
74823 struct plocation field_addr;
74824 {
74825 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
74826 field_addr = *field_addr_tmp;
74827 FC_FREE(field_addr_tmp);
74828 }
74829#endif /* FREECIV_JSON_CONNECTION */
74830
74831 log_packet_detailed("packet_ruleset_achievement_100: got info about ()");
74832
74833#ifdef FREECIV_DELTA_PROTOCOL
74834 packet_ruleset_achievement_100_fields fields;
74835 struct packet_ruleset_achievement *old;
74836 struct genhash **hash = pc->phs.received + PACKET_RULESET_ACHIEVEMENT;
74837
74838 if (nullptr == *hash) {
74839 *hash = genhash_new_full(hash_packet_ruleset_achievement_100, cmp_packet_ruleset_achievement_100,
74840 nullptr, nullptr, nullptr, destroy_packet_ruleset_achievement);
74841 }
74842
74843 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
74844 *real_packet = *old;
74845 } else {
74846 /* packet is already initialized empty */
74847 log_packet_detailed(" no old info");
74848 }
74849
74850#ifdef FREECIV_JSON_CONNECTION
74851 field_addr.name = "fields";
74852#endif /* FREECIV_JSON_CONNECTION */
74853 DIO_BV_GET(&din, &field_addr, fields);
74854
74855 if (BV_ISSET(fields, 0)) {
74856 log_packet_detailed(" got field 'id'");
74857
74858#ifdef FREECIV_JSON_CONNECTION
74859 field_addr.name = "id";
74860#endif /* FREECIV_JSON_CONNECTION */
74861
74862 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
74863 RECEIVE_PACKET_FIELD_ERROR(id);
74864 }
74865 }
74866
74867 if (BV_ISSET(fields, 1)) {
74868 log_packet_detailed(" got field 'name'");
74869
74870#ifdef FREECIV_JSON_CONNECTION
74871 field_addr.name = "name";
74872#endif /* FREECIV_JSON_CONNECTION */
74873
74874 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
74875 RECEIVE_PACKET_FIELD_ERROR(name);
74876 }
74877 }
74878
74879 if (BV_ISSET(fields, 2)) {
74880 log_packet_detailed(" got field 'rule_name'");
74881
74882#ifdef FREECIV_JSON_CONNECTION
74883 field_addr.name = "rule_name";
74884#endif /* FREECIV_JSON_CONNECTION */
74885
74886 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
74887 RECEIVE_PACKET_FIELD_ERROR(rule_name);
74888 }
74889 }
74890
74891 if (BV_ISSET(fields, 3)) {
74892 log_packet_detailed(" got field 'type'");
74893
74894#ifdef FREECIV_JSON_CONNECTION
74895 field_addr.name = "type";
74896#endif /* FREECIV_JSON_CONNECTION */
74897
74898 {
74899 int readin;
74900
74901 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
74902 RECEIVE_PACKET_FIELD_ERROR(type);
74903 }
74904 real_packet->type = readin;
74905 }
74906 }
74907
74908 real_packet->unique = BV_ISSET(fields, 4);
74909
74910 if (BV_ISSET(fields, 5)) {
74911 log_packet_detailed(" got field 'value'");
74912
74913#ifdef FREECIV_JSON_CONNECTION
74914 field_addr.name = "value";
74915#endif /* FREECIV_JSON_CONNECTION */
74916
74917 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->value)) {
74918 RECEIVE_PACKET_FIELD_ERROR(value);
74919 }
74920 }
74921
74922 if (nullptr == old) {
74923 old = fc_malloc(sizeof(*old));
74924 init_packet_ruleset_achievement(old);
74925 *old = *real_packet;
74926 genhash_insert(*hash, old, old);
74927 } else {
74928 *old = *real_packet;
74929 }
74930
74931#else /* FREECIV_DELTA_PROTOCOL */
74932#ifdef FREECIV_JSON_CONNECTION
74933 field_addr.name = "id";
74934#endif /* FREECIV_JSON_CONNECTION */
74935
74936 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
74937 RECEIVE_PACKET_FIELD_ERROR(id);
74938 }
74939
74940#ifdef FREECIV_JSON_CONNECTION
74941 field_addr.name = "name";
74942#endif /* FREECIV_JSON_CONNECTION */
74943
74944 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
74945 RECEIVE_PACKET_FIELD_ERROR(name);
74946 }
74947
74948#ifdef FREECIV_JSON_CONNECTION
74949 field_addr.name = "rule_name";
74950#endif /* FREECIV_JSON_CONNECTION */
74951
74952 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
74953 RECEIVE_PACKET_FIELD_ERROR(rule_name);
74954 }
74955
74956#ifdef FREECIV_JSON_CONNECTION
74957 field_addr.name = "type";
74958#endif /* FREECIV_JSON_CONNECTION */
74959
74960 {
74961 int readin;
74962
74963 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
74964 RECEIVE_PACKET_FIELD_ERROR(type);
74965 }
74966 real_packet->type = readin;
74967 }
74968
74969#ifdef FREECIV_JSON_CONNECTION
74970 field_addr.name = "unique";
74971#endif /* FREECIV_JSON_CONNECTION */
74972
74973 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->unique)) {
74974 RECEIVE_PACKET_FIELD_ERROR(unique);
74975 }
74976
74977#ifdef FREECIV_JSON_CONNECTION
74978 field_addr.name = "value";
74979#endif /* FREECIV_JSON_CONNECTION */
74980
74981 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->value)) {
74982 RECEIVE_PACKET_FIELD_ERROR(value);
74983 }
74984#endif /* FREECIV_DELTA_PROTOCOL */
74985
74986 RECEIVE_PACKET_END(real_packet);
74987#undef FREE_PACKET_STRUCT
74988}
74989
74990 static int send_packet_ruleset_achievement_100(struct connection *pc, const struct packet_ruleset_achievement *packet)
74991{
74992 const struct packet_ruleset_achievement *real_packet = packet;
74993 int e;
74994 SEND_PACKET_START(PACKET_RULESET_ACHIEVEMENT);
74995
74996 log_packet_detailed("packet_ruleset_achievement_100: sending info about ()");
74997
74998#ifdef FREECIV_DELTA_PROTOCOL
74999 packet_ruleset_achievement_100_fields fields;
75000 struct packet_ruleset_achievement *old;
75001 bool differ;
75002 struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACHIEVEMENT;
75003
75004 if (nullptr == *hash) {
75005 *hash = genhash_new_full(hash_packet_ruleset_achievement_100, cmp_packet_ruleset_achievement_100,
75006 nullptr, nullptr, nullptr, destroy_packet_ruleset_achievement);
75007 }
75008 BV_CLR_ALL(fields);
75009
75010 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
75011 old = fc_malloc(sizeof(*old));
75012 /* temporary bitcopy just to insert correctly */
75013 *old = *real_packet;
75014 genhash_insert(*hash, old, old);
75015 init_packet_ruleset_achievement(old);
75016 }
75017
75018 differ = (old->id != real_packet->id);
75019 if (differ) {
75020 BV_SET(fields, 0);
75021 }
75022
75023 differ = (strcmp(old->name, real_packet->name) != 0);
75024 if (differ) {
75025 BV_SET(fields, 1);
75026 }
75027
75028 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
75029 if (differ) {
75030 BV_SET(fields, 2);
75031 }
75032
75033 differ = (old->type != real_packet->type);
75034 if (differ) {
75035 BV_SET(fields, 3);
75036 }
75037
75038 /* folded into head */
75039 if (real_packet->unique) {
75040 BV_SET(fields, 4);
75041 }
75042
75043 differ = (old->value != real_packet->value);
75044 if (differ) {
75045 BV_SET(fields, 5);
75046 }
75047#endif /* FREECIV_DELTA_PROTOCOL */
75048
75049#ifdef FREECIV_JSON_CONNECTION
75050 struct plocation field_addr;
75051 {
75052 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
75053 field_addr = *field_addr_tmp;
75054 FC_FREE(field_addr_tmp);
75055 }
75056#endif /* FREECIV_JSON_CONNECTION */
75057
75058#ifdef FREECIV_DELTA_PROTOCOL
75059#ifdef FREECIV_JSON_CONNECTION
75060 field_addr.name = "fields";
75061#endif /* FREECIV_JSON_CONNECTION */
75062 e = 0;
75063 e |= DIO_BV_PUT(&dout, &field_addr, fields);
75064 if (e) {
75065 log_packet_detailed("fields bitvector error detected");
75066 }
75067
75068 if (BV_ISSET(fields, 0)) {
75069 log_packet_detailed(" field 'id' has changed");
75070
75071#ifdef FREECIV_JSON_CONNECTION
75072 field_addr.name = "id";
75073#endif /* FREECIV_JSON_CONNECTION */
75074 e = 0;
75075
75076 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
75077
75078 if (e) {
75079 log_packet_detailed("'id' field error detected");
75080 }
75081 }
75082
75083 if (BV_ISSET(fields, 1)) {
75084 log_packet_detailed(" field 'name' has changed");
75085
75086#ifdef FREECIV_JSON_CONNECTION
75087 field_addr.name = "name";
75088#endif /* FREECIV_JSON_CONNECTION */
75089 e = 0;
75090
75091 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
75092
75093 if (e) {
75094 log_packet_detailed("'name' field error detected");
75095 }
75096 }
75097
75098 if (BV_ISSET(fields, 2)) {
75099 log_packet_detailed(" field 'rule_name' has changed");
75100
75101#ifdef FREECIV_JSON_CONNECTION
75102 field_addr.name = "rule_name";
75103#endif /* FREECIV_JSON_CONNECTION */
75104 e = 0;
75105
75106 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
75107
75108 if (e) {
75109 log_packet_detailed("'rule_name' field error detected");
75110 }
75111 }
75112
75113 if (BV_ISSET(fields, 3)) {
75114 log_packet_detailed(" field 'type' has changed");
75115
75116#ifdef FREECIV_JSON_CONNECTION
75117 field_addr.name = "type";
75118#endif /* FREECIV_JSON_CONNECTION */
75119 e = 0;
75120
75121 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
75122
75123 if (e) {
75124 log_packet_detailed("'type' field error detected");
75125 }
75126 }
75127
75128 /* field 4 is folded into the header */
75129
75130 if (BV_ISSET(fields, 5)) {
75131 log_packet_detailed(" field 'value' has changed");
75132
75133#ifdef FREECIV_JSON_CONNECTION
75134 field_addr.name = "value";
75135#endif /* FREECIV_JSON_CONNECTION */
75136 e = 0;
75137
75138 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->value);
75139
75140 if (e) {
75141 log_packet_detailed("'value' field error detected");
75142 }
75143 }
75144
75145 *old = *real_packet;
75146
75147#else /* FREECIV_DELTA_PROTOCOL */
75148#ifdef FREECIV_JSON_CONNECTION
75149 field_addr.name = "id";
75150#endif /* FREECIV_JSON_CONNECTION */
75151 e = 0;
75152
75153 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
75154
75155 if (e) {
75156 log_packet_detailed("'id' field error detected");
75157 }
75158
75159#ifdef FREECIV_JSON_CONNECTION
75160 field_addr.name = "name";
75161#endif /* FREECIV_JSON_CONNECTION */
75162 e = 0;
75163
75164 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
75165
75166 if (e) {
75167 log_packet_detailed("'name' field error detected");
75168 }
75169
75170#ifdef FREECIV_JSON_CONNECTION
75171 field_addr.name = "rule_name";
75172#endif /* FREECIV_JSON_CONNECTION */
75173 e = 0;
75174
75175 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
75176
75177 if (e) {
75178 log_packet_detailed("'rule_name' field error detected");
75179 }
75180
75181#ifdef FREECIV_JSON_CONNECTION
75182 field_addr.name = "type";
75183#endif /* FREECIV_JSON_CONNECTION */
75184 e = 0;
75185
75186 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
75187
75188 if (e) {
75189 log_packet_detailed("'type' field error detected");
75190 }
75191
75192#ifdef FREECIV_JSON_CONNECTION
75193 field_addr.name = "unique";
75194#endif /* FREECIV_JSON_CONNECTION */
75195 e = 0;
75196
75197 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->unique);
75198
75199 if (e) {
75200 log_packet_detailed("'unique' field error detected");
75201 }
75202
75203#ifdef FREECIV_JSON_CONNECTION
75204 field_addr.name = "value";
75205#endif /* FREECIV_JSON_CONNECTION */
75206 e = 0;
75207
75208 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->value);
75209
75210 if (e) {
75211 log_packet_detailed("'value' field error detected");
75212 }
75213#endif /* FREECIV_DELTA_PROTOCOL */
75214
75215 SEND_PACKET_END(PACKET_RULESET_ACHIEVEMENT);
75216}
75217
75218 int send_packet_ruleset_achievement(struct connection *pc, const struct packet_ruleset_achievement *packet)
75219{
75220 if (!pc->used) {
75221 log_error("WARNING: trying to send data to the closed connection %s",
75222 conn_description(pc));
75223 return -1;
75224 }
75225 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACHIEVEMENT].packet != nullptr, -1,
75226 "Handler for PACKET_RULESET_ACHIEVEMENT not installed");
75227 return pc->phs.handlers->send[PACKET_RULESET_ACHIEVEMENT].packet(pc, packet);
75228}
75229
75230 void lsend_packet_ruleset_achievement(struct conn_list *dest, const struct packet_ruleset_achievement *packet)
75231{
75232 conn_list_iterate(dest, pconn) {
75233 send_packet_ruleset_achievement(pconn, packet);
75234 } conn_list_iterate_end;
75235}
75236
75237 static inline void init_packet_ruleset_trade(struct packet_ruleset_trade *packet)
75238{
75239 memset(packet, 0, sizeof(*packet));
75240}
75241
75242#define free_packet_ruleset_trade(_packet) (void) 0
75243#define destroy_packet_ruleset_trade free
75244
75245#ifdef FREECIV_DELTA_PROTOCOL
75246#define hash_packet_ruleset_trade_100 hash_const
75247#define cmp_packet_ruleset_trade_100 cmp_const
75248 BV_DEFINE(packet_ruleset_trade_100_fields, 4);
75249#endif /* FREECIV_DELTA_PROTOCOL */
75250
75251 static struct packet_ruleset_trade *receive_packet_ruleset_trade_100(struct connection *pc)
75252{
75253#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_trade(_packet)
75254 RECEIVE_PACKET_START(packet_ruleset_trade, real_packet);
75255
75256#ifdef FREECIV_JSON_CONNECTION
75257 struct plocation field_addr;
75258 {
75259 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
75260 field_addr = *field_addr_tmp;
75261 FC_FREE(field_addr_tmp);
75262 }
75263#endif /* FREECIV_JSON_CONNECTION */
75264
75265 log_packet_detailed("packet_ruleset_trade_100: got info about ()");
75266
75267#ifdef FREECIV_DELTA_PROTOCOL
75268 packet_ruleset_trade_100_fields fields;
75269 struct packet_ruleset_trade *old;
75270 struct genhash **hash = pc->phs.received + PACKET_RULESET_TRADE;
75271
75272 if (nullptr == *hash) {
75273 *hash = genhash_new_full(hash_packet_ruleset_trade_100, cmp_packet_ruleset_trade_100,
75274 nullptr, nullptr, nullptr, destroy_packet_ruleset_trade);
75275 }
75276
75277 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
75278 *real_packet = *old;
75279 } else {
75280 /* packet is already initialized empty */
75281 log_packet_detailed(" no old info");
75282 }
75283
75284#ifdef FREECIV_JSON_CONNECTION
75285 field_addr.name = "fields";
75286#endif /* FREECIV_JSON_CONNECTION */
75287 DIO_BV_GET(&din, &field_addr, fields);
75288
75289 if (BV_ISSET(fields, 0)) {
75290 log_packet_detailed(" got field 'id'");
75291
75292#ifdef FREECIV_JSON_CONNECTION
75293 field_addr.name = "id";
75294#endif /* FREECIV_JSON_CONNECTION */
75295
75296 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
75297 RECEIVE_PACKET_FIELD_ERROR(id);
75298 }
75299 }
75300
75301 if (BV_ISSET(fields, 1)) {
75302 log_packet_detailed(" got field 'trade_pct'");
75303
75304#ifdef FREECIV_JSON_CONNECTION
75305 field_addr.name = "trade_pct";
75306#endif /* FREECIV_JSON_CONNECTION */
75307
75308 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->trade_pct)) {
75309 RECEIVE_PACKET_FIELD_ERROR(trade_pct);
75310 }
75311 }
75312
75313 if (BV_ISSET(fields, 2)) {
75314 log_packet_detailed(" got field 'cancelling'");
75315
75316#ifdef FREECIV_JSON_CONNECTION
75317 field_addr.name = "cancelling";
75318#endif /* FREECIV_JSON_CONNECTION */
75319
75320 {
75321 int readin;
75322
75323 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75324 RECEIVE_PACKET_FIELD_ERROR(cancelling);
75325 }
75326 real_packet->cancelling = readin;
75327 }
75328 }
75329
75330 if (BV_ISSET(fields, 3)) {
75331 log_packet_detailed(" got field 'bonus_type'");
75332
75333#ifdef FREECIV_JSON_CONNECTION
75334 field_addr.name = "bonus_type";
75335#endif /* FREECIV_JSON_CONNECTION */
75336
75337 {
75338 int readin;
75339
75340 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75341 RECEIVE_PACKET_FIELD_ERROR(bonus_type);
75342 }
75343 real_packet->bonus_type = readin;
75344 }
75345 }
75346
75347 if (nullptr == old) {
75348 old = fc_malloc(sizeof(*old));
75349 init_packet_ruleset_trade(old);
75350 *old = *real_packet;
75351 genhash_insert(*hash, old, old);
75352 } else {
75353 *old = *real_packet;
75354 }
75355
75356#else /* FREECIV_DELTA_PROTOCOL */
75357#ifdef FREECIV_JSON_CONNECTION
75358 field_addr.name = "id";
75359#endif /* FREECIV_JSON_CONNECTION */
75360
75361 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
75362 RECEIVE_PACKET_FIELD_ERROR(id);
75363 }
75364
75365#ifdef FREECIV_JSON_CONNECTION
75366 field_addr.name = "trade_pct";
75367#endif /* FREECIV_JSON_CONNECTION */
75368
75369 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->trade_pct)) {
75370 RECEIVE_PACKET_FIELD_ERROR(trade_pct);
75371 }
75372
75373#ifdef FREECIV_JSON_CONNECTION
75374 field_addr.name = "cancelling";
75375#endif /* FREECIV_JSON_CONNECTION */
75376
75377 {
75378 int readin;
75379
75380 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75381 RECEIVE_PACKET_FIELD_ERROR(cancelling);
75382 }
75383 real_packet->cancelling = readin;
75384 }
75385
75386#ifdef FREECIV_JSON_CONNECTION
75387 field_addr.name = "bonus_type";
75388#endif /* FREECIV_JSON_CONNECTION */
75389
75390 {
75391 int readin;
75392
75393 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75394 RECEIVE_PACKET_FIELD_ERROR(bonus_type);
75395 }
75396 real_packet->bonus_type = readin;
75397 }
75398#endif /* FREECIV_DELTA_PROTOCOL */
75399
75400 RECEIVE_PACKET_END(real_packet);
75401#undef FREE_PACKET_STRUCT
75402}
75403
75404 static int send_packet_ruleset_trade_100(struct connection *pc, const struct packet_ruleset_trade *packet)
75405{
75406 const struct packet_ruleset_trade *real_packet = packet;
75407 int e;
75408 SEND_PACKET_START(PACKET_RULESET_TRADE);
75409
75410 log_packet_detailed("packet_ruleset_trade_100: sending info about ()");
75411
75412#ifdef FREECIV_DELTA_PROTOCOL
75413 packet_ruleset_trade_100_fields fields;
75414 struct packet_ruleset_trade *old;
75415 bool differ;
75416 struct genhash **hash = pc->phs.sent + PACKET_RULESET_TRADE;
75417
75418 if (nullptr == *hash) {
75419 *hash = genhash_new_full(hash_packet_ruleset_trade_100, cmp_packet_ruleset_trade_100,
75420 nullptr, nullptr, nullptr, destroy_packet_ruleset_trade);
75421 }
75422 BV_CLR_ALL(fields);
75423
75424 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
75425 old = fc_malloc(sizeof(*old));
75426 /* temporary bitcopy just to insert correctly */
75427 *old = *real_packet;
75428 genhash_insert(*hash, old, old);
75429 init_packet_ruleset_trade(old);
75430 }
75431
75432 differ = (old->id != real_packet->id);
75433 if (differ) {
75434 BV_SET(fields, 0);
75435 }
75436
75437 differ = (old->trade_pct != real_packet->trade_pct);
75438 if (differ) {
75439 BV_SET(fields, 1);
75440 }
75441
75442 differ = (old->cancelling != real_packet->cancelling);
75443 if (differ) {
75444 BV_SET(fields, 2);
75445 }
75446
75447 differ = (old->bonus_type != real_packet->bonus_type);
75448 if (differ) {
75449 BV_SET(fields, 3);
75450 }
75451#endif /* FREECIV_DELTA_PROTOCOL */
75452
75453#ifdef FREECIV_JSON_CONNECTION
75454 struct plocation field_addr;
75455 {
75456 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
75457 field_addr = *field_addr_tmp;
75458 FC_FREE(field_addr_tmp);
75459 }
75460#endif /* FREECIV_JSON_CONNECTION */
75461
75462#ifdef FREECIV_DELTA_PROTOCOL
75463#ifdef FREECIV_JSON_CONNECTION
75464 field_addr.name = "fields";
75465#endif /* FREECIV_JSON_CONNECTION */
75466 e = 0;
75467 e |= DIO_BV_PUT(&dout, &field_addr, fields);
75468 if (e) {
75469 log_packet_detailed("fields bitvector error detected");
75470 }
75471
75472 if (BV_ISSET(fields, 0)) {
75473 log_packet_detailed(" field 'id' has changed");
75474
75475#ifdef FREECIV_JSON_CONNECTION
75476 field_addr.name = "id";
75477#endif /* FREECIV_JSON_CONNECTION */
75478 e = 0;
75479
75480 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
75481
75482 if (e) {
75483 log_packet_detailed("'id' field error detected");
75484 }
75485 }
75486
75487 if (BV_ISSET(fields, 1)) {
75488 log_packet_detailed(" field 'trade_pct' has changed");
75489
75490#ifdef FREECIV_JSON_CONNECTION
75491 field_addr.name = "trade_pct";
75492#endif /* FREECIV_JSON_CONNECTION */
75493 e = 0;
75494
75495 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->trade_pct);
75496
75497 if (e) {
75498 log_packet_detailed("'trade_pct' field error detected");
75499 }
75500 }
75501
75502 if (BV_ISSET(fields, 2)) {
75503 log_packet_detailed(" field 'cancelling' has changed");
75504
75505#ifdef FREECIV_JSON_CONNECTION
75506 field_addr.name = "cancelling";
75507#endif /* FREECIV_JSON_CONNECTION */
75508 e = 0;
75509
75510 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cancelling);
75511
75512 if (e) {
75513 log_packet_detailed("'cancelling' field error detected");
75514 }
75515 }
75516
75517 if (BV_ISSET(fields, 3)) {
75518 log_packet_detailed(" field 'bonus_type' has changed");
75519
75520#ifdef FREECIV_JSON_CONNECTION
75521 field_addr.name = "bonus_type";
75522#endif /* FREECIV_JSON_CONNECTION */
75523 e = 0;
75524
75525 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->bonus_type);
75526
75527 if (e) {
75528 log_packet_detailed("'bonus_type' field error detected");
75529 }
75530 }
75531
75532 *old = *real_packet;
75533
75534#else /* FREECIV_DELTA_PROTOCOL */
75535#ifdef FREECIV_JSON_CONNECTION
75536 field_addr.name = "id";
75537#endif /* FREECIV_JSON_CONNECTION */
75538 e = 0;
75539
75540 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
75541
75542 if (e) {
75543 log_packet_detailed("'id' field error detected");
75544 }
75545
75546#ifdef FREECIV_JSON_CONNECTION
75547 field_addr.name = "trade_pct";
75548#endif /* FREECIV_JSON_CONNECTION */
75549 e = 0;
75550
75551 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->trade_pct);
75552
75553 if (e) {
75554 log_packet_detailed("'trade_pct' field error detected");
75555 }
75556
75557#ifdef FREECIV_JSON_CONNECTION
75558 field_addr.name = "cancelling";
75559#endif /* FREECIV_JSON_CONNECTION */
75560 e = 0;
75561
75562 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cancelling);
75563
75564 if (e) {
75565 log_packet_detailed("'cancelling' field error detected");
75566 }
75567
75568#ifdef FREECIV_JSON_CONNECTION
75569 field_addr.name = "bonus_type";
75570#endif /* FREECIV_JSON_CONNECTION */
75571 e = 0;
75572
75573 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->bonus_type);
75574
75575 if (e) {
75576 log_packet_detailed("'bonus_type' field error detected");
75577 }
75578#endif /* FREECIV_DELTA_PROTOCOL */
75579
75580 SEND_PACKET_END(PACKET_RULESET_TRADE);
75581}
75582
75583 int send_packet_ruleset_trade(struct connection *pc, const struct packet_ruleset_trade *packet)
75584{
75585 if (!pc->used) {
75586 log_error("WARNING: trying to send data to the closed connection %s",
75587 conn_description(pc));
75588 return -1;
75589 }
75590 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_TRADE].packet != nullptr, -1,
75591 "Handler for PACKET_RULESET_TRADE not installed");
75592 return pc->phs.handlers->send[PACKET_RULESET_TRADE].packet(pc, packet);
75593}
75594
75595 void lsend_packet_ruleset_trade(struct conn_list *dest, const struct packet_ruleset_trade *packet)
75596{
75597 conn_list_iterate(dest, pconn) {
75598 send_packet_ruleset_trade(pconn, packet);
75599 } conn_list_iterate_end;
75600}
75601
75602 static inline void init_packet_ruleset_action(struct packet_ruleset_action *packet)
75603{
75604 memset(packet, 0, sizeof(*packet));
75605}
75606
75607#define free_packet_ruleset_action(_packet) (void) 0
75608#define destroy_packet_ruleset_action free
75609
75610#ifdef FREECIV_DELTA_PROTOCOL
75611#define hash_packet_ruleset_action_100 hash_const
75612#define cmp_packet_ruleset_action_100 cmp_const
75613 BV_DEFINE(packet_ruleset_action_100_fields, 12);
75614#endif /* FREECIV_DELTA_PROTOCOL */
75615
75616 static struct packet_ruleset_action *receive_packet_ruleset_action_100(struct connection *pc)
75617{
75618#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_action(_packet)
75619 RECEIVE_PACKET_START(packet_ruleset_action, real_packet);
75620
75621#ifdef FREECIV_JSON_CONNECTION
75622 struct plocation field_addr;
75623 {
75624 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
75625 field_addr = *field_addr_tmp;
75626 FC_FREE(field_addr_tmp);
75627 }
75628#endif /* FREECIV_JSON_CONNECTION */
75629
75630 log_packet_detailed("packet_ruleset_action_100: got info about ()");
75631
75632#ifdef FREECIV_DELTA_PROTOCOL
75633 packet_ruleset_action_100_fields fields;
75634 struct packet_ruleset_action *old;
75635 struct genhash **hash = pc->phs.received + PACKET_RULESET_ACTION;
75636
75637 if (nullptr == *hash) {
75638 *hash = genhash_new_full(hash_packet_ruleset_action_100, cmp_packet_ruleset_action_100,
75639 nullptr, nullptr, nullptr, destroy_packet_ruleset_action);
75640 }
75641
75642 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
75643 *real_packet = *old;
75644 } else {
75645 /* packet is already initialized empty */
75646 log_packet_detailed(" no old info");
75647 }
75648
75649#ifdef FREECIV_JSON_CONNECTION
75650 field_addr.name = "fields";
75651#endif /* FREECIV_JSON_CONNECTION */
75652 DIO_BV_GET(&din, &field_addr, fields);
75653
75654 if (BV_ISSET(fields, 0)) {
75655 log_packet_detailed(" got field 'id'");
75656
75657#ifdef FREECIV_JSON_CONNECTION
75658 field_addr.name = "id";
75659#endif /* FREECIV_JSON_CONNECTION */
75660
75661 {
75662 int readin;
75663
75664 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75665 RECEIVE_PACKET_FIELD_ERROR(id);
75666 }
75667 real_packet->id = readin;
75668 }
75669 }
75670
75671 if (BV_ISSET(fields, 1)) {
75672 log_packet_detailed(" got field 'ui_name'");
75673
75674#ifdef FREECIV_JSON_CONNECTION
75675 field_addr.name = "ui_name";
75676#endif /* FREECIV_JSON_CONNECTION */
75677
75678 if (!DIO_GET(string, &din, &field_addr, real_packet->ui_name, sizeof(real_packet->ui_name))) {
75679 RECEIVE_PACKET_FIELD_ERROR(ui_name);
75680 }
75681 }
75682
75683 real_packet->quiet = BV_ISSET(fields, 2);
75684
75685 if (BV_ISSET(fields, 3)) {
75686 log_packet_detailed(" got field 'result'");
75687
75688#ifdef FREECIV_JSON_CONNECTION
75689 field_addr.name = "result";
75690#endif /* FREECIV_JSON_CONNECTION */
75691
75692 {
75693 int readin;
75694
75695 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75696 RECEIVE_PACKET_FIELD_ERROR(result);
75697 }
75698 real_packet->result = readin;
75699 }
75700 }
75701
75702 if (BV_ISSET(fields, 4)) {
75703 log_packet_detailed(" got field 'sub_results'");
75704
75705#ifdef FREECIV_JSON_CONNECTION
75706 field_addr.name = "sub_results";
75707#endif /* FREECIV_JSON_CONNECTION */
75708
75709 if (!DIO_BV_GET(&din, &field_addr, real_packet->sub_results)) {
75710 RECEIVE_PACKET_FIELD_ERROR(sub_results);
75711 }
75712 }
75713
75714 real_packet->actor_consuming_always = BV_ISSET(fields, 5);
75715
75716 if (BV_ISSET(fields, 6)) {
75717 log_packet_detailed(" got field 'act_kind'");
75718
75719#ifdef FREECIV_JSON_CONNECTION
75720 field_addr.name = "act_kind";
75721#endif /* FREECIV_JSON_CONNECTION */
75722
75723 {
75724 int readin;
75725
75726 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75727 RECEIVE_PACKET_FIELD_ERROR(act_kind);
75728 }
75729 real_packet->act_kind = readin;
75730 }
75731 }
75732
75733 if (BV_ISSET(fields, 7)) {
75734 log_packet_detailed(" got field 'tgt_kind'");
75735
75736#ifdef FREECIV_JSON_CONNECTION
75737 field_addr.name = "tgt_kind";
75738#endif /* FREECIV_JSON_CONNECTION */
75739
75740 {
75741 int readin;
75742
75743 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75744 RECEIVE_PACKET_FIELD_ERROR(tgt_kind);
75745 }
75746 real_packet->tgt_kind = readin;
75747 }
75748 }
75749
75750 if (BV_ISSET(fields, 8)) {
75751 log_packet_detailed(" got field 'sub_tgt_kind'");
75752
75753#ifdef FREECIV_JSON_CONNECTION
75754 field_addr.name = "sub_tgt_kind";
75755#endif /* FREECIV_JSON_CONNECTION */
75756
75757 {
75758 int readin;
75759
75760 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75761 RECEIVE_PACKET_FIELD_ERROR(sub_tgt_kind);
75762 }
75763 real_packet->sub_tgt_kind = readin;
75764 }
75765 }
75766
75767 if (BV_ISSET(fields, 9)) {
75768 log_packet_detailed(" got field 'min_distance'");
75769
75770#ifdef FREECIV_JSON_CONNECTION
75771 field_addr.name = "min_distance";
75772#endif /* FREECIV_JSON_CONNECTION */
75773
75774 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->min_distance)) {
75775 RECEIVE_PACKET_FIELD_ERROR(min_distance);
75776 }
75777 }
75778
75779 if (BV_ISSET(fields, 10)) {
75780 log_packet_detailed(" got field 'max_distance'");
75781
75782#ifdef FREECIV_JSON_CONNECTION
75783 field_addr.name = "max_distance";
75784#endif /* FREECIV_JSON_CONNECTION */
75785
75786 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->max_distance)) {
75787 RECEIVE_PACKET_FIELD_ERROR(max_distance);
75788 }
75789 }
75790
75791 if (BV_ISSET(fields, 11)) {
75792 log_packet_detailed(" got field 'blocked_by'");
75793
75794#ifdef FREECIV_JSON_CONNECTION
75795 field_addr.name = "blocked_by";
75796#endif /* FREECIV_JSON_CONNECTION */
75797
75798 if (!DIO_BV_GET(&din, &field_addr, real_packet->blocked_by)) {
75799 RECEIVE_PACKET_FIELD_ERROR(blocked_by);
75800 }
75801 }
75802
75803 if (nullptr == old) {
75804 old = fc_malloc(sizeof(*old));
75805 init_packet_ruleset_action(old);
75806 *old = *real_packet;
75807 genhash_insert(*hash, old, old);
75808 } else {
75809 *old = *real_packet;
75810 }
75811
75812#else /* FREECIV_DELTA_PROTOCOL */
75813#ifdef FREECIV_JSON_CONNECTION
75814 field_addr.name = "id";
75815#endif /* FREECIV_JSON_CONNECTION */
75816
75817 {
75818 int readin;
75819
75820 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75821 RECEIVE_PACKET_FIELD_ERROR(id);
75822 }
75823 real_packet->id = readin;
75824 }
75825
75826#ifdef FREECIV_JSON_CONNECTION
75827 field_addr.name = "ui_name";
75828#endif /* FREECIV_JSON_CONNECTION */
75829
75830 if (!DIO_GET(string, &din, &field_addr, real_packet->ui_name, sizeof(real_packet->ui_name))) {
75831 RECEIVE_PACKET_FIELD_ERROR(ui_name);
75832 }
75833
75834#ifdef FREECIV_JSON_CONNECTION
75835 field_addr.name = "quiet";
75836#endif /* FREECIV_JSON_CONNECTION */
75837
75838 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->quiet)) {
75839 RECEIVE_PACKET_FIELD_ERROR(quiet);
75840 }
75841
75842#ifdef FREECIV_JSON_CONNECTION
75843 field_addr.name = "result";
75844#endif /* FREECIV_JSON_CONNECTION */
75845
75846 {
75847 int readin;
75848
75849 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75850 RECEIVE_PACKET_FIELD_ERROR(result);
75851 }
75852 real_packet->result = readin;
75853 }
75854
75855#ifdef FREECIV_JSON_CONNECTION
75856 field_addr.name = "sub_results";
75857#endif /* FREECIV_JSON_CONNECTION */
75858
75859 if (!DIO_BV_GET(&din, &field_addr, real_packet->sub_results)) {
75860 RECEIVE_PACKET_FIELD_ERROR(sub_results);
75861 }
75862
75863#ifdef FREECIV_JSON_CONNECTION
75864 field_addr.name = "actor_consuming_always";
75865#endif /* FREECIV_JSON_CONNECTION */
75866
75867 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->actor_consuming_always)) {
75868 RECEIVE_PACKET_FIELD_ERROR(actor_consuming_always);
75869 }
75870
75871#ifdef FREECIV_JSON_CONNECTION
75872 field_addr.name = "act_kind";
75873#endif /* FREECIV_JSON_CONNECTION */
75874
75875 {
75876 int readin;
75877
75878 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75879 RECEIVE_PACKET_FIELD_ERROR(act_kind);
75880 }
75881 real_packet->act_kind = readin;
75882 }
75883
75884#ifdef FREECIV_JSON_CONNECTION
75885 field_addr.name = "tgt_kind";
75886#endif /* FREECIV_JSON_CONNECTION */
75887
75888 {
75889 int readin;
75890
75891 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75892 RECEIVE_PACKET_FIELD_ERROR(tgt_kind);
75893 }
75894 real_packet->tgt_kind = readin;
75895 }
75896
75897#ifdef FREECIV_JSON_CONNECTION
75898 field_addr.name = "sub_tgt_kind";
75899#endif /* FREECIV_JSON_CONNECTION */
75900
75901 {
75902 int readin;
75903
75904 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
75905 RECEIVE_PACKET_FIELD_ERROR(sub_tgt_kind);
75906 }
75907 real_packet->sub_tgt_kind = readin;
75908 }
75909
75910#ifdef FREECIV_JSON_CONNECTION
75911 field_addr.name = "min_distance";
75912#endif /* FREECIV_JSON_CONNECTION */
75913
75914 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->min_distance)) {
75915 RECEIVE_PACKET_FIELD_ERROR(min_distance);
75916 }
75917
75918#ifdef FREECIV_JSON_CONNECTION
75919 field_addr.name = "max_distance";
75920#endif /* FREECIV_JSON_CONNECTION */
75921
75922 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->max_distance)) {
75923 RECEIVE_PACKET_FIELD_ERROR(max_distance);
75924 }
75925
75926#ifdef FREECIV_JSON_CONNECTION
75927 field_addr.name = "blocked_by";
75928#endif /* FREECIV_JSON_CONNECTION */
75929
75930 if (!DIO_BV_GET(&din, &field_addr, real_packet->blocked_by)) {
75931 RECEIVE_PACKET_FIELD_ERROR(blocked_by);
75932 }
75933#endif /* FREECIV_DELTA_PROTOCOL */
75934
75935 RECEIVE_PACKET_END(real_packet);
75936#undef FREE_PACKET_STRUCT
75937}
75938
75939 static int send_packet_ruleset_action_100(struct connection *pc, const struct packet_ruleset_action *packet)
75940{
75941 const struct packet_ruleset_action *real_packet = packet;
75942 int e;
75943 SEND_PACKET_START(PACKET_RULESET_ACTION);
75944
75945 log_packet_detailed("packet_ruleset_action_100: sending info about ()");
75946
75947#ifdef FREECIV_DELTA_PROTOCOL
75948 packet_ruleset_action_100_fields fields;
75949 struct packet_ruleset_action *old;
75950 bool differ;
75951 struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACTION;
75952
75953 if (nullptr == *hash) {
75954 *hash = genhash_new_full(hash_packet_ruleset_action_100, cmp_packet_ruleset_action_100,
75955 nullptr, nullptr, nullptr, destroy_packet_ruleset_action);
75956 }
75957 BV_CLR_ALL(fields);
75958
75959 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
75960 old = fc_malloc(sizeof(*old));
75961 /* temporary bitcopy just to insert correctly */
75962 *old = *real_packet;
75963 genhash_insert(*hash, old, old);
75964 init_packet_ruleset_action(old);
75965 }
75966
75967 differ = (old->id != real_packet->id);
75968 if (differ) {
75969 BV_SET(fields, 0);
75970 }
75971
75972 differ = (strcmp(old->ui_name, real_packet->ui_name) != 0);
75973 if (differ) {
75974 BV_SET(fields, 1);
75975 }
75976
75977 /* folded into head */
75978 if (real_packet->quiet) {
75979 BV_SET(fields, 2);
75980 }
75981
75982 differ = (old->result != real_packet->result);
75983 if (differ) {
75984 BV_SET(fields, 3);
75985 }
75986
75987 differ = !BV_ARE_EQUAL(old->sub_results, real_packet->sub_results);
75988 if (differ) {
75989 BV_SET(fields, 4);
75990 }
75991
75992 /* folded into head */
75993 if (real_packet->actor_consuming_always) {
75994 BV_SET(fields, 5);
75995 }
75996
75997 differ = (old->act_kind != real_packet->act_kind);
75998 if (differ) {
75999 BV_SET(fields, 6);
76000 }
76001
76002 differ = (old->tgt_kind != real_packet->tgt_kind);
76003 if (differ) {
76004 BV_SET(fields, 7);
76005 }
76006
76007 differ = (old->sub_tgt_kind != real_packet->sub_tgt_kind);
76008 if (differ) {
76009 BV_SET(fields, 8);
76010 }
76011
76012 differ = (old->min_distance != real_packet->min_distance);
76013 if (differ) {
76014 BV_SET(fields, 9);
76015 }
76016
76017 differ = (old->max_distance != real_packet->max_distance);
76018 if (differ) {
76019 BV_SET(fields, 10);
76020 }
76021
76022 differ = !BV_ARE_EQUAL(old->blocked_by, real_packet->blocked_by);
76023 if (differ) {
76024 BV_SET(fields, 11);
76025 }
76026#endif /* FREECIV_DELTA_PROTOCOL */
76027
76028#ifdef FREECIV_JSON_CONNECTION
76029 struct plocation field_addr;
76030 {
76031 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
76032 field_addr = *field_addr_tmp;
76033 FC_FREE(field_addr_tmp);
76034 }
76035#endif /* FREECIV_JSON_CONNECTION */
76036
76037#ifdef FREECIV_DELTA_PROTOCOL
76038#ifdef FREECIV_JSON_CONNECTION
76039 field_addr.name = "fields";
76040#endif /* FREECIV_JSON_CONNECTION */
76041 e = 0;
76042 e |= DIO_BV_PUT(&dout, &field_addr, fields);
76043 if (e) {
76044 log_packet_detailed("fields bitvector error detected");
76045 }
76046
76047 if (BV_ISSET(fields, 0)) {
76048 log_packet_detailed(" field 'id' has changed");
76049
76050#ifdef FREECIV_JSON_CONNECTION
76051 field_addr.name = "id";
76052#endif /* FREECIV_JSON_CONNECTION */
76053 e = 0;
76054
76055 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
76056
76057 if (e) {
76058 log_packet_detailed("'id' field error detected");
76059 }
76060 }
76061
76062 if (BV_ISSET(fields, 1)) {
76063 log_packet_detailed(" field 'ui_name' has changed");
76064
76065#ifdef FREECIV_JSON_CONNECTION
76066 field_addr.name = "ui_name";
76067#endif /* FREECIV_JSON_CONNECTION */
76068 e = 0;
76069
76070 e |= DIO_PUT(string, &dout, &field_addr, real_packet->ui_name);
76071
76072 if (e) {
76073 log_packet_detailed("'ui_name' field error detected");
76074 }
76075 }
76076
76077 /* field 2 is folded into the header */
76078
76079 if (BV_ISSET(fields, 3)) {
76080 log_packet_detailed(" field 'result' has changed");
76081
76082#ifdef FREECIV_JSON_CONNECTION
76083 field_addr.name = "result";
76084#endif /* FREECIV_JSON_CONNECTION */
76085 e = 0;
76086
76087 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->result);
76088
76089 if (e) {
76090 log_packet_detailed("'result' field error detected");
76091 }
76092 }
76093
76094 if (BV_ISSET(fields, 4)) {
76095 log_packet_detailed(" field 'sub_results' has changed");
76096
76097#ifdef FREECIV_JSON_CONNECTION
76098 field_addr.name = "sub_results";
76099#endif /* FREECIV_JSON_CONNECTION */
76100 e = 0;
76101
76102 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->sub_results);
76103
76104 if (e) {
76105 log_packet_detailed("'sub_results' field error detected");
76106 }
76107 }
76108
76109 /* field 5 is folded into the header */
76110
76111 if (BV_ISSET(fields, 6)) {
76112 log_packet_detailed(" field 'act_kind' has changed");
76113
76114#ifdef FREECIV_JSON_CONNECTION
76115 field_addr.name = "act_kind";
76116#endif /* FREECIV_JSON_CONNECTION */
76117 e = 0;
76118
76119 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->act_kind);
76120
76121 if (e) {
76122 log_packet_detailed("'act_kind' field error detected");
76123 }
76124 }
76125
76126 if (BV_ISSET(fields, 7)) {
76127 log_packet_detailed(" field 'tgt_kind' has changed");
76128
76129#ifdef FREECIV_JSON_CONNECTION
76130 field_addr.name = "tgt_kind";
76131#endif /* FREECIV_JSON_CONNECTION */
76132 e = 0;
76133
76134 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tgt_kind);
76135
76136 if (e) {
76137 log_packet_detailed("'tgt_kind' field error detected");
76138 }
76139 }
76140
76141 if (BV_ISSET(fields, 8)) {
76142 log_packet_detailed(" field 'sub_tgt_kind' has changed");
76143
76144#ifdef FREECIV_JSON_CONNECTION
76145 field_addr.name = "sub_tgt_kind";
76146#endif /* FREECIV_JSON_CONNECTION */
76147 e = 0;
76148
76149 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sub_tgt_kind);
76150
76151 if (e) {
76152 log_packet_detailed("'sub_tgt_kind' field error detected");
76153 }
76154 }
76155
76156 if (BV_ISSET(fields, 9)) {
76157 log_packet_detailed(" field 'min_distance' has changed");
76158
76159#ifdef FREECIV_JSON_CONNECTION
76160 field_addr.name = "min_distance";
76161#endif /* FREECIV_JSON_CONNECTION */
76162 e = 0;
76163
76164 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->min_distance);
76165
76166 if (e) {
76167 log_packet_detailed("'min_distance' field error detected");
76168 }
76169 }
76170
76171 if (BV_ISSET(fields, 10)) {
76172 log_packet_detailed(" field 'max_distance' has changed");
76173
76174#ifdef FREECIV_JSON_CONNECTION
76175 field_addr.name = "max_distance";
76176#endif /* FREECIV_JSON_CONNECTION */
76177 e = 0;
76178
76179 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->max_distance);
76180
76181 if (e) {
76182 log_packet_detailed("'max_distance' field error detected");
76183 }
76184 }
76185
76186 if (BV_ISSET(fields, 11)) {
76187 log_packet_detailed(" field 'blocked_by' has changed");
76188
76189#ifdef FREECIV_JSON_CONNECTION
76190 field_addr.name = "blocked_by";
76191#endif /* FREECIV_JSON_CONNECTION */
76192 e = 0;
76193
76194 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->blocked_by);
76195
76196 if (e) {
76197 log_packet_detailed("'blocked_by' field error detected");
76198 }
76199 }
76200
76201 *old = *real_packet;
76202
76203#else /* FREECIV_DELTA_PROTOCOL */
76204#ifdef FREECIV_JSON_CONNECTION
76205 field_addr.name = "id";
76206#endif /* FREECIV_JSON_CONNECTION */
76207 e = 0;
76208
76209 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
76210
76211 if (e) {
76212 log_packet_detailed("'id' field error detected");
76213 }
76214
76215#ifdef FREECIV_JSON_CONNECTION
76216 field_addr.name = "ui_name";
76217#endif /* FREECIV_JSON_CONNECTION */
76218 e = 0;
76219
76220 e |= DIO_PUT(string, &dout, &field_addr, real_packet->ui_name);
76221
76222 if (e) {
76223 log_packet_detailed("'ui_name' field error detected");
76224 }
76225
76226#ifdef FREECIV_JSON_CONNECTION
76227 field_addr.name = "quiet";
76228#endif /* FREECIV_JSON_CONNECTION */
76229 e = 0;
76230
76231 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->quiet);
76232
76233 if (e) {
76234 log_packet_detailed("'quiet' field error detected");
76235 }
76236
76237#ifdef FREECIV_JSON_CONNECTION
76238 field_addr.name = "result";
76239#endif /* FREECIV_JSON_CONNECTION */
76240 e = 0;
76241
76242 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->result);
76243
76244 if (e) {
76245 log_packet_detailed("'result' field error detected");
76246 }
76247
76248#ifdef FREECIV_JSON_CONNECTION
76249 field_addr.name = "sub_results";
76250#endif /* FREECIV_JSON_CONNECTION */
76251 e = 0;
76252
76253 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->sub_results);
76254
76255 if (e) {
76256 log_packet_detailed("'sub_results' field error detected");
76257 }
76258
76259#ifdef FREECIV_JSON_CONNECTION
76260 field_addr.name = "actor_consuming_always";
76261#endif /* FREECIV_JSON_CONNECTION */
76262 e = 0;
76263
76264 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->actor_consuming_always);
76265
76266 if (e) {
76267 log_packet_detailed("'actor_consuming_always' field error detected");
76268 }
76269
76270#ifdef FREECIV_JSON_CONNECTION
76271 field_addr.name = "act_kind";
76272#endif /* FREECIV_JSON_CONNECTION */
76273 e = 0;
76274
76275 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->act_kind);
76276
76277 if (e) {
76278 log_packet_detailed("'act_kind' field error detected");
76279 }
76280
76281#ifdef FREECIV_JSON_CONNECTION
76282 field_addr.name = "tgt_kind";
76283#endif /* FREECIV_JSON_CONNECTION */
76284 e = 0;
76285
76286 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tgt_kind);
76287
76288 if (e) {
76289 log_packet_detailed("'tgt_kind' field error detected");
76290 }
76291
76292#ifdef FREECIV_JSON_CONNECTION
76293 field_addr.name = "sub_tgt_kind";
76294#endif /* FREECIV_JSON_CONNECTION */
76295 e = 0;
76296
76297 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->sub_tgt_kind);
76298
76299 if (e) {
76300 log_packet_detailed("'sub_tgt_kind' field error detected");
76301 }
76302
76303#ifdef FREECIV_JSON_CONNECTION
76304 field_addr.name = "min_distance";
76305#endif /* FREECIV_JSON_CONNECTION */
76306 e = 0;
76307
76308 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->min_distance);
76309
76310 if (e) {
76311 log_packet_detailed("'min_distance' field error detected");
76312 }
76313
76314#ifdef FREECIV_JSON_CONNECTION
76315 field_addr.name = "max_distance";
76316#endif /* FREECIV_JSON_CONNECTION */
76317 e = 0;
76318
76319 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->max_distance);
76320
76321 if (e) {
76322 log_packet_detailed("'max_distance' field error detected");
76323 }
76324
76325#ifdef FREECIV_JSON_CONNECTION
76326 field_addr.name = "blocked_by";
76327#endif /* FREECIV_JSON_CONNECTION */
76328 e = 0;
76329
76330 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->blocked_by);
76331
76332 if (e) {
76333 log_packet_detailed("'blocked_by' field error detected");
76334 }
76335#endif /* FREECIV_DELTA_PROTOCOL */
76336
76337 SEND_PACKET_END(PACKET_RULESET_ACTION);
76338}
76339
76340 int send_packet_ruleset_action(struct connection *pc, const struct packet_ruleset_action *packet)
76341{
76342 if (!pc->used) {
76343 log_error("WARNING: trying to send data to the closed connection %s",
76344 conn_description(pc));
76345 return -1;
76346 }
76347 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACTION].packet != nullptr, -1,
76348 "Handler for PACKET_RULESET_ACTION not installed");
76349 return pc->phs.handlers->send[PACKET_RULESET_ACTION].packet(pc, packet);
76350}
76351
76352 void lsend_packet_ruleset_action(struct conn_list *dest, const struct packet_ruleset_action *packet)
76353{
76354 conn_list_iterate(dest, pconn) {
76355 send_packet_ruleset_action(pconn, packet);
76356 } conn_list_iterate_end;
76357}
76358
76359 static inline void init_packet_ruleset_action_enabler(struct packet_ruleset_action_enabler *packet)
76360{
76361 memset(packet, 0, sizeof(*packet));
76362
76363 requirement_vector_init(&packet->actor_reqs);
76364 requirement_vector_init(&packet->target_reqs);
76365}
76366
76367 static inline void free_packet_ruleset_action_enabler(struct packet_ruleset_action_enabler *packet)
76368{
76369 requirement_vector_free(&packet->target_reqs);
76370 requirement_vector_free(&packet->actor_reqs);
76371}
76372
76373 static inline void destroy_packet_ruleset_action_enabler(void *packet)
76374{
76375 free_packet_ruleset_action_enabler((struct packet_ruleset_action_enabler *) packet);
76376 free(packet);
76377}
76378
76379#ifdef FREECIV_DELTA_PROTOCOL
76380#define hash_packet_ruleset_action_enabler_100 hash_const
76381#define cmp_packet_ruleset_action_enabler_100 cmp_const
76382 BV_DEFINE(packet_ruleset_action_enabler_100_fields, 3);
76383#endif /* FREECIV_DELTA_PROTOCOL */
76384
76385 static struct packet_ruleset_action_enabler *receive_packet_ruleset_action_enabler_100(struct connection *pc)
76386{
76387#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_action_enabler(_packet)
76388 RECEIVE_PACKET_START(packet_ruleset_action_enabler, real_packet);
76389
76390#ifdef FREECIV_JSON_CONNECTION
76391 struct plocation field_addr;
76392 {
76393 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
76394 field_addr = *field_addr_tmp;
76395 FC_FREE(field_addr_tmp);
76396 }
76397#endif /* FREECIV_JSON_CONNECTION */
76398
76399 log_packet_detailed("packet_ruleset_action_enabler_100: got info about ()");
76400
76401#ifdef FREECIV_DELTA_PROTOCOL
76402 packet_ruleset_action_enabler_100_fields fields;
76403 struct packet_ruleset_action_enabler *old;
76404 struct genhash **hash = pc->phs.received + PACKET_RULESET_ACTION_ENABLER;
76405
76406 if (nullptr == *hash) {
76407 *hash = genhash_new_full(hash_packet_ruleset_action_enabler_100, cmp_packet_ruleset_action_enabler_100,
76408 nullptr, nullptr, nullptr, destroy_packet_ruleset_action_enabler);
76409 }
76410
76411 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
76412 real_packet->enabled_action = old->enabled_action;
76413 requirement_vector_copy(&real_packet->actor_reqs, &old->actor_reqs);
76414 requirement_vector_copy(&real_packet->target_reqs, &old->target_reqs);
76415 } else {
76416 /* packet is already initialized empty */
76417 log_packet_detailed(" no old info");
76418 }
76419
76420#ifdef FREECIV_JSON_CONNECTION
76421 field_addr.name = "fields";
76422#endif /* FREECIV_JSON_CONNECTION */
76423 DIO_BV_GET(&din, &field_addr, fields);
76424
76425 if (BV_ISSET(fields, 0)) {
76426 log_packet_detailed(" got field 'enabled_action'");
76427
76428#ifdef FREECIV_JSON_CONNECTION
76429 field_addr.name = "enabled_action";
76430#endif /* FREECIV_JSON_CONNECTION */
76431
76432 {
76433 int readin;
76434
76435 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
76436 RECEIVE_PACKET_FIELD_ERROR(enabled_action);
76437 }
76438 real_packet->enabled_action = readin;
76439 }
76440 }
76441
76442 if (BV_ISSET(fields, 1)) {
76443 log_packet_detailed(" got field 'actor_reqs'");
76444
76445#ifdef FREECIV_JSON_CONNECTION
76446 field_addr.name = "actor_reqs";
76447#endif /* FREECIV_JSON_CONNECTION */
76448
76449 {
76450 int i;
76451
76452 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
76453 RECEIVE_PACKET_FIELD_ERROR(actor_reqs);
76454 }
76455 requirement_vector_reserve(&real_packet->actor_reqs, i);
76456
76457#ifdef FREECIV_JSON_CONNECTION
76458 /* Enter array. */
76459 field_addr.sub_location = plocation_elem_new(0);
76460#endif /* FREECIV_JSON_CONNECTION */
76461
76462 for (i = 0; i < requirement_vector_size(&real_packet->actor_reqs); i++) {
76463#ifdef FREECIV_JSON_CONNECTION
76464 /* Next array element */
76465 field_addr.sub_location->number = i;
76466#endif /* FREECIV_JSON_CONNECTION */
76467
76468 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->actor_reqs.p[i])) {
76469 RECEIVE_PACKET_FIELD_ERROR(actor_reqs);
76470 }
76471 }
76472
76473#ifdef FREECIV_JSON_CONNECTION
76474 /* Exit array. */
76475 FC_FREE(field_addr.sub_location);
76476#endif /* FREECIV_JSON_CONNECTION */
76477 }
76478 }
76479
76480 if (BV_ISSET(fields, 2)) {
76481 log_packet_detailed(" got field 'target_reqs'");
76482
76483#ifdef FREECIV_JSON_CONNECTION
76484 field_addr.name = "target_reqs";
76485#endif /* FREECIV_JSON_CONNECTION */
76486
76487 {
76488 int i;
76489
76490 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
76491 RECEIVE_PACKET_FIELD_ERROR(target_reqs);
76492 }
76493 requirement_vector_reserve(&real_packet->target_reqs, i);
76494
76495#ifdef FREECIV_JSON_CONNECTION
76496 /* Enter array. */
76497 field_addr.sub_location = plocation_elem_new(0);
76498#endif /* FREECIV_JSON_CONNECTION */
76499
76500 for (i = 0; i < requirement_vector_size(&real_packet->target_reqs); i++) {
76501#ifdef FREECIV_JSON_CONNECTION
76502 /* Next array element */
76503 field_addr.sub_location->number = i;
76504#endif /* FREECIV_JSON_CONNECTION */
76505
76506 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->target_reqs.p[i])) {
76507 RECEIVE_PACKET_FIELD_ERROR(target_reqs);
76508 }
76509 }
76510
76511#ifdef FREECIV_JSON_CONNECTION
76512 /* Exit array. */
76513 FC_FREE(field_addr.sub_location);
76514#endif /* FREECIV_JSON_CONNECTION */
76515 }
76516 }
76517
76518 if (nullptr == old) {
76519 old = fc_malloc(sizeof(*old));
76520 init_packet_ruleset_action_enabler(old);
76521 old->enabled_action = real_packet->enabled_action;
76522 requirement_vector_copy(&old->actor_reqs, &real_packet->actor_reqs);
76523 requirement_vector_copy(&old->target_reqs, &real_packet->target_reqs);
76524 genhash_insert(*hash, old, old);
76525 } else {
76526 old->enabled_action = real_packet->enabled_action;
76527 requirement_vector_copy(&old->actor_reqs, &real_packet->actor_reqs);
76528 requirement_vector_copy(&old->target_reqs, &real_packet->target_reqs);
76529 }
76530
76531#else /* FREECIV_DELTA_PROTOCOL */
76532#ifdef FREECIV_JSON_CONNECTION
76533 field_addr.name = "enabled_action";
76534#endif /* FREECIV_JSON_CONNECTION */
76535
76536 {
76537 int readin;
76538
76539 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
76540 RECEIVE_PACKET_FIELD_ERROR(enabled_action);
76541 }
76542 real_packet->enabled_action = readin;
76543 }
76544
76545#ifdef FREECIV_JSON_CONNECTION
76546 field_addr.name = "actor_reqs";
76547#endif /* FREECIV_JSON_CONNECTION */
76548
76549 {
76550 int i;
76551
76552 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
76553 RECEIVE_PACKET_FIELD_ERROR(actor_reqs);
76554 }
76555 requirement_vector_reserve(&real_packet->actor_reqs, i);
76556
76557#ifdef FREECIV_JSON_CONNECTION
76558 /* Enter array. */
76559 field_addr.sub_location = plocation_elem_new(0);
76560#endif /* FREECIV_JSON_CONNECTION */
76561
76562 for (i = 0; i < requirement_vector_size(&real_packet->actor_reqs); i++) {
76563#ifdef FREECIV_JSON_CONNECTION
76564 /* Next array element */
76565 field_addr.sub_location->number = i;
76566#endif /* FREECIV_JSON_CONNECTION */
76567
76568 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->actor_reqs.p[i])) {
76569 RECEIVE_PACKET_FIELD_ERROR(actor_reqs);
76570 }
76571 }
76572
76573#ifdef FREECIV_JSON_CONNECTION
76574 /* Exit array. */
76575 FC_FREE(field_addr.sub_location);
76576#endif /* FREECIV_JSON_CONNECTION */
76577 }
76578
76579#ifdef FREECIV_JSON_CONNECTION
76580 field_addr.name = "target_reqs";
76581#endif /* FREECIV_JSON_CONNECTION */
76582
76583 {
76584 int i;
76585
76586 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
76587 RECEIVE_PACKET_FIELD_ERROR(target_reqs);
76588 }
76589 requirement_vector_reserve(&real_packet->target_reqs, i);
76590
76591#ifdef FREECIV_JSON_CONNECTION
76592 /* Enter array. */
76593 field_addr.sub_location = plocation_elem_new(0);
76594#endif /* FREECIV_JSON_CONNECTION */
76595
76596 for (i = 0; i < requirement_vector_size(&real_packet->target_reqs); i++) {
76597#ifdef FREECIV_JSON_CONNECTION
76598 /* Next array element */
76599 field_addr.sub_location->number = i;
76600#endif /* FREECIV_JSON_CONNECTION */
76601
76602 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->target_reqs.p[i])) {
76603 RECEIVE_PACKET_FIELD_ERROR(target_reqs);
76604 }
76605 }
76606
76607#ifdef FREECIV_JSON_CONNECTION
76608 /* Exit array. */
76609 FC_FREE(field_addr.sub_location);
76610#endif /* FREECIV_JSON_CONNECTION */
76611 }
76612#endif /* FREECIV_DELTA_PROTOCOL */
76613
76614 RECEIVE_PACKET_END(real_packet);
76615#undef FREE_PACKET_STRUCT
76616}
76617
76618 static int send_packet_ruleset_action_enabler_100(struct connection *pc, const struct packet_ruleset_action_enabler *packet)
76619{
76620 const struct packet_ruleset_action_enabler *real_packet = packet;
76621 int e;
76622 SEND_PACKET_START(PACKET_RULESET_ACTION_ENABLER);
76623
76624 log_packet_detailed("packet_ruleset_action_enabler_100: sending info about ()");
76625
76626#ifdef FREECIV_DELTA_PROTOCOL
76627 packet_ruleset_action_enabler_100_fields fields;
76628 struct packet_ruleset_action_enabler *old;
76629 bool differ;
76630 struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACTION_ENABLER;
76631
76632 if (nullptr == *hash) {
76633 *hash = genhash_new_full(hash_packet_ruleset_action_enabler_100, cmp_packet_ruleset_action_enabler_100,
76634 nullptr, nullptr, nullptr, destroy_packet_ruleset_action_enabler);
76635 }
76636 BV_CLR_ALL(fields);
76637
76638 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
76639 old = fc_malloc(sizeof(*old));
76640 /* temporary bitcopy just to insert correctly */
76641 *old = *real_packet;
76642 genhash_insert(*hash, old, old);
76643 init_packet_ruleset_action_enabler(old);
76644 }
76645
76646 differ = (old->enabled_action != real_packet->enabled_action);
76647 if (differ) {
76648 BV_SET(fields, 0);
76649 }
76650
76651 differ = (requirement_vector_size(&old->actor_reqs) != requirement_vector_size(&real_packet->actor_reqs));
76652 if (!differ) {
76653 int i;
76654
76655 for (i = 0; i < requirement_vector_size(&old->actor_reqs); i++) {
76656 differ = !are_requirements_equal(&old->actor_reqs.p[i], &real_packet->actor_reqs.p[i]);
76657 if (differ) {
76658 break;
76659 }
76660 }
76661 }
76662 if (differ) {
76663 BV_SET(fields, 1);
76664 }
76665
76666 differ = (requirement_vector_size(&old->target_reqs) != requirement_vector_size(&real_packet->target_reqs));
76667 if (!differ) {
76668 int i;
76669
76670 for (i = 0; i < requirement_vector_size(&old->target_reqs); i++) {
76671 differ = !are_requirements_equal(&old->target_reqs.p[i], &real_packet->target_reqs.p[i]);
76672 if (differ) {
76673 break;
76674 }
76675 }
76676 }
76677 if (differ) {
76678 BV_SET(fields, 2);
76679 }
76680#endif /* FREECIV_DELTA_PROTOCOL */
76681
76682#ifdef FREECIV_JSON_CONNECTION
76683 struct plocation field_addr;
76684 {
76685 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
76686 field_addr = *field_addr_tmp;
76687 FC_FREE(field_addr_tmp);
76688 }
76689#endif /* FREECIV_JSON_CONNECTION */
76690
76691#ifdef FREECIV_DELTA_PROTOCOL
76692#ifdef FREECIV_JSON_CONNECTION
76693 field_addr.name = "fields";
76694#endif /* FREECIV_JSON_CONNECTION */
76695 e = 0;
76696 e |= DIO_BV_PUT(&dout, &field_addr, fields);
76697 if (e) {
76698 log_packet_detailed("fields bitvector error detected");
76699 }
76700
76701 if (BV_ISSET(fields, 0)) {
76702 log_packet_detailed(" field 'enabled_action' has changed");
76703
76704#ifdef FREECIV_JSON_CONNECTION
76705 field_addr.name = "enabled_action";
76706#endif /* FREECIV_JSON_CONNECTION */
76707 e = 0;
76708
76709 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->enabled_action);
76710
76711 if (e) {
76712 log_packet_detailed("'enabled_action' field error detected");
76713 }
76714 }
76715
76716 if (BV_ISSET(fields, 1)) {
76717 log_packet_detailed(" field 'actor_reqs' has changed");
76718
76719#ifdef FREECIV_JSON_CONNECTION
76720 field_addr.name = "actor_reqs";
76721#endif /* FREECIV_JSON_CONNECTION */
76722 e = 0;
76723
76724 {
76725 int i;
76726
76727 fc_assert(requirement_vector_size(&real_packet->actor_reqs) < MAX_UINT16);
76728 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->actor_reqs));
76729
76730#ifdef FREECIV_JSON_CONNECTION
76731 /* Enter array. */
76732 field_addr.sub_location = plocation_elem_new(0);
76733#endif /* FREECIV_JSON_CONNECTION */
76734
76735 for (i = 0; i < requirement_vector_size(&real_packet->actor_reqs); i++) {
76736#ifdef FREECIV_JSON_CONNECTION
76737 /* Next array element. */
76738 field_addr.sub_location->number = i;
76739#endif /* FREECIV_JSON_CONNECTION */
76740
76741 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->actor_reqs.p[i]);
76742 }
76743
76744#ifdef FREECIV_JSON_CONNECTION
76745 /* Exit array. */
76746 FC_FREE(field_addr.sub_location);
76747#endif /* FREECIV_JSON_CONNECTION */
76748 }
76749
76750 if (e) {
76751 log_packet_detailed("'actor_reqs' field error detected");
76752 }
76753 }
76754
76755 if (BV_ISSET(fields, 2)) {
76756 log_packet_detailed(" field 'target_reqs' has changed");
76757
76758#ifdef FREECIV_JSON_CONNECTION
76759 field_addr.name = "target_reqs";
76760#endif /* FREECIV_JSON_CONNECTION */
76761 e = 0;
76762
76763 {
76764 int i;
76765
76766 fc_assert(requirement_vector_size(&real_packet->target_reqs) < MAX_UINT16);
76767 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->target_reqs));
76768
76769#ifdef FREECIV_JSON_CONNECTION
76770 /* Enter array. */
76771 field_addr.sub_location = plocation_elem_new(0);
76772#endif /* FREECIV_JSON_CONNECTION */
76773
76774 for (i = 0; i < requirement_vector_size(&real_packet->target_reqs); i++) {
76775#ifdef FREECIV_JSON_CONNECTION
76776 /* Next array element. */
76777 field_addr.sub_location->number = i;
76778#endif /* FREECIV_JSON_CONNECTION */
76779
76780 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->target_reqs.p[i]);
76781 }
76782
76783#ifdef FREECIV_JSON_CONNECTION
76784 /* Exit array. */
76785 FC_FREE(field_addr.sub_location);
76786#endif /* FREECIV_JSON_CONNECTION */
76787 }
76788
76789 if (e) {
76790 log_packet_detailed("'target_reqs' field error detected");
76791 }
76792 }
76793
76794 old->enabled_action = real_packet->enabled_action;
76795 requirement_vector_copy(&old->actor_reqs, &real_packet->actor_reqs);
76796 requirement_vector_copy(&old->target_reqs, &real_packet->target_reqs);
76797
76798#else /* FREECIV_DELTA_PROTOCOL */
76799#ifdef FREECIV_JSON_CONNECTION
76800 field_addr.name = "enabled_action";
76801#endif /* FREECIV_JSON_CONNECTION */
76802 e = 0;
76803
76804 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->enabled_action);
76805
76806 if (e) {
76807 log_packet_detailed("'enabled_action' field error detected");
76808 }
76809
76810#ifdef FREECIV_JSON_CONNECTION
76811 field_addr.name = "actor_reqs";
76812#endif /* FREECIV_JSON_CONNECTION */
76813 e = 0;
76814
76815 {
76816 int i;
76817
76818 fc_assert(requirement_vector_size(&real_packet->actor_reqs) < MAX_UINT16);
76819 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->actor_reqs));
76820
76821#ifdef FREECIV_JSON_CONNECTION
76822 /* Enter array. */
76823 field_addr.sub_location = plocation_elem_new(0);
76824#endif /* FREECIV_JSON_CONNECTION */
76825
76826 for (i = 0; i < requirement_vector_size(&real_packet->actor_reqs); i++) {
76827#ifdef FREECIV_JSON_CONNECTION
76828 /* Next array element. */
76829 field_addr.sub_location->number = i;
76830#endif /* FREECIV_JSON_CONNECTION */
76831
76832 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->actor_reqs.p[i]);
76833 }
76834
76835#ifdef FREECIV_JSON_CONNECTION
76836 /* Exit array. */
76837 FC_FREE(field_addr.sub_location);
76838#endif /* FREECIV_JSON_CONNECTION */
76839 }
76840
76841 if (e) {
76842 log_packet_detailed("'actor_reqs' field error detected");
76843 }
76844
76845#ifdef FREECIV_JSON_CONNECTION
76846 field_addr.name = "target_reqs";
76847#endif /* FREECIV_JSON_CONNECTION */
76848 e = 0;
76849
76850 {
76851 int i;
76852
76853 fc_assert(requirement_vector_size(&real_packet->target_reqs) < MAX_UINT16);
76854 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->target_reqs));
76855
76856#ifdef FREECIV_JSON_CONNECTION
76857 /* Enter array. */
76858 field_addr.sub_location = plocation_elem_new(0);
76859#endif /* FREECIV_JSON_CONNECTION */
76860
76861 for (i = 0; i < requirement_vector_size(&real_packet->target_reqs); i++) {
76862#ifdef FREECIV_JSON_CONNECTION
76863 /* Next array element. */
76864 field_addr.sub_location->number = i;
76865#endif /* FREECIV_JSON_CONNECTION */
76866
76867 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->target_reqs.p[i]);
76868 }
76869
76870#ifdef FREECIV_JSON_CONNECTION
76871 /* Exit array. */
76872 FC_FREE(field_addr.sub_location);
76873#endif /* FREECIV_JSON_CONNECTION */
76874 }
76875
76876 if (e) {
76877 log_packet_detailed("'target_reqs' field error detected");
76878 }
76879#endif /* FREECIV_DELTA_PROTOCOL */
76880
76881 SEND_PACKET_END(PACKET_RULESET_ACTION_ENABLER);
76882}
76883
76884 int send_packet_ruleset_action_enabler(struct connection *pc, const struct packet_ruleset_action_enabler *packet)
76885{
76886 if (!pc->used) {
76887 log_error("WARNING: trying to send data to the closed connection %s",
76888 conn_description(pc));
76889 return -1;
76890 }
76891 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACTION_ENABLER].packet != nullptr, -1,
76892 "Handler for PACKET_RULESET_ACTION_ENABLER not installed");
76893 return pc->phs.handlers->send[PACKET_RULESET_ACTION_ENABLER].packet(pc, packet);
76894}
76895
76896 void lsend_packet_ruleset_action_enabler(struct conn_list *dest, const struct packet_ruleset_action_enabler *packet)
76897{
76898 conn_list_iterate(dest, pconn) {
76899 send_packet_ruleset_action_enabler(pconn, packet);
76900 } conn_list_iterate_end;
76901}
76902
76903 static inline void init_packet_ruleset_action_auto(struct packet_ruleset_action_auto *packet)
76904{
76905 memset(packet, 0, sizeof(*packet));
76906
76907 requirement_vector_init(&packet->reqs);
76908}
76909
76910 static inline void free_packet_ruleset_action_auto(struct packet_ruleset_action_auto *packet)
76911{
76912 requirement_vector_free(&packet->reqs);
76913}
76914
76915 static inline void destroy_packet_ruleset_action_auto(void *packet)
76916{
76917 free_packet_ruleset_action_auto((struct packet_ruleset_action_auto *) packet);
76918 free(packet);
76919}
76920
76921#ifdef FREECIV_DELTA_PROTOCOL
76922#define hash_packet_ruleset_action_auto_100 hash_const
76923#define cmp_packet_ruleset_action_auto_100 cmp_const
76924 BV_DEFINE(packet_ruleset_action_auto_100_fields, 5);
76925#endif /* FREECIV_DELTA_PROTOCOL */
76926
76927 static struct packet_ruleset_action_auto *receive_packet_ruleset_action_auto_100(struct connection *pc)
76928{
76929#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_action_auto(_packet)
76930 RECEIVE_PACKET_START(packet_ruleset_action_auto, real_packet);
76931
76932#ifdef FREECIV_JSON_CONNECTION
76933 struct plocation field_addr;
76934 {
76935 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
76936 field_addr = *field_addr_tmp;
76937 FC_FREE(field_addr_tmp);
76938 }
76939#endif /* FREECIV_JSON_CONNECTION */
76940
76941 log_packet_detailed("packet_ruleset_action_auto_100: got info about ()");
76942
76943#ifdef FREECIV_DELTA_PROTOCOL
76944 packet_ruleset_action_auto_100_fields fields;
76945 struct packet_ruleset_action_auto *old;
76946 struct genhash **hash = pc->phs.received + PACKET_RULESET_ACTION_AUTO;
76947
76948 if (nullptr == *hash) {
76949 *hash = genhash_new_full(hash_packet_ruleset_action_auto_100, cmp_packet_ruleset_action_auto_100,
76950 nullptr, nullptr, nullptr, destroy_packet_ruleset_action_auto);
76951 }
76952
76953 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
76954 real_packet->id = old->id;
76955 real_packet->cause = old->cause;
76956 requirement_vector_copy(&real_packet->reqs, &old->reqs);
76957 real_packet->alternatives_count = old->alternatives_count;
76958 {
76959 int i;
76960
76961 for (i = 0; i < old->alternatives_count; i++) {
76962 real_packet->alternatives[i] = old->alternatives[i];
76963 }
76964 }
76965 } else {
76966 /* packet is already initialized empty */
76967 log_packet_detailed(" no old info");
76968 }
76969
76970#ifdef FREECIV_JSON_CONNECTION
76971 field_addr.name = "fields";
76972#endif /* FREECIV_JSON_CONNECTION */
76973 DIO_BV_GET(&din, &field_addr, fields);
76974
76975 if (BV_ISSET(fields, 0)) {
76976 log_packet_detailed(" got field 'id'");
76977
76978#ifdef FREECIV_JSON_CONNECTION
76979 field_addr.name = "id";
76980#endif /* FREECIV_JSON_CONNECTION */
76981
76982 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
76983 RECEIVE_PACKET_FIELD_ERROR(id);
76984 }
76985 }
76986
76987 if (BV_ISSET(fields, 1)) {
76988 log_packet_detailed(" got field 'cause'");
76989
76990#ifdef FREECIV_JSON_CONNECTION
76991 field_addr.name = "cause";
76992#endif /* FREECIV_JSON_CONNECTION */
76993
76994 {
76995 int readin;
76996
76997 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
76998 RECEIVE_PACKET_FIELD_ERROR(cause);
76999 }
77000 real_packet->cause = readin;
77001 }
77002 }
77003
77004 if (BV_ISSET(fields, 2)) {
77005 log_packet_detailed(" got field 'reqs'");
77006
77007#ifdef FREECIV_JSON_CONNECTION
77008 field_addr.name = "reqs";
77009#endif /* FREECIV_JSON_CONNECTION */
77010
77011 {
77012 int i;
77013
77014 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
77015 RECEIVE_PACKET_FIELD_ERROR(reqs);
77016 }
77017 requirement_vector_reserve(&real_packet->reqs, i);
77018
77019#ifdef FREECIV_JSON_CONNECTION
77020 /* Enter array. */
77021 field_addr.sub_location = plocation_elem_new(0);
77022#endif /* FREECIV_JSON_CONNECTION */
77023
77024 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
77025#ifdef FREECIV_JSON_CONNECTION
77026 /* Next array element */
77027 field_addr.sub_location->number = i;
77028#endif /* FREECIV_JSON_CONNECTION */
77029
77030 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
77031 RECEIVE_PACKET_FIELD_ERROR(reqs);
77032 }
77033 }
77034
77035#ifdef FREECIV_JSON_CONNECTION
77036 /* Exit array. */
77037 FC_FREE(field_addr.sub_location);
77038#endif /* FREECIV_JSON_CONNECTION */
77039 }
77040 }
77041
77042 if (BV_ISSET(fields, 3)) {
77043 log_packet_detailed(" got field 'alternatives_count'");
77044
77045#ifdef FREECIV_JSON_CONNECTION
77046 field_addr.name = "alternatives_count";
77047#endif /* FREECIV_JSON_CONNECTION */
77048
77049 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->alternatives_count)) {
77050 RECEIVE_PACKET_FIELD_ERROR(alternatives_count);
77051 }
77052 }
77053
77054 if (BV_ISSET(fields, 4)) {
77055 log_packet_detailed(" got field 'alternatives'");
77056
77057#ifdef FREECIV_JSON_CONNECTION
77058 field_addr.name = "alternatives";
77059#endif /* FREECIV_JSON_CONNECTION */
77060
77061 {
77062 int i;
77063
77064 if (real_packet->alternatives_count > MAX_NUM_ACTIONS) {
77065 RECEIVE_PACKET_FIELD_ERROR(alternatives, ": array truncated");
77066 }
77067
77068#ifdef FREECIV_JSON_CONNECTION
77069 /* Enter array. */
77070 field_addr.sub_location = plocation_elem_new(0);
77071#endif /* FREECIV_JSON_CONNECTION */
77072
77073 for (i = 0; i < real_packet->alternatives_count; i++) {
77074#ifdef FREECIV_JSON_CONNECTION
77075 /* Next array element */
77076 field_addr.sub_location->number = i;
77077#endif /* FREECIV_JSON_CONNECTION */
77078
77079 {
77080 int readin;
77081
77082 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77083 RECEIVE_PACKET_FIELD_ERROR(alternatives);
77084 }
77085 real_packet->alternatives[i] = readin;
77086 }
77087 }
77088
77089#ifdef FREECIV_JSON_CONNECTION
77090 /* Exit array. */
77091 FC_FREE(field_addr.sub_location);
77092#endif /* FREECIV_JSON_CONNECTION */
77093 }
77094 }
77095
77096 if (nullptr == old) {
77097 old = fc_malloc(sizeof(*old));
77098 init_packet_ruleset_action_auto(old);
77099 old->id = real_packet->id;
77100 old->cause = real_packet->cause;
77101 requirement_vector_copy(&old->reqs, &real_packet->reqs);
77102 old->alternatives_count = real_packet->alternatives_count;
77103 {
77104 int i;
77105
77106 for (i = 0; i < real_packet->alternatives_count; i++) {
77107 old->alternatives[i] = real_packet->alternatives[i];
77108 }
77109 }
77110 genhash_insert(*hash, old, old);
77111 } else {
77112 old->id = real_packet->id;
77113 old->cause = real_packet->cause;
77114 requirement_vector_copy(&old->reqs, &real_packet->reqs);
77115 old->alternatives_count = real_packet->alternatives_count;
77116 {
77117 int i;
77118
77119 for (i = 0; i < real_packet->alternatives_count; i++) {
77120 old->alternatives[i] = real_packet->alternatives[i];
77121 }
77122 }
77123 }
77124
77125#else /* FREECIV_DELTA_PROTOCOL */
77126#ifdef FREECIV_JSON_CONNECTION
77127 field_addr.name = "id";
77128#endif /* FREECIV_JSON_CONNECTION */
77129
77130 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
77131 RECEIVE_PACKET_FIELD_ERROR(id);
77132 }
77133
77134#ifdef FREECIV_JSON_CONNECTION
77135 field_addr.name = "cause";
77136#endif /* FREECIV_JSON_CONNECTION */
77137
77138 {
77139 int readin;
77140
77141 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77142 RECEIVE_PACKET_FIELD_ERROR(cause);
77143 }
77144 real_packet->cause = readin;
77145 }
77146
77147#ifdef FREECIV_JSON_CONNECTION
77148 field_addr.name = "reqs";
77149#endif /* FREECIV_JSON_CONNECTION */
77150
77151 {
77152 int i;
77153
77154 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
77155 RECEIVE_PACKET_FIELD_ERROR(reqs);
77156 }
77157 requirement_vector_reserve(&real_packet->reqs, i);
77158
77159#ifdef FREECIV_JSON_CONNECTION
77160 /* Enter array. */
77161 field_addr.sub_location = plocation_elem_new(0);
77162#endif /* FREECIV_JSON_CONNECTION */
77163
77164 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
77165#ifdef FREECIV_JSON_CONNECTION
77166 /* Next array element */
77167 field_addr.sub_location->number = i;
77168#endif /* FREECIV_JSON_CONNECTION */
77169
77170 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
77171 RECEIVE_PACKET_FIELD_ERROR(reqs);
77172 }
77173 }
77174
77175#ifdef FREECIV_JSON_CONNECTION
77176 /* Exit array. */
77177 FC_FREE(field_addr.sub_location);
77178#endif /* FREECIV_JSON_CONNECTION */
77179 }
77180
77181#ifdef FREECIV_JSON_CONNECTION
77182 field_addr.name = "alternatives_count";
77183#endif /* FREECIV_JSON_CONNECTION */
77184
77185 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->alternatives_count)) {
77186 RECEIVE_PACKET_FIELD_ERROR(alternatives_count);
77187 }
77188
77189#ifdef FREECIV_JSON_CONNECTION
77190 field_addr.name = "alternatives";
77191#endif /* FREECIV_JSON_CONNECTION */
77192
77193 {
77194 int i;
77195
77196 if (real_packet->alternatives_count > MAX_NUM_ACTIONS) {
77197 RECEIVE_PACKET_FIELD_ERROR(alternatives, ": array truncated");
77198 }
77199
77200#ifdef FREECIV_JSON_CONNECTION
77201 /* Enter array. */
77202 field_addr.sub_location = plocation_elem_new(0);
77203#endif /* FREECIV_JSON_CONNECTION */
77204
77205 for (i = 0; i < real_packet->alternatives_count; i++) {
77206#ifdef FREECIV_JSON_CONNECTION
77207 /* Next array element */
77208 field_addr.sub_location->number = i;
77209#endif /* FREECIV_JSON_CONNECTION */
77210
77211 {
77212 int readin;
77213
77214 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77215 RECEIVE_PACKET_FIELD_ERROR(alternatives);
77216 }
77217 real_packet->alternatives[i] = readin;
77218 }
77219 }
77220
77221#ifdef FREECIV_JSON_CONNECTION
77222 /* Exit array. */
77223 FC_FREE(field_addr.sub_location);
77224#endif /* FREECIV_JSON_CONNECTION */
77225 }
77226#endif /* FREECIV_DELTA_PROTOCOL */
77227
77228 RECEIVE_PACKET_END(real_packet);
77229#undef FREE_PACKET_STRUCT
77230}
77231
77232 static int send_packet_ruleset_action_auto_100(struct connection *pc, const struct packet_ruleset_action_auto *packet)
77233{
77234 const struct packet_ruleset_action_auto *real_packet = packet;
77235 int e;
77236 SEND_PACKET_START(PACKET_RULESET_ACTION_AUTO);
77237
77238 log_packet_detailed("packet_ruleset_action_auto_100: sending info about ()");
77239
77240#ifdef FREECIV_DELTA_PROTOCOL
77241 packet_ruleset_action_auto_100_fields fields;
77242 struct packet_ruleset_action_auto *old;
77243 bool differ;
77244 struct genhash **hash = pc->phs.sent + PACKET_RULESET_ACTION_AUTO;
77245
77246 if (nullptr == *hash) {
77247 *hash = genhash_new_full(hash_packet_ruleset_action_auto_100, cmp_packet_ruleset_action_auto_100,
77248 nullptr, nullptr, nullptr, destroy_packet_ruleset_action_auto);
77249 }
77250 BV_CLR_ALL(fields);
77251
77252 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
77253 old = fc_malloc(sizeof(*old));
77254 /* temporary bitcopy just to insert correctly */
77255 *old = *real_packet;
77256 genhash_insert(*hash, old, old);
77257 init_packet_ruleset_action_auto(old);
77258 }
77259
77260 differ = (old->id != real_packet->id);
77261 if (differ) {
77262 BV_SET(fields, 0);
77263 }
77264
77265 differ = (old->cause != real_packet->cause);
77266 if (differ) {
77267 BV_SET(fields, 1);
77268 }
77269
77270 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
77271 if (!differ) {
77272 int i;
77273
77274 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
77275 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
77276 if (differ) {
77277 break;
77278 }
77279 }
77280 }
77281 if (differ) {
77282 BV_SET(fields, 2);
77283 }
77284
77285 differ = (old->alternatives_count != real_packet->alternatives_count);
77286 if (differ) {
77287 BV_SET(fields, 3);
77288 }
77289
77290 differ = (old->alternatives_count != real_packet->alternatives_count);
77291 if (!differ) {
77292 int i;
77293
77294 for (i = 0; i < old->alternatives_count; i++) {
77295 differ = (old->alternatives[i] != real_packet->alternatives[i]);
77296 if (differ) {
77297 break;
77298 }
77299 }
77300 }
77301 if (differ) {
77302 BV_SET(fields, 4);
77303 }
77304#endif /* FREECIV_DELTA_PROTOCOL */
77305
77306#ifdef FREECIV_JSON_CONNECTION
77307 struct plocation field_addr;
77308 {
77309 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
77310 field_addr = *field_addr_tmp;
77311 FC_FREE(field_addr_tmp);
77312 }
77313#endif /* FREECIV_JSON_CONNECTION */
77314
77315#ifdef FREECIV_DELTA_PROTOCOL
77316#ifdef FREECIV_JSON_CONNECTION
77317 field_addr.name = "fields";
77318#endif /* FREECIV_JSON_CONNECTION */
77319 e = 0;
77320 e |= DIO_BV_PUT(&dout, &field_addr, fields);
77321 if (e) {
77322 log_packet_detailed("fields bitvector error detected");
77323 }
77324
77325 if (BV_ISSET(fields, 0)) {
77326 log_packet_detailed(" field 'id' has changed");
77327
77328#ifdef FREECIV_JSON_CONNECTION
77329 field_addr.name = "id";
77330#endif /* FREECIV_JSON_CONNECTION */
77331 e = 0;
77332
77333 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
77334
77335 if (e) {
77336 log_packet_detailed("'id' field error detected");
77337 }
77338 }
77339
77340 if (BV_ISSET(fields, 1)) {
77341 log_packet_detailed(" field 'cause' has changed");
77342
77343#ifdef FREECIV_JSON_CONNECTION
77344 field_addr.name = "cause";
77345#endif /* FREECIV_JSON_CONNECTION */
77346 e = 0;
77347
77348 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cause);
77349
77350 if (e) {
77351 log_packet_detailed("'cause' field error detected");
77352 }
77353 }
77354
77355 if (BV_ISSET(fields, 2)) {
77356 log_packet_detailed(" field 'reqs' has changed");
77357
77358#ifdef FREECIV_JSON_CONNECTION
77359 field_addr.name = "reqs";
77360#endif /* FREECIV_JSON_CONNECTION */
77361 e = 0;
77362
77363 {
77364 int i;
77365
77366 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
77367 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
77368
77369#ifdef FREECIV_JSON_CONNECTION
77370 /* Enter array. */
77371 field_addr.sub_location = plocation_elem_new(0);
77372#endif /* FREECIV_JSON_CONNECTION */
77373
77374 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
77375#ifdef FREECIV_JSON_CONNECTION
77376 /* Next array element. */
77377 field_addr.sub_location->number = i;
77378#endif /* FREECIV_JSON_CONNECTION */
77379
77380 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
77381 }
77382
77383#ifdef FREECIV_JSON_CONNECTION
77384 /* Exit array. */
77385 FC_FREE(field_addr.sub_location);
77386#endif /* FREECIV_JSON_CONNECTION */
77387 }
77388
77389 if (e) {
77390 log_packet_detailed("'reqs' field error detected");
77391 }
77392 }
77393
77394 if (BV_ISSET(fields, 3)) {
77395 log_packet_detailed(" field 'alternatives_count' has changed");
77396
77397#ifdef FREECIV_JSON_CONNECTION
77398 field_addr.name = "alternatives_count";
77399#endif /* FREECIV_JSON_CONNECTION */
77400 e = 0;
77401
77402 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->alternatives_count);
77403
77404 if (e) {
77405 log_packet_detailed("'alternatives_count' field error detected");
77406 }
77407 }
77408
77409 if (BV_ISSET(fields, 4)) {
77410 log_packet_detailed(" field 'alternatives' has changed");
77411
77412#ifdef FREECIV_JSON_CONNECTION
77413 field_addr.name = "alternatives";
77414#endif /* FREECIV_JSON_CONNECTION */
77415 e = 0;
77416
77417 {
77418 int i;
77419
77420#ifdef FREECIV_JSON_CONNECTION
77421 /* Create the array. */
77422 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->alternatives_count);
77423
77424 /* Enter array. */
77425 field_addr.sub_location = plocation_elem_new(0);
77426#endif /* FREECIV_JSON_CONNECTION */
77427
77428 for (i = 0; i < real_packet->alternatives_count; i++) {
77429#ifdef FREECIV_JSON_CONNECTION
77430 /* Next array element. */
77431 field_addr.sub_location->number = i;
77432#endif /* FREECIV_JSON_CONNECTION */
77433
77434 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->alternatives[i]);
77435 }
77436
77437#ifdef FREECIV_JSON_CONNECTION
77438 /* Exit array. */
77439 FC_FREE(field_addr.sub_location);
77440#endif /* FREECIV_JSON_CONNECTION */
77441 }
77442
77443 if (e) {
77444 log_packet_detailed("'alternatives' field error detected");
77445 }
77446 }
77447
77448 old->id = real_packet->id;
77449 old->cause = real_packet->cause;
77450 requirement_vector_copy(&old->reqs, &real_packet->reqs);
77451 old->alternatives_count = real_packet->alternatives_count;
77452 {
77453 int i;
77454
77455 for (i = 0; i < real_packet->alternatives_count; i++) {
77456 old->alternatives[i] = real_packet->alternatives[i];
77457 }
77458 }
77459
77460#else /* FREECIV_DELTA_PROTOCOL */
77461#ifdef FREECIV_JSON_CONNECTION
77462 field_addr.name = "id";
77463#endif /* FREECIV_JSON_CONNECTION */
77464 e = 0;
77465
77466 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
77467
77468 if (e) {
77469 log_packet_detailed("'id' field error detected");
77470 }
77471
77472#ifdef FREECIV_JSON_CONNECTION
77473 field_addr.name = "cause";
77474#endif /* FREECIV_JSON_CONNECTION */
77475 e = 0;
77476
77477 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->cause);
77478
77479 if (e) {
77480 log_packet_detailed("'cause' field error detected");
77481 }
77482
77483#ifdef FREECIV_JSON_CONNECTION
77484 field_addr.name = "reqs";
77485#endif /* FREECIV_JSON_CONNECTION */
77486 e = 0;
77487
77488 {
77489 int i;
77490
77491 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
77492 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
77493
77494#ifdef FREECIV_JSON_CONNECTION
77495 /* Enter array. */
77496 field_addr.sub_location = plocation_elem_new(0);
77497#endif /* FREECIV_JSON_CONNECTION */
77498
77499 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
77500#ifdef FREECIV_JSON_CONNECTION
77501 /* Next array element. */
77502 field_addr.sub_location->number = i;
77503#endif /* FREECIV_JSON_CONNECTION */
77504
77505 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
77506 }
77507
77508#ifdef FREECIV_JSON_CONNECTION
77509 /* Exit array. */
77510 FC_FREE(field_addr.sub_location);
77511#endif /* FREECIV_JSON_CONNECTION */
77512 }
77513
77514 if (e) {
77515 log_packet_detailed("'reqs' field error detected");
77516 }
77517
77518#ifdef FREECIV_JSON_CONNECTION
77519 field_addr.name = "alternatives_count";
77520#endif /* FREECIV_JSON_CONNECTION */
77521 e = 0;
77522
77523 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->alternatives_count);
77524
77525 if (e) {
77526 log_packet_detailed("'alternatives_count' field error detected");
77527 }
77528
77529#ifdef FREECIV_JSON_CONNECTION
77530 field_addr.name = "alternatives";
77531#endif /* FREECIV_JSON_CONNECTION */
77532 e = 0;
77533
77534 {
77535 int i;
77536
77537#ifdef FREECIV_JSON_CONNECTION
77538 /* Create the array. */
77539 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->alternatives_count);
77540
77541 /* Enter array. */
77542 field_addr.sub_location = plocation_elem_new(0);
77543#endif /* FREECIV_JSON_CONNECTION */
77544
77545 for (i = 0; i < real_packet->alternatives_count; i++) {
77546#ifdef FREECIV_JSON_CONNECTION
77547 /* Next array element. */
77548 field_addr.sub_location->number = i;
77549#endif /* FREECIV_JSON_CONNECTION */
77550
77551 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->alternatives[i]);
77552 }
77553
77554#ifdef FREECIV_JSON_CONNECTION
77555 /* Exit array. */
77556 FC_FREE(field_addr.sub_location);
77557#endif /* FREECIV_JSON_CONNECTION */
77558 }
77559
77560 if (e) {
77561 log_packet_detailed("'alternatives' field error detected");
77562 }
77563#endif /* FREECIV_DELTA_PROTOCOL */
77564
77565 SEND_PACKET_END(PACKET_RULESET_ACTION_AUTO);
77566}
77567
77568 int send_packet_ruleset_action_auto(struct connection *pc, const struct packet_ruleset_action_auto *packet)
77569{
77570 if (!pc->used) {
77571 log_error("WARNING: trying to send data to the closed connection %s",
77572 conn_description(pc));
77573 return -1;
77574 }
77575 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_ACTION_AUTO].packet != nullptr, -1,
77576 "Handler for PACKET_RULESET_ACTION_AUTO not installed");
77577 return pc->phs.handlers->send[PACKET_RULESET_ACTION_AUTO].packet(pc, packet);
77578}
77579
77580 void lsend_packet_ruleset_action_auto(struct conn_list *dest, const struct packet_ruleset_action_auto *packet)
77581{
77582 conn_list_iterate(dest, pconn) {
77583 send_packet_ruleset_action_auto(pconn, packet);
77584 } conn_list_iterate_end;
77585}
77586
77587 static inline void init_packet_ruleset_counter(struct packet_ruleset_counter *packet)
77588{
77589 memset(packet, 0, sizeof(*packet));
77590
77591 packet->helptext = strvec_new();
77592}
77593
77594 static inline void free_packet_ruleset_counter(struct packet_ruleset_counter *packet)
77595{
77596 if (packet->helptext) {
77597 strvec_destroy(packet->helptext);
77598 packet->helptext = nullptr;
77599 }
77600}
77601
77602 static inline void destroy_packet_ruleset_counter(void *packet)
77603{
77604 free_packet_ruleset_counter((struct packet_ruleset_counter *) packet);
77605 free(packet);
77606}
77607
77608#ifdef FREECIV_DELTA_PROTOCOL
77609#define hash_packet_ruleset_counter_100 hash_const
77610#define cmp_packet_ruleset_counter_100 cmp_const
77611 BV_DEFINE(packet_ruleset_counter_100_fields, 7);
77612#endif /* FREECIV_DELTA_PROTOCOL */
77613
77614 static struct packet_ruleset_counter *receive_packet_ruleset_counter_100(struct connection *pc)
77615{
77616#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_counter(_packet)
77617 RECEIVE_PACKET_START(packet_ruleset_counter, real_packet);
77618
77619#ifdef FREECIV_JSON_CONNECTION
77620 struct plocation field_addr;
77621 {
77622 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
77623 field_addr = *field_addr_tmp;
77624 FC_FREE(field_addr_tmp);
77625 }
77626#endif /* FREECIV_JSON_CONNECTION */
77627
77628 log_packet_detailed("packet_ruleset_counter_100: got info about ()");
77629
77630#ifdef FREECIV_DELTA_PROTOCOL
77631 packet_ruleset_counter_100_fields fields;
77632 struct packet_ruleset_counter *old;
77633 struct genhash **hash = pc->phs.received + PACKET_RULESET_COUNTER;
77634
77635 if (nullptr == *hash) {
77636 *hash = genhash_new_full(hash_packet_ruleset_counter_100, cmp_packet_ruleset_counter_100,
77637 nullptr, nullptr, nullptr, destroy_packet_ruleset_counter);
77638 }
77639
77640 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
77641 sz_strlcpy(real_packet->name, old->name);
77642 sz_strlcpy(real_packet->rule_name, old->rule_name);
77643 if (old->helptext) {
77644 strvec_copy(real_packet->helptext, old->helptext);
77645 } else {
77646 strvec_clear(real_packet->helptext);
77647 }
77648 real_packet->def = old->def;
77649 real_packet->checkpoint = old->checkpoint;
77650 real_packet->type = old->type;
77651 real_packet->behaviour = old->behaviour;
77652 } else {
77653 /* packet is already initialized empty */
77654 log_packet_detailed(" no old info");
77655 }
77656
77657#ifdef FREECIV_JSON_CONNECTION
77658 field_addr.name = "fields";
77659#endif /* FREECIV_JSON_CONNECTION */
77660 DIO_BV_GET(&din, &field_addr, fields);
77661
77662 if (BV_ISSET(fields, 0)) {
77663 log_packet_detailed(" got field 'name'");
77664
77665#ifdef FREECIV_JSON_CONNECTION
77666 field_addr.name = "name";
77667#endif /* FREECIV_JSON_CONNECTION */
77668
77669 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
77670 RECEIVE_PACKET_FIELD_ERROR(name);
77671 }
77672 }
77673
77674 if (BV_ISSET(fields, 1)) {
77675 log_packet_detailed(" got field 'rule_name'");
77676
77677#ifdef FREECIV_JSON_CONNECTION
77678 field_addr.name = "rule_name";
77679#endif /* FREECIV_JSON_CONNECTION */
77680
77681 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
77682 RECEIVE_PACKET_FIELD_ERROR(rule_name);
77683 }
77684 }
77685
77686 if (BV_ISSET(fields, 2)) {
77687 log_packet_detailed(" got field 'helptext'");
77688
77689#ifdef FREECIV_JSON_CONNECTION
77690 field_addr.name = "helptext";
77691#endif /* FREECIV_JSON_CONNECTION */
77692
77693 {
77694 int i;
77695
77696 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
77697 RECEIVE_PACKET_FIELD_ERROR(helptext);
77698 }
77699 strvec_reserve(real_packet->helptext, i);
77700
77701#ifdef FREECIV_JSON_CONNECTION
77702 /* Enter array. */
77703 field_addr.sub_location = plocation_elem_new(0);
77704#endif /* FREECIV_JSON_CONNECTION */
77705
77706 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
77707#ifdef FREECIV_JSON_CONNECTION
77708 /* Next array element */
77709 field_addr.sub_location->number = i;
77710#endif /* FREECIV_JSON_CONNECTION */
77711
77712 {
77713 char readin[MAX_LEN_PACKET];
77714
77715 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
77716 || !strvec_set(real_packet->helptext, i, readin)) {
77717 RECEIVE_PACKET_FIELD_ERROR(helptext);
77718 }
77719 }
77720 }
77721
77722#ifdef FREECIV_JSON_CONNECTION
77723 /* Exit array. */
77724 FC_FREE(field_addr.sub_location);
77725#endif /* FREECIV_JSON_CONNECTION */
77726 }
77727 }
77728
77729 if (BV_ISSET(fields, 3)) {
77730 log_packet_detailed(" got field 'def'");
77731
77732#ifdef FREECIV_JSON_CONNECTION
77733 field_addr.name = "def";
77734#endif /* FREECIV_JSON_CONNECTION */
77735
77736 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->def)) {
77737 RECEIVE_PACKET_FIELD_ERROR(def);
77738 }
77739 }
77740
77741 if (BV_ISSET(fields, 4)) {
77742 log_packet_detailed(" got field 'checkpoint'");
77743
77744#ifdef FREECIV_JSON_CONNECTION
77745 field_addr.name = "checkpoint";
77746#endif /* FREECIV_JSON_CONNECTION */
77747
77748 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->checkpoint)) {
77749 RECEIVE_PACKET_FIELD_ERROR(checkpoint);
77750 }
77751 }
77752
77753 if (BV_ISSET(fields, 5)) {
77754 log_packet_detailed(" got field 'type'");
77755
77756#ifdef FREECIV_JSON_CONNECTION
77757 field_addr.name = "type";
77758#endif /* FREECIV_JSON_CONNECTION */
77759
77760 {
77761 int readin;
77762
77763 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77764 RECEIVE_PACKET_FIELD_ERROR(type);
77765 }
77766 real_packet->type = readin;
77767 }
77768 }
77769
77770 if (BV_ISSET(fields, 6)) {
77771 log_packet_detailed(" got field 'behaviour'");
77772
77773#ifdef FREECIV_JSON_CONNECTION
77774 field_addr.name = "behaviour";
77775#endif /* FREECIV_JSON_CONNECTION */
77776
77777 {
77778 int readin;
77779
77780 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77781 RECEIVE_PACKET_FIELD_ERROR(behaviour);
77782 }
77783 real_packet->behaviour = readin;
77784 }
77785 }
77786
77787 if (nullptr == old) {
77788 old = fc_malloc(sizeof(*old));
77789 init_packet_ruleset_counter(old);
77790 sz_strlcpy(old->name, real_packet->name);
77791 sz_strlcpy(old->rule_name, real_packet->rule_name);
77792 if (real_packet->helptext) {
77793 strvec_copy(old->helptext, real_packet->helptext);
77794 } else {
77795 strvec_clear(old->helptext);
77796 }
77797 old->def = real_packet->def;
77798 old->checkpoint = real_packet->checkpoint;
77799 old->type = real_packet->type;
77800 old->behaviour = real_packet->behaviour;
77801 genhash_insert(*hash, old, old);
77802 } else {
77803 sz_strlcpy(old->name, real_packet->name);
77804 sz_strlcpy(old->rule_name, real_packet->rule_name);
77805 if (real_packet->helptext) {
77806 strvec_copy(old->helptext, real_packet->helptext);
77807 } else {
77808 strvec_clear(old->helptext);
77809 }
77810 old->def = real_packet->def;
77811 old->checkpoint = real_packet->checkpoint;
77812 old->type = real_packet->type;
77813 old->behaviour = real_packet->behaviour;
77814 }
77815
77816#else /* FREECIV_DELTA_PROTOCOL */
77817#ifdef FREECIV_JSON_CONNECTION
77818 field_addr.name = "name";
77819#endif /* FREECIV_JSON_CONNECTION */
77820
77821 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
77822 RECEIVE_PACKET_FIELD_ERROR(name);
77823 }
77824
77825#ifdef FREECIV_JSON_CONNECTION
77826 field_addr.name = "rule_name";
77827#endif /* FREECIV_JSON_CONNECTION */
77828
77829 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
77830 RECEIVE_PACKET_FIELD_ERROR(rule_name);
77831 }
77832
77833#ifdef FREECIV_JSON_CONNECTION
77834 field_addr.name = "helptext";
77835#endif /* FREECIV_JSON_CONNECTION */
77836
77837 {
77838 int i;
77839
77840 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
77841 RECEIVE_PACKET_FIELD_ERROR(helptext);
77842 }
77843 strvec_reserve(real_packet->helptext, i);
77844
77845#ifdef FREECIV_JSON_CONNECTION
77846 /* Enter array. */
77847 field_addr.sub_location = plocation_elem_new(0);
77848#endif /* FREECIV_JSON_CONNECTION */
77849
77850 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
77851#ifdef FREECIV_JSON_CONNECTION
77852 /* Next array element */
77853 field_addr.sub_location->number = i;
77854#endif /* FREECIV_JSON_CONNECTION */
77855
77856 {
77857 char readin[MAX_LEN_PACKET];
77858
77859 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
77860 || !strvec_set(real_packet->helptext, i, readin)) {
77861 RECEIVE_PACKET_FIELD_ERROR(helptext);
77862 }
77863 }
77864 }
77865
77866#ifdef FREECIV_JSON_CONNECTION
77867 /* Exit array. */
77868 FC_FREE(field_addr.sub_location);
77869#endif /* FREECIV_JSON_CONNECTION */
77870 }
77871
77872#ifdef FREECIV_JSON_CONNECTION
77873 field_addr.name = "def";
77874#endif /* FREECIV_JSON_CONNECTION */
77875
77876 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->def)) {
77877 RECEIVE_PACKET_FIELD_ERROR(def);
77878 }
77879
77880#ifdef FREECIV_JSON_CONNECTION
77881 field_addr.name = "checkpoint";
77882#endif /* FREECIV_JSON_CONNECTION */
77883
77884 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->checkpoint)) {
77885 RECEIVE_PACKET_FIELD_ERROR(checkpoint);
77886 }
77887
77888#ifdef FREECIV_JSON_CONNECTION
77889 field_addr.name = "type";
77890#endif /* FREECIV_JSON_CONNECTION */
77891
77892 {
77893 int readin;
77894
77895 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77896 RECEIVE_PACKET_FIELD_ERROR(type);
77897 }
77898 real_packet->type = readin;
77899 }
77900
77901#ifdef FREECIV_JSON_CONNECTION
77902 field_addr.name = "behaviour";
77903#endif /* FREECIV_JSON_CONNECTION */
77904
77905 {
77906 int readin;
77907
77908 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
77909 RECEIVE_PACKET_FIELD_ERROR(behaviour);
77910 }
77911 real_packet->behaviour = readin;
77912 }
77913#endif /* FREECIV_DELTA_PROTOCOL */
77914
77915 RECEIVE_PACKET_END(real_packet);
77916#undef FREE_PACKET_STRUCT
77917}
77918
77919 static int send_packet_ruleset_counter_100(struct connection *pc, const struct packet_ruleset_counter *packet)
77920{
77921 const struct packet_ruleset_counter *real_packet = packet;
77922 int e;
77923 SEND_PACKET_START(PACKET_RULESET_COUNTER);
77924
77925 log_packet_detailed("packet_ruleset_counter_100: sending info about ()");
77926
77927#ifdef FREECIV_DELTA_PROTOCOL
77928 packet_ruleset_counter_100_fields fields;
77929 struct packet_ruleset_counter *old;
77930 bool differ;
77931 struct genhash **hash = pc->phs.sent + PACKET_RULESET_COUNTER;
77932
77933 if (nullptr == *hash) {
77934 *hash = genhash_new_full(hash_packet_ruleset_counter_100, cmp_packet_ruleset_counter_100,
77935 nullptr, nullptr, nullptr, destroy_packet_ruleset_counter);
77936 }
77937 BV_CLR_ALL(fields);
77938
77939 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
77940 old = fc_malloc(sizeof(*old));
77941 /* temporary bitcopy just to insert correctly */
77942 *old = *real_packet;
77943 genhash_insert(*hash, old, old);
77944 init_packet_ruleset_counter(old);
77945 }
77946
77947 differ = (strcmp(old->name, real_packet->name) != 0);
77948 if (differ) {
77949 BV_SET(fields, 0);
77950 }
77951
77952 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
77953 if (differ) {
77954 BV_SET(fields, 1);
77955 }
77956
77957 if (real_packet->helptext) {
77958 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
77959 } else {
77960 differ = (strvec_size(old->helptext) > 0);
77961 }
77962 if (differ) {
77963 BV_SET(fields, 2);
77964 }
77965
77966 differ = (old->def != real_packet->def);
77967 if (differ) {
77968 BV_SET(fields, 3);
77969 }
77970
77971 differ = (old->checkpoint != real_packet->checkpoint);
77972 if (differ) {
77973 BV_SET(fields, 4);
77974 }
77975
77976 differ = (old->type != real_packet->type);
77977 if (differ) {
77978 BV_SET(fields, 5);
77979 }
77980
77981 differ = (old->behaviour != real_packet->behaviour);
77982 if (differ) {
77983 BV_SET(fields, 6);
77984 }
77985#endif /* FREECIV_DELTA_PROTOCOL */
77986
77987#ifdef FREECIV_JSON_CONNECTION
77988 struct plocation field_addr;
77989 {
77990 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
77991 field_addr = *field_addr_tmp;
77992 FC_FREE(field_addr_tmp);
77993 }
77994#endif /* FREECIV_JSON_CONNECTION */
77995
77996#ifdef FREECIV_DELTA_PROTOCOL
77997#ifdef FREECIV_JSON_CONNECTION
77998 field_addr.name = "fields";
77999#endif /* FREECIV_JSON_CONNECTION */
78000 e = 0;
78001 e |= DIO_BV_PUT(&dout, &field_addr, fields);
78002 if (e) {
78003 log_packet_detailed("fields bitvector error detected");
78004 }
78005
78006 if (BV_ISSET(fields, 0)) {
78007 log_packet_detailed(" field 'name' has changed");
78008
78009#ifdef FREECIV_JSON_CONNECTION
78010 field_addr.name = "name";
78011#endif /* FREECIV_JSON_CONNECTION */
78012 e = 0;
78013
78014 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
78015
78016 if (e) {
78017 log_packet_detailed("'name' field error detected");
78018 }
78019 }
78020
78021 if (BV_ISSET(fields, 1)) {
78022 log_packet_detailed(" field 'rule_name' has changed");
78023
78024#ifdef FREECIV_JSON_CONNECTION
78025 field_addr.name = "rule_name";
78026#endif /* FREECIV_JSON_CONNECTION */
78027 e = 0;
78028
78029 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
78030
78031 if (e) {
78032 log_packet_detailed("'rule_name' field error detected");
78033 }
78034 }
78035
78036 if (BV_ISSET(fields, 2)) {
78037 log_packet_detailed(" field 'helptext' has changed");
78038
78039#ifdef FREECIV_JSON_CONNECTION
78040 field_addr.name = "helptext";
78041#endif /* FREECIV_JSON_CONNECTION */
78042 e = 0;
78043
78044 if (!real_packet->helptext) {
78045 /* Transmit null as empty */
78046 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
78047 } else {
78048 int i;
78049
78050 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
78051 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
78052
78053#ifdef FREECIV_JSON_CONNECTION
78054 /* Enter array. */
78055 field_addr.sub_location = plocation_elem_new(0);
78056#endif /* FREECIV_JSON_CONNECTION */
78057
78058 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
78059#ifdef FREECIV_JSON_CONNECTION
78060 /* Next array element. */
78061 field_addr.sub_location->number = i;
78062#endif /* FREECIV_JSON_CONNECTION */
78063
78064 {
78065 const char *pstr = strvec_get(real_packet->helptext, i);
78066
78067 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
78068 }
78069 }
78070
78071#ifdef FREECIV_JSON_CONNECTION
78072 /* Exit array. */
78073 FC_FREE(field_addr.sub_location);
78074#endif /* FREECIV_JSON_CONNECTION */
78075 }
78076
78077 if (e) {
78078 log_packet_detailed("'helptext' field error detected");
78079 }
78080 }
78081
78082 if (BV_ISSET(fields, 3)) {
78083 log_packet_detailed(" field 'def' has changed");
78084
78085#ifdef FREECIV_JSON_CONNECTION
78086 field_addr.name = "def";
78087#endif /* FREECIV_JSON_CONNECTION */
78088 e = 0;
78089
78090 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->def);
78091
78092 if (e) {
78093 log_packet_detailed("'def' field error detected");
78094 }
78095 }
78096
78097 if (BV_ISSET(fields, 4)) {
78098 log_packet_detailed(" field 'checkpoint' has changed");
78099
78100#ifdef FREECIV_JSON_CONNECTION
78101 field_addr.name = "checkpoint";
78102#endif /* FREECIV_JSON_CONNECTION */
78103 e = 0;
78104
78105 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->checkpoint);
78106
78107 if (e) {
78108 log_packet_detailed("'checkpoint' field error detected");
78109 }
78110 }
78111
78112 if (BV_ISSET(fields, 5)) {
78113 log_packet_detailed(" field 'type' has changed");
78114
78115#ifdef FREECIV_JSON_CONNECTION
78116 field_addr.name = "type";
78117#endif /* FREECIV_JSON_CONNECTION */
78118 e = 0;
78119
78120 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
78121
78122 if (e) {
78123 log_packet_detailed("'type' field error detected");
78124 }
78125 }
78126
78127 if (BV_ISSET(fields, 6)) {
78128 log_packet_detailed(" field 'behaviour' has changed");
78129
78130#ifdef FREECIV_JSON_CONNECTION
78131 field_addr.name = "behaviour";
78132#endif /* FREECIV_JSON_CONNECTION */
78133 e = 0;
78134
78135 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->behaviour);
78136
78137 if (e) {
78138 log_packet_detailed("'behaviour' field error detected");
78139 }
78140 }
78141
78142 sz_strlcpy(old->name, real_packet->name);
78143 sz_strlcpy(old->rule_name, real_packet->rule_name);
78144 if (real_packet->helptext) {
78145 strvec_copy(old->helptext, real_packet->helptext);
78146 } else {
78147 strvec_clear(old->helptext);
78148 }
78149 old->def = real_packet->def;
78150 old->checkpoint = real_packet->checkpoint;
78151 old->type = real_packet->type;
78152 old->behaviour = real_packet->behaviour;
78153
78154#else /* FREECIV_DELTA_PROTOCOL */
78155#ifdef FREECIV_JSON_CONNECTION
78156 field_addr.name = "name";
78157#endif /* FREECIV_JSON_CONNECTION */
78158 e = 0;
78159
78160 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
78161
78162 if (e) {
78163 log_packet_detailed("'name' field error detected");
78164 }
78165
78166#ifdef FREECIV_JSON_CONNECTION
78167 field_addr.name = "rule_name";
78168#endif /* FREECIV_JSON_CONNECTION */
78169 e = 0;
78170
78171 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
78172
78173 if (e) {
78174 log_packet_detailed("'rule_name' field error detected");
78175 }
78176
78177#ifdef FREECIV_JSON_CONNECTION
78178 field_addr.name = "helptext";
78179#endif /* FREECIV_JSON_CONNECTION */
78180 e = 0;
78181
78182 if (!real_packet->helptext) {
78183 /* Transmit null as empty */
78184 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
78185 } else {
78186 int i;
78187
78188 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
78189 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
78190
78191#ifdef FREECIV_JSON_CONNECTION
78192 /* Enter array. */
78193 field_addr.sub_location = plocation_elem_new(0);
78194#endif /* FREECIV_JSON_CONNECTION */
78195
78196 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
78197#ifdef FREECIV_JSON_CONNECTION
78198 /* Next array element. */
78199 field_addr.sub_location->number = i;
78200#endif /* FREECIV_JSON_CONNECTION */
78201
78202 {
78203 const char *pstr = strvec_get(real_packet->helptext, i);
78204
78205 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
78206 }
78207 }
78208
78209#ifdef FREECIV_JSON_CONNECTION
78210 /* Exit array. */
78211 FC_FREE(field_addr.sub_location);
78212#endif /* FREECIV_JSON_CONNECTION */
78213 }
78214
78215 if (e) {
78216 log_packet_detailed("'helptext' field error detected");
78217 }
78218
78219#ifdef FREECIV_JSON_CONNECTION
78220 field_addr.name = "def";
78221#endif /* FREECIV_JSON_CONNECTION */
78222 e = 0;
78223
78224 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->def);
78225
78226 if (e) {
78227 log_packet_detailed("'def' field error detected");
78228 }
78229
78230#ifdef FREECIV_JSON_CONNECTION
78231 field_addr.name = "checkpoint";
78232#endif /* FREECIV_JSON_CONNECTION */
78233 e = 0;
78234
78235 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->checkpoint);
78236
78237 if (e) {
78238 log_packet_detailed("'checkpoint' field error detected");
78239 }
78240
78241#ifdef FREECIV_JSON_CONNECTION
78242 field_addr.name = "type";
78243#endif /* FREECIV_JSON_CONNECTION */
78244 e = 0;
78245
78246 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
78247
78248 if (e) {
78249 log_packet_detailed("'type' field error detected");
78250 }
78251
78252#ifdef FREECIV_JSON_CONNECTION
78253 field_addr.name = "behaviour";
78254#endif /* FREECIV_JSON_CONNECTION */
78255 e = 0;
78256
78257 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->behaviour);
78258
78259 if (e) {
78260 log_packet_detailed("'behaviour' field error detected");
78261 }
78262#endif /* FREECIV_DELTA_PROTOCOL */
78263
78264 SEND_PACKET_END(PACKET_RULESET_COUNTER);
78265}
78266
78267 int send_packet_ruleset_counter(struct connection *pc, const struct packet_ruleset_counter *packet)
78268{
78269 if (!pc->used) {
78270 log_error("WARNING: trying to send data to the closed connection %s",
78271 conn_description(pc));
78272 return -1;
78273 }
78274 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_COUNTER].packet != nullptr, -1,
78275 "Handler for PACKET_RULESET_COUNTER not installed");
78276 return pc->phs.handlers->send[PACKET_RULESET_COUNTER].packet(pc, packet);
78277}
78278
78279 void lsend_packet_ruleset_counter(struct conn_list *dest, const struct packet_ruleset_counter *packet)
78280{
78281 conn_list_iterate(dest, pconn) {
78282 send_packet_ruleset_counter(pconn, packet);
78283 } conn_list_iterate_end;
78284}
78285
78286 static inline void init_packet_ruleset_music(struct packet_ruleset_music *packet)
78287{
78288 memset(packet, 0, sizeof(*packet));
78289
78290 requirement_vector_init(&packet->reqs);
78291}
78292
78293 static inline void free_packet_ruleset_music(struct packet_ruleset_music *packet)
78294{
78295 requirement_vector_free(&packet->reqs);
78296}
78297
78298 static inline void destroy_packet_ruleset_music(void *packet)
78299{
78300 free_packet_ruleset_music((struct packet_ruleset_music *) packet);
78301 free(packet);
78302}
78303
78304#ifdef FREECIV_DELTA_PROTOCOL
78305#define hash_packet_ruleset_music_100 hash_const
78306#define cmp_packet_ruleset_music_100 cmp_const
78307 BV_DEFINE(packet_ruleset_music_100_fields, 4);
78308#endif /* FREECIV_DELTA_PROTOCOL */
78309
78310 static struct packet_ruleset_music *receive_packet_ruleset_music_100(struct connection *pc)
78311{
78312#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_music(_packet)
78313 RECEIVE_PACKET_START(packet_ruleset_music, real_packet);
78314
78315#ifdef FREECIV_JSON_CONNECTION
78316 struct plocation field_addr;
78317 {
78318 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
78319 field_addr = *field_addr_tmp;
78320 FC_FREE(field_addr_tmp);
78321 }
78322#endif /* FREECIV_JSON_CONNECTION */
78323
78324 log_packet_detailed("packet_ruleset_music_100: got info about ()");
78325
78326#ifdef FREECIV_DELTA_PROTOCOL
78327 packet_ruleset_music_100_fields fields;
78328 struct packet_ruleset_music *old;
78329 struct genhash **hash = pc->phs.received + PACKET_RULESET_MUSIC;
78330
78331 if (nullptr == *hash) {
78332 *hash = genhash_new_full(hash_packet_ruleset_music_100, cmp_packet_ruleset_music_100,
78333 nullptr, nullptr, nullptr, destroy_packet_ruleset_music);
78334 }
78335
78336 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
78337 real_packet->id = old->id;
78338 sz_strlcpy(real_packet->music_peaceful, old->music_peaceful);
78339 sz_strlcpy(real_packet->music_combat, old->music_combat);
78340 requirement_vector_copy(&real_packet->reqs, &old->reqs);
78341 } else {
78342 /* packet is already initialized empty */
78343 log_packet_detailed(" no old info");
78344 }
78345
78346#ifdef FREECIV_JSON_CONNECTION
78347 field_addr.name = "fields";
78348#endif /* FREECIV_JSON_CONNECTION */
78349 DIO_BV_GET(&din, &field_addr, fields);
78350
78351 if (BV_ISSET(fields, 0)) {
78352 log_packet_detailed(" got field 'id'");
78353
78354#ifdef FREECIV_JSON_CONNECTION
78355 field_addr.name = "id";
78356#endif /* FREECIV_JSON_CONNECTION */
78357
78358 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
78359 RECEIVE_PACKET_FIELD_ERROR(id);
78360 }
78361 }
78362
78363 if (BV_ISSET(fields, 1)) {
78364 log_packet_detailed(" got field 'music_peaceful'");
78365
78366#ifdef FREECIV_JSON_CONNECTION
78367 field_addr.name = "music_peaceful";
78368#endif /* FREECIV_JSON_CONNECTION */
78369
78370 if (!DIO_GET(string, &din, &field_addr, real_packet->music_peaceful, sizeof(real_packet->music_peaceful))) {
78371 RECEIVE_PACKET_FIELD_ERROR(music_peaceful);
78372 }
78373 }
78374
78375 if (BV_ISSET(fields, 2)) {
78376 log_packet_detailed(" got field 'music_combat'");
78377
78378#ifdef FREECIV_JSON_CONNECTION
78379 field_addr.name = "music_combat";
78380#endif /* FREECIV_JSON_CONNECTION */
78381
78382 if (!DIO_GET(string, &din, &field_addr, real_packet->music_combat, sizeof(real_packet->music_combat))) {
78383 RECEIVE_PACKET_FIELD_ERROR(music_combat);
78384 }
78385 }
78386
78387 if (BV_ISSET(fields, 3)) {
78388 log_packet_detailed(" got field 'reqs'");
78389
78390#ifdef FREECIV_JSON_CONNECTION
78391 field_addr.name = "reqs";
78392#endif /* FREECIV_JSON_CONNECTION */
78393
78394 {
78395 int i;
78396
78397 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
78398 RECEIVE_PACKET_FIELD_ERROR(reqs);
78399 }
78400 requirement_vector_reserve(&real_packet->reqs, i);
78401
78402#ifdef FREECIV_JSON_CONNECTION
78403 /* Enter array. */
78404 field_addr.sub_location = plocation_elem_new(0);
78405#endif /* FREECIV_JSON_CONNECTION */
78406
78407 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
78408#ifdef FREECIV_JSON_CONNECTION
78409 /* Next array element */
78410 field_addr.sub_location->number = i;
78411#endif /* FREECIV_JSON_CONNECTION */
78412
78413 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
78414 RECEIVE_PACKET_FIELD_ERROR(reqs);
78415 }
78416 }
78417
78418#ifdef FREECIV_JSON_CONNECTION
78419 /* Exit array. */
78420 FC_FREE(field_addr.sub_location);
78421#endif /* FREECIV_JSON_CONNECTION */
78422 }
78423 }
78424
78425 if (nullptr == old) {
78426 old = fc_malloc(sizeof(*old));
78427 init_packet_ruleset_music(old);
78428 old->id = real_packet->id;
78429 sz_strlcpy(old->music_peaceful, real_packet->music_peaceful);
78430 sz_strlcpy(old->music_combat, real_packet->music_combat);
78431 requirement_vector_copy(&old->reqs, &real_packet->reqs);
78432 genhash_insert(*hash, old, old);
78433 } else {
78434 old->id = real_packet->id;
78435 sz_strlcpy(old->music_peaceful, real_packet->music_peaceful);
78436 sz_strlcpy(old->music_combat, real_packet->music_combat);
78437 requirement_vector_copy(&old->reqs, &real_packet->reqs);
78438 }
78439
78440#else /* FREECIV_DELTA_PROTOCOL */
78441#ifdef FREECIV_JSON_CONNECTION
78442 field_addr.name = "id";
78443#endif /* FREECIV_JSON_CONNECTION */
78444
78445 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
78446 RECEIVE_PACKET_FIELD_ERROR(id);
78447 }
78448
78449#ifdef FREECIV_JSON_CONNECTION
78450 field_addr.name = "music_peaceful";
78451#endif /* FREECIV_JSON_CONNECTION */
78452
78453 if (!DIO_GET(string, &din, &field_addr, real_packet->music_peaceful, sizeof(real_packet->music_peaceful))) {
78454 RECEIVE_PACKET_FIELD_ERROR(music_peaceful);
78455 }
78456
78457#ifdef FREECIV_JSON_CONNECTION
78458 field_addr.name = "music_combat";
78459#endif /* FREECIV_JSON_CONNECTION */
78460
78461 if (!DIO_GET(string, &din, &field_addr, real_packet->music_combat, sizeof(real_packet->music_combat))) {
78462 RECEIVE_PACKET_FIELD_ERROR(music_combat);
78463 }
78464
78465#ifdef FREECIV_JSON_CONNECTION
78466 field_addr.name = "reqs";
78467#endif /* FREECIV_JSON_CONNECTION */
78468
78469 {
78470 int i;
78471
78472 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
78473 RECEIVE_PACKET_FIELD_ERROR(reqs);
78474 }
78475 requirement_vector_reserve(&real_packet->reqs, i);
78476
78477#ifdef FREECIV_JSON_CONNECTION
78478 /* Enter array. */
78479 field_addr.sub_location = plocation_elem_new(0);
78480#endif /* FREECIV_JSON_CONNECTION */
78481
78482 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
78483#ifdef FREECIV_JSON_CONNECTION
78484 /* Next array element */
78485 field_addr.sub_location->number = i;
78486#endif /* FREECIV_JSON_CONNECTION */
78487
78488 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
78489 RECEIVE_PACKET_FIELD_ERROR(reqs);
78490 }
78491 }
78492
78493#ifdef FREECIV_JSON_CONNECTION
78494 /* Exit array. */
78495 FC_FREE(field_addr.sub_location);
78496#endif /* FREECIV_JSON_CONNECTION */
78497 }
78498#endif /* FREECIV_DELTA_PROTOCOL */
78499
78500 RECEIVE_PACKET_END(real_packet);
78501#undef FREE_PACKET_STRUCT
78502}
78503
78504 static int send_packet_ruleset_music_100(struct connection *pc, const struct packet_ruleset_music *packet)
78505{
78506 const struct packet_ruleset_music *real_packet = packet;
78507 int e;
78508 SEND_PACKET_START(PACKET_RULESET_MUSIC);
78509
78510 log_packet_detailed("packet_ruleset_music_100: sending info about ()");
78511
78512#ifdef FREECIV_DELTA_PROTOCOL
78513 packet_ruleset_music_100_fields fields;
78514 struct packet_ruleset_music *old;
78515 bool differ;
78516 struct genhash **hash = pc->phs.sent + PACKET_RULESET_MUSIC;
78517
78518 if (nullptr == *hash) {
78519 *hash = genhash_new_full(hash_packet_ruleset_music_100, cmp_packet_ruleset_music_100,
78520 nullptr, nullptr, nullptr, destroy_packet_ruleset_music);
78521 }
78522 BV_CLR_ALL(fields);
78523
78524 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
78525 old = fc_malloc(sizeof(*old));
78526 /* temporary bitcopy just to insert correctly */
78527 *old = *real_packet;
78528 genhash_insert(*hash, old, old);
78529 init_packet_ruleset_music(old);
78530 }
78531
78532 differ = (old->id != real_packet->id);
78533 if (differ) {
78534 BV_SET(fields, 0);
78535 }
78536
78537 differ = (strcmp(old->music_peaceful, real_packet->music_peaceful) != 0);
78538 if (differ) {
78539 BV_SET(fields, 1);
78540 }
78541
78542 differ = (strcmp(old->music_combat, real_packet->music_combat) != 0);
78543 if (differ) {
78544 BV_SET(fields, 2);
78545 }
78546
78547 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
78548 if (!differ) {
78549 int i;
78550
78551 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
78552 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
78553 if (differ) {
78554 break;
78555 }
78556 }
78557 }
78558 if (differ) {
78559 BV_SET(fields, 3);
78560 }
78561#endif /* FREECIV_DELTA_PROTOCOL */
78562
78563#ifdef FREECIV_JSON_CONNECTION
78564 struct plocation field_addr;
78565 {
78566 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
78567 field_addr = *field_addr_tmp;
78568 FC_FREE(field_addr_tmp);
78569 }
78570#endif /* FREECIV_JSON_CONNECTION */
78571
78572#ifdef FREECIV_DELTA_PROTOCOL
78573#ifdef FREECIV_JSON_CONNECTION
78574 field_addr.name = "fields";
78575#endif /* FREECIV_JSON_CONNECTION */
78576 e = 0;
78577 e |= DIO_BV_PUT(&dout, &field_addr, fields);
78578 if (e) {
78579 log_packet_detailed("fields bitvector error detected");
78580 }
78581
78582 if (BV_ISSET(fields, 0)) {
78583 log_packet_detailed(" field 'id' has changed");
78584
78585#ifdef FREECIV_JSON_CONNECTION
78586 field_addr.name = "id";
78587#endif /* FREECIV_JSON_CONNECTION */
78588 e = 0;
78589
78590 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
78591
78592 if (e) {
78593 log_packet_detailed("'id' field error detected");
78594 }
78595 }
78596
78597 if (BV_ISSET(fields, 1)) {
78598 log_packet_detailed(" field 'music_peaceful' has changed");
78599
78600#ifdef FREECIV_JSON_CONNECTION
78601 field_addr.name = "music_peaceful";
78602#endif /* FREECIV_JSON_CONNECTION */
78603 e = 0;
78604
78605 e |= DIO_PUT(string, &dout, &field_addr, real_packet->music_peaceful);
78606
78607 if (e) {
78608 log_packet_detailed("'music_peaceful' field error detected");
78609 }
78610 }
78611
78612 if (BV_ISSET(fields, 2)) {
78613 log_packet_detailed(" field 'music_combat' has changed");
78614
78615#ifdef FREECIV_JSON_CONNECTION
78616 field_addr.name = "music_combat";
78617#endif /* FREECIV_JSON_CONNECTION */
78618 e = 0;
78619
78620 e |= DIO_PUT(string, &dout, &field_addr, real_packet->music_combat);
78621
78622 if (e) {
78623 log_packet_detailed("'music_combat' field error detected");
78624 }
78625 }
78626
78627 if (BV_ISSET(fields, 3)) {
78628 log_packet_detailed(" field 'reqs' has changed");
78629
78630#ifdef FREECIV_JSON_CONNECTION
78631 field_addr.name = "reqs";
78632#endif /* FREECIV_JSON_CONNECTION */
78633 e = 0;
78634
78635 {
78636 int i;
78637
78638 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
78639 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
78640
78641#ifdef FREECIV_JSON_CONNECTION
78642 /* Enter array. */
78643 field_addr.sub_location = plocation_elem_new(0);
78644#endif /* FREECIV_JSON_CONNECTION */
78645
78646 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
78647#ifdef FREECIV_JSON_CONNECTION
78648 /* Next array element. */
78649 field_addr.sub_location->number = i;
78650#endif /* FREECIV_JSON_CONNECTION */
78651
78652 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
78653 }
78654
78655#ifdef FREECIV_JSON_CONNECTION
78656 /* Exit array. */
78657 FC_FREE(field_addr.sub_location);
78658#endif /* FREECIV_JSON_CONNECTION */
78659 }
78660
78661 if (e) {
78662 log_packet_detailed("'reqs' field error detected");
78663 }
78664 }
78665
78666 old->id = real_packet->id;
78667 sz_strlcpy(old->music_peaceful, real_packet->music_peaceful);
78668 sz_strlcpy(old->music_combat, real_packet->music_combat);
78669 requirement_vector_copy(&old->reqs, &real_packet->reqs);
78670
78671#else /* FREECIV_DELTA_PROTOCOL */
78672#ifdef FREECIV_JSON_CONNECTION
78673 field_addr.name = "id";
78674#endif /* FREECIV_JSON_CONNECTION */
78675 e = 0;
78676
78677 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
78678
78679 if (e) {
78680 log_packet_detailed("'id' field error detected");
78681 }
78682
78683#ifdef FREECIV_JSON_CONNECTION
78684 field_addr.name = "music_peaceful";
78685#endif /* FREECIV_JSON_CONNECTION */
78686 e = 0;
78687
78688 e |= DIO_PUT(string, &dout, &field_addr, real_packet->music_peaceful);
78689
78690 if (e) {
78691 log_packet_detailed("'music_peaceful' field error detected");
78692 }
78693
78694#ifdef FREECIV_JSON_CONNECTION
78695 field_addr.name = "music_combat";
78696#endif /* FREECIV_JSON_CONNECTION */
78697 e = 0;
78698
78699 e |= DIO_PUT(string, &dout, &field_addr, real_packet->music_combat);
78700
78701 if (e) {
78702 log_packet_detailed("'music_combat' field error detected");
78703 }
78704
78705#ifdef FREECIV_JSON_CONNECTION
78706 field_addr.name = "reqs";
78707#endif /* FREECIV_JSON_CONNECTION */
78708 e = 0;
78709
78710 {
78711 int i;
78712
78713 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
78714 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
78715
78716#ifdef FREECIV_JSON_CONNECTION
78717 /* Enter array. */
78718 field_addr.sub_location = plocation_elem_new(0);
78719#endif /* FREECIV_JSON_CONNECTION */
78720
78721 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
78722#ifdef FREECIV_JSON_CONNECTION
78723 /* Next array element. */
78724 field_addr.sub_location->number = i;
78725#endif /* FREECIV_JSON_CONNECTION */
78726
78727 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
78728 }
78729
78730#ifdef FREECIV_JSON_CONNECTION
78731 /* Exit array. */
78732 FC_FREE(field_addr.sub_location);
78733#endif /* FREECIV_JSON_CONNECTION */
78734 }
78735
78736 if (e) {
78737 log_packet_detailed("'reqs' field error detected");
78738 }
78739#endif /* FREECIV_DELTA_PROTOCOL */
78740
78741 SEND_PACKET_END(PACKET_RULESET_MUSIC);
78742}
78743
78744 int send_packet_ruleset_music(struct connection *pc, const struct packet_ruleset_music *packet)
78745{
78746 if (!pc->used) {
78747 log_error("WARNING: trying to send data to the closed connection %s",
78748 conn_description(pc));
78749 return -1;
78750 }
78751 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_MUSIC].packet != nullptr, -1,
78752 "Handler for PACKET_RULESET_MUSIC not installed");
78753 return pc->phs.handlers->send[PACKET_RULESET_MUSIC].packet(pc, packet);
78754}
78755
78756 void lsend_packet_ruleset_music(struct conn_list *dest, const struct packet_ruleset_music *packet)
78757{
78758 conn_list_iterate(dest, pconn) {
78759 send_packet_ruleset_music(pconn, packet);
78760 } conn_list_iterate_end;
78761}
78762
78763 static inline void init_packet_ruleset_multiplier(struct packet_ruleset_multiplier *packet)
78764{
78765 memset(packet, 0, sizeof(*packet));
78766
78767 requirement_vector_init(&packet->reqs);
78768 packet->helptext = strvec_new();
78769}
78770
78771 static inline void free_packet_ruleset_multiplier(struct packet_ruleset_multiplier *packet)
78772{
78773 if (packet->helptext) {
78774 strvec_destroy(packet->helptext);
78775 packet->helptext = nullptr;
78776 }
78777 requirement_vector_free(&packet->reqs);
78778}
78779
78780 static inline void destroy_packet_ruleset_multiplier(void *packet)
78781{
78782 free_packet_ruleset_multiplier((struct packet_ruleset_multiplier *) packet);
78783 free(packet);
78784}
78785
78786#ifdef FREECIV_DELTA_PROTOCOL
78787#define hash_packet_ruleset_multiplier_100 hash_const
78788#define cmp_packet_ruleset_multiplier_100 cmp_const
78789 BV_DEFINE(packet_ruleset_multiplier_100_fields, 12);
78790#endif /* FREECIV_DELTA_PROTOCOL */
78791
78792 static struct packet_ruleset_multiplier *receive_packet_ruleset_multiplier_100(struct connection *pc)
78793{
78794#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_multiplier(_packet)
78795 RECEIVE_PACKET_START(packet_ruleset_multiplier, real_packet);
78796
78797#ifdef FREECIV_JSON_CONNECTION
78798 struct plocation field_addr;
78799 {
78800 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
78801 field_addr = *field_addr_tmp;
78802 FC_FREE(field_addr_tmp);
78803 }
78804#endif /* FREECIV_JSON_CONNECTION */
78805
78806 log_packet_detailed("packet_ruleset_multiplier_100: got info about ()");
78807
78808#ifdef FREECIV_DELTA_PROTOCOL
78809 packet_ruleset_multiplier_100_fields fields;
78810 struct packet_ruleset_multiplier *old;
78811 struct genhash **hash = pc->phs.received + PACKET_RULESET_MULTIPLIER;
78812
78813 if (nullptr == *hash) {
78814 *hash = genhash_new_full(hash_packet_ruleset_multiplier_100, cmp_packet_ruleset_multiplier_100,
78815 nullptr, nullptr, nullptr, destroy_packet_ruleset_multiplier);
78816 }
78817
78818 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
78819 real_packet->id = old->id;
78820 real_packet->start = old->start;
78821 real_packet->stop = old->stop;
78822 real_packet->step = old->step;
78823 real_packet->def = old->def;
78824 real_packet->offset = old->offset;
78825 real_packet->factor = old->factor;
78826 real_packet->minimum_turns = old->minimum_turns;
78827 sz_strlcpy(real_packet->name, old->name);
78828 sz_strlcpy(real_packet->rule_name, old->rule_name);
78829 requirement_vector_copy(&real_packet->reqs, &old->reqs);
78830 if (old->helptext) {
78831 strvec_copy(real_packet->helptext, old->helptext);
78832 } else {
78833 strvec_clear(real_packet->helptext);
78834 }
78835 } else {
78836 /* packet is already initialized empty */
78837 log_packet_detailed(" no old info");
78838 }
78839
78840#ifdef FREECIV_JSON_CONNECTION
78841 field_addr.name = "fields";
78842#endif /* FREECIV_JSON_CONNECTION */
78843 DIO_BV_GET(&din, &field_addr, fields);
78844
78845 if (BV_ISSET(fields, 0)) {
78846 log_packet_detailed(" got field 'id'");
78847
78848#ifdef FREECIV_JSON_CONNECTION
78849 field_addr.name = "id";
78850#endif /* FREECIV_JSON_CONNECTION */
78851
78852 {
78853 int readin;
78854
78855 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
78856 RECEIVE_PACKET_FIELD_ERROR(id);
78857 }
78858 real_packet->id = readin;
78859 }
78860 }
78861
78862 if (BV_ISSET(fields, 1)) {
78863 log_packet_detailed(" got field 'start'");
78864
78865#ifdef FREECIV_JSON_CONNECTION
78866 field_addr.name = "start";
78867#endif /* FREECIV_JSON_CONNECTION */
78868
78869 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->start)) {
78870 RECEIVE_PACKET_FIELD_ERROR(start);
78871 }
78872 }
78873
78874 if (BV_ISSET(fields, 2)) {
78875 log_packet_detailed(" got field 'stop'");
78876
78877#ifdef FREECIV_JSON_CONNECTION
78878 field_addr.name = "stop";
78879#endif /* FREECIV_JSON_CONNECTION */
78880
78881 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->stop)) {
78882 RECEIVE_PACKET_FIELD_ERROR(stop);
78883 }
78884 }
78885
78886 if (BV_ISSET(fields, 3)) {
78887 log_packet_detailed(" got field 'step'");
78888
78889#ifdef FREECIV_JSON_CONNECTION
78890 field_addr.name = "step";
78891#endif /* FREECIV_JSON_CONNECTION */
78892
78893 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->step)) {
78894 RECEIVE_PACKET_FIELD_ERROR(step);
78895 }
78896 }
78897
78898 if (BV_ISSET(fields, 4)) {
78899 log_packet_detailed(" got field 'def'");
78900
78901#ifdef FREECIV_JSON_CONNECTION
78902 field_addr.name = "def";
78903#endif /* FREECIV_JSON_CONNECTION */
78904
78905 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->def)) {
78906 RECEIVE_PACKET_FIELD_ERROR(def);
78907 }
78908 }
78909
78910 if (BV_ISSET(fields, 5)) {
78911 log_packet_detailed(" got field 'offset'");
78912
78913#ifdef FREECIV_JSON_CONNECTION
78914 field_addr.name = "offset";
78915#endif /* FREECIV_JSON_CONNECTION */
78916
78917 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->offset)) {
78918 RECEIVE_PACKET_FIELD_ERROR(offset);
78919 }
78920 }
78921
78922 if (BV_ISSET(fields, 6)) {
78923 log_packet_detailed(" got field 'factor'");
78924
78925#ifdef FREECIV_JSON_CONNECTION
78926 field_addr.name = "factor";
78927#endif /* FREECIV_JSON_CONNECTION */
78928
78929 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->factor)) {
78930 RECEIVE_PACKET_FIELD_ERROR(factor);
78931 }
78932 }
78933
78934 if (BV_ISSET(fields, 7)) {
78935 log_packet_detailed(" got field 'minimum_turns'");
78936
78937#ifdef FREECIV_JSON_CONNECTION
78938 field_addr.name = "minimum_turns";
78939#endif /* FREECIV_JSON_CONNECTION */
78940
78941 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->minimum_turns)) {
78942 RECEIVE_PACKET_FIELD_ERROR(minimum_turns);
78943 }
78944 }
78945
78946 if (BV_ISSET(fields, 8)) {
78947 log_packet_detailed(" got field 'name'");
78948
78949#ifdef FREECIV_JSON_CONNECTION
78950 field_addr.name = "name";
78951#endif /* FREECIV_JSON_CONNECTION */
78952
78953 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
78954 RECEIVE_PACKET_FIELD_ERROR(name);
78955 }
78956 }
78957
78958 if (BV_ISSET(fields, 9)) {
78959 log_packet_detailed(" got field 'rule_name'");
78960
78961#ifdef FREECIV_JSON_CONNECTION
78962 field_addr.name = "rule_name";
78963#endif /* FREECIV_JSON_CONNECTION */
78964
78965 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
78966 RECEIVE_PACKET_FIELD_ERROR(rule_name);
78967 }
78968 }
78969
78970 if (BV_ISSET(fields, 10)) {
78971 log_packet_detailed(" got field 'reqs'");
78972
78973#ifdef FREECIV_JSON_CONNECTION
78974 field_addr.name = "reqs";
78975#endif /* FREECIV_JSON_CONNECTION */
78976
78977 {
78978 int i;
78979
78980 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
78981 RECEIVE_PACKET_FIELD_ERROR(reqs);
78982 }
78983 requirement_vector_reserve(&real_packet->reqs, i);
78984
78985#ifdef FREECIV_JSON_CONNECTION
78986 /* Enter array. */
78987 field_addr.sub_location = plocation_elem_new(0);
78988#endif /* FREECIV_JSON_CONNECTION */
78989
78990 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
78991#ifdef FREECIV_JSON_CONNECTION
78992 /* Next array element */
78993 field_addr.sub_location->number = i;
78994#endif /* FREECIV_JSON_CONNECTION */
78995
78996 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
78997 RECEIVE_PACKET_FIELD_ERROR(reqs);
78998 }
78999 }
79000
79001#ifdef FREECIV_JSON_CONNECTION
79002 /* Exit array. */
79003 FC_FREE(field_addr.sub_location);
79004#endif /* FREECIV_JSON_CONNECTION */
79005 }
79006 }
79007
79008 if (BV_ISSET(fields, 11)) {
79009 log_packet_detailed(" got field 'helptext'");
79010
79011#ifdef FREECIV_JSON_CONNECTION
79012 field_addr.name = "helptext";
79013#endif /* FREECIV_JSON_CONNECTION */
79014
79015 {
79016 int i;
79017
79018 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
79019 RECEIVE_PACKET_FIELD_ERROR(helptext);
79020 }
79021 strvec_reserve(real_packet->helptext, i);
79022
79023#ifdef FREECIV_JSON_CONNECTION
79024 /* Enter array. */
79025 field_addr.sub_location = plocation_elem_new(0);
79026#endif /* FREECIV_JSON_CONNECTION */
79027
79028 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
79029#ifdef FREECIV_JSON_CONNECTION
79030 /* Next array element */
79031 field_addr.sub_location->number = i;
79032#endif /* FREECIV_JSON_CONNECTION */
79033
79034 {
79035 char readin[MAX_LEN_PACKET];
79036
79037 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
79038 || !strvec_set(real_packet->helptext, i, readin)) {
79039 RECEIVE_PACKET_FIELD_ERROR(helptext);
79040 }
79041 }
79042 }
79043
79044#ifdef FREECIV_JSON_CONNECTION
79045 /* Exit array. */
79046 FC_FREE(field_addr.sub_location);
79047#endif /* FREECIV_JSON_CONNECTION */
79048 }
79049 }
79050
79051 if (nullptr == old) {
79052 old = fc_malloc(sizeof(*old));
79053 init_packet_ruleset_multiplier(old);
79054 old->id = real_packet->id;
79055 old->start = real_packet->start;
79056 old->stop = real_packet->stop;
79057 old->step = real_packet->step;
79058 old->def = real_packet->def;
79059 old->offset = real_packet->offset;
79060 old->factor = real_packet->factor;
79061 old->minimum_turns = real_packet->minimum_turns;
79062 sz_strlcpy(old->name, real_packet->name);
79063 sz_strlcpy(old->rule_name, real_packet->rule_name);
79064 requirement_vector_copy(&old->reqs, &real_packet->reqs);
79065 if (real_packet->helptext) {
79066 strvec_copy(old->helptext, real_packet->helptext);
79067 } else {
79068 strvec_clear(old->helptext);
79069 }
79070 genhash_insert(*hash, old, old);
79071 } else {
79072 old->id = real_packet->id;
79073 old->start = real_packet->start;
79074 old->stop = real_packet->stop;
79075 old->step = real_packet->step;
79076 old->def = real_packet->def;
79077 old->offset = real_packet->offset;
79078 old->factor = real_packet->factor;
79079 old->minimum_turns = real_packet->minimum_turns;
79080 sz_strlcpy(old->name, real_packet->name);
79081 sz_strlcpy(old->rule_name, real_packet->rule_name);
79082 requirement_vector_copy(&old->reqs, &real_packet->reqs);
79083 if (real_packet->helptext) {
79084 strvec_copy(old->helptext, real_packet->helptext);
79085 } else {
79086 strvec_clear(old->helptext);
79087 }
79088 }
79089
79090#else /* FREECIV_DELTA_PROTOCOL */
79091#ifdef FREECIV_JSON_CONNECTION
79092 field_addr.name = "id";
79093#endif /* FREECIV_JSON_CONNECTION */
79094
79095 {
79096 int readin;
79097
79098 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
79099 RECEIVE_PACKET_FIELD_ERROR(id);
79100 }
79101 real_packet->id = readin;
79102 }
79103
79104#ifdef FREECIV_JSON_CONNECTION
79105 field_addr.name = "start";
79106#endif /* FREECIV_JSON_CONNECTION */
79107
79108 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->start)) {
79109 RECEIVE_PACKET_FIELD_ERROR(start);
79110 }
79111
79112#ifdef FREECIV_JSON_CONNECTION
79113 field_addr.name = "stop";
79114#endif /* FREECIV_JSON_CONNECTION */
79115
79116 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->stop)) {
79117 RECEIVE_PACKET_FIELD_ERROR(stop);
79118 }
79119
79120#ifdef FREECIV_JSON_CONNECTION
79121 field_addr.name = "step";
79122#endif /* FREECIV_JSON_CONNECTION */
79123
79124 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->step)) {
79125 RECEIVE_PACKET_FIELD_ERROR(step);
79126 }
79127
79128#ifdef FREECIV_JSON_CONNECTION
79129 field_addr.name = "def";
79130#endif /* FREECIV_JSON_CONNECTION */
79131
79132 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->def)) {
79133 RECEIVE_PACKET_FIELD_ERROR(def);
79134 }
79135
79136#ifdef FREECIV_JSON_CONNECTION
79137 field_addr.name = "offset";
79138#endif /* FREECIV_JSON_CONNECTION */
79139
79140 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->offset)) {
79141 RECEIVE_PACKET_FIELD_ERROR(offset);
79142 }
79143
79144#ifdef FREECIV_JSON_CONNECTION
79145 field_addr.name = "factor";
79146#endif /* FREECIV_JSON_CONNECTION */
79147
79148 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->factor)) {
79149 RECEIVE_PACKET_FIELD_ERROR(factor);
79150 }
79151
79152#ifdef FREECIV_JSON_CONNECTION
79153 field_addr.name = "minimum_turns";
79154#endif /* FREECIV_JSON_CONNECTION */
79155
79156 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->minimum_turns)) {
79157 RECEIVE_PACKET_FIELD_ERROR(minimum_turns);
79158 }
79159
79160#ifdef FREECIV_JSON_CONNECTION
79161 field_addr.name = "name";
79162#endif /* FREECIV_JSON_CONNECTION */
79163
79164 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
79165 RECEIVE_PACKET_FIELD_ERROR(name);
79166 }
79167
79168#ifdef FREECIV_JSON_CONNECTION
79169 field_addr.name = "rule_name";
79170#endif /* FREECIV_JSON_CONNECTION */
79171
79172 if (!DIO_GET(string, &din, &field_addr, real_packet->rule_name, sizeof(real_packet->rule_name))) {
79173 RECEIVE_PACKET_FIELD_ERROR(rule_name);
79174 }
79175
79176#ifdef FREECIV_JSON_CONNECTION
79177 field_addr.name = "reqs";
79178#endif /* FREECIV_JSON_CONNECTION */
79179
79180 {
79181 int i;
79182
79183 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
79184 RECEIVE_PACKET_FIELD_ERROR(reqs);
79185 }
79186 requirement_vector_reserve(&real_packet->reqs, i);
79187
79188#ifdef FREECIV_JSON_CONNECTION
79189 /* Enter array. */
79190 field_addr.sub_location = plocation_elem_new(0);
79191#endif /* FREECIV_JSON_CONNECTION */
79192
79193 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
79194#ifdef FREECIV_JSON_CONNECTION
79195 /* Next array element */
79196 field_addr.sub_location->number = i;
79197#endif /* FREECIV_JSON_CONNECTION */
79198
79199 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
79200 RECEIVE_PACKET_FIELD_ERROR(reqs);
79201 }
79202 }
79203
79204#ifdef FREECIV_JSON_CONNECTION
79205 /* Exit array. */
79206 FC_FREE(field_addr.sub_location);
79207#endif /* FREECIV_JSON_CONNECTION */
79208 }
79209
79210#ifdef FREECIV_JSON_CONNECTION
79211 field_addr.name = "helptext";
79212#endif /* FREECIV_JSON_CONNECTION */
79213
79214 {
79215 int i;
79216
79217 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
79218 RECEIVE_PACKET_FIELD_ERROR(helptext);
79219 }
79220 strvec_reserve(real_packet->helptext, i);
79221
79222#ifdef FREECIV_JSON_CONNECTION
79223 /* Enter array. */
79224 field_addr.sub_location = plocation_elem_new(0);
79225#endif /* FREECIV_JSON_CONNECTION */
79226
79227 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
79228#ifdef FREECIV_JSON_CONNECTION
79229 /* Next array element */
79230 field_addr.sub_location->number = i;
79231#endif /* FREECIV_JSON_CONNECTION */
79232
79233 {
79234 char readin[MAX_LEN_PACKET];
79235
79236 if (!DIO_GET(string, &din, &field_addr, readin, sizeof(readin))
79237 || !strvec_set(real_packet->helptext, i, readin)) {
79238 RECEIVE_PACKET_FIELD_ERROR(helptext);
79239 }
79240 }
79241 }
79242
79243#ifdef FREECIV_JSON_CONNECTION
79244 /* Exit array. */
79245 FC_FREE(field_addr.sub_location);
79246#endif /* FREECIV_JSON_CONNECTION */
79247 }
79248#endif /* FREECIV_DELTA_PROTOCOL */
79249
79250 RECEIVE_PACKET_END(real_packet);
79251#undef FREE_PACKET_STRUCT
79252}
79253
79254 static int send_packet_ruleset_multiplier_100(struct connection *pc, const struct packet_ruleset_multiplier *packet)
79255{
79256 const struct packet_ruleset_multiplier *real_packet = packet;
79257 int e;
79258 SEND_PACKET_START(PACKET_RULESET_MULTIPLIER);
79259
79260 log_packet_detailed("packet_ruleset_multiplier_100: sending info about ()");
79261
79262#ifdef FREECIV_DELTA_PROTOCOL
79263 packet_ruleset_multiplier_100_fields fields;
79264 struct packet_ruleset_multiplier *old;
79265 bool differ;
79266 struct genhash **hash = pc->phs.sent + PACKET_RULESET_MULTIPLIER;
79267
79268 if (nullptr == *hash) {
79269 *hash = genhash_new_full(hash_packet_ruleset_multiplier_100, cmp_packet_ruleset_multiplier_100,
79270 nullptr, nullptr, nullptr, destroy_packet_ruleset_multiplier);
79271 }
79272 BV_CLR_ALL(fields);
79273
79274 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
79275 old = fc_malloc(sizeof(*old));
79276 /* temporary bitcopy just to insert correctly */
79277 *old = *real_packet;
79278 genhash_insert(*hash, old, old);
79279 init_packet_ruleset_multiplier(old);
79280 }
79281
79282 differ = (old->id != real_packet->id);
79283 if (differ) {
79284 BV_SET(fields, 0);
79285 }
79286
79287 differ = (old->start != real_packet->start);
79288 if (differ) {
79289 BV_SET(fields, 1);
79290 }
79291
79292 differ = (old->stop != real_packet->stop);
79293 if (differ) {
79294 BV_SET(fields, 2);
79295 }
79296
79297 differ = (old->step != real_packet->step);
79298 if (differ) {
79299 BV_SET(fields, 3);
79300 }
79301
79302 differ = (old->def != real_packet->def);
79303 if (differ) {
79304 BV_SET(fields, 4);
79305 }
79306
79307 differ = (old->offset != real_packet->offset);
79308 if (differ) {
79309 BV_SET(fields, 5);
79310 }
79311
79312 differ = (old->factor != real_packet->factor);
79313 if (differ) {
79314 BV_SET(fields, 6);
79315 }
79316
79317 differ = (old->minimum_turns != real_packet->minimum_turns);
79318 if (differ) {
79319 BV_SET(fields, 7);
79320 }
79321
79322 differ = (strcmp(old->name, real_packet->name) != 0);
79323 if (differ) {
79324 BV_SET(fields, 8);
79325 }
79326
79327 differ = (strcmp(old->rule_name, real_packet->rule_name) != 0);
79328 if (differ) {
79329 BV_SET(fields, 9);
79330 }
79331
79332 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
79333 if (!differ) {
79334 int i;
79335
79336 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
79337 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
79338 if (differ) {
79339 break;
79340 }
79341 }
79342 }
79343 if (differ) {
79344 BV_SET(fields, 10);
79345 }
79346
79347 if (real_packet->helptext) {
79348 differ = !are_strvecs_equal(old->helptext, real_packet->helptext);
79349 } else {
79350 differ = (strvec_size(old->helptext) > 0);
79351 }
79352 if (differ) {
79353 BV_SET(fields, 11);
79354 }
79355#endif /* FREECIV_DELTA_PROTOCOL */
79356
79357#ifdef FREECIV_JSON_CONNECTION
79358 struct plocation field_addr;
79359 {
79360 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
79361 field_addr = *field_addr_tmp;
79362 FC_FREE(field_addr_tmp);
79363 }
79364#endif /* FREECIV_JSON_CONNECTION */
79365
79366#ifdef FREECIV_DELTA_PROTOCOL
79367#ifdef FREECIV_JSON_CONNECTION
79368 field_addr.name = "fields";
79369#endif /* FREECIV_JSON_CONNECTION */
79370 e = 0;
79371 e |= DIO_BV_PUT(&dout, &field_addr, fields);
79372 if (e) {
79373 log_packet_detailed("fields bitvector error detected");
79374 }
79375
79376 if (BV_ISSET(fields, 0)) {
79377 log_packet_detailed(" field 'id' has changed");
79378
79379#ifdef FREECIV_JSON_CONNECTION
79380 field_addr.name = "id";
79381#endif /* FREECIV_JSON_CONNECTION */
79382 e = 0;
79383
79384 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
79385
79386 if (e) {
79387 log_packet_detailed("'id' field error detected");
79388 }
79389 }
79390
79391 if (BV_ISSET(fields, 1)) {
79392 log_packet_detailed(" field 'start' has changed");
79393
79394#ifdef FREECIV_JSON_CONNECTION
79395 field_addr.name = "start";
79396#endif /* FREECIV_JSON_CONNECTION */
79397 e = 0;
79398
79399 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->start);
79400
79401 if (e) {
79402 log_packet_detailed("'start' field error detected");
79403 }
79404 }
79405
79406 if (BV_ISSET(fields, 2)) {
79407 log_packet_detailed(" field 'stop' has changed");
79408
79409#ifdef FREECIV_JSON_CONNECTION
79410 field_addr.name = "stop";
79411#endif /* FREECIV_JSON_CONNECTION */
79412 e = 0;
79413
79414 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->stop);
79415
79416 if (e) {
79417 log_packet_detailed("'stop' field error detected");
79418 }
79419 }
79420
79421 if (BV_ISSET(fields, 3)) {
79422 log_packet_detailed(" field 'step' has changed");
79423
79424#ifdef FREECIV_JSON_CONNECTION
79425 field_addr.name = "step";
79426#endif /* FREECIV_JSON_CONNECTION */
79427 e = 0;
79428
79429 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->step);
79430
79431 if (e) {
79432 log_packet_detailed("'step' field error detected");
79433 }
79434 }
79435
79436 if (BV_ISSET(fields, 4)) {
79437 log_packet_detailed(" field 'def' has changed");
79438
79439#ifdef FREECIV_JSON_CONNECTION
79440 field_addr.name = "def";
79441#endif /* FREECIV_JSON_CONNECTION */
79442 e = 0;
79443
79444 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->def);
79445
79446 if (e) {
79447 log_packet_detailed("'def' field error detected");
79448 }
79449 }
79450
79451 if (BV_ISSET(fields, 5)) {
79452 log_packet_detailed(" field 'offset' has changed");
79453
79454#ifdef FREECIV_JSON_CONNECTION
79455 field_addr.name = "offset";
79456#endif /* FREECIV_JSON_CONNECTION */
79457 e = 0;
79458
79459 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->offset);
79460
79461 if (e) {
79462 log_packet_detailed("'offset' field error detected");
79463 }
79464 }
79465
79466 if (BV_ISSET(fields, 6)) {
79467 log_packet_detailed(" field 'factor' has changed");
79468
79469#ifdef FREECIV_JSON_CONNECTION
79470 field_addr.name = "factor";
79471#endif /* FREECIV_JSON_CONNECTION */
79472 e = 0;
79473
79474 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->factor);
79475
79476 if (e) {
79477 log_packet_detailed("'factor' field error detected");
79478 }
79479 }
79480
79481 if (BV_ISSET(fields, 7)) {
79482 log_packet_detailed(" field 'minimum_turns' has changed");
79483
79484#ifdef FREECIV_JSON_CONNECTION
79485 field_addr.name = "minimum_turns";
79486#endif /* FREECIV_JSON_CONNECTION */
79487 e = 0;
79488
79489 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->minimum_turns);
79490
79491 if (e) {
79492 log_packet_detailed("'minimum_turns' field error detected");
79493 }
79494 }
79495
79496 if (BV_ISSET(fields, 8)) {
79497 log_packet_detailed(" field 'name' has changed");
79498
79499#ifdef FREECIV_JSON_CONNECTION
79500 field_addr.name = "name";
79501#endif /* FREECIV_JSON_CONNECTION */
79502 e = 0;
79503
79504 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
79505
79506 if (e) {
79507 log_packet_detailed("'name' field error detected");
79508 }
79509 }
79510
79511 if (BV_ISSET(fields, 9)) {
79512 log_packet_detailed(" field 'rule_name' has changed");
79513
79514#ifdef FREECIV_JSON_CONNECTION
79515 field_addr.name = "rule_name";
79516#endif /* FREECIV_JSON_CONNECTION */
79517 e = 0;
79518
79519 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
79520
79521 if (e) {
79522 log_packet_detailed("'rule_name' field error detected");
79523 }
79524 }
79525
79526 if (BV_ISSET(fields, 10)) {
79527 log_packet_detailed(" field 'reqs' has changed");
79528
79529#ifdef FREECIV_JSON_CONNECTION
79530 field_addr.name = "reqs";
79531#endif /* FREECIV_JSON_CONNECTION */
79532 e = 0;
79533
79534 {
79535 int i;
79536
79537 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
79538 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
79539
79540#ifdef FREECIV_JSON_CONNECTION
79541 /* Enter array. */
79542 field_addr.sub_location = plocation_elem_new(0);
79543#endif /* FREECIV_JSON_CONNECTION */
79544
79545 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
79546#ifdef FREECIV_JSON_CONNECTION
79547 /* Next array element. */
79548 field_addr.sub_location->number = i;
79549#endif /* FREECIV_JSON_CONNECTION */
79550
79551 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
79552 }
79553
79554#ifdef FREECIV_JSON_CONNECTION
79555 /* Exit array. */
79556 FC_FREE(field_addr.sub_location);
79557#endif /* FREECIV_JSON_CONNECTION */
79558 }
79559
79560 if (e) {
79561 log_packet_detailed("'reqs' field error detected");
79562 }
79563 }
79564
79565 if (BV_ISSET(fields, 11)) {
79566 log_packet_detailed(" field 'helptext' has changed");
79567
79568#ifdef FREECIV_JSON_CONNECTION
79569 field_addr.name = "helptext";
79570#endif /* FREECIV_JSON_CONNECTION */
79571 e = 0;
79572
79573 if (!real_packet->helptext) {
79574 /* Transmit null as empty */
79575 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
79576 } else {
79577 int i;
79578
79579 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
79580 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
79581
79582#ifdef FREECIV_JSON_CONNECTION
79583 /* Enter array. */
79584 field_addr.sub_location = plocation_elem_new(0);
79585#endif /* FREECIV_JSON_CONNECTION */
79586
79587 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
79588#ifdef FREECIV_JSON_CONNECTION
79589 /* Next array element. */
79590 field_addr.sub_location->number = i;
79591#endif /* FREECIV_JSON_CONNECTION */
79592
79593 {
79594 const char *pstr = strvec_get(real_packet->helptext, i);
79595
79596 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
79597 }
79598 }
79599
79600#ifdef FREECIV_JSON_CONNECTION
79601 /* Exit array. */
79602 FC_FREE(field_addr.sub_location);
79603#endif /* FREECIV_JSON_CONNECTION */
79604 }
79605
79606 if (e) {
79607 log_packet_detailed("'helptext' field error detected");
79608 }
79609 }
79610
79611 old->id = real_packet->id;
79612 old->start = real_packet->start;
79613 old->stop = real_packet->stop;
79614 old->step = real_packet->step;
79615 old->def = real_packet->def;
79616 old->offset = real_packet->offset;
79617 old->factor = real_packet->factor;
79618 old->minimum_turns = real_packet->minimum_turns;
79619 sz_strlcpy(old->name, real_packet->name);
79620 sz_strlcpy(old->rule_name, real_packet->rule_name);
79621 requirement_vector_copy(&old->reqs, &real_packet->reqs);
79622 if (real_packet->helptext) {
79623 strvec_copy(old->helptext, real_packet->helptext);
79624 } else {
79625 strvec_clear(old->helptext);
79626 }
79627
79628#else /* FREECIV_DELTA_PROTOCOL */
79629#ifdef FREECIV_JSON_CONNECTION
79630 field_addr.name = "id";
79631#endif /* FREECIV_JSON_CONNECTION */
79632 e = 0;
79633
79634 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
79635
79636 if (e) {
79637 log_packet_detailed("'id' field error detected");
79638 }
79639
79640#ifdef FREECIV_JSON_CONNECTION
79641 field_addr.name = "start";
79642#endif /* FREECIV_JSON_CONNECTION */
79643 e = 0;
79644
79645 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->start);
79646
79647 if (e) {
79648 log_packet_detailed("'start' field error detected");
79649 }
79650
79651#ifdef FREECIV_JSON_CONNECTION
79652 field_addr.name = "stop";
79653#endif /* FREECIV_JSON_CONNECTION */
79654 e = 0;
79655
79656 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->stop);
79657
79658 if (e) {
79659 log_packet_detailed("'stop' field error detected");
79660 }
79661
79662#ifdef FREECIV_JSON_CONNECTION
79663 field_addr.name = "step";
79664#endif /* FREECIV_JSON_CONNECTION */
79665 e = 0;
79666
79667 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->step);
79668
79669 if (e) {
79670 log_packet_detailed("'step' field error detected");
79671 }
79672
79673#ifdef FREECIV_JSON_CONNECTION
79674 field_addr.name = "def";
79675#endif /* FREECIV_JSON_CONNECTION */
79676 e = 0;
79677
79678 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->def);
79679
79680 if (e) {
79681 log_packet_detailed("'def' field error detected");
79682 }
79683
79684#ifdef FREECIV_JSON_CONNECTION
79685 field_addr.name = "offset";
79686#endif /* FREECIV_JSON_CONNECTION */
79687 e = 0;
79688
79689 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->offset);
79690
79691 if (e) {
79692 log_packet_detailed("'offset' field error detected");
79693 }
79694
79695#ifdef FREECIV_JSON_CONNECTION
79696 field_addr.name = "factor";
79697#endif /* FREECIV_JSON_CONNECTION */
79698 e = 0;
79699
79700 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->factor);
79701
79702 if (e) {
79703 log_packet_detailed("'factor' field error detected");
79704 }
79705
79706#ifdef FREECIV_JSON_CONNECTION
79707 field_addr.name = "minimum_turns";
79708#endif /* FREECIV_JSON_CONNECTION */
79709 e = 0;
79710
79711 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->minimum_turns);
79712
79713 if (e) {
79714 log_packet_detailed("'minimum_turns' field error detected");
79715 }
79716
79717#ifdef FREECIV_JSON_CONNECTION
79718 field_addr.name = "name";
79719#endif /* FREECIV_JSON_CONNECTION */
79720 e = 0;
79721
79722 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
79723
79724 if (e) {
79725 log_packet_detailed("'name' field error detected");
79726 }
79727
79728#ifdef FREECIV_JSON_CONNECTION
79729 field_addr.name = "rule_name";
79730#endif /* FREECIV_JSON_CONNECTION */
79731 e = 0;
79732
79733 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rule_name);
79734
79735 if (e) {
79736 log_packet_detailed("'rule_name' field error detected");
79737 }
79738
79739#ifdef FREECIV_JSON_CONNECTION
79740 field_addr.name = "reqs";
79741#endif /* FREECIV_JSON_CONNECTION */
79742 e = 0;
79743
79744 {
79745 int i;
79746
79747 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
79748 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
79749
79750#ifdef FREECIV_JSON_CONNECTION
79751 /* Enter array. */
79752 field_addr.sub_location = plocation_elem_new(0);
79753#endif /* FREECIV_JSON_CONNECTION */
79754
79755 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
79756#ifdef FREECIV_JSON_CONNECTION
79757 /* Next array element. */
79758 field_addr.sub_location->number = i;
79759#endif /* FREECIV_JSON_CONNECTION */
79760
79761 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
79762 }
79763
79764#ifdef FREECIV_JSON_CONNECTION
79765 /* Exit array. */
79766 FC_FREE(field_addr.sub_location);
79767#endif /* FREECIV_JSON_CONNECTION */
79768 }
79769
79770 if (e) {
79771 log_packet_detailed("'reqs' field error detected");
79772 }
79773
79774#ifdef FREECIV_JSON_CONNECTION
79775 field_addr.name = "helptext";
79776#endif /* FREECIV_JSON_CONNECTION */
79777 e = 0;
79778
79779 if (!real_packet->helptext) {
79780 /* Transmit null as empty */
79781 e |= DIO_PUT(arraylen, &dout, &field_addr, 0);
79782 } else {
79783 int i;
79784
79785 fc_assert(strvec_size(real_packet->helptext) < MAX_UINT16);
79786 e |= DIO_PUT(arraylen, &dout, &field_addr, strvec_size(real_packet->helptext));
79787
79788#ifdef FREECIV_JSON_CONNECTION
79789 /* Enter array. */
79790 field_addr.sub_location = plocation_elem_new(0);
79791#endif /* FREECIV_JSON_CONNECTION */
79792
79793 for (i = 0; i < strvec_size(real_packet->helptext); i++) {
79794#ifdef FREECIV_JSON_CONNECTION
79795 /* Next array element. */
79796 field_addr.sub_location->number = i;
79797#endif /* FREECIV_JSON_CONNECTION */
79798
79799 {
79800 const char *pstr = strvec_get(real_packet->helptext, i);
79801
79802 e |= DIO_PUT(string, &dout, &field_addr, pstr ? pstr : "");
79803 }
79804 }
79805
79806#ifdef FREECIV_JSON_CONNECTION
79807 /* Exit array. */
79808 FC_FREE(field_addr.sub_location);
79809#endif /* FREECIV_JSON_CONNECTION */
79810 }
79811
79812 if (e) {
79813 log_packet_detailed("'helptext' field error detected");
79814 }
79815#endif /* FREECIV_DELTA_PROTOCOL */
79816
79817 SEND_PACKET_END(PACKET_RULESET_MULTIPLIER);
79818}
79819
79820 int send_packet_ruleset_multiplier(struct connection *pc, const struct packet_ruleset_multiplier *packet)
79821{
79822 if (!pc->used) {
79823 log_error("WARNING: trying to send data to the closed connection %s",
79824 conn_description(pc));
79825 return -1;
79826 }
79827 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_MULTIPLIER].packet != nullptr, -1,
79828 "Handler for PACKET_RULESET_MULTIPLIER not installed");
79829 return pc->phs.handlers->send[PACKET_RULESET_MULTIPLIER].packet(pc, packet);
79830}
79831
79832 void lsend_packet_ruleset_multiplier(struct conn_list *dest, const struct packet_ruleset_multiplier *packet)
79833{
79834 conn_list_iterate(dest, pconn) {
79835 send_packet_ruleset_multiplier(pconn, packet);
79836 } conn_list_iterate_end;
79837}
79838
79839 static inline void init_packet_ruleset_clause(struct packet_ruleset_clause *packet)
79840{
79841 memset(packet, 0, sizeof(*packet));
79842
79843 requirement_vector_init(&packet->giver_reqs);
79844 requirement_vector_init(&packet->receiver_reqs);
79845 requirement_vector_init(&packet->either_reqs);
79846}
79847
79848 static inline void free_packet_ruleset_clause(struct packet_ruleset_clause *packet)
79849{
79850 requirement_vector_free(&packet->either_reqs);
79851 requirement_vector_free(&packet->receiver_reqs);
79852 requirement_vector_free(&packet->giver_reqs);
79853}
79854
79855 static inline void destroy_packet_ruleset_clause(void *packet)
79856{
79857 free_packet_ruleset_clause((struct packet_ruleset_clause *) packet);
79858 free(packet);
79859}
79860
79861#ifdef FREECIV_DELTA_PROTOCOL
79862#define hash_packet_ruleset_clause_100 hash_const
79863#define cmp_packet_ruleset_clause_100 cmp_const
79864 BV_DEFINE(packet_ruleset_clause_100_fields, 5);
79865#endif /* FREECIV_DELTA_PROTOCOL */
79866
79867 static struct packet_ruleset_clause *receive_packet_ruleset_clause_100(struct connection *pc)
79868{
79869#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_clause(_packet)
79870 RECEIVE_PACKET_START(packet_ruleset_clause, real_packet);
79871
79872#ifdef FREECIV_JSON_CONNECTION
79873 struct plocation field_addr;
79874 {
79875 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
79876 field_addr = *field_addr_tmp;
79877 FC_FREE(field_addr_tmp);
79878 }
79879#endif /* FREECIV_JSON_CONNECTION */
79880
79881 log_packet_detailed("packet_ruleset_clause_100: got info about ()");
79882
79883#ifdef FREECIV_DELTA_PROTOCOL
79884 packet_ruleset_clause_100_fields fields;
79885 struct packet_ruleset_clause *old;
79886 struct genhash **hash = pc->phs.received + PACKET_RULESET_CLAUSE;
79887
79888 if (nullptr == *hash) {
79889 *hash = genhash_new_full(hash_packet_ruleset_clause_100, cmp_packet_ruleset_clause_100,
79890 nullptr, nullptr, nullptr, destroy_packet_ruleset_clause);
79891 }
79892
79893 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
79894 real_packet->type = old->type;
79895 real_packet->enabled = old->enabled;
79896 requirement_vector_copy(&real_packet->giver_reqs, &old->giver_reqs);
79897 requirement_vector_copy(&real_packet->receiver_reqs, &old->receiver_reqs);
79898 requirement_vector_copy(&real_packet->either_reqs, &old->either_reqs);
79899 } else {
79900 /* packet is already initialized empty */
79901 log_packet_detailed(" no old info");
79902 }
79903
79904#ifdef FREECIV_JSON_CONNECTION
79905 field_addr.name = "fields";
79906#endif /* FREECIV_JSON_CONNECTION */
79907 DIO_BV_GET(&din, &field_addr, fields);
79908
79909 if (BV_ISSET(fields, 0)) {
79910 log_packet_detailed(" got field 'type'");
79911
79912#ifdef FREECIV_JSON_CONNECTION
79913 field_addr.name = "type";
79914#endif /* FREECIV_JSON_CONNECTION */
79915
79916 {
79917 int readin;
79918
79919 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
79920 RECEIVE_PACKET_FIELD_ERROR(type);
79921 }
79922 real_packet->type = readin;
79923 }
79924 }
79925
79926 real_packet->enabled = BV_ISSET(fields, 1);
79927
79928 if (BV_ISSET(fields, 2)) {
79929 log_packet_detailed(" got field 'giver_reqs'");
79930
79931#ifdef FREECIV_JSON_CONNECTION
79932 field_addr.name = "giver_reqs";
79933#endif /* FREECIV_JSON_CONNECTION */
79934
79935 {
79936 int i;
79937
79938 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
79939 RECEIVE_PACKET_FIELD_ERROR(giver_reqs);
79940 }
79941 requirement_vector_reserve(&real_packet->giver_reqs, i);
79942
79943#ifdef FREECIV_JSON_CONNECTION
79944 /* Enter array. */
79945 field_addr.sub_location = plocation_elem_new(0);
79946#endif /* FREECIV_JSON_CONNECTION */
79947
79948 for (i = 0; i < requirement_vector_size(&real_packet->giver_reqs); i++) {
79949#ifdef FREECIV_JSON_CONNECTION
79950 /* Next array element */
79951 field_addr.sub_location->number = i;
79952#endif /* FREECIV_JSON_CONNECTION */
79953
79954 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->giver_reqs.p[i])) {
79955 RECEIVE_PACKET_FIELD_ERROR(giver_reqs);
79956 }
79957 }
79958
79959#ifdef FREECIV_JSON_CONNECTION
79960 /* Exit array. */
79961 FC_FREE(field_addr.sub_location);
79962#endif /* FREECIV_JSON_CONNECTION */
79963 }
79964 }
79965
79966 if (BV_ISSET(fields, 3)) {
79967 log_packet_detailed(" got field 'receiver_reqs'");
79968
79969#ifdef FREECIV_JSON_CONNECTION
79970 field_addr.name = "receiver_reqs";
79971#endif /* FREECIV_JSON_CONNECTION */
79972
79973 {
79974 int i;
79975
79976 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
79977 RECEIVE_PACKET_FIELD_ERROR(receiver_reqs);
79978 }
79979 requirement_vector_reserve(&real_packet->receiver_reqs, i);
79980
79981#ifdef FREECIV_JSON_CONNECTION
79982 /* Enter array. */
79983 field_addr.sub_location = plocation_elem_new(0);
79984#endif /* FREECIV_JSON_CONNECTION */
79985
79986 for (i = 0; i < requirement_vector_size(&real_packet->receiver_reqs); i++) {
79987#ifdef FREECIV_JSON_CONNECTION
79988 /* Next array element */
79989 field_addr.sub_location->number = i;
79990#endif /* FREECIV_JSON_CONNECTION */
79991
79992 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->receiver_reqs.p[i])) {
79993 RECEIVE_PACKET_FIELD_ERROR(receiver_reqs);
79994 }
79995 }
79996
79997#ifdef FREECIV_JSON_CONNECTION
79998 /* Exit array. */
79999 FC_FREE(field_addr.sub_location);
80000#endif /* FREECIV_JSON_CONNECTION */
80001 }
80002 }
80003
80004 if (BV_ISSET(fields, 4)) {
80005 log_packet_detailed(" got field 'either_reqs'");
80006
80007#ifdef FREECIV_JSON_CONNECTION
80008 field_addr.name = "either_reqs";
80009#endif /* FREECIV_JSON_CONNECTION */
80010
80011 {
80012 int i;
80013
80014 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
80015 RECEIVE_PACKET_FIELD_ERROR(either_reqs);
80016 }
80017 requirement_vector_reserve(&real_packet->either_reqs, i);
80018
80019#ifdef FREECIV_JSON_CONNECTION
80020 /* Enter array. */
80021 field_addr.sub_location = plocation_elem_new(0);
80022#endif /* FREECIV_JSON_CONNECTION */
80023
80024 for (i = 0; i < requirement_vector_size(&real_packet->either_reqs); i++) {
80025#ifdef FREECIV_JSON_CONNECTION
80026 /* Next array element */
80027 field_addr.sub_location->number = i;
80028#endif /* FREECIV_JSON_CONNECTION */
80029
80030 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->either_reqs.p[i])) {
80031 RECEIVE_PACKET_FIELD_ERROR(either_reqs);
80032 }
80033 }
80034
80035#ifdef FREECIV_JSON_CONNECTION
80036 /* Exit array. */
80037 FC_FREE(field_addr.sub_location);
80038#endif /* FREECIV_JSON_CONNECTION */
80039 }
80040 }
80041
80042 if (nullptr == old) {
80043 old = fc_malloc(sizeof(*old));
80044 init_packet_ruleset_clause(old);
80045 old->type = real_packet->type;
80046 old->enabled = real_packet->enabled;
80047 requirement_vector_copy(&old->giver_reqs, &real_packet->giver_reqs);
80048 requirement_vector_copy(&old->receiver_reqs, &real_packet->receiver_reqs);
80049 requirement_vector_copy(&old->either_reqs, &real_packet->either_reqs);
80050 genhash_insert(*hash, old, old);
80051 } else {
80052 old->type = real_packet->type;
80053 old->enabled = real_packet->enabled;
80054 requirement_vector_copy(&old->giver_reqs, &real_packet->giver_reqs);
80055 requirement_vector_copy(&old->receiver_reqs, &real_packet->receiver_reqs);
80056 requirement_vector_copy(&old->either_reqs, &real_packet->either_reqs);
80057 }
80058
80059#else /* FREECIV_DELTA_PROTOCOL */
80060#ifdef FREECIV_JSON_CONNECTION
80061 field_addr.name = "type";
80062#endif /* FREECIV_JSON_CONNECTION */
80063
80064 {
80065 int readin;
80066
80067 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
80068 RECEIVE_PACKET_FIELD_ERROR(type);
80069 }
80070 real_packet->type = readin;
80071 }
80072
80073#ifdef FREECIV_JSON_CONNECTION
80074 field_addr.name = "enabled";
80075#endif /* FREECIV_JSON_CONNECTION */
80076
80077 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->enabled)) {
80078 RECEIVE_PACKET_FIELD_ERROR(enabled);
80079 }
80080
80081#ifdef FREECIV_JSON_CONNECTION
80082 field_addr.name = "giver_reqs";
80083#endif /* FREECIV_JSON_CONNECTION */
80084
80085 {
80086 int i;
80087
80088 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
80089 RECEIVE_PACKET_FIELD_ERROR(giver_reqs);
80090 }
80091 requirement_vector_reserve(&real_packet->giver_reqs, i);
80092
80093#ifdef FREECIV_JSON_CONNECTION
80094 /* Enter array. */
80095 field_addr.sub_location = plocation_elem_new(0);
80096#endif /* FREECIV_JSON_CONNECTION */
80097
80098 for (i = 0; i < requirement_vector_size(&real_packet->giver_reqs); i++) {
80099#ifdef FREECIV_JSON_CONNECTION
80100 /* Next array element */
80101 field_addr.sub_location->number = i;
80102#endif /* FREECIV_JSON_CONNECTION */
80103
80104 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->giver_reqs.p[i])) {
80105 RECEIVE_PACKET_FIELD_ERROR(giver_reqs);
80106 }
80107 }
80108
80109#ifdef FREECIV_JSON_CONNECTION
80110 /* Exit array. */
80111 FC_FREE(field_addr.sub_location);
80112#endif /* FREECIV_JSON_CONNECTION */
80113 }
80114
80115#ifdef FREECIV_JSON_CONNECTION
80116 field_addr.name = "receiver_reqs";
80117#endif /* FREECIV_JSON_CONNECTION */
80118
80119 {
80120 int i;
80121
80122 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
80123 RECEIVE_PACKET_FIELD_ERROR(receiver_reqs);
80124 }
80125 requirement_vector_reserve(&real_packet->receiver_reqs, i);
80126
80127#ifdef FREECIV_JSON_CONNECTION
80128 /* Enter array. */
80129 field_addr.sub_location = plocation_elem_new(0);
80130#endif /* FREECIV_JSON_CONNECTION */
80131
80132 for (i = 0; i < requirement_vector_size(&real_packet->receiver_reqs); i++) {
80133#ifdef FREECIV_JSON_CONNECTION
80134 /* Next array element */
80135 field_addr.sub_location->number = i;
80136#endif /* FREECIV_JSON_CONNECTION */
80137
80138 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->receiver_reqs.p[i])) {
80139 RECEIVE_PACKET_FIELD_ERROR(receiver_reqs);
80140 }
80141 }
80142
80143#ifdef FREECIV_JSON_CONNECTION
80144 /* Exit array. */
80145 FC_FREE(field_addr.sub_location);
80146#endif /* FREECIV_JSON_CONNECTION */
80147 }
80148
80149#ifdef FREECIV_JSON_CONNECTION
80150 field_addr.name = "either_reqs";
80151#endif /* FREECIV_JSON_CONNECTION */
80152
80153 {
80154 int i;
80155
80156 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
80157 RECEIVE_PACKET_FIELD_ERROR(either_reqs);
80158 }
80159 requirement_vector_reserve(&real_packet->either_reqs, i);
80160
80161#ifdef FREECIV_JSON_CONNECTION
80162 /* Enter array. */
80163 field_addr.sub_location = plocation_elem_new(0);
80164#endif /* FREECIV_JSON_CONNECTION */
80165
80166 for (i = 0; i < requirement_vector_size(&real_packet->either_reqs); i++) {
80167#ifdef FREECIV_JSON_CONNECTION
80168 /* Next array element */
80169 field_addr.sub_location->number = i;
80170#endif /* FREECIV_JSON_CONNECTION */
80171
80172 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->either_reqs.p[i])) {
80173 RECEIVE_PACKET_FIELD_ERROR(either_reqs);
80174 }
80175 }
80176
80177#ifdef FREECIV_JSON_CONNECTION
80178 /* Exit array. */
80179 FC_FREE(field_addr.sub_location);
80180#endif /* FREECIV_JSON_CONNECTION */
80181 }
80182#endif /* FREECIV_DELTA_PROTOCOL */
80183
80184 RECEIVE_PACKET_END(real_packet);
80185#undef FREE_PACKET_STRUCT
80186}
80187
80188 static int send_packet_ruleset_clause_100(struct connection *pc, const struct packet_ruleset_clause *packet)
80189{
80190 const struct packet_ruleset_clause *real_packet = packet;
80191 int e;
80192 SEND_PACKET_START(PACKET_RULESET_CLAUSE);
80193
80194 log_packet_detailed("packet_ruleset_clause_100: sending info about ()");
80195
80196#ifdef FREECIV_DELTA_PROTOCOL
80197 packet_ruleset_clause_100_fields fields;
80198 struct packet_ruleset_clause *old;
80199 bool differ;
80200 struct genhash **hash = pc->phs.sent + PACKET_RULESET_CLAUSE;
80201
80202 if (nullptr == *hash) {
80203 *hash = genhash_new_full(hash_packet_ruleset_clause_100, cmp_packet_ruleset_clause_100,
80204 nullptr, nullptr, nullptr, destroy_packet_ruleset_clause);
80205 }
80206 BV_CLR_ALL(fields);
80207
80208 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
80209 old = fc_malloc(sizeof(*old));
80210 /* temporary bitcopy just to insert correctly */
80211 *old = *real_packet;
80212 genhash_insert(*hash, old, old);
80213 init_packet_ruleset_clause(old);
80214 }
80215
80216 differ = (old->type != real_packet->type);
80217 if (differ) {
80218 BV_SET(fields, 0);
80219 }
80220
80221 /* folded into head */
80222 if (real_packet->enabled) {
80223 BV_SET(fields, 1);
80224 }
80225
80226 differ = (requirement_vector_size(&old->giver_reqs) != requirement_vector_size(&real_packet->giver_reqs));
80227 if (!differ) {
80228 int i;
80229
80230 for (i = 0; i < requirement_vector_size(&old->giver_reqs); i++) {
80231 differ = !are_requirements_equal(&old->giver_reqs.p[i], &real_packet->giver_reqs.p[i]);
80232 if (differ) {
80233 break;
80234 }
80235 }
80236 }
80237 if (differ) {
80238 BV_SET(fields, 2);
80239 }
80240
80241 differ = (requirement_vector_size(&old->receiver_reqs) != requirement_vector_size(&real_packet->receiver_reqs));
80242 if (!differ) {
80243 int i;
80244
80245 for (i = 0; i < requirement_vector_size(&old->receiver_reqs); i++) {
80246 differ = !are_requirements_equal(&old->receiver_reqs.p[i], &real_packet->receiver_reqs.p[i]);
80247 if (differ) {
80248 break;
80249 }
80250 }
80251 }
80252 if (differ) {
80253 BV_SET(fields, 3);
80254 }
80255
80256 differ = (requirement_vector_size(&old->either_reqs) != requirement_vector_size(&real_packet->either_reqs));
80257 if (!differ) {
80258 int i;
80259
80260 for (i = 0; i < requirement_vector_size(&old->either_reqs); i++) {
80261 differ = !are_requirements_equal(&old->either_reqs.p[i], &real_packet->either_reqs.p[i]);
80262 if (differ) {
80263 break;
80264 }
80265 }
80266 }
80267 if (differ) {
80268 BV_SET(fields, 4);
80269 }
80270#endif /* FREECIV_DELTA_PROTOCOL */
80271
80272#ifdef FREECIV_JSON_CONNECTION
80273 struct plocation field_addr;
80274 {
80275 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
80276 field_addr = *field_addr_tmp;
80277 FC_FREE(field_addr_tmp);
80278 }
80279#endif /* FREECIV_JSON_CONNECTION */
80280
80281#ifdef FREECIV_DELTA_PROTOCOL
80282#ifdef FREECIV_JSON_CONNECTION
80283 field_addr.name = "fields";
80284#endif /* FREECIV_JSON_CONNECTION */
80285 e = 0;
80286 e |= DIO_BV_PUT(&dout, &field_addr, fields);
80287 if (e) {
80288 log_packet_detailed("fields bitvector error detected");
80289 }
80290
80291 if (BV_ISSET(fields, 0)) {
80292 log_packet_detailed(" field 'type' has changed");
80293
80294#ifdef FREECIV_JSON_CONNECTION
80295 field_addr.name = "type";
80296#endif /* FREECIV_JSON_CONNECTION */
80297 e = 0;
80298
80299 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
80300
80301 if (e) {
80302 log_packet_detailed("'type' field error detected");
80303 }
80304 }
80305
80306 /* field 1 is folded into the header */
80307
80308 if (BV_ISSET(fields, 2)) {
80309 log_packet_detailed(" field 'giver_reqs' has changed");
80310
80311#ifdef FREECIV_JSON_CONNECTION
80312 field_addr.name = "giver_reqs";
80313#endif /* FREECIV_JSON_CONNECTION */
80314 e = 0;
80315
80316 {
80317 int i;
80318
80319 fc_assert(requirement_vector_size(&real_packet->giver_reqs) < MAX_UINT16);
80320 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->giver_reqs));
80321
80322#ifdef FREECIV_JSON_CONNECTION
80323 /* Enter array. */
80324 field_addr.sub_location = plocation_elem_new(0);
80325#endif /* FREECIV_JSON_CONNECTION */
80326
80327 for (i = 0; i < requirement_vector_size(&real_packet->giver_reqs); i++) {
80328#ifdef FREECIV_JSON_CONNECTION
80329 /* Next array element. */
80330 field_addr.sub_location->number = i;
80331#endif /* FREECIV_JSON_CONNECTION */
80332
80333 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->giver_reqs.p[i]);
80334 }
80335
80336#ifdef FREECIV_JSON_CONNECTION
80337 /* Exit array. */
80338 FC_FREE(field_addr.sub_location);
80339#endif /* FREECIV_JSON_CONNECTION */
80340 }
80341
80342 if (e) {
80343 log_packet_detailed("'giver_reqs' field error detected");
80344 }
80345 }
80346
80347 if (BV_ISSET(fields, 3)) {
80348 log_packet_detailed(" field 'receiver_reqs' has changed");
80349
80350#ifdef FREECIV_JSON_CONNECTION
80351 field_addr.name = "receiver_reqs";
80352#endif /* FREECIV_JSON_CONNECTION */
80353 e = 0;
80354
80355 {
80356 int i;
80357
80358 fc_assert(requirement_vector_size(&real_packet->receiver_reqs) < MAX_UINT16);
80359 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->receiver_reqs));
80360
80361#ifdef FREECIV_JSON_CONNECTION
80362 /* Enter array. */
80363 field_addr.sub_location = plocation_elem_new(0);
80364#endif /* FREECIV_JSON_CONNECTION */
80365
80366 for (i = 0; i < requirement_vector_size(&real_packet->receiver_reqs); i++) {
80367#ifdef FREECIV_JSON_CONNECTION
80368 /* Next array element. */
80369 field_addr.sub_location->number = i;
80370#endif /* FREECIV_JSON_CONNECTION */
80371
80372 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->receiver_reqs.p[i]);
80373 }
80374
80375#ifdef FREECIV_JSON_CONNECTION
80376 /* Exit array. */
80377 FC_FREE(field_addr.sub_location);
80378#endif /* FREECIV_JSON_CONNECTION */
80379 }
80380
80381 if (e) {
80382 log_packet_detailed("'receiver_reqs' field error detected");
80383 }
80384 }
80385
80386 if (BV_ISSET(fields, 4)) {
80387 log_packet_detailed(" field 'either_reqs' has changed");
80388
80389#ifdef FREECIV_JSON_CONNECTION
80390 field_addr.name = "either_reqs";
80391#endif /* FREECIV_JSON_CONNECTION */
80392 e = 0;
80393
80394 {
80395 int i;
80396
80397 fc_assert(requirement_vector_size(&real_packet->either_reqs) < MAX_UINT16);
80398 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->either_reqs));
80399
80400#ifdef FREECIV_JSON_CONNECTION
80401 /* Enter array. */
80402 field_addr.sub_location = plocation_elem_new(0);
80403#endif /* FREECIV_JSON_CONNECTION */
80404
80405 for (i = 0; i < requirement_vector_size(&real_packet->either_reqs); i++) {
80406#ifdef FREECIV_JSON_CONNECTION
80407 /* Next array element. */
80408 field_addr.sub_location->number = i;
80409#endif /* FREECIV_JSON_CONNECTION */
80410
80411 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->either_reqs.p[i]);
80412 }
80413
80414#ifdef FREECIV_JSON_CONNECTION
80415 /* Exit array. */
80416 FC_FREE(field_addr.sub_location);
80417#endif /* FREECIV_JSON_CONNECTION */
80418 }
80419
80420 if (e) {
80421 log_packet_detailed("'either_reqs' field error detected");
80422 }
80423 }
80424
80425 old->type = real_packet->type;
80426 old->enabled = real_packet->enabled;
80427 requirement_vector_copy(&old->giver_reqs, &real_packet->giver_reqs);
80428 requirement_vector_copy(&old->receiver_reqs, &real_packet->receiver_reqs);
80429 requirement_vector_copy(&old->either_reqs, &real_packet->either_reqs);
80430
80431#else /* FREECIV_DELTA_PROTOCOL */
80432#ifdef FREECIV_JSON_CONNECTION
80433 field_addr.name = "type";
80434#endif /* FREECIV_JSON_CONNECTION */
80435 e = 0;
80436
80437 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->type);
80438
80439 if (e) {
80440 log_packet_detailed("'type' field error detected");
80441 }
80442
80443#ifdef FREECIV_JSON_CONNECTION
80444 field_addr.name = "enabled";
80445#endif /* FREECIV_JSON_CONNECTION */
80446 e = 0;
80447
80448 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->enabled);
80449
80450 if (e) {
80451 log_packet_detailed("'enabled' field error detected");
80452 }
80453
80454#ifdef FREECIV_JSON_CONNECTION
80455 field_addr.name = "giver_reqs";
80456#endif /* FREECIV_JSON_CONNECTION */
80457 e = 0;
80458
80459 {
80460 int i;
80461
80462 fc_assert(requirement_vector_size(&real_packet->giver_reqs) < MAX_UINT16);
80463 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->giver_reqs));
80464
80465#ifdef FREECIV_JSON_CONNECTION
80466 /* Enter array. */
80467 field_addr.sub_location = plocation_elem_new(0);
80468#endif /* FREECIV_JSON_CONNECTION */
80469
80470 for (i = 0; i < requirement_vector_size(&real_packet->giver_reqs); i++) {
80471#ifdef FREECIV_JSON_CONNECTION
80472 /* Next array element. */
80473 field_addr.sub_location->number = i;
80474#endif /* FREECIV_JSON_CONNECTION */
80475
80476 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->giver_reqs.p[i]);
80477 }
80478
80479#ifdef FREECIV_JSON_CONNECTION
80480 /* Exit array. */
80481 FC_FREE(field_addr.sub_location);
80482#endif /* FREECIV_JSON_CONNECTION */
80483 }
80484
80485 if (e) {
80486 log_packet_detailed("'giver_reqs' field error detected");
80487 }
80488
80489#ifdef FREECIV_JSON_CONNECTION
80490 field_addr.name = "receiver_reqs";
80491#endif /* FREECIV_JSON_CONNECTION */
80492 e = 0;
80493
80494 {
80495 int i;
80496
80497 fc_assert(requirement_vector_size(&real_packet->receiver_reqs) < MAX_UINT16);
80498 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->receiver_reqs));
80499
80500#ifdef FREECIV_JSON_CONNECTION
80501 /* Enter array. */
80502 field_addr.sub_location = plocation_elem_new(0);
80503#endif /* FREECIV_JSON_CONNECTION */
80504
80505 for (i = 0; i < requirement_vector_size(&real_packet->receiver_reqs); i++) {
80506#ifdef FREECIV_JSON_CONNECTION
80507 /* Next array element. */
80508 field_addr.sub_location->number = i;
80509#endif /* FREECIV_JSON_CONNECTION */
80510
80511 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->receiver_reqs.p[i]);
80512 }
80513
80514#ifdef FREECIV_JSON_CONNECTION
80515 /* Exit array. */
80516 FC_FREE(field_addr.sub_location);
80517#endif /* FREECIV_JSON_CONNECTION */
80518 }
80519
80520 if (e) {
80521 log_packet_detailed("'receiver_reqs' field error detected");
80522 }
80523
80524#ifdef FREECIV_JSON_CONNECTION
80525 field_addr.name = "either_reqs";
80526#endif /* FREECIV_JSON_CONNECTION */
80527 e = 0;
80528
80529 {
80530 int i;
80531
80532 fc_assert(requirement_vector_size(&real_packet->either_reqs) < MAX_UINT16);
80533 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->either_reqs));
80534
80535#ifdef FREECIV_JSON_CONNECTION
80536 /* Enter array. */
80537 field_addr.sub_location = plocation_elem_new(0);
80538#endif /* FREECIV_JSON_CONNECTION */
80539
80540 for (i = 0; i < requirement_vector_size(&real_packet->either_reqs); i++) {
80541#ifdef FREECIV_JSON_CONNECTION
80542 /* Next array element. */
80543 field_addr.sub_location->number = i;
80544#endif /* FREECIV_JSON_CONNECTION */
80545
80546 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->either_reqs.p[i]);
80547 }
80548
80549#ifdef FREECIV_JSON_CONNECTION
80550 /* Exit array. */
80551 FC_FREE(field_addr.sub_location);
80552#endif /* FREECIV_JSON_CONNECTION */
80553 }
80554
80555 if (e) {
80556 log_packet_detailed("'either_reqs' field error detected");
80557 }
80558#endif /* FREECIV_DELTA_PROTOCOL */
80559
80560 SEND_PACKET_END(PACKET_RULESET_CLAUSE);
80561}
80562
80563 int send_packet_ruleset_clause(struct connection *pc, const struct packet_ruleset_clause *packet)
80564{
80565 if (!pc->used) {
80566 log_error("WARNING: trying to send data to the closed connection %s",
80567 conn_description(pc));
80568 return -1;
80569 }
80570 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CLAUSE].packet != nullptr, -1,
80571 "Handler for PACKET_RULESET_CLAUSE not installed");
80572 return pc->phs.handlers->send[PACKET_RULESET_CLAUSE].packet(pc, packet);
80573}
80574
80575 void lsend_packet_ruleset_clause(struct conn_list *dest, const struct packet_ruleset_clause *packet)
80576{
80577 conn_list_iterate(dest, pconn) {
80578 send_packet_ruleset_clause(pconn, packet);
80579 } conn_list_iterate_end;
80580}
80581
80582 static inline void init_packet_ruleset_control(struct packet_ruleset_control *packet)
80583{
80584 memset(packet, 0, sizeof(*packet));
80585}
80586
80587#define free_packet_ruleset_control(_packet) (void) 0
80588#define destroy_packet_ruleset_control free
80589
80590#ifdef FREECIV_DELTA_PROTOCOL
80591#define hash_packet_ruleset_control_100 hash_const
80592#define cmp_packet_ruleset_control_100 cmp_const
80593 BV_DEFINE(packet_ruleset_control_100_fields, 31);
80594#endif /* FREECIV_DELTA_PROTOCOL */
80595
80596 static struct packet_ruleset_control *receive_packet_ruleset_control_100(struct connection *pc)
80597{
80598#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_control(_packet)
80599 RECEIVE_PACKET_START(packet_ruleset_control, real_packet);
80600
80601#ifdef FREECIV_JSON_CONNECTION
80602 struct plocation field_addr;
80603 {
80604 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
80605 field_addr = *field_addr_tmp;
80606 FC_FREE(field_addr_tmp);
80607 }
80608#endif /* FREECIV_JSON_CONNECTION */
80609
80610 log_packet_detailed("packet_ruleset_control_100: got info about ()");
80611
80612#ifdef FREECIV_DELTA_PROTOCOL
80613 packet_ruleset_control_100_fields fields;
80614 struct packet_ruleset_control *old;
80615 struct genhash **hash = pc->phs.received + PACKET_RULESET_CONTROL;
80616
80617 if (nullptr == *hash) {
80618 *hash = genhash_new_full(hash_packet_ruleset_control_100, cmp_packet_ruleset_control_100,
80619 nullptr, nullptr, nullptr, destroy_packet_ruleset_control);
80620 }
80621
80622 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
80623 *real_packet = *old;
80624 } else {
80625 /* packet is already initialized empty */
80626 log_packet_detailed(" no old info");
80627 }
80628
80629#ifdef FREECIV_JSON_CONNECTION
80630 field_addr.name = "fields";
80631#endif /* FREECIV_JSON_CONNECTION */
80632 DIO_BV_GET(&din, &field_addr, fields);
80633
80634 if (BV_ISSET(fields, 0)) {
80635 log_packet_detailed(" got field 'num_unit_classes'");
80636
80637#ifdef FREECIV_JSON_CONNECTION
80638 field_addr.name = "num_unit_classes";
80639#endif /* FREECIV_JSON_CONNECTION */
80640
80641 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_unit_classes)) {
80642 RECEIVE_PACKET_FIELD_ERROR(num_unit_classes);
80643 }
80644 }
80645
80646 if (BV_ISSET(fields, 1)) {
80647 log_packet_detailed(" got field 'num_unit_types'");
80648
80649#ifdef FREECIV_JSON_CONNECTION
80650 field_addr.name = "num_unit_types";
80651#endif /* FREECIV_JSON_CONNECTION */
80652
80653 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_unit_types)) {
80654 RECEIVE_PACKET_FIELD_ERROR(num_unit_types);
80655 }
80656 }
80657
80658 if (BV_ISSET(fields, 2)) {
80659 log_packet_detailed(" got field 'num_impr_types'");
80660
80661#ifdef FREECIV_JSON_CONNECTION
80662 field_addr.name = "num_impr_types";
80663#endif /* FREECIV_JSON_CONNECTION */
80664
80665 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_impr_types)) {
80666 RECEIVE_PACKET_FIELD_ERROR(num_impr_types);
80667 }
80668 }
80669
80670 if (BV_ISSET(fields, 3)) {
80671 log_packet_detailed(" got field 'num_tech_classes'");
80672
80673#ifdef FREECIV_JSON_CONNECTION
80674 field_addr.name = "num_tech_classes";
80675#endif /* FREECIV_JSON_CONNECTION */
80676
80677 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_tech_classes)) {
80678 RECEIVE_PACKET_FIELD_ERROR(num_tech_classes);
80679 }
80680 }
80681
80682 if (BV_ISSET(fields, 4)) {
80683 log_packet_detailed(" got field 'num_tech_types'");
80684
80685#ifdef FREECIV_JSON_CONNECTION
80686 field_addr.name = "num_tech_types";
80687#endif /* FREECIV_JSON_CONNECTION */
80688
80689 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_tech_types)) {
80690 RECEIVE_PACKET_FIELD_ERROR(num_tech_types);
80691 }
80692 }
80693
80694 if (BV_ISSET(fields, 5)) {
80695 log_packet_detailed(" got field 'num_extra_types'");
80696
80697#ifdef FREECIV_JSON_CONNECTION
80698 field_addr.name = "num_extra_types";
80699#endif /* FREECIV_JSON_CONNECTION */
80700
80701 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_extra_types)) {
80702 RECEIVE_PACKET_FIELD_ERROR(num_extra_types);
80703 }
80704 }
80705
80706 if (BV_ISSET(fields, 6)) {
80707 log_packet_detailed(" got field 'num_base_types'");
80708
80709#ifdef FREECIV_JSON_CONNECTION
80710 field_addr.name = "num_base_types";
80711#endif /* FREECIV_JSON_CONNECTION */
80712
80713 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_base_types)) {
80714 RECEIVE_PACKET_FIELD_ERROR(num_base_types);
80715 }
80716 }
80717
80718 if (BV_ISSET(fields, 7)) {
80719 log_packet_detailed(" got field 'num_road_types'");
80720
80721#ifdef FREECIV_JSON_CONNECTION
80722 field_addr.name = "num_road_types";
80723#endif /* FREECIV_JSON_CONNECTION */
80724
80725 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_road_types)) {
80726 RECEIVE_PACKET_FIELD_ERROR(num_road_types);
80727 }
80728 }
80729
80730 if (BV_ISSET(fields, 8)) {
80731 log_packet_detailed(" got field 'num_resource_types'");
80732
80733#ifdef FREECIV_JSON_CONNECTION
80734 field_addr.name = "num_resource_types";
80735#endif /* FREECIV_JSON_CONNECTION */
80736
80737 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_resource_types)) {
80738 RECEIVE_PACKET_FIELD_ERROR(num_resource_types);
80739 }
80740 }
80741
80742 if (BV_ISSET(fields, 9)) {
80743 log_packet_detailed(" got field 'num_goods_types'");
80744
80745#ifdef FREECIV_JSON_CONNECTION
80746 field_addr.name = "num_goods_types";
80747#endif /* FREECIV_JSON_CONNECTION */
80748
80749 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_goods_types)) {
80750 RECEIVE_PACKET_FIELD_ERROR(num_goods_types);
80751 }
80752 }
80753
80754 if (BV_ISSET(fields, 10)) {
80755 log_packet_detailed(" got field 'num_disaster_types'");
80756
80757#ifdef FREECIV_JSON_CONNECTION
80758 field_addr.name = "num_disaster_types";
80759#endif /* FREECIV_JSON_CONNECTION */
80760
80761 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_disaster_types)) {
80762 RECEIVE_PACKET_FIELD_ERROR(num_disaster_types);
80763 }
80764 }
80765
80766 if (BV_ISSET(fields, 11)) {
80767 log_packet_detailed(" got field 'num_achievement_types'");
80768
80769#ifdef FREECIV_JSON_CONNECTION
80770 field_addr.name = "num_achievement_types";
80771#endif /* FREECIV_JSON_CONNECTION */
80772
80773 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_achievement_types)) {
80774 RECEIVE_PACKET_FIELD_ERROR(num_achievement_types);
80775 }
80776 }
80777
80778 if (BV_ISSET(fields, 12)) {
80779 log_packet_detailed(" got field 'num_multipliers'");
80780
80781#ifdef FREECIV_JSON_CONNECTION
80782 field_addr.name = "num_multipliers";
80783#endif /* FREECIV_JSON_CONNECTION */
80784
80785 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_multipliers)) {
80786 RECEIVE_PACKET_FIELD_ERROR(num_multipliers);
80787 }
80788 }
80789
80790 if (BV_ISSET(fields, 13)) {
80791 log_packet_detailed(" got field 'num_styles'");
80792
80793#ifdef FREECIV_JSON_CONNECTION
80794 field_addr.name = "num_styles";
80795#endif /* FREECIV_JSON_CONNECTION */
80796
80797 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_styles)) {
80798 RECEIVE_PACKET_FIELD_ERROR(num_styles);
80799 }
80800 }
80801
80802 if (BV_ISSET(fields, 14)) {
80803 log_packet_detailed(" got field 'num_music_styles'");
80804
80805#ifdef FREECIV_JSON_CONNECTION
80806 field_addr.name = "num_music_styles";
80807#endif /* FREECIV_JSON_CONNECTION */
80808
80809 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_music_styles)) {
80810 RECEIVE_PACKET_FIELD_ERROR(num_music_styles);
80811 }
80812 }
80813
80814 if (BV_ISSET(fields, 15)) {
80815 log_packet_detailed(" got field 'government_count'");
80816
80817#ifdef FREECIV_JSON_CONNECTION
80818 field_addr.name = "government_count";
80819#endif /* FREECIV_JSON_CONNECTION */
80820
80821 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->government_count)) {
80822 RECEIVE_PACKET_FIELD_ERROR(government_count);
80823 }
80824 }
80825
80826 if (BV_ISSET(fields, 16)) {
80827 log_packet_detailed(" got field 'nation_count'");
80828
80829#ifdef FREECIV_JSON_CONNECTION
80830 field_addr.name = "nation_count";
80831#endif /* FREECIV_JSON_CONNECTION */
80832
80833 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->nation_count)) {
80834 RECEIVE_PACKET_FIELD_ERROR(nation_count);
80835 }
80836 }
80837
80838 if (BV_ISSET(fields, 17)) {
80839 log_packet_detailed(" got field 'num_city_styles'");
80840
80841#ifdef FREECIV_JSON_CONNECTION
80842 field_addr.name = "num_city_styles";
80843#endif /* FREECIV_JSON_CONNECTION */
80844
80845 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_city_styles)) {
80846 RECEIVE_PACKET_FIELD_ERROR(num_city_styles);
80847 }
80848 }
80849
80850 if (BV_ISSET(fields, 18)) {
80851 log_packet_detailed(" got field 'terrain_count'");
80852
80853#ifdef FREECIV_JSON_CONNECTION
80854 field_addr.name = "terrain_count";
80855#endif /* FREECIV_JSON_CONNECTION */
80856
80857 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->terrain_count)) {
80858 RECEIVE_PACKET_FIELD_ERROR(terrain_count);
80859 }
80860 }
80861
80862 if (BV_ISSET(fields, 19)) {
80863 log_packet_detailed(" got field 'num_specialist_types'");
80864
80865#ifdef FREECIV_JSON_CONNECTION
80866 field_addr.name = "num_specialist_types";
80867#endif /* FREECIV_JSON_CONNECTION */
80868
80869 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_specialist_types)) {
80870 RECEIVE_PACKET_FIELD_ERROR(num_specialist_types);
80871 }
80872 }
80873
80874 if (BV_ISSET(fields, 20)) {
80875 log_packet_detailed(" got field 'num_nation_groups'");
80876
80877#ifdef FREECIV_JSON_CONNECTION
80878 field_addr.name = "num_nation_groups";
80879#endif /* FREECIV_JSON_CONNECTION */
80880
80881 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_nation_groups)) {
80882 RECEIVE_PACKET_FIELD_ERROR(num_nation_groups);
80883 }
80884 }
80885
80886 if (BV_ISSET(fields, 21)) {
80887 log_packet_detailed(" got field 'num_nation_sets'");
80888
80889#ifdef FREECIV_JSON_CONNECTION
80890 field_addr.name = "num_nation_sets";
80891#endif /* FREECIV_JSON_CONNECTION */
80892
80893 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_nation_sets)) {
80894 RECEIVE_PACKET_FIELD_ERROR(num_nation_sets);
80895 }
80896 }
80897
80898 if (BV_ISSET(fields, 22)) {
80899 log_packet_detailed(" got field 'preferred_tileset'");
80900
80901#ifdef FREECIV_JSON_CONNECTION
80902 field_addr.name = "preferred_tileset";
80903#endif /* FREECIV_JSON_CONNECTION */
80904
80905 if (!DIO_GET(string, &din, &field_addr, real_packet->preferred_tileset, sizeof(real_packet->preferred_tileset))) {
80906 RECEIVE_PACKET_FIELD_ERROR(preferred_tileset);
80907 }
80908 }
80909
80910 if (BV_ISSET(fields, 23)) {
80911 log_packet_detailed(" got field 'preferred_soundset'");
80912
80913#ifdef FREECIV_JSON_CONNECTION
80914 field_addr.name = "preferred_soundset";
80915#endif /* FREECIV_JSON_CONNECTION */
80916
80917 if (!DIO_GET(string, &din, &field_addr, real_packet->preferred_soundset, sizeof(real_packet->preferred_soundset))) {
80918 RECEIVE_PACKET_FIELD_ERROR(preferred_soundset);
80919 }
80920 }
80921
80922 if (BV_ISSET(fields, 24)) {
80923 log_packet_detailed(" got field 'preferred_musicset'");
80924
80925#ifdef FREECIV_JSON_CONNECTION
80926 field_addr.name = "preferred_musicset";
80927#endif /* FREECIV_JSON_CONNECTION */
80928
80929 if (!DIO_GET(string, &din, &field_addr, real_packet->preferred_musicset, sizeof(real_packet->preferred_musicset))) {
80930 RECEIVE_PACKET_FIELD_ERROR(preferred_musicset);
80931 }
80932 }
80933
80934 real_packet->popup_tech_help = BV_ISSET(fields, 25);
80935
80936 if (BV_ISSET(fields, 26)) {
80937 log_packet_detailed(" got field 'name'");
80938
80939#ifdef FREECIV_JSON_CONNECTION
80940 field_addr.name = "name";
80941#endif /* FREECIV_JSON_CONNECTION */
80942
80943 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
80944 RECEIVE_PACKET_FIELD_ERROR(name);
80945 }
80946 }
80947
80948 if (BV_ISSET(fields, 27)) {
80949 log_packet_detailed(" got field 'version'");
80950
80951#ifdef FREECIV_JSON_CONNECTION
80952 field_addr.name = "version";
80953#endif /* FREECIV_JSON_CONNECTION */
80954
80955 if (!DIO_GET(string, &din, &field_addr, real_packet->version, sizeof(real_packet->version))) {
80956 RECEIVE_PACKET_FIELD_ERROR(version);
80957 }
80958 }
80959
80960 if (BV_ISSET(fields, 28)) {
80961 log_packet_detailed(" got field 'alt_dir'");
80962
80963#ifdef FREECIV_JSON_CONNECTION
80964 field_addr.name = "alt_dir";
80965#endif /* FREECIV_JSON_CONNECTION */
80966
80967 if (!DIO_GET(string, &din, &field_addr, real_packet->alt_dir, sizeof(real_packet->alt_dir))) {
80968 RECEIVE_PACKET_FIELD_ERROR(alt_dir);
80969 }
80970 }
80971
80972 if (BV_ISSET(fields, 29)) {
80973 log_packet_detailed(" got field 'desc_length'");
80974
80975#ifdef FREECIV_JSON_CONNECTION
80976 field_addr.name = "desc_length";
80977#endif /* FREECIV_JSON_CONNECTION */
80978
80979 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->desc_length)) {
80980 RECEIVE_PACKET_FIELD_ERROR(desc_length);
80981 }
80982 }
80983
80984 if (BV_ISSET(fields, 30)) {
80985 log_packet_detailed(" got field 'num_counters'");
80986
80987#ifdef FREECIV_JSON_CONNECTION
80988 field_addr.name = "num_counters";
80989#endif /* FREECIV_JSON_CONNECTION */
80990
80991 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_counters)) {
80992 RECEIVE_PACKET_FIELD_ERROR(num_counters);
80993 }
80994 }
80995
80996 if (nullptr == old) {
80997 old = fc_malloc(sizeof(*old));
80998 init_packet_ruleset_control(old);
80999 *old = *real_packet;
81000 genhash_insert(*hash, old, old);
81001 } else {
81002 *old = *real_packet;
81003 }
81004
81005#else /* FREECIV_DELTA_PROTOCOL */
81006#ifdef FREECIV_JSON_CONNECTION
81007 field_addr.name = "num_unit_classes";
81008#endif /* FREECIV_JSON_CONNECTION */
81009
81010 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_unit_classes)) {
81011 RECEIVE_PACKET_FIELD_ERROR(num_unit_classes);
81012 }
81013
81014#ifdef FREECIV_JSON_CONNECTION
81015 field_addr.name = "num_unit_types";
81016#endif /* FREECIV_JSON_CONNECTION */
81017
81018 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_unit_types)) {
81019 RECEIVE_PACKET_FIELD_ERROR(num_unit_types);
81020 }
81021
81022#ifdef FREECIV_JSON_CONNECTION
81023 field_addr.name = "num_impr_types";
81024#endif /* FREECIV_JSON_CONNECTION */
81025
81026 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_impr_types)) {
81027 RECEIVE_PACKET_FIELD_ERROR(num_impr_types);
81028 }
81029
81030#ifdef FREECIV_JSON_CONNECTION
81031 field_addr.name = "num_tech_classes";
81032#endif /* FREECIV_JSON_CONNECTION */
81033
81034 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_tech_classes)) {
81035 RECEIVE_PACKET_FIELD_ERROR(num_tech_classes);
81036 }
81037
81038#ifdef FREECIV_JSON_CONNECTION
81039 field_addr.name = "num_tech_types";
81040#endif /* FREECIV_JSON_CONNECTION */
81041
81042 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_tech_types)) {
81043 RECEIVE_PACKET_FIELD_ERROR(num_tech_types);
81044 }
81045
81046#ifdef FREECIV_JSON_CONNECTION
81047 field_addr.name = "num_extra_types";
81048#endif /* FREECIV_JSON_CONNECTION */
81049
81050 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_extra_types)) {
81051 RECEIVE_PACKET_FIELD_ERROR(num_extra_types);
81052 }
81053
81054#ifdef FREECIV_JSON_CONNECTION
81055 field_addr.name = "num_base_types";
81056#endif /* FREECIV_JSON_CONNECTION */
81057
81058 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_base_types)) {
81059 RECEIVE_PACKET_FIELD_ERROR(num_base_types);
81060 }
81061
81062#ifdef FREECIV_JSON_CONNECTION
81063 field_addr.name = "num_road_types";
81064#endif /* FREECIV_JSON_CONNECTION */
81065
81066 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_road_types)) {
81067 RECEIVE_PACKET_FIELD_ERROR(num_road_types);
81068 }
81069
81070#ifdef FREECIV_JSON_CONNECTION
81071 field_addr.name = "num_resource_types";
81072#endif /* FREECIV_JSON_CONNECTION */
81073
81074 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_resource_types)) {
81075 RECEIVE_PACKET_FIELD_ERROR(num_resource_types);
81076 }
81077
81078#ifdef FREECIV_JSON_CONNECTION
81079 field_addr.name = "num_goods_types";
81080#endif /* FREECIV_JSON_CONNECTION */
81081
81082 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_goods_types)) {
81083 RECEIVE_PACKET_FIELD_ERROR(num_goods_types);
81084 }
81085
81086#ifdef FREECIV_JSON_CONNECTION
81087 field_addr.name = "num_disaster_types";
81088#endif /* FREECIV_JSON_CONNECTION */
81089
81090 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_disaster_types)) {
81091 RECEIVE_PACKET_FIELD_ERROR(num_disaster_types);
81092 }
81093
81094#ifdef FREECIV_JSON_CONNECTION
81095 field_addr.name = "num_achievement_types";
81096#endif /* FREECIV_JSON_CONNECTION */
81097
81098 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_achievement_types)) {
81099 RECEIVE_PACKET_FIELD_ERROR(num_achievement_types);
81100 }
81101
81102#ifdef FREECIV_JSON_CONNECTION
81103 field_addr.name = "num_multipliers";
81104#endif /* FREECIV_JSON_CONNECTION */
81105
81106 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_multipliers)) {
81107 RECEIVE_PACKET_FIELD_ERROR(num_multipliers);
81108 }
81109
81110#ifdef FREECIV_JSON_CONNECTION
81111 field_addr.name = "num_styles";
81112#endif /* FREECIV_JSON_CONNECTION */
81113
81114 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_styles)) {
81115 RECEIVE_PACKET_FIELD_ERROR(num_styles);
81116 }
81117
81118#ifdef FREECIV_JSON_CONNECTION
81119 field_addr.name = "num_music_styles";
81120#endif /* FREECIV_JSON_CONNECTION */
81121
81122 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_music_styles)) {
81123 RECEIVE_PACKET_FIELD_ERROR(num_music_styles);
81124 }
81125
81126#ifdef FREECIV_JSON_CONNECTION
81127 field_addr.name = "government_count";
81128#endif /* FREECIV_JSON_CONNECTION */
81129
81130 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->government_count)) {
81131 RECEIVE_PACKET_FIELD_ERROR(government_count);
81132 }
81133
81134#ifdef FREECIV_JSON_CONNECTION
81135 field_addr.name = "nation_count";
81136#endif /* FREECIV_JSON_CONNECTION */
81137
81138 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->nation_count)) {
81139 RECEIVE_PACKET_FIELD_ERROR(nation_count);
81140 }
81141
81142#ifdef FREECIV_JSON_CONNECTION
81143 field_addr.name = "num_city_styles";
81144#endif /* FREECIV_JSON_CONNECTION */
81145
81146 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_city_styles)) {
81147 RECEIVE_PACKET_FIELD_ERROR(num_city_styles);
81148 }
81149
81150#ifdef FREECIV_JSON_CONNECTION
81151 field_addr.name = "terrain_count";
81152#endif /* FREECIV_JSON_CONNECTION */
81153
81154 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->terrain_count)) {
81155 RECEIVE_PACKET_FIELD_ERROR(terrain_count);
81156 }
81157
81158#ifdef FREECIV_JSON_CONNECTION
81159 field_addr.name = "num_specialist_types";
81160#endif /* FREECIV_JSON_CONNECTION */
81161
81162 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_specialist_types)) {
81163 RECEIVE_PACKET_FIELD_ERROR(num_specialist_types);
81164 }
81165
81166#ifdef FREECIV_JSON_CONNECTION
81167 field_addr.name = "num_nation_groups";
81168#endif /* FREECIV_JSON_CONNECTION */
81169
81170 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_nation_groups)) {
81171 RECEIVE_PACKET_FIELD_ERROR(num_nation_groups);
81172 }
81173
81174#ifdef FREECIV_JSON_CONNECTION
81175 field_addr.name = "num_nation_sets";
81176#endif /* FREECIV_JSON_CONNECTION */
81177
81178 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_nation_sets)) {
81179 RECEIVE_PACKET_FIELD_ERROR(num_nation_sets);
81180 }
81181
81182#ifdef FREECIV_JSON_CONNECTION
81183 field_addr.name = "preferred_tileset";
81184#endif /* FREECIV_JSON_CONNECTION */
81185
81186 if (!DIO_GET(string, &din, &field_addr, real_packet->preferred_tileset, sizeof(real_packet->preferred_tileset))) {
81187 RECEIVE_PACKET_FIELD_ERROR(preferred_tileset);
81188 }
81189
81190#ifdef FREECIV_JSON_CONNECTION
81191 field_addr.name = "preferred_soundset";
81192#endif /* FREECIV_JSON_CONNECTION */
81193
81194 if (!DIO_GET(string, &din, &field_addr, real_packet->preferred_soundset, sizeof(real_packet->preferred_soundset))) {
81195 RECEIVE_PACKET_FIELD_ERROR(preferred_soundset);
81196 }
81197
81198#ifdef FREECIV_JSON_CONNECTION
81199 field_addr.name = "preferred_musicset";
81200#endif /* FREECIV_JSON_CONNECTION */
81201
81202 if (!DIO_GET(string, &din, &field_addr, real_packet->preferred_musicset, sizeof(real_packet->preferred_musicset))) {
81203 RECEIVE_PACKET_FIELD_ERROR(preferred_musicset);
81204 }
81205
81206#ifdef FREECIV_JSON_CONNECTION
81207 field_addr.name = "popup_tech_help";
81208#endif /* FREECIV_JSON_CONNECTION */
81209
81210 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->popup_tech_help)) {
81211 RECEIVE_PACKET_FIELD_ERROR(popup_tech_help);
81212 }
81213
81214#ifdef FREECIV_JSON_CONNECTION
81215 field_addr.name = "name";
81216#endif /* FREECIV_JSON_CONNECTION */
81217
81218 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
81219 RECEIVE_PACKET_FIELD_ERROR(name);
81220 }
81221
81222#ifdef FREECIV_JSON_CONNECTION
81223 field_addr.name = "version";
81224#endif /* FREECIV_JSON_CONNECTION */
81225
81226 if (!DIO_GET(string, &din, &field_addr, real_packet->version, sizeof(real_packet->version))) {
81227 RECEIVE_PACKET_FIELD_ERROR(version);
81228 }
81229
81230#ifdef FREECIV_JSON_CONNECTION
81231 field_addr.name = "alt_dir";
81232#endif /* FREECIV_JSON_CONNECTION */
81233
81234 if (!DIO_GET(string, &din, &field_addr, real_packet->alt_dir, sizeof(real_packet->alt_dir))) {
81235 RECEIVE_PACKET_FIELD_ERROR(alt_dir);
81236 }
81237
81238#ifdef FREECIV_JSON_CONNECTION
81239 field_addr.name = "desc_length";
81240#endif /* FREECIV_JSON_CONNECTION */
81241
81242 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->desc_length)) {
81243 RECEIVE_PACKET_FIELD_ERROR(desc_length);
81244 }
81245
81246#ifdef FREECIV_JSON_CONNECTION
81247 field_addr.name = "num_counters";
81248#endif /* FREECIV_JSON_CONNECTION */
81249
81250 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->num_counters)) {
81251 RECEIVE_PACKET_FIELD_ERROR(num_counters);
81252 }
81253#endif /* FREECIV_DELTA_PROTOCOL */
81254
81255 RECEIVE_PACKET_END(real_packet);
81256#undef FREE_PACKET_STRUCT
81257}
81258
81259 static int send_packet_ruleset_control_100(struct connection *pc, const struct packet_ruleset_control *packet)
81260{
81261 const struct packet_ruleset_control *real_packet = packet;
81262 int e;
81263 SEND_PACKET_START(PACKET_RULESET_CONTROL);
81264
81265 log_packet_detailed("packet_ruleset_control_100: sending info about ()");
81266
81267#ifdef FREECIV_DELTA_PROTOCOL
81268 packet_ruleset_control_100_fields fields;
81269 struct packet_ruleset_control *old;
81270 bool differ;
81271 struct genhash **hash = pc->phs.sent + PACKET_RULESET_CONTROL;
81272
81273 if (nullptr == *hash) {
81274 *hash = genhash_new_full(hash_packet_ruleset_control_100, cmp_packet_ruleset_control_100,
81275 nullptr, nullptr, nullptr, destroy_packet_ruleset_control);
81276 }
81277 BV_CLR_ALL(fields);
81278
81279 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
81280 old = fc_malloc(sizeof(*old));
81281 /* temporary bitcopy just to insert correctly */
81282 *old = *real_packet;
81283 genhash_insert(*hash, old, old);
81284 init_packet_ruleset_control(old);
81285 }
81286
81287 differ = (old->num_unit_classes != real_packet->num_unit_classes);
81288 if (differ) {
81289 BV_SET(fields, 0);
81290 }
81291
81292 differ = (old->num_unit_types != real_packet->num_unit_types);
81293 if (differ) {
81294 BV_SET(fields, 1);
81295 }
81296
81297 differ = (old->num_impr_types != real_packet->num_impr_types);
81298 if (differ) {
81299 BV_SET(fields, 2);
81300 }
81301
81302 differ = (old->num_tech_classes != real_packet->num_tech_classes);
81303 if (differ) {
81304 BV_SET(fields, 3);
81305 }
81306
81307 differ = (old->num_tech_types != real_packet->num_tech_types);
81308 if (differ) {
81309 BV_SET(fields, 4);
81310 }
81311
81312 differ = (old->num_extra_types != real_packet->num_extra_types);
81313 if (differ) {
81314 BV_SET(fields, 5);
81315 }
81316
81317 differ = (old->num_base_types != real_packet->num_base_types);
81318 if (differ) {
81319 BV_SET(fields, 6);
81320 }
81321
81322 differ = (old->num_road_types != real_packet->num_road_types);
81323 if (differ) {
81324 BV_SET(fields, 7);
81325 }
81326
81327 differ = (old->num_resource_types != real_packet->num_resource_types);
81328 if (differ) {
81329 BV_SET(fields, 8);
81330 }
81331
81332 differ = (old->num_goods_types != real_packet->num_goods_types);
81333 if (differ) {
81334 BV_SET(fields, 9);
81335 }
81336
81337 differ = (old->num_disaster_types != real_packet->num_disaster_types);
81338 if (differ) {
81339 BV_SET(fields, 10);
81340 }
81341
81342 differ = (old->num_achievement_types != real_packet->num_achievement_types);
81343 if (differ) {
81344 BV_SET(fields, 11);
81345 }
81346
81347 differ = (old->num_multipliers != real_packet->num_multipliers);
81348 if (differ) {
81349 BV_SET(fields, 12);
81350 }
81351
81352 differ = (old->num_styles != real_packet->num_styles);
81353 if (differ) {
81354 BV_SET(fields, 13);
81355 }
81356
81357 differ = (old->num_music_styles != real_packet->num_music_styles);
81358 if (differ) {
81359 BV_SET(fields, 14);
81360 }
81361
81362 differ = (old->government_count != real_packet->government_count);
81363 if (differ) {
81364 BV_SET(fields, 15);
81365 }
81366
81367 differ = (old->nation_count != real_packet->nation_count);
81368 if (differ) {
81369 BV_SET(fields, 16);
81370 }
81371
81372 differ = (old->num_city_styles != real_packet->num_city_styles);
81373 if (differ) {
81374 BV_SET(fields, 17);
81375 }
81376
81377 differ = (old->terrain_count != real_packet->terrain_count);
81378 if (differ) {
81379 BV_SET(fields, 18);
81380 }
81381
81382 differ = (old->num_specialist_types != real_packet->num_specialist_types);
81383 if (differ) {
81384 BV_SET(fields, 19);
81385 }
81386
81387 differ = (old->num_nation_groups != real_packet->num_nation_groups);
81388 if (differ) {
81389 BV_SET(fields, 20);
81390 }
81391
81392 differ = (old->num_nation_sets != real_packet->num_nation_sets);
81393 if (differ) {
81394 BV_SET(fields, 21);
81395 }
81396
81397 differ = (strcmp(old->preferred_tileset, real_packet->preferred_tileset) != 0);
81398 if (differ) {
81399 BV_SET(fields, 22);
81400 }
81401
81402 differ = (strcmp(old->preferred_soundset, real_packet->preferred_soundset) != 0);
81403 if (differ) {
81404 BV_SET(fields, 23);
81405 }
81406
81407 differ = (strcmp(old->preferred_musicset, real_packet->preferred_musicset) != 0);
81408 if (differ) {
81409 BV_SET(fields, 24);
81410 }
81411
81412 /* folded into head */
81413 if (real_packet->popup_tech_help) {
81414 BV_SET(fields, 25);
81415 }
81416
81417 differ = (strcmp(old->name, real_packet->name) != 0);
81418 if (differ) {
81419 BV_SET(fields, 26);
81420 }
81421
81422 differ = (strcmp(old->version, real_packet->version) != 0);
81423 if (differ) {
81424 BV_SET(fields, 27);
81425 }
81426
81427 differ = (strcmp(old->alt_dir, real_packet->alt_dir) != 0);
81428 if (differ) {
81429 BV_SET(fields, 28);
81430 }
81431
81432 differ = (old->desc_length != real_packet->desc_length);
81433 if (differ) {
81434 BV_SET(fields, 29);
81435 }
81436
81437 differ = (old->num_counters != real_packet->num_counters);
81438 if (differ) {
81439 BV_SET(fields, 30);
81440 }
81441#endif /* FREECIV_DELTA_PROTOCOL */
81442
81443#ifdef FREECIV_JSON_CONNECTION
81444 struct plocation field_addr;
81445 {
81446 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
81447 field_addr = *field_addr_tmp;
81448 FC_FREE(field_addr_tmp);
81449 }
81450#endif /* FREECIV_JSON_CONNECTION */
81451
81452#ifdef FREECIV_DELTA_PROTOCOL
81453#ifdef FREECIV_JSON_CONNECTION
81454 field_addr.name = "fields";
81455#endif /* FREECIV_JSON_CONNECTION */
81456 e = 0;
81457 e |= DIO_BV_PUT(&dout, &field_addr, fields);
81458 if (e) {
81459 log_packet_detailed("fields bitvector error detected");
81460 }
81461
81462 if (BV_ISSET(fields, 0)) {
81463 log_packet_detailed(" field 'num_unit_classes' has changed");
81464
81465#ifdef FREECIV_JSON_CONNECTION
81466 field_addr.name = "num_unit_classes";
81467#endif /* FREECIV_JSON_CONNECTION */
81468 e = 0;
81469
81470 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_unit_classes);
81471
81472 if (e) {
81473 log_packet_detailed("'num_unit_classes' field error detected");
81474 }
81475 }
81476
81477 if (BV_ISSET(fields, 1)) {
81478 log_packet_detailed(" field 'num_unit_types' has changed");
81479
81480#ifdef FREECIV_JSON_CONNECTION
81481 field_addr.name = "num_unit_types";
81482#endif /* FREECIV_JSON_CONNECTION */
81483 e = 0;
81484
81485 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_unit_types);
81486
81487 if (e) {
81488 log_packet_detailed("'num_unit_types' field error detected");
81489 }
81490 }
81491
81492 if (BV_ISSET(fields, 2)) {
81493 log_packet_detailed(" field 'num_impr_types' has changed");
81494
81495#ifdef FREECIV_JSON_CONNECTION
81496 field_addr.name = "num_impr_types";
81497#endif /* FREECIV_JSON_CONNECTION */
81498 e = 0;
81499
81500 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_impr_types);
81501
81502 if (e) {
81503 log_packet_detailed("'num_impr_types' field error detected");
81504 }
81505 }
81506
81507 if (BV_ISSET(fields, 3)) {
81508 log_packet_detailed(" field 'num_tech_classes' has changed");
81509
81510#ifdef FREECIV_JSON_CONNECTION
81511 field_addr.name = "num_tech_classes";
81512#endif /* FREECIV_JSON_CONNECTION */
81513 e = 0;
81514
81515 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_tech_classes);
81516
81517 if (e) {
81518 log_packet_detailed("'num_tech_classes' field error detected");
81519 }
81520 }
81521
81522 if (BV_ISSET(fields, 4)) {
81523 log_packet_detailed(" field 'num_tech_types' has changed");
81524
81525#ifdef FREECIV_JSON_CONNECTION
81526 field_addr.name = "num_tech_types";
81527#endif /* FREECIV_JSON_CONNECTION */
81528 e = 0;
81529
81530 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_tech_types);
81531
81532 if (e) {
81533 log_packet_detailed("'num_tech_types' field error detected");
81534 }
81535 }
81536
81537 if (BV_ISSET(fields, 5)) {
81538 log_packet_detailed(" field 'num_extra_types' has changed");
81539
81540#ifdef FREECIV_JSON_CONNECTION
81541 field_addr.name = "num_extra_types";
81542#endif /* FREECIV_JSON_CONNECTION */
81543 e = 0;
81544
81545 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_extra_types);
81546
81547 if (e) {
81548 log_packet_detailed("'num_extra_types' field error detected");
81549 }
81550 }
81551
81552 if (BV_ISSET(fields, 6)) {
81553 log_packet_detailed(" field 'num_base_types' has changed");
81554
81555#ifdef FREECIV_JSON_CONNECTION
81556 field_addr.name = "num_base_types";
81557#endif /* FREECIV_JSON_CONNECTION */
81558 e = 0;
81559
81560 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_base_types);
81561
81562 if (e) {
81563 log_packet_detailed("'num_base_types' field error detected");
81564 }
81565 }
81566
81567 if (BV_ISSET(fields, 7)) {
81568 log_packet_detailed(" field 'num_road_types' has changed");
81569
81570#ifdef FREECIV_JSON_CONNECTION
81571 field_addr.name = "num_road_types";
81572#endif /* FREECIV_JSON_CONNECTION */
81573 e = 0;
81574
81575 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_road_types);
81576
81577 if (e) {
81578 log_packet_detailed("'num_road_types' field error detected");
81579 }
81580 }
81581
81582 if (BV_ISSET(fields, 8)) {
81583 log_packet_detailed(" field 'num_resource_types' has changed");
81584
81585#ifdef FREECIV_JSON_CONNECTION
81586 field_addr.name = "num_resource_types";
81587#endif /* FREECIV_JSON_CONNECTION */
81588 e = 0;
81589
81590 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_resource_types);
81591
81592 if (e) {
81593 log_packet_detailed("'num_resource_types' field error detected");
81594 }
81595 }
81596
81597 if (BV_ISSET(fields, 9)) {
81598 log_packet_detailed(" field 'num_goods_types' has changed");
81599
81600#ifdef FREECIV_JSON_CONNECTION
81601 field_addr.name = "num_goods_types";
81602#endif /* FREECIV_JSON_CONNECTION */
81603 e = 0;
81604
81605 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_goods_types);
81606
81607 if (e) {
81608 log_packet_detailed("'num_goods_types' field error detected");
81609 }
81610 }
81611
81612 if (BV_ISSET(fields, 10)) {
81613 log_packet_detailed(" field 'num_disaster_types' has changed");
81614
81615#ifdef FREECIV_JSON_CONNECTION
81616 field_addr.name = "num_disaster_types";
81617#endif /* FREECIV_JSON_CONNECTION */
81618 e = 0;
81619
81620 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_disaster_types);
81621
81622 if (e) {
81623 log_packet_detailed("'num_disaster_types' field error detected");
81624 }
81625 }
81626
81627 if (BV_ISSET(fields, 11)) {
81628 log_packet_detailed(" field 'num_achievement_types' has changed");
81629
81630#ifdef FREECIV_JSON_CONNECTION
81631 field_addr.name = "num_achievement_types";
81632#endif /* FREECIV_JSON_CONNECTION */
81633 e = 0;
81634
81635 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_achievement_types);
81636
81637 if (e) {
81638 log_packet_detailed("'num_achievement_types' field error detected");
81639 }
81640 }
81641
81642 if (BV_ISSET(fields, 12)) {
81643 log_packet_detailed(" field 'num_multipliers' has changed");
81644
81645#ifdef FREECIV_JSON_CONNECTION
81646 field_addr.name = "num_multipliers";
81647#endif /* FREECIV_JSON_CONNECTION */
81648 e = 0;
81649
81650 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_multipliers);
81651
81652 if (e) {
81653 log_packet_detailed("'num_multipliers' field error detected");
81654 }
81655 }
81656
81657 if (BV_ISSET(fields, 13)) {
81658 log_packet_detailed(" field 'num_styles' has changed");
81659
81660#ifdef FREECIV_JSON_CONNECTION
81661 field_addr.name = "num_styles";
81662#endif /* FREECIV_JSON_CONNECTION */
81663 e = 0;
81664
81665 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_styles);
81666
81667 if (e) {
81668 log_packet_detailed("'num_styles' field error detected");
81669 }
81670 }
81671
81672 if (BV_ISSET(fields, 14)) {
81673 log_packet_detailed(" field 'num_music_styles' has changed");
81674
81675#ifdef FREECIV_JSON_CONNECTION
81676 field_addr.name = "num_music_styles";
81677#endif /* FREECIV_JSON_CONNECTION */
81678 e = 0;
81679
81680 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_music_styles);
81681
81682 if (e) {
81683 log_packet_detailed("'num_music_styles' field error detected");
81684 }
81685 }
81686
81687 if (BV_ISSET(fields, 15)) {
81688 log_packet_detailed(" field 'government_count' has changed");
81689
81690#ifdef FREECIV_JSON_CONNECTION
81691 field_addr.name = "government_count";
81692#endif /* FREECIV_JSON_CONNECTION */
81693 e = 0;
81694
81695 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->government_count);
81696
81697 if (e) {
81698 log_packet_detailed("'government_count' field error detected");
81699 }
81700 }
81701
81702 if (BV_ISSET(fields, 16)) {
81703 log_packet_detailed(" field 'nation_count' has changed");
81704
81705#ifdef FREECIV_JSON_CONNECTION
81706 field_addr.name = "nation_count";
81707#endif /* FREECIV_JSON_CONNECTION */
81708 e = 0;
81709
81710 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->nation_count);
81711
81712 if (e) {
81713 log_packet_detailed("'nation_count' field error detected");
81714 }
81715 }
81716
81717 if (BV_ISSET(fields, 17)) {
81718 log_packet_detailed(" field 'num_city_styles' has changed");
81719
81720#ifdef FREECIV_JSON_CONNECTION
81721 field_addr.name = "num_city_styles";
81722#endif /* FREECIV_JSON_CONNECTION */
81723 e = 0;
81724
81725 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_city_styles);
81726
81727 if (e) {
81728 log_packet_detailed("'num_city_styles' field error detected");
81729 }
81730 }
81731
81732 if (BV_ISSET(fields, 18)) {
81733 log_packet_detailed(" field 'terrain_count' has changed");
81734
81735#ifdef FREECIV_JSON_CONNECTION
81736 field_addr.name = "terrain_count";
81737#endif /* FREECIV_JSON_CONNECTION */
81738 e = 0;
81739
81740 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->terrain_count);
81741
81742 if (e) {
81743 log_packet_detailed("'terrain_count' field error detected");
81744 }
81745 }
81746
81747 if (BV_ISSET(fields, 19)) {
81748 log_packet_detailed(" field 'num_specialist_types' has changed");
81749
81750#ifdef FREECIV_JSON_CONNECTION
81751 field_addr.name = "num_specialist_types";
81752#endif /* FREECIV_JSON_CONNECTION */
81753 e = 0;
81754
81755 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_specialist_types);
81756
81757 if (e) {
81758 log_packet_detailed("'num_specialist_types' field error detected");
81759 }
81760 }
81761
81762 if (BV_ISSET(fields, 20)) {
81763 log_packet_detailed(" field 'num_nation_groups' has changed");
81764
81765#ifdef FREECIV_JSON_CONNECTION
81766 field_addr.name = "num_nation_groups";
81767#endif /* FREECIV_JSON_CONNECTION */
81768 e = 0;
81769
81770 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_nation_groups);
81771
81772 if (e) {
81773 log_packet_detailed("'num_nation_groups' field error detected");
81774 }
81775 }
81776
81777 if (BV_ISSET(fields, 21)) {
81778 log_packet_detailed(" field 'num_nation_sets' has changed");
81779
81780#ifdef FREECIV_JSON_CONNECTION
81781 field_addr.name = "num_nation_sets";
81782#endif /* FREECIV_JSON_CONNECTION */
81783 e = 0;
81784
81785 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_nation_sets);
81786
81787 if (e) {
81788 log_packet_detailed("'num_nation_sets' field error detected");
81789 }
81790 }
81791
81792 if (BV_ISSET(fields, 22)) {
81793 log_packet_detailed(" field 'preferred_tileset' has changed");
81794
81795#ifdef FREECIV_JSON_CONNECTION
81796 field_addr.name = "preferred_tileset";
81797#endif /* FREECIV_JSON_CONNECTION */
81798 e = 0;
81799
81800 e |= DIO_PUT(string, &dout, &field_addr, real_packet->preferred_tileset);
81801
81802 if (e) {
81803 log_packet_detailed("'preferred_tileset' field error detected");
81804 }
81805 }
81806
81807 if (BV_ISSET(fields, 23)) {
81808 log_packet_detailed(" field 'preferred_soundset' has changed");
81809
81810#ifdef FREECIV_JSON_CONNECTION
81811 field_addr.name = "preferred_soundset";
81812#endif /* FREECIV_JSON_CONNECTION */
81813 e = 0;
81814
81815 e |= DIO_PUT(string, &dout, &field_addr, real_packet->preferred_soundset);
81816
81817 if (e) {
81818 log_packet_detailed("'preferred_soundset' field error detected");
81819 }
81820 }
81821
81822 if (BV_ISSET(fields, 24)) {
81823 log_packet_detailed(" field 'preferred_musicset' has changed");
81824
81825#ifdef FREECIV_JSON_CONNECTION
81826 field_addr.name = "preferred_musicset";
81827#endif /* FREECIV_JSON_CONNECTION */
81828 e = 0;
81829
81830 e |= DIO_PUT(string, &dout, &field_addr, real_packet->preferred_musicset);
81831
81832 if (e) {
81833 log_packet_detailed("'preferred_musicset' field error detected");
81834 }
81835 }
81836
81837 /* field 25 is folded into the header */
81838
81839 if (BV_ISSET(fields, 26)) {
81840 log_packet_detailed(" field 'name' has changed");
81841
81842#ifdef FREECIV_JSON_CONNECTION
81843 field_addr.name = "name";
81844#endif /* FREECIV_JSON_CONNECTION */
81845 e = 0;
81846
81847 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
81848
81849 if (e) {
81850 log_packet_detailed("'name' field error detected");
81851 }
81852 }
81853
81854 if (BV_ISSET(fields, 27)) {
81855 log_packet_detailed(" field 'version' has changed");
81856
81857#ifdef FREECIV_JSON_CONNECTION
81858 field_addr.name = "version";
81859#endif /* FREECIV_JSON_CONNECTION */
81860 e = 0;
81861
81862 e |= DIO_PUT(string, &dout, &field_addr, real_packet->version);
81863
81864 if (e) {
81865 log_packet_detailed("'version' field error detected");
81866 }
81867 }
81868
81869 if (BV_ISSET(fields, 28)) {
81870 log_packet_detailed(" field 'alt_dir' has changed");
81871
81872#ifdef FREECIV_JSON_CONNECTION
81873 field_addr.name = "alt_dir";
81874#endif /* FREECIV_JSON_CONNECTION */
81875 e = 0;
81876
81877 e |= DIO_PUT(string, &dout, &field_addr, real_packet->alt_dir);
81878
81879 if (e) {
81880 log_packet_detailed("'alt_dir' field error detected");
81881 }
81882 }
81883
81884 if (BV_ISSET(fields, 29)) {
81885 log_packet_detailed(" field 'desc_length' has changed");
81886
81887#ifdef FREECIV_JSON_CONNECTION
81888 field_addr.name = "desc_length";
81889#endif /* FREECIV_JSON_CONNECTION */
81890 e = 0;
81891
81892 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->desc_length);
81893
81894 if (e) {
81895 log_packet_detailed("'desc_length' field error detected");
81896 }
81897 }
81898
81899 if (BV_ISSET(fields, 30)) {
81900 log_packet_detailed(" field 'num_counters' has changed");
81901
81902#ifdef FREECIV_JSON_CONNECTION
81903 field_addr.name = "num_counters";
81904#endif /* FREECIV_JSON_CONNECTION */
81905 e = 0;
81906
81907 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_counters);
81908
81909 if (e) {
81910 log_packet_detailed("'num_counters' field error detected");
81911 }
81912 }
81913
81914 *old = *real_packet;
81915
81916#else /* FREECIV_DELTA_PROTOCOL */
81917#ifdef FREECIV_JSON_CONNECTION
81918 field_addr.name = "num_unit_classes";
81919#endif /* FREECIV_JSON_CONNECTION */
81920 e = 0;
81921
81922 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_unit_classes);
81923
81924 if (e) {
81925 log_packet_detailed("'num_unit_classes' field error detected");
81926 }
81927
81928#ifdef FREECIV_JSON_CONNECTION
81929 field_addr.name = "num_unit_types";
81930#endif /* FREECIV_JSON_CONNECTION */
81931 e = 0;
81932
81933 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_unit_types);
81934
81935 if (e) {
81936 log_packet_detailed("'num_unit_types' field error detected");
81937 }
81938
81939#ifdef FREECIV_JSON_CONNECTION
81940 field_addr.name = "num_impr_types";
81941#endif /* FREECIV_JSON_CONNECTION */
81942 e = 0;
81943
81944 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_impr_types);
81945
81946 if (e) {
81947 log_packet_detailed("'num_impr_types' field error detected");
81948 }
81949
81950#ifdef FREECIV_JSON_CONNECTION
81951 field_addr.name = "num_tech_classes";
81952#endif /* FREECIV_JSON_CONNECTION */
81953 e = 0;
81954
81955 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_tech_classes);
81956
81957 if (e) {
81958 log_packet_detailed("'num_tech_classes' field error detected");
81959 }
81960
81961#ifdef FREECIV_JSON_CONNECTION
81962 field_addr.name = "num_tech_types";
81963#endif /* FREECIV_JSON_CONNECTION */
81964 e = 0;
81965
81966 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_tech_types);
81967
81968 if (e) {
81969 log_packet_detailed("'num_tech_types' field error detected");
81970 }
81971
81972#ifdef FREECIV_JSON_CONNECTION
81973 field_addr.name = "num_extra_types";
81974#endif /* FREECIV_JSON_CONNECTION */
81975 e = 0;
81976
81977 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_extra_types);
81978
81979 if (e) {
81980 log_packet_detailed("'num_extra_types' field error detected");
81981 }
81982
81983#ifdef FREECIV_JSON_CONNECTION
81984 field_addr.name = "num_base_types";
81985#endif /* FREECIV_JSON_CONNECTION */
81986 e = 0;
81987
81988 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_base_types);
81989
81990 if (e) {
81991 log_packet_detailed("'num_base_types' field error detected");
81992 }
81993
81994#ifdef FREECIV_JSON_CONNECTION
81995 field_addr.name = "num_road_types";
81996#endif /* FREECIV_JSON_CONNECTION */
81997 e = 0;
81998
81999 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_road_types);
82000
82001 if (e) {
82002 log_packet_detailed("'num_road_types' field error detected");
82003 }
82004
82005#ifdef FREECIV_JSON_CONNECTION
82006 field_addr.name = "num_resource_types";
82007#endif /* FREECIV_JSON_CONNECTION */
82008 e = 0;
82009
82010 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_resource_types);
82011
82012 if (e) {
82013 log_packet_detailed("'num_resource_types' field error detected");
82014 }
82015
82016#ifdef FREECIV_JSON_CONNECTION
82017 field_addr.name = "num_goods_types";
82018#endif /* FREECIV_JSON_CONNECTION */
82019 e = 0;
82020
82021 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_goods_types);
82022
82023 if (e) {
82024 log_packet_detailed("'num_goods_types' field error detected");
82025 }
82026
82027#ifdef FREECIV_JSON_CONNECTION
82028 field_addr.name = "num_disaster_types";
82029#endif /* FREECIV_JSON_CONNECTION */
82030 e = 0;
82031
82032 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_disaster_types);
82033
82034 if (e) {
82035 log_packet_detailed("'num_disaster_types' field error detected");
82036 }
82037
82038#ifdef FREECIV_JSON_CONNECTION
82039 field_addr.name = "num_achievement_types";
82040#endif /* FREECIV_JSON_CONNECTION */
82041 e = 0;
82042
82043 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_achievement_types);
82044
82045 if (e) {
82046 log_packet_detailed("'num_achievement_types' field error detected");
82047 }
82048
82049#ifdef FREECIV_JSON_CONNECTION
82050 field_addr.name = "num_multipliers";
82051#endif /* FREECIV_JSON_CONNECTION */
82052 e = 0;
82053
82054 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_multipliers);
82055
82056 if (e) {
82057 log_packet_detailed("'num_multipliers' field error detected");
82058 }
82059
82060#ifdef FREECIV_JSON_CONNECTION
82061 field_addr.name = "num_styles";
82062#endif /* FREECIV_JSON_CONNECTION */
82063 e = 0;
82064
82065 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_styles);
82066
82067 if (e) {
82068 log_packet_detailed("'num_styles' field error detected");
82069 }
82070
82071#ifdef FREECIV_JSON_CONNECTION
82072 field_addr.name = "num_music_styles";
82073#endif /* FREECIV_JSON_CONNECTION */
82074 e = 0;
82075
82076 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_music_styles);
82077
82078 if (e) {
82079 log_packet_detailed("'num_music_styles' field error detected");
82080 }
82081
82082#ifdef FREECIV_JSON_CONNECTION
82083 field_addr.name = "government_count";
82084#endif /* FREECIV_JSON_CONNECTION */
82085 e = 0;
82086
82087 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->government_count);
82088
82089 if (e) {
82090 log_packet_detailed("'government_count' field error detected");
82091 }
82092
82093#ifdef FREECIV_JSON_CONNECTION
82094 field_addr.name = "nation_count";
82095#endif /* FREECIV_JSON_CONNECTION */
82096 e = 0;
82097
82098 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->nation_count);
82099
82100 if (e) {
82101 log_packet_detailed("'nation_count' field error detected");
82102 }
82103
82104#ifdef FREECIV_JSON_CONNECTION
82105 field_addr.name = "num_city_styles";
82106#endif /* FREECIV_JSON_CONNECTION */
82107 e = 0;
82108
82109 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_city_styles);
82110
82111 if (e) {
82112 log_packet_detailed("'num_city_styles' field error detected");
82113 }
82114
82115#ifdef FREECIV_JSON_CONNECTION
82116 field_addr.name = "terrain_count";
82117#endif /* FREECIV_JSON_CONNECTION */
82118 e = 0;
82119
82120 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->terrain_count);
82121
82122 if (e) {
82123 log_packet_detailed("'terrain_count' field error detected");
82124 }
82125
82126#ifdef FREECIV_JSON_CONNECTION
82127 field_addr.name = "num_specialist_types";
82128#endif /* FREECIV_JSON_CONNECTION */
82129 e = 0;
82130
82131 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_specialist_types);
82132
82133 if (e) {
82134 log_packet_detailed("'num_specialist_types' field error detected");
82135 }
82136
82137#ifdef FREECIV_JSON_CONNECTION
82138 field_addr.name = "num_nation_groups";
82139#endif /* FREECIV_JSON_CONNECTION */
82140 e = 0;
82141
82142 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_nation_groups);
82143
82144 if (e) {
82145 log_packet_detailed("'num_nation_groups' field error detected");
82146 }
82147
82148#ifdef FREECIV_JSON_CONNECTION
82149 field_addr.name = "num_nation_sets";
82150#endif /* FREECIV_JSON_CONNECTION */
82151 e = 0;
82152
82153 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_nation_sets);
82154
82155 if (e) {
82156 log_packet_detailed("'num_nation_sets' field error detected");
82157 }
82158
82159#ifdef FREECIV_JSON_CONNECTION
82160 field_addr.name = "preferred_tileset";
82161#endif /* FREECIV_JSON_CONNECTION */
82162 e = 0;
82163
82164 e |= DIO_PUT(string, &dout, &field_addr, real_packet->preferred_tileset);
82165
82166 if (e) {
82167 log_packet_detailed("'preferred_tileset' field error detected");
82168 }
82169
82170#ifdef FREECIV_JSON_CONNECTION
82171 field_addr.name = "preferred_soundset";
82172#endif /* FREECIV_JSON_CONNECTION */
82173 e = 0;
82174
82175 e |= DIO_PUT(string, &dout, &field_addr, real_packet->preferred_soundset);
82176
82177 if (e) {
82178 log_packet_detailed("'preferred_soundset' field error detected");
82179 }
82180
82181#ifdef FREECIV_JSON_CONNECTION
82182 field_addr.name = "preferred_musicset";
82183#endif /* FREECIV_JSON_CONNECTION */
82184 e = 0;
82185
82186 e |= DIO_PUT(string, &dout, &field_addr, real_packet->preferred_musicset);
82187
82188 if (e) {
82189 log_packet_detailed("'preferred_musicset' field error detected");
82190 }
82191
82192#ifdef FREECIV_JSON_CONNECTION
82193 field_addr.name = "popup_tech_help";
82194#endif /* FREECIV_JSON_CONNECTION */
82195 e = 0;
82196
82197 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->popup_tech_help);
82198
82199 if (e) {
82200 log_packet_detailed("'popup_tech_help' field error detected");
82201 }
82202
82203#ifdef FREECIV_JSON_CONNECTION
82204 field_addr.name = "name";
82205#endif /* FREECIV_JSON_CONNECTION */
82206 e = 0;
82207
82208 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
82209
82210 if (e) {
82211 log_packet_detailed("'name' field error detected");
82212 }
82213
82214#ifdef FREECIV_JSON_CONNECTION
82215 field_addr.name = "version";
82216#endif /* FREECIV_JSON_CONNECTION */
82217 e = 0;
82218
82219 e |= DIO_PUT(string, &dout, &field_addr, real_packet->version);
82220
82221 if (e) {
82222 log_packet_detailed("'version' field error detected");
82223 }
82224
82225#ifdef FREECIV_JSON_CONNECTION
82226 field_addr.name = "alt_dir";
82227#endif /* FREECIV_JSON_CONNECTION */
82228 e = 0;
82229
82230 e |= DIO_PUT(string, &dout, &field_addr, real_packet->alt_dir);
82231
82232 if (e) {
82233 log_packet_detailed("'alt_dir' field error detected");
82234 }
82235
82236#ifdef FREECIV_JSON_CONNECTION
82237 field_addr.name = "desc_length";
82238#endif /* FREECIV_JSON_CONNECTION */
82239 e = 0;
82240
82241 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->desc_length);
82242
82243 if (e) {
82244 log_packet_detailed("'desc_length' field error detected");
82245 }
82246
82247#ifdef FREECIV_JSON_CONNECTION
82248 field_addr.name = "num_counters";
82249#endif /* FREECIV_JSON_CONNECTION */
82250 e = 0;
82251
82252 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->num_counters);
82253
82254 if (e) {
82255 log_packet_detailed("'num_counters' field error detected");
82256 }
82257#endif /* FREECIV_DELTA_PROTOCOL */
82258
82259 SEND_PACKET_END(PACKET_RULESET_CONTROL);
82260}
82261
82262 int send_packet_ruleset_control(struct connection *pc, const struct packet_ruleset_control *packet)
82263{
82264 if (!pc->used) {
82265 log_error("WARNING: trying to send data to the closed connection %s",
82266 conn_description(pc));
82267 return -1;
82268 }
82269 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CONTROL].packet != nullptr, -1,
82270 "Handler for PACKET_RULESET_CONTROL not installed");
82271 return pc->phs.handlers->send[PACKET_RULESET_CONTROL].packet(pc, packet);
82272}
82273
82274 void lsend_packet_ruleset_control(struct conn_list *dest, const struct packet_ruleset_control *packet)
82275{
82276 conn_list_iterate(dest, pconn) {
82277 send_packet_ruleset_control(pconn, packet);
82278 } conn_list_iterate_end;
82279}
82280
82281 static inline void init_packet_ruleset_summary(struct packet_ruleset_summary *packet)
82282{
82283 memset(packet, 0, sizeof(*packet));
82284}
82285
82286#define free_packet_ruleset_summary(_packet) (void) 0
82287#define destroy_packet_ruleset_summary free
82288
82289#ifdef FREECIV_DELTA_PROTOCOL
82290#define hash_packet_ruleset_summary_100 hash_const
82291#define cmp_packet_ruleset_summary_100 cmp_const
82292 BV_DEFINE(packet_ruleset_summary_100_fields, 1);
82293#endif /* FREECIV_DELTA_PROTOCOL */
82294
82295 static struct packet_ruleset_summary *receive_packet_ruleset_summary_100(struct connection *pc)
82296{
82297#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_summary(_packet)
82298 RECEIVE_PACKET_START(packet_ruleset_summary, real_packet);
82299
82300#ifdef FREECIV_JSON_CONNECTION
82301 struct plocation field_addr;
82302 {
82303 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82304 field_addr = *field_addr_tmp;
82305 FC_FREE(field_addr_tmp);
82306 }
82307#endif /* FREECIV_JSON_CONNECTION */
82308
82309 log_packet_detailed("packet_ruleset_summary_100: got info about ()");
82310
82311#ifdef FREECIV_DELTA_PROTOCOL
82312 packet_ruleset_summary_100_fields fields;
82313 struct packet_ruleset_summary *old;
82314 struct genhash **hash = pc->phs.received + PACKET_RULESET_SUMMARY;
82315
82316 if (nullptr == *hash) {
82317 *hash = genhash_new_full(hash_packet_ruleset_summary_100, cmp_packet_ruleset_summary_100,
82318 nullptr, nullptr, nullptr, destroy_packet_ruleset_summary);
82319 }
82320
82321 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
82322 *real_packet = *old;
82323 } else {
82324 /* packet is already initialized empty */
82325 log_packet_detailed(" no old info");
82326 }
82327
82328#ifdef FREECIV_JSON_CONNECTION
82329 field_addr.name = "fields";
82330#endif /* FREECIV_JSON_CONNECTION */
82331 DIO_BV_GET(&din, &field_addr, fields);
82332
82333 if (BV_ISSET(fields, 0)) {
82334 log_packet_detailed(" got field 'text'");
82335
82336#ifdef FREECIV_JSON_CONNECTION
82337 field_addr.name = "text";
82338#endif /* FREECIV_JSON_CONNECTION */
82339
82340 if (!DIO_GET(string, &din, &field_addr, real_packet->text, sizeof(real_packet->text))) {
82341 RECEIVE_PACKET_FIELD_ERROR(text);
82342 }
82343 }
82344
82345 if (nullptr == old) {
82346 old = fc_malloc(sizeof(*old));
82347 init_packet_ruleset_summary(old);
82348 *old = *real_packet;
82349 genhash_insert(*hash, old, old);
82350 } else {
82351 *old = *real_packet;
82352 }
82353
82354#else /* FREECIV_DELTA_PROTOCOL */
82355#ifdef FREECIV_JSON_CONNECTION
82356 field_addr.name = "text";
82357#endif /* FREECIV_JSON_CONNECTION */
82358
82359 if (!DIO_GET(string, &din, &field_addr, real_packet->text, sizeof(real_packet->text))) {
82360 RECEIVE_PACKET_FIELD_ERROR(text);
82361 }
82362#endif /* FREECIV_DELTA_PROTOCOL */
82363
82364 RECEIVE_PACKET_END(real_packet);
82365#undef FREE_PACKET_STRUCT
82366}
82367
82368 static int send_packet_ruleset_summary_100(struct connection *pc, const struct packet_ruleset_summary *packet)
82369{
82370 const struct packet_ruleset_summary *real_packet = packet;
82371 int e;
82372 SEND_PACKET_START(PACKET_RULESET_SUMMARY);
82373
82374 log_packet_detailed("packet_ruleset_summary_100: sending info about ()");
82375
82376#ifdef FREECIV_DELTA_PROTOCOL
82377 packet_ruleset_summary_100_fields fields;
82378 struct packet_ruleset_summary *old;
82379 bool differ;
82380 struct genhash **hash = pc->phs.sent + PACKET_RULESET_SUMMARY;
82381
82382 if (nullptr == *hash) {
82383 *hash = genhash_new_full(hash_packet_ruleset_summary_100, cmp_packet_ruleset_summary_100,
82384 nullptr, nullptr, nullptr, destroy_packet_ruleset_summary);
82385 }
82386 BV_CLR_ALL(fields);
82387
82388 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
82389 old = fc_malloc(sizeof(*old));
82390 /* temporary bitcopy just to insert correctly */
82391 *old = *real_packet;
82392 genhash_insert(*hash, old, old);
82393 init_packet_ruleset_summary(old);
82394 }
82395
82396 differ = (strcmp(old->text, real_packet->text) != 0);
82397 if (differ) {
82398 BV_SET(fields, 0);
82399 }
82400#endif /* FREECIV_DELTA_PROTOCOL */
82401
82402#ifdef FREECIV_JSON_CONNECTION
82403 struct plocation field_addr;
82404 {
82405 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82406 field_addr = *field_addr_tmp;
82407 FC_FREE(field_addr_tmp);
82408 }
82409#endif /* FREECIV_JSON_CONNECTION */
82410
82411#ifdef FREECIV_DELTA_PROTOCOL
82412#ifdef FREECIV_JSON_CONNECTION
82413 field_addr.name = "fields";
82414#endif /* FREECIV_JSON_CONNECTION */
82415 e = 0;
82416 e |= DIO_BV_PUT(&dout, &field_addr, fields);
82417 if (e) {
82418 log_packet_detailed("fields bitvector error detected");
82419 }
82420
82421 if (BV_ISSET(fields, 0)) {
82422 log_packet_detailed(" field 'text' has changed");
82423
82424#ifdef FREECIV_JSON_CONNECTION
82425 field_addr.name = "text";
82426#endif /* FREECIV_JSON_CONNECTION */
82427 e = 0;
82428
82429 e |= DIO_PUT(string, &dout, &field_addr, real_packet->text);
82430
82431 if (e) {
82432 log_packet_detailed("'text' field error detected");
82433 }
82434 }
82435
82436 *old = *real_packet;
82437
82438#else /* FREECIV_DELTA_PROTOCOL */
82439#ifdef FREECIV_JSON_CONNECTION
82440 field_addr.name = "text";
82441#endif /* FREECIV_JSON_CONNECTION */
82442 e = 0;
82443
82444 e |= DIO_PUT(string, &dout, &field_addr, real_packet->text);
82445
82446 if (e) {
82447 log_packet_detailed("'text' field error detected");
82448 }
82449#endif /* FREECIV_DELTA_PROTOCOL */
82450
82451 SEND_PACKET_END(PACKET_RULESET_SUMMARY);
82452}
82453
82454 int send_packet_ruleset_summary(struct connection *pc, const struct packet_ruleset_summary *packet)
82455{
82456 if (!pc->used) {
82457 log_error("WARNING: trying to send data to the closed connection %s",
82458 conn_description(pc));
82459 return -1;
82460 }
82461 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_SUMMARY].packet != nullptr, -1,
82462 "Handler for PACKET_RULESET_SUMMARY not installed");
82463 return pc->phs.handlers->send[PACKET_RULESET_SUMMARY].packet(pc, packet);
82464}
82465
82466 void lsend_packet_ruleset_summary(struct conn_list *dest, const struct packet_ruleset_summary *packet)
82467{
82468 conn_list_iterate(dest, pconn) {
82469 send_packet_ruleset_summary(pconn, packet);
82470 } conn_list_iterate_end;
82471}
82472
82473 static inline void init_packet_ruleset_description_part(struct packet_ruleset_description_part *packet)
82474{
82475 memset(packet, 0, sizeof(*packet));
82476}
82477
82478#define free_packet_ruleset_description_part(_packet) (void) 0
82479#define destroy_packet_ruleset_description_part free
82480
82481#ifdef FREECIV_DELTA_PROTOCOL
82482#define hash_packet_ruleset_description_part_100 hash_const
82483#define cmp_packet_ruleset_description_part_100 cmp_const
82484 BV_DEFINE(packet_ruleset_description_part_100_fields, 1);
82485#endif /* FREECIV_DELTA_PROTOCOL */
82486
82487 static struct packet_ruleset_description_part *receive_packet_ruleset_description_part_100(struct connection *pc)
82488{
82489#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_description_part(_packet)
82490 RECEIVE_PACKET_START(packet_ruleset_description_part, real_packet);
82491
82492#ifdef FREECIV_JSON_CONNECTION
82493 struct plocation field_addr;
82494 {
82495 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82496 field_addr = *field_addr_tmp;
82497 FC_FREE(field_addr_tmp);
82498 }
82499#endif /* FREECIV_JSON_CONNECTION */
82500
82501 log_packet_detailed("packet_ruleset_description_part_100: got info about ()");
82502
82503#ifdef FREECIV_DELTA_PROTOCOL
82504 packet_ruleset_description_part_100_fields fields;
82505 struct packet_ruleset_description_part *old;
82506 struct genhash **hash = pc->phs.received + PACKET_RULESET_DESCRIPTION_PART;
82507
82508 if (nullptr == *hash) {
82509 *hash = genhash_new_full(hash_packet_ruleset_description_part_100, cmp_packet_ruleset_description_part_100,
82510 nullptr, nullptr, nullptr, destroy_packet_ruleset_description_part);
82511 }
82512
82513 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
82514 *real_packet = *old;
82515 } else {
82516 /* packet is already initialized empty */
82517 log_packet_detailed(" no old info");
82518 }
82519
82520#ifdef FREECIV_JSON_CONNECTION
82521 field_addr.name = "fields";
82522#endif /* FREECIV_JSON_CONNECTION */
82523 DIO_BV_GET(&din, &field_addr, fields);
82524
82525 if (BV_ISSET(fields, 0)) {
82526 log_packet_detailed(" got field 'text'");
82527
82528#ifdef FREECIV_JSON_CONNECTION
82529 field_addr.name = "text";
82530#endif /* FREECIV_JSON_CONNECTION */
82531
82532 if (!DIO_GET(string, &din, &field_addr, real_packet->text, sizeof(real_packet->text))) {
82533 RECEIVE_PACKET_FIELD_ERROR(text);
82534 }
82535 }
82536
82537 if (nullptr == old) {
82538 old = fc_malloc(sizeof(*old));
82539 init_packet_ruleset_description_part(old);
82540 *old = *real_packet;
82541 genhash_insert(*hash, old, old);
82542 } else {
82543 *old = *real_packet;
82544 }
82545
82546#else /* FREECIV_DELTA_PROTOCOL */
82547#ifdef FREECIV_JSON_CONNECTION
82548 field_addr.name = "text";
82549#endif /* FREECIV_JSON_CONNECTION */
82550
82551 if (!DIO_GET(string, &din, &field_addr, real_packet->text, sizeof(real_packet->text))) {
82552 RECEIVE_PACKET_FIELD_ERROR(text);
82553 }
82554#endif /* FREECIV_DELTA_PROTOCOL */
82555
82556 RECEIVE_PACKET_END(real_packet);
82557#undef FREE_PACKET_STRUCT
82558}
82559
82560 static int send_packet_ruleset_description_part_100(struct connection *pc, const struct packet_ruleset_description_part *packet)
82561{
82562 const struct packet_ruleset_description_part *real_packet = packet;
82563 int e;
82564 SEND_PACKET_START(PACKET_RULESET_DESCRIPTION_PART);
82565
82566 log_packet_detailed("packet_ruleset_description_part_100: sending info about ()");
82567
82568#ifdef FREECIV_DELTA_PROTOCOL
82569 packet_ruleset_description_part_100_fields fields;
82570 struct packet_ruleset_description_part *old;
82571 bool differ;
82572 struct genhash **hash = pc->phs.sent + PACKET_RULESET_DESCRIPTION_PART;
82573
82574 if (nullptr == *hash) {
82575 *hash = genhash_new_full(hash_packet_ruleset_description_part_100, cmp_packet_ruleset_description_part_100,
82576 nullptr, nullptr, nullptr, destroy_packet_ruleset_description_part);
82577 }
82578 BV_CLR_ALL(fields);
82579
82580 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
82581 old = fc_malloc(sizeof(*old));
82582 /* temporary bitcopy just to insert correctly */
82583 *old = *real_packet;
82584 genhash_insert(*hash, old, old);
82585 init_packet_ruleset_description_part(old);
82586 }
82587
82588 differ = (strcmp(old->text, real_packet->text) != 0);
82589 if (differ) {
82590 BV_SET(fields, 0);
82591 }
82592#endif /* FREECIV_DELTA_PROTOCOL */
82593
82594#ifdef FREECIV_JSON_CONNECTION
82595 struct plocation field_addr;
82596 {
82597 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82598 field_addr = *field_addr_tmp;
82599 FC_FREE(field_addr_tmp);
82600 }
82601#endif /* FREECIV_JSON_CONNECTION */
82602
82603#ifdef FREECIV_DELTA_PROTOCOL
82604#ifdef FREECIV_JSON_CONNECTION
82605 field_addr.name = "fields";
82606#endif /* FREECIV_JSON_CONNECTION */
82607 e = 0;
82608 e |= DIO_BV_PUT(&dout, &field_addr, fields);
82609 if (e) {
82610 log_packet_detailed("fields bitvector error detected");
82611 }
82612
82613 if (BV_ISSET(fields, 0)) {
82614 log_packet_detailed(" field 'text' has changed");
82615
82616#ifdef FREECIV_JSON_CONNECTION
82617 field_addr.name = "text";
82618#endif /* FREECIV_JSON_CONNECTION */
82619 e = 0;
82620
82621 e |= DIO_PUT(string, &dout, &field_addr, real_packet->text);
82622
82623 if (e) {
82624 log_packet_detailed("'text' field error detected");
82625 }
82626 }
82627
82628 *old = *real_packet;
82629
82630#else /* FREECIV_DELTA_PROTOCOL */
82631#ifdef FREECIV_JSON_CONNECTION
82632 field_addr.name = "text";
82633#endif /* FREECIV_JSON_CONNECTION */
82634 e = 0;
82635
82636 e |= DIO_PUT(string, &dout, &field_addr, real_packet->text);
82637
82638 if (e) {
82639 log_packet_detailed("'text' field error detected");
82640 }
82641#endif /* FREECIV_DELTA_PROTOCOL */
82642
82643 SEND_PACKET_END(PACKET_RULESET_DESCRIPTION_PART);
82644}
82645
82646 int send_packet_ruleset_description_part(struct connection *pc, const struct packet_ruleset_description_part *packet)
82647{
82648 if (!pc->used) {
82649 log_error("WARNING: trying to send data to the closed connection %s",
82650 conn_description(pc));
82651 return -1;
82652 }
82653 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_DESCRIPTION_PART].packet != nullptr, -1,
82654 "Handler for PACKET_RULESET_DESCRIPTION_PART not installed");
82655 return pc->phs.handlers->send[PACKET_RULESET_DESCRIPTION_PART].packet(pc, packet);
82656}
82657
82658 void lsend_packet_ruleset_description_part(struct conn_list *dest, const struct packet_ruleset_description_part *packet)
82659{
82660 conn_list_iterate(dest, pconn) {
82661 send_packet_ruleset_description_part(pconn, packet);
82662 } conn_list_iterate_end;
82663}
82664
82665 static inline void init_packet_single_want_hack_req(struct packet_single_want_hack_req *packet)
82666{
82667 memset(packet, 0, sizeof(*packet));
82668}
82669
82670#define free_packet_single_want_hack_req(_packet) (void) 0
82671#define destroy_packet_single_want_hack_req free
82672
82673#ifdef FREECIV_DELTA_PROTOCOL
82674#define hash_packet_single_want_hack_req_100 hash_const
82675#define cmp_packet_single_want_hack_req_100 cmp_const
82676 BV_DEFINE(packet_single_want_hack_req_100_fields, 1);
82677#endif /* FREECIV_DELTA_PROTOCOL */
82678
82679 static struct packet_single_want_hack_req *receive_packet_single_want_hack_req_100(struct connection *pc)
82680{
82681#define FREE_PACKET_STRUCT(_packet) free_packet_single_want_hack_req(_packet)
82682 RECEIVE_PACKET_START(packet_single_want_hack_req, real_packet);
82683
82684#ifdef FREECIV_JSON_CONNECTION
82685 struct plocation field_addr;
82686 {
82687 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82688 field_addr = *field_addr_tmp;
82689 FC_FREE(field_addr_tmp);
82690 }
82691#endif /* FREECIV_JSON_CONNECTION */
82692
82693 log_packet_detailed("packet_single_want_hack_req_100: got info about ()");
82694
82695#ifdef FREECIV_DELTA_PROTOCOL
82696 packet_single_want_hack_req_100_fields fields;
82697 struct packet_single_want_hack_req *old;
82698 struct genhash **hash = pc->phs.received + PACKET_SINGLE_WANT_HACK_REQ;
82699
82700 if (nullptr == *hash) {
82701 *hash = genhash_new_full(hash_packet_single_want_hack_req_100, cmp_packet_single_want_hack_req_100,
82702 nullptr, nullptr, nullptr, destroy_packet_single_want_hack_req);
82703 }
82704
82705 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
82706 *real_packet = *old;
82707 } else {
82708 /* packet is already initialized empty */
82709 log_packet_detailed(" no old info");
82710 }
82711
82712#ifdef FREECIV_JSON_CONNECTION
82713 field_addr.name = "fields";
82714#endif /* FREECIV_JSON_CONNECTION */
82715 DIO_BV_GET(&din, &field_addr, fields);
82716
82717 if (BV_ISSET(fields, 0)) {
82718 log_packet_detailed(" got field 'token'");
82719
82720#ifdef FREECIV_JSON_CONNECTION
82721 field_addr.name = "token";
82722#endif /* FREECIV_JSON_CONNECTION */
82723
82724 if (!DIO_GET(string, &din, &field_addr, real_packet->token, sizeof(real_packet->token))) {
82725 RECEIVE_PACKET_FIELD_ERROR(token);
82726 }
82727 }
82728
82729 if (nullptr == old) {
82730 old = fc_malloc(sizeof(*old));
82731 init_packet_single_want_hack_req(old);
82732 *old = *real_packet;
82733 genhash_insert(*hash, old, old);
82734 } else {
82735 *old = *real_packet;
82736 }
82737
82738#else /* FREECIV_DELTA_PROTOCOL */
82739#ifdef FREECIV_JSON_CONNECTION
82740 field_addr.name = "token";
82741#endif /* FREECIV_JSON_CONNECTION */
82742
82743 if (!DIO_GET(string, &din, &field_addr, real_packet->token, sizeof(real_packet->token))) {
82744 RECEIVE_PACKET_FIELD_ERROR(token);
82745 }
82746#endif /* FREECIV_DELTA_PROTOCOL */
82747
82748 RECEIVE_PACKET_END(real_packet);
82749#undef FREE_PACKET_STRUCT
82750}
82751
82752 static int send_packet_single_want_hack_req_100(struct connection *pc, const struct packet_single_want_hack_req *packet)
82753{
82754 const struct packet_single_want_hack_req *real_packet = packet;
82755 int e;
82756 SEND_PACKET_START(PACKET_SINGLE_WANT_HACK_REQ);
82757
82758 log_packet_detailed("packet_single_want_hack_req_100: sending info about ()");
82759
82760#ifdef FREECIV_DELTA_PROTOCOL
82761 packet_single_want_hack_req_100_fields fields;
82762 struct packet_single_want_hack_req *old;
82763 bool differ;
82764 struct genhash **hash = pc->phs.sent + PACKET_SINGLE_WANT_HACK_REQ;
82765
82766 if (nullptr == *hash) {
82767 *hash = genhash_new_full(hash_packet_single_want_hack_req_100, cmp_packet_single_want_hack_req_100,
82768 nullptr, nullptr, nullptr, destroy_packet_single_want_hack_req);
82769 }
82770 BV_CLR_ALL(fields);
82771
82772 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
82773 old = fc_malloc(sizeof(*old));
82774 /* temporary bitcopy just to insert correctly */
82775 *old = *real_packet;
82776 genhash_insert(*hash, old, old);
82777 init_packet_single_want_hack_req(old);
82778 }
82779
82780 differ = (strcmp(old->token, real_packet->token) != 0);
82781 if (differ) {
82782 BV_SET(fields, 0);
82783 }
82784#endif /* FREECIV_DELTA_PROTOCOL */
82785
82786#ifdef FREECIV_JSON_CONNECTION
82787 struct plocation field_addr;
82788 {
82789 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82790 field_addr = *field_addr_tmp;
82791 FC_FREE(field_addr_tmp);
82792 }
82793#endif /* FREECIV_JSON_CONNECTION */
82794
82795#ifdef FREECIV_DELTA_PROTOCOL
82796#ifdef FREECIV_JSON_CONNECTION
82797 field_addr.name = "fields";
82798#endif /* FREECIV_JSON_CONNECTION */
82799 e = 0;
82800 e |= DIO_BV_PUT(&dout, &field_addr, fields);
82801 if (e) {
82802 log_packet_detailed("fields bitvector error detected");
82803 }
82804
82805 if (BV_ISSET(fields, 0)) {
82806 log_packet_detailed(" field 'token' has changed");
82807
82808#ifdef FREECIV_JSON_CONNECTION
82809 field_addr.name = "token";
82810#endif /* FREECIV_JSON_CONNECTION */
82811 e = 0;
82812
82813 e |= DIO_PUT(string, &dout, &field_addr, real_packet->token);
82814
82815 if (e) {
82816 log_packet_detailed("'token' field error detected");
82817 }
82818 }
82819
82820 *old = *real_packet;
82821
82822#else /* FREECIV_DELTA_PROTOCOL */
82823#ifdef FREECIV_JSON_CONNECTION
82824 field_addr.name = "token";
82825#endif /* FREECIV_JSON_CONNECTION */
82826 e = 0;
82827
82828 e |= DIO_PUT(string, &dout, &field_addr, real_packet->token);
82829
82830 if (e) {
82831 log_packet_detailed("'token' field error detected");
82832 }
82833#endif /* FREECIV_DELTA_PROTOCOL */
82834
82835 SEND_PACKET_END(PACKET_SINGLE_WANT_HACK_REQ);
82836}
82837
82838 int send_packet_single_want_hack_req(struct connection *pc, const struct packet_single_want_hack_req *packet)
82839{
82840 if (!pc->used) {
82841 log_error("WARNING: trying to send data to the closed connection %s",
82842 conn_description(pc));
82843 return -1;
82844 }
82845 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REQ].packet != nullptr, -1,
82846 "Handler for PACKET_SINGLE_WANT_HACK_REQ not installed");
82847 return pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REQ].packet(pc, packet);
82848}
82849
82850 static inline void init_packet_single_want_hack_reply(struct packet_single_want_hack_reply *packet)
82851{
82852 memset(packet, 0, sizeof(*packet));
82853}
82854
82855#define free_packet_single_want_hack_reply(_packet) (void) 0
82856#define destroy_packet_single_want_hack_reply free
82857
82858#ifdef FREECIV_DELTA_PROTOCOL
82859#define hash_packet_single_want_hack_reply_100 hash_const
82860#define cmp_packet_single_want_hack_reply_100 cmp_const
82861 BV_DEFINE(packet_single_want_hack_reply_100_fields, 1);
82862#endif /* FREECIV_DELTA_PROTOCOL */
82863
82864 static struct packet_single_want_hack_reply *receive_packet_single_want_hack_reply_100(struct connection *pc)
82865{
82866#define FREE_PACKET_STRUCT(_packet) free_packet_single_want_hack_reply(_packet)
82867 RECEIVE_PACKET_START(packet_single_want_hack_reply, real_packet);
82868
82869#ifdef FREECIV_JSON_CONNECTION
82870 struct plocation field_addr;
82871 {
82872 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82873 field_addr = *field_addr_tmp;
82874 FC_FREE(field_addr_tmp);
82875 }
82876#endif /* FREECIV_JSON_CONNECTION */
82877
82878 log_packet_detailed("packet_single_want_hack_reply_100: got info about ()");
82879
82880#ifdef FREECIV_DELTA_PROTOCOL
82881 packet_single_want_hack_reply_100_fields fields;
82882 struct packet_single_want_hack_reply *old;
82883 struct genhash **hash = pc->phs.received + PACKET_SINGLE_WANT_HACK_REPLY;
82884
82885 if (nullptr == *hash) {
82886 *hash = genhash_new_full(hash_packet_single_want_hack_reply_100, cmp_packet_single_want_hack_reply_100,
82887 nullptr, nullptr, nullptr, destroy_packet_single_want_hack_reply);
82888 }
82889
82890 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
82891 *real_packet = *old;
82892 } else {
82893 /* packet is already initialized empty */
82894 log_packet_detailed(" no old info");
82895 }
82896
82897#ifdef FREECIV_JSON_CONNECTION
82898 field_addr.name = "fields";
82899#endif /* FREECIV_JSON_CONNECTION */
82900 DIO_BV_GET(&din, &field_addr, fields);
82901
82902 real_packet->you_have_hack = BV_ISSET(fields, 0);
82903
82904 if (nullptr == old) {
82905 old = fc_malloc(sizeof(*old));
82906 init_packet_single_want_hack_reply(old);
82907 *old = *real_packet;
82908 genhash_insert(*hash, old, old);
82909 } else {
82910 *old = *real_packet;
82911 }
82912
82913#else /* FREECIV_DELTA_PROTOCOL */
82914#ifdef FREECIV_JSON_CONNECTION
82915 field_addr.name = "you_have_hack";
82916#endif /* FREECIV_JSON_CONNECTION */
82917
82918 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->you_have_hack)) {
82919 RECEIVE_PACKET_FIELD_ERROR(you_have_hack);
82920 }
82921#endif /* FREECIV_DELTA_PROTOCOL */
82922
82923 RECEIVE_PACKET_END(real_packet);
82924#undef FREE_PACKET_STRUCT
82925}
82926
82927 static int send_packet_single_want_hack_reply_100(struct connection *pc, const struct packet_single_want_hack_reply *packet)
82928{
82929 const struct packet_single_want_hack_reply *real_packet = packet;
82930 int e;
82931 SEND_PACKET_START(PACKET_SINGLE_WANT_HACK_REPLY);
82932
82933 log_packet_detailed("packet_single_want_hack_reply_100: sending info about ()");
82934
82935#ifdef FREECIV_DELTA_PROTOCOL
82936 packet_single_want_hack_reply_100_fields fields;
82937 struct packet_single_want_hack_reply *old;
82938 struct genhash **hash = pc->phs.sent + PACKET_SINGLE_WANT_HACK_REPLY;
82939
82940 if (nullptr == *hash) {
82941 *hash = genhash_new_full(hash_packet_single_want_hack_reply_100, cmp_packet_single_want_hack_reply_100,
82942 nullptr, nullptr, nullptr, destroy_packet_single_want_hack_reply);
82943 }
82944 BV_CLR_ALL(fields);
82945
82946 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
82947 old = fc_malloc(sizeof(*old));
82948 /* temporary bitcopy just to insert correctly */
82949 *old = *real_packet;
82950 genhash_insert(*hash, old, old);
82951 init_packet_single_want_hack_reply(old);
82952 }
82953
82954 /* folded into head */
82955 if (real_packet->you_have_hack) {
82956 BV_SET(fields, 0);
82957 }
82958#endif /* FREECIV_DELTA_PROTOCOL */
82959
82960#ifdef FREECIV_JSON_CONNECTION
82961 struct plocation field_addr;
82962 {
82963 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
82964 field_addr = *field_addr_tmp;
82965 FC_FREE(field_addr_tmp);
82966 }
82967#endif /* FREECIV_JSON_CONNECTION */
82968
82969#ifdef FREECIV_DELTA_PROTOCOL
82970#ifdef FREECIV_JSON_CONNECTION
82971 field_addr.name = "fields";
82972#endif /* FREECIV_JSON_CONNECTION */
82973 e = 0;
82974 e |= DIO_BV_PUT(&dout, &field_addr, fields);
82975 if (e) {
82976 log_packet_detailed("fields bitvector error detected");
82977 }
82978
82979 /* field 0 is folded into the header */
82980
82981 *old = *real_packet;
82982
82983#else /* FREECIV_DELTA_PROTOCOL */
82984#ifdef FREECIV_JSON_CONNECTION
82985 field_addr.name = "you_have_hack";
82986#endif /* FREECIV_JSON_CONNECTION */
82987 e = 0;
82988
82989 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->you_have_hack);
82990
82991 if (e) {
82992 log_packet_detailed("'you_have_hack' field error detected");
82993 }
82994#endif /* FREECIV_DELTA_PROTOCOL */
82995
82996 SEND_PACKET_END(PACKET_SINGLE_WANT_HACK_REPLY);
82997}
82998
82999 int send_packet_single_want_hack_reply(struct connection *pc, const struct packet_single_want_hack_reply *packet)
83000{
83001 if (!pc->used) {
83002 log_error("WARNING: trying to send data to the closed connection %s",
83003 conn_description(pc));
83004 return -1;
83005 }
83006 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REPLY].packet != nullptr, -1,
83007 "Handler for PACKET_SINGLE_WANT_HACK_REPLY not installed");
83008 return pc->phs.handlers->send[PACKET_SINGLE_WANT_HACK_REPLY].packet(pc, packet);
83009}
83010
83011 int dsend_packet_single_want_hack_reply(struct connection *pc, bool you_have_hack)
83012{
83013 struct packet_single_want_hack_reply packet, *real_packet = &packet;
83014
83015 real_packet->you_have_hack = you_have_hack;
83016
83017 return send_packet_single_want_hack_reply(pc, real_packet);
83018}
83019
83020 static inline void init_packet_ruleset_choices(struct packet_ruleset_choices *packet)
83021{
83022 memset(packet, 0, sizeof(*packet));
83023}
83024
83025#define free_packet_ruleset_choices(_packet) (void) 0
83026#define destroy_packet_ruleset_choices free
83027
83028#ifdef FREECIV_DELTA_PROTOCOL
83029#define hash_packet_ruleset_choices_100 hash_const
83030#define cmp_packet_ruleset_choices_100 cmp_const
83031 BV_DEFINE(packet_ruleset_choices_100_fields, 2);
83032#endif /* FREECIV_DELTA_PROTOCOL */
83033
83034 static struct packet_ruleset_choices *receive_packet_ruleset_choices_100(struct connection *pc)
83035{
83036#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_choices(_packet)
83037 RECEIVE_PACKET_START(packet_ruleset_choices, real_packet);
83038
83039#ifdef FREECIV_JSON_CONNECTION
83040 struct plocation field_addr;
83041 {
83042 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83043 field_addr = *field_addr_tmp;
83044 FC_FREE(field_addr_tmp);
83045 }
83046#endif /* FREECIV_JSON_CONNECTION */
83047
83048 log_packet_detailed("packet_ruleset_choices_100: got info about ()");
83049
83050#ifdef FREECIV_DELTA_PROTOCOL
83051 packet_ruleset_choices_100_fields fields;
83052 struct packet_ruleset_choices *old;
83053 struct genhash **hash = pc->phs.received + PACKET_RULESET_CHOICES;
83054
83055 if (nullptr == *hash) {
83056 *hash = genhash_new_full(hash_packet_ruleset_choices_100, cmp_packet_ruleset_choices_100,
83057 nullptr, nullptr, nullptr, destroy_packet_ruleset_choices);
83058 }
83059
83060 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
83061 *real_packet = *old;
83062 } else {
83063 /* packet is already initialized empty */
83064 log_packet_detailed(" no old info");
83065 }
83066
83067#ifdef FREECIV_JSON_CONNECTION
83068 field_addr.name = "fields";
83069#endif /* FREECIV_JSON_CONNECTION */
83070 DIO_BV_GET(&din, &field_addr, fields);
83071
83072 if (BV_ISSET(fields, 0)) {
83073 log_packet_detailed(" got field 'ruleset_count'");
83074
83075#ifdef FREECIV_JSON_CONNECTION
83076 field_addr.name = "ruleset_count";
83077#endif /* FREECIV_JSON_CONNECTION */
83078
83079 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ruleset_count)) {
83080 RECEIVE_PACKET_FIELD_ERROR(ruleset_count);
83081 }
83082 }
83083
83084 if (BV_ISSET(fields, 1)) {
83085 log_packet_detailed(" got field 'rulesets'");
83086
83087#ifdef FREECIV_JSON_CONNECTION
83088 field_addr.name = "rulesets";
83089#endif /* FREECIV_JSON_CONNECTION */
83090
83091 {
83092 int i;
83093
83094 if (real_packet->ruleset_count > MAX_NUM_RULESETS) {
83095 RECEIVE_PACKET_FIELD_ERROR(rulesets, ": array truncated");
83096 }
83097
83098#ifdef FREECIV_JSON_CONNECTION
83099 /* Enter array. */
83100 field_addr.sub_location = plocation_elem_new(0);
83101#endif /* FREECIV_JSON_CONNECTION */
83102
83103 for (i = 0; i < real_packet->ruleset_count; i++) {
83104#ifdef FREECIV_JSON_CONNECTION
83105 /* Next array element */
83106 field_addr.sub_location->number = i;
83107#endif /* FREECIV_JSON_CONNECTION */
83108
83109 if (!DIO_GET(string, &din, &field_addr, real_packet->rulesets[i], sizeof(real_packet->rulesets[i]))) {
83110 RECEIVE_PACKET_FIELD_ERROR(rulesets);
83111 }
83112 }
83113
83114#ifdef FREECIV_JSON_CONNECTION
83115 /* Exit array. */
83116 FC_FREE(field_addr.sub_location);
83117#endif /* FREECIV_JSON_CONNECTION */
83118 }
83119 }
83120
83121 if (nullptr == old) {
83122 old = fc_malloc(sizeof(*old));
83123 init_packet_ruleset_choices(old);
83124 *old = *real_packet;
83125 genhash_insert(*hash, old, old);
83126 } else {
83127 *old = *real_packet;
83128 }
83129
83130#else /* FREECIV_DELTA_PROTOCOL */
83131#ifdef FREECIV_JSON_CONNECTION
83132 field_addr.name = "ruleset_count";
83133#endif /* FREECIV_JSON_CONNECTION */
83134
83135 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ruleset_count)) {
83136 RECEIVE_PACKET_FIELD_ERROR(ruleset_count);
83137 }
83138
83139#ifdef FREECIV_JSON_CONNECTION
83140 field_addr.name = "rulesets";
83141#endif /* FREECIV_JSON_CONNECTION */
83142
83143 {
83144 int i;
83145
83146 if (real_packet->ruleset_count > MAX_NUM_RULESETS) {
83147 RECEIVE_PACKET_FIELD_ERROR(rulesets, ": array truncated");
83148 }
83149
83150#ifdef FREECIV_JSON_CONNECTION
83151 /* Enter array. */
83152 field_addr.sub_location = plocation_elem_new(0);
83153#endif /* FREECIV_JSON_CONNECTION */
83154
83155 for (i = 0; i < real_packet->ruleset_count; i++) {
83156#ifdef FREECIV_JSON_CONNECTION
83157 /* Next array element */
83158 field_addr.sub_location->number = i;
83159#endif /* FREECIV_JSON_CONNECTION */
83160
83161 if (!DIO_GET(string, &din, &field_addr, real_packet->rulesets[i], sizeof(real_packet->rulesets[i]))) {
83162 RECEIVE_PACKET_FIELD_ERROR(rulesets);
83163 }
83164 }
83165
83166#ifdef FREECIV_JSON_CONNECTION
83167 /* Exit array. */
83168 FC_FREE(field_addr.sub_location);
83169#endif /* FREECIV_JSON_CONNECTION */
83170 }
83171#endif /* FREECIV_DELTA_PROTOCOL */
83172
83173 RECEIVE_PACKET_END(real_packet);
83174#undef FREE_PACKET_STRUCT
83175}
83176
83177 static int send_packet_ruleset_choices_100(struct connection *pc, const struct packet_ruleset_choices *packet)
83178{
83179 const struct packet_ruleset_choices *real_packet = packet;
83180 int e;
83181 SEND_PACKET_START(PACKET_RULESET_CHOICES);
83182
83183 log_packet_detailed("packet_ruleset_choices_100: sending info about ()");
83184
83185#ifdef FREECIV_DELTA_PROTOCOL
83186 packet_ruleset_choices_100_fields fields;
83187 struct packet_ruleset_choices *old;
83188 bool differ;
83189 struct genhash **hash = pc->phs.sent + PACKET_RULESET_CHOICES;
83190
83191 if (nullptr == *hash) {
83192 *hash = genhash_new_full(hash_packet_ruleset_choices_100, cmp_packet_ruleset_choices_100,
83193 nullptr, nullptr, nullptr, destroy_packet_ruleset_choices);
83194 }
83195 BV_CLR_ALL(fields);
83196
83197 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
83198 old = fc_malloc(sizeof(*old));
83199 /* temporary bitcopy just to insert correctly */
83200 *old = *real_packet;
83201 genhash_insert(*hash, old, old);
83202 init_packet_ruleset_choices(old);
83203 }
83204
83205 differ = (old->ruleset_count != real_packet->ruleset_count);
83206 if (differ) {
83207 BV_SET(fields, 0);
83208 }
83209
83210 differ = (old->ruleset_count != real_packet->ruleset_count);
83211 if (!differ) {
83212 int i;
83213
83214 for (i = 0; i < old->ruleset_count; i++) {
83215 differ = (strcmp(old->rulesets[i], real_packet->rulesets[i]) != 0);
83216 if (differ) {
83217 break;
83218 }
83219 }
83220 }
83221 if (differ) {
83222 BV_SET(fields, 1);
83223 }
83224#endif /* FREECIV_DELTA_PROTOCOL */
83225
83226#ifdef FREECIV_JSON_CONNECTION
83227 struct plocation field_addr;
83228 {
83229 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83230 field_addr = *field_addr_tmp;
83231 FC_FREE(field_addr_tmp);
83232 }
83233#endif /* FREECIV_JSON_CONNECTION */
83234
83235#ifdef FREECIV_DELTA_PROTOCOL
83236#ifdef FREECIV_JSON_CONNECTION
83237 field_addr.name = "fields";
83238#endif /* FREECIV_JSON_CONNECTION */
83239 e = 0;
83240 e |= DIO_BV_PUT(&dout, &field_addr, fields);
83241 if (e) {
83242 log_packet_detailed("fields bitvector error detected");
83243 }
83244
83245 if (BV_ISSET(fields, 0)) {
83246 log_packet_detailed(" field 'ruleset_count' has changed");
83247
83248#ifdef FREECIV_JSON_CONNECTION
83249 field_addr.name = "ruleset_count";
83250#endif /* FREECIV_JSON_CONNECTION */
83251 e = 0;
83252
83253 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ruleset_count);
83254
83255 if (e) {
83256 log_packet_detailed("'ruleset_count' field error detected");
83257 }
83258 }
83259
83260 if (BV_ISSET(fields, 1)) {
83261 log_packet_detailed(" field 'rulesets' has changed");
83262
83263#ifdef FREECIV_JSON_CONNECTION
83264 field_addr.name = "rulesets";
83265#endif /* FREECIV_JSON_CONNECTION */
83266 e = 0;
83267
83268 {
83269 int i;
83270
83271#ifdef FREECIV_JSON_CONNECTION
83272 /* Create the array. */
83273 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ruleset_count);
83274
83275 /* Enter array. */
83276 field_addr.sub_location = plocation_elem_new(0);
83277#endif /* FREECIV_JSON_CONNECTION */
83278
83279 for (i = 0; i < real_packet->ruleset_count; i++) {
83280#ifdef FREECIV_JSON_CONNECTION
83281 /* Next array element. */
83282 field_addr.sub_location->number = i;
83283#endif /* FREECIV_JSON_CONNECTION */
83284
83285 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rulesets[i]);
83286 }
83287
83288#ifdef FREECIV_JSON_CONNECTION
83289 /* Exit array. */
83290 FC_FREE(field_addr.sub_location);
83291#endif /* FREECIV_JSON_CONNECTION */
83292 }
83293
83294 if (e) {
83295 log_packet_detailed("'rulesets' field error detected");
83296 }
83297 }
83298
83299 *old = *real_packet;
83300
83301#else /* FREECIV_DELTA_PROTOCOL */
83302#ifdef FREECIV_JSON_CONNECTION
83303 field_addr.name = "ruleset_count";
83304#endif /* FREECIV_JSON_CONNECTION */
83305 e = 0;
83306
83307 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ruleset_count);
83308
83309 if (e) {
83310 log_packet_detailed("'ruleset_count' field error detected");
83311 }
83312
83313#ifdef FREECIV_JSON_CONNECTION
83314 field_addr.name = "rulesets";
83315#endif /* FREECIV_JSON_CONNECTION */
83316 e = 0;
83317
83318 {
83319 int i;
83320
83321#ifdef FREECIV_JSON_CONNECTION
83322 /* Create the array. */
83323 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->ruleset_count);
83324
83325 /* Enter array. */
83326 field_addr.sub_location = plocation_elem_new(0);
83327#endif /* FREECIV_JSON_CONNECTION */
83328
83329 for (i = 0; i < real_packet->ruleset_count; i++) {
83330#ifdef FREECIV_JSON_CONNECTION
83331 /* Next array element. */
83332 field_addr.sub_location->number = i;
83333#endif /* FREECIV_JSON_CONNECTION */
83334
83335 e |= DIO_PUT(string, &dout, &field_addr, real_packet->rulesets[i]);
83336 }
83337
83338#ifdef FREECIV_JSON_CONNECTION
83339 /* Exit array. */
83340 FC_FREE(field_addr.sub_location);
83341#endif /* FREECIV_JSON_CONNECTION */
83342 }
83343
83344 if (e) {
83345 log_packet_detailed("'rulesets' field error detected");
83346 }
83347#endif /* FREECIV_DELTA_PROTOCOL */
83348
83349 SEND_PACKET_END(PACKET_RULESET_CHOICES);
83350}
83351
83352 int send_packet_ruleset_choices(struct connection *pc, const struct packet_ruleset_choices *packet)
83353{
83354 if (!pc->used) {
83355 log_error("WARNING: trying to send data to the closed connection %s",
83356 conn_description(pc));
83357 return -1;
83358 }
83359 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_CHOICES].packet != nullptr, -1,
83360 "Handler for PACKET_RULESET_CHOICES not installed");
83361 return pc->phs.handlers->send[PACKET_RULESET_CHOICES].packet(pc, packet);
83362}
83363
83364 static inline void init_packet_ruleset_select(struct packet_ruleset_select *packet)
83365{
83366 memset(packet, 0, sizeof(*packet));
83367}
83368
83369#define free_packet_ruleset_select(_packet) (void) 0
83370#define destroy_packet_ruleset_select free
83371
83372#ifdef FREECIV_DELTA_PROTOCOL
83373#define hash_packet_ruleset_select_100 hash_const
83374#define cmp_packet_ruleset_select_100 cmp_const
83375 BV_DEFINE(packet_ruleset_select_100_fields, 1);
83376#endif /* FREECIV_DELTA_PROTOCOL */
83377
83378 static struct packet_ruleset_select *receive_packet_ruleset_select_100(struct connection *pc)
83379{
83380#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_select(_packet)
83381 RECEIVE_PACKET_START(packet_ruleset_select, real_packet);
83382
83383#ifdef FREECIV_JSON_CONNECTION
83384 struct plocation field_addr;
83385 {
83386 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83387 field_addr = *field_addr_tmp;
83388 FC_FREE(field_addr_tmp);
83389 }
83390#endif /* FREECIV_JSON_CONNECTION */
83391
83392 log_packet_detailed("packet_ruleset_select_100: got info about ()");
83393
83394#ifdef FREECIV_DELTA_PROTOCOL
83395 packet_ruleset_select_100_fields fields;
83396 struct packet_ruleset_select *old;
83397 struct genhash **hash = pc->phs.received + PACKET_RULESET_SELECT;
83398
83399 if (nullptr == *hash) {
83400 *hash = genhash_new_full(hash_packet_ruleset_select_100, cmp_packet_ruleset_select_100,
83401 nullptr, nullptr, nullptr, destroy_packet_ruleset_select);
83402 }
83403
83404 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
83405 *real_packet = *old;
83406 } else {
83407 /* packet is already initialized empty */
83408 log_packet_detailed(" no old info");
83409 }
83410
83411#ifdef FREECIV_JSON_CONNECTION
83412 field_addr.name = "fields";
83413#endif /* FREECIV_JSON_CONNECTION */
83414 DIO_BV_GET(&din, &field_addr, fields);
83415
83416 if (BV_ISSET(fields, 0)) {
83417 log_packet_detailed(" got field 'modpack'");
83418
83419#ifdef FREECIV_JSON_CONNECTION
83420 field_addr.name = "modpack";
83421#endif /* FREECIV_JSON_CONNECTION */
83422
83423 if (!DIO_GET(string, &din, &field_addr, real_packet->modpack, sizeof(real_packet->modpack))) {
83424 RECEIVE_PACKET_FIELD_ERROR(modpack);
83425 }
83426 }
83427
83428 if (nullptr == old) {
83429 old = fc_malloc(sizeof(*old));
83430 init_packet_ruleset_select(old);
83431 *old = *real_packet;
83432 genhash_insert(*hash, old, old);
83433 } else {
83434 *old = *real_packet;
83435 }
83436
83437#else /* FREECIV_DELTA_PROTOCOL */
83438#ifdef FREECIV_JSON_CONNECTION
83439 field_addr.name = "modpack";
83440#endif /* FREECIV_JSON_CONNECTION */
83441
83442 if (!DIO_GET(string, &din, &field_addr, real_packet->modpack, sizeof(real_packet->modpack))) {
83443 RECEIVE_PACKET_FIELD_ERROR(modpack);
83444 }
83445#endif /* FREECIV_DELTA_PROTOCOL */
83446
83447 RECEIVE_PACKET_END(real_packet);
83448#undef FREE_PACKET_STRUCT
83449}
83450
83451 static int send_packet_ruleset_select_100(struct connection *pc, const struct packet_ruleset_select *packet)
83452{
83453 const struct packet_ruleset_select *real_packet = packet;
83454 int e;
83455 SEND_PACKET_START(PACKET_RULESET_SELECT);
83456
83457 log_packet_detailed("packet_ruleset_select_100: sending info about ()");
83458
83459#ifdef FREECIV_DELTA_PROTOCOL
83460 packet_ruleset_select_100_fields fields;
83461 struct packet_ruleset_select *old;
83462 bool differ;
83463 struct genhash **hash = pc->phs.sent + PACKET_RULESET_SELECT;
83464
83465 if (nullptr == *hash) {
83466 *hash = genhash_new_full(hash_packet_ruleset_select_100, cmp_packet_ruleset_select_100,
83467 nullptr, nullptr, nullptr, destroy_packet_ruleset_select);
83468 }
83469 BV_CLR_ALL(fields);
83470
83471 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
83472 old = fc_malloc(sizeof(*old));
83473 /* temporary bitcopy just to insert correctly */
83474 *old = *real_packet;
83475 genhash_insert(*hash, old, old);
83476 init_packet_ruleset_select(old);
83477 }
83478
83479 differ = (strcmp(old->modpack, real_packet->modpack) != 0);
83480 if (differ) {
83481 BV_SET(fields, 0);
83482 }
83483#endif /* FREECIV_DELTA_PROTOCOL */
83484
83485#ifdef FREECIV_JSON_CONNECTION
83486 struct plocation field_addr;
83487 {
83488 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83489 field_addr = *field_addr_tmp;
83490 FC_FREE(field_addr_tmp);
83491 }
83492#endif /* FREECIV_JSON_CONNECTION */
83493
83494#ifdef FREECIV_DELTA_PROTOCOL
83495#ifdef FREECIV_JSON_CONNECTION
83496 field_addr.name = "fields";
83497#endif /* FREECIV_JSON_CONNECTION */
83498 e = 0;
83499 e |= DIO_BV_PUT(&dout, &field_addr, fields);
83500 if (e) {
83501 log_packet_detailed("fields bitvector error detected");
83502 }
83503
83504 if (BV_ISSET(fields, 0)) {
83505 log_packet_detailed(" field 'modpack' has changed");
83506
83507#ifdef FREECIV_JSON_CONNECTION
83508 field_addr.name = "modpack";
83509#endif /* FREECIV_JSON_CONNECTION */
83510 e = 0;
83511
83512 e |= DIO_PUT(string, &dout, &field_addr, real_packet->modpack);
83513
83514 if (e) {
83515 log_packet_detailed("'modpack' field error detected");
83516 }
83517 }
83518
83519 *old = *real_packet;
83520
83521#else /* FREECIV_DELTA_PROTOCOL */
83522#ifdef FREECIV_JSON_CONNECTION
83523 field_addr.name = "modpack";
83524#endif /* FREECIV_JSON_CONNECTION */
83525 e = 0;
83526
83527 e |= DIO_PUT(string, &dout, &field_addr, real_packet->modpack);
83528
83529 if (e) {
83530 log_packet_detailed("'modpack' field error detected");
83531 }
83532#endif /* FREECIV_DELTA_PROTOCOL */
83533
83534 SEND_PACKET_END(PACKET_RULESET_SELECT);
83535}
83536
83537 int send_packet_ruleset_select(struct connection *pc, const struct packet_ruleset_select *packet)
83538{
83539 if (!pc->used) {
83540 log_error("WARNING: trying to send data to the closed connection %s",
83541 conn_description(pc));
83542 return -1;
83543 }
83544 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_SELECT].packet != nullptr, -1,
83545 "Handler for PACKET_RULESET_SELECT not installed");
83546 return pc->phs.handlers->send[PACKET_RULESET_SELECT].packet(pc, packet);
83547}
83548
83549 static inline void init_packet_game_load(struct packet_game_load *packet)
83550{
83551 memset(packet, 0, sizeof(*packet));
83552}
83553
83554#define free_packet_game_load(_packet) (void) 0
83555#define destroy_packet_game_load free
83556
83557#ifdef FREECIV_DELTA_PROTOCOL
83558#define hash_packet_game_load_100 hash_const
83559#define cmp_packet_game_load_100 cmp_const
83560 BV_DEFINE(packet_game_load_100_fields, 2);
83561#endif /* FREECIV_DELTA_PROTOCOL */
83562
83563 static struct packet_game_load *receive_packet_game_load_100(struct connection *pc)
83564{
83565#define FREE_PACKET_STRUCT(_packet) free_packet_game_load(_packet)
83566 RECEIVE_PACKET_START(packet_game_load, real_packet);
83567
83568#ifdef FREECIV_JSON_CONNECTION
83569 struct plocation field_addr;
83570 {
83571 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83572 field_addr = *field_addr_tmp;
83573 FC_FREE(field_addr_tmp);
83574 }
83575#endif /* FREECIV_JSON_CONNECTION */
83576
83577 log_packet_detailed("packet_game_load_100: got info about ()");
83578
83579#ifdef FREECIV_DELTA_PROTOCOL
83580 packet_game_load_100_fields fields;
83581 struct packet_game_load *old;
83582 struct genhash **hash = pc->phs.received + PACKET_GAME_LOAD;
83583
83584 if (nullptr == *hash) {
83585 *hash = genhash_new_full(hash_packet_game_load_100, cmp_packet_game_load_100,
83586 nullptr, nullptr, nullptr, destroy_packet_game_load);
83587 }
83588
83589 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
83590 *real_packet = *old;
83591 } else {
83592 /* packet is already initialized empty */
83593 log_packet_detailed(" no old info");
83594 }
83595
83596#ifdef FREECIV_JSON_CONNECTION
83597 field_addr.name = "fields";
83598#endif /* FREECIV_JSON_CONNECTION */
83599 DIO_BV_GET(&din, &field_addr, fields);
83600
83601 real_packet->load_successful = BV_ISSET(fields, 0);
83602
83603 if (BV_ISSET(fields, 1)) {
83604 log_packet_detailed(" got field 'load_filename'");
83605
83606#ifdef FREECIV_JSON_CONNECTION
83607 field_addr.name = "load_filename";
83608#endif /* FREECIV_JSON_CONNECTION */
83609
83610 if (!DIO_GET(string, &din, &field_addr, real_packet->load_filename, sizeof(real_packet->load_filename))) {
83611 RECEIVE_PACKET_FIELD_ERROR(load_filename);
83612 }
83613 }
83614
83615 if (nullptr == old) {
83616 old = fc_malloc(sizeof(*old));
83617 init_packet_game_load(old);
83618 *old = *real_packet;
83619 genhash_insert(*hash, old, old);
83620 } else {
83621 *old = *real_packet;
83622 }
83623
83624#else /* FREECIV_DELTA_PROTOCOL */
83625#ifdef FREECIV_JSON_CONNECTION
83626 field_addr.name = "load_successful";
83627#endif /* FREECIV_JSON_CONNECTION */
83628
83629 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->load_successful)) {
83630 RECEIVE_PACKET_FIELD_ERROR(load_successful);
83631 }
83632
83633#ifdef FREECIV_JSON_CONNECTION
83634 field_addr.name = "load_filename";
83635#endif /* FREECIV_JSON_CONNECTION */
83636
83637 if (!DIO_GET(string, &din, &field_addr, real_packet->load_filename, sizeof(real_packet->load_filename))) {
83638 RECEIVE_PACKET_FIELD_ERROR(load_filename);
83639 }
83640#endif /* FREECIV_DELTA_PROTOCOL */
83641
83642 RECEIVE_PACKET_END(real_packet);
83643#undef FREE_PACKET_STRUCT
83644}
83645
83646 static int send_packet_game_load_100(struct connection *pc, const struct packet_game_load *packet)
83647{
83648 const struct packet_game_load *real_packet = packet;
83649 int e;
83650 SEND_PACKET_START(PACKET_GAME_LOAD);
83651
83652 log_packet_detailed("packet_game_load_100: sending info about ()");
83653
83654#ifdef FREECIV_DELTA_PROTOCOL
83655 packet_game_load_100_fields fields;
83656 struct packet_game_load *old;
83657 bool differ;
83658 struct genhash **hash = pc->phs.sent + PACKET_GAME_LOAD;
83659
83660 if (nullptr == *hash) {
83661 *hash = genhash_new_full(hash_packet_game_load_100, cmp_packet_game_load_100,
83662 nullptr, nullptr, nullptr, destroy_packet_game_load);
83663 }
83664 BV_CLR_ALL(fields);
83665
83666 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
83667 old = fc_malloc(sizeof(*old));
83668 /* temporary bitcopy just to insert correctly */
83669 *old = *real_packet;
83670 genhash_insert(*hash, old, old);
83671 init_packet_game_load(old);
83672 }
83673
83674 /* folded into head */
83675 if (real_packet->load_successful) {
83676 BV_SET(fields, 0);
83677 }
83678
83679 differ = (strcmp(old->load_filename, real_packet->load_filename) != 0);
83680 if (differ) {
83681 BV_SET(fields, 1);
83682 }
83683#endif /* FREECIV_DELTA_PROTOCOL */
83684
83685#ifdef FREECIV_JSON_CONNECTION
83686 struct plocation field_addr;
83687 {
83688 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83689 field_addr = *field_addr_tmp;
83690 FC_FREE(field_addr_tmp);
83691 }
83692#endif /* FREECIV_JSON_CONNECTION */
83693
83694#ifdef FREECIV_DELTA_PROTOCOL
83695#ifdef FREECIV_JSON_CONNECTION
83696 field_addr.name = "fields";
83697#endif /* FREECIV_JSON_CONNECTION */
83698 e = 0;
83699 e |= DIO_BV_PUT(&dout, &field_addr, fields);
83700 if (e) {
83701 log_packet_detailed("fields bitvector error detected");
83702 }
83703
83704 /* field 0 is folded into the header */
83705
83706 if (BV_ISSET(fields, 1)) {
83707 log_packet_detailed(" field 'load_filename' has changed");
83708
83709#ifdef FREECIV_JSON_CONNECTION
83710 field_addr.name = "load_filename";
83711#endif /* FREECIV_JSON_CONNECTION */
83712 e = 0;
83713
83714 e |= DIO_PUT(string, &dout, &field_addr, real_packet->load_filename);
83715
83716 if (e) {
83717 log_packet_detailed("'load_filename' field error detected");
83718 }
83719 }
83720
83721 *old = *real_packet;
83722
83723#else /* FREECIV_DELTA_PROTOCOL */
83724#ifdef FREECIV_JSON_CONNECTION
83725 field_addr.name = "load_successful";
83726#endif /* FREECIV_JSON_CONNECTION */
83727 e = 0;
83728
83729 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->load_successful);
83730
83731 if (e) {
83732 log_packet_detailed("'load_successful' field error detected");
83733 }
83734
83735#ifdef FREECIV_JSON_CONNECTION
83736 field_addr.name = "load_filename";
83737#endif /* FREECIV_JSON_CONNECTION */
83738 e = 0;
83739
83740 e |= DIO_PUT(string, &dout, &field_addr, real_packet->load_filename);
83741
83742 if (e) {
83743 log_packet_detailed("'load_filename' field error detected");
83744 }
83745#endif /* FREECIV_DELTA_PROTOCOL */
83746
83747 SEND_PACKET_END(PACKET_GAME_LOAD);
83748}
83749
83750 int send_packet_game_load(struct connection *pc, const struct packet_game_load *packet)
83751{
83752 if (!pc->used) {
83753 log_error("WARNING: trying to send data to the closed connection %s",
83754 conn_description(pc));
83755 return -1;
83756 }
83757 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_GAME_LOAD].packet != nullptr, -1,
83758 "Handler for PACKET_GAME_LOAD not installed");
83759 return pc->phs.handlers->send[PACKET_GAME_LOAD].packet(pc, packet);
83760}
83761
83762 void lsend_packet_game_load(struct conn_list *dest, const struct packet_game_load *packet)
83763{
83764 conn_list_iterate(dest, pconn) {
83765 send_packet_game_load(pconn, packet);
83766 } conn_list_iterate_end;
83767}
83768
83769 int dsend_packet_game_load(struct connection *pc, bool load_successful, const char *load_filename)
83770{
83771 struct packet_game_load packet, *real_packet = &packet;
83772
83773 real_packet->load_successful = load_successful;
83774 sz_strlcpy(real_packet->load_filename, load_filename);
83775
83776 return send_packet_game_load(pc, real_packet);
83777}
83778
83779 void dlsend_packet_game_load(struct conn_list *dest, bool load_successful, const char *load_filename)
83780{
83781 struct packet_game_load packet, *real_packet = &packet;
83782
83783 real_packet->load_successful = load_successful;
83784 sz_strlcpy(real_packet->load_filename, load_filename);
83785
83786 lsend_packet_game_load(dest, real_packet);
83787}
83788
83789 static inline void init_packet_server_setting_control(struct packet_server_setting_control *packet)
83790{
83791 memset(packet, 0, sizeof(*packet));
83792}
83793
83794#define free_packet_server_setting_control(_packet) (void) 0
83795#define destroy_packet_server_setting_control free
83796
83797#ifdef FREECIV_DELTA_PROTOCOL
83798#define hash_packet_server_setting_control_100 hash_const
83799#define cmp_packet_server_setting_control_100 cmp_const
83800 BV_DEFINE(packet_server_setting_control_100_fields, 3);
83801#endif /* FREECIV_DELTA_PROTOCOL */
83802
83803 static struct packet_server_setting_control *receive_packet_server_setting_control_100(struct connection *pc)
83804{
83805#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_control(_packet)
83806 RECEIVE_PACKET_START(packet_server_setting_control, real_packet);
83807
83808#ifdef FREECIV_JSON_CONNECTION
83809 struct plocation field_addr;
83810 {
83811 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
83812 field_addr = *field_addr_tmp;
83813 FC_FREE(field_addr_tmp);
83814 }
83815#endif /* FREECIV_JSON_CONNECTION */
83816
83817 log_packet_detailed("packet_server_setting_control_100: got info about ()");
83818
83819#ifdef FREECIV_DELTA_PROTOCOL
83820 packet_server_setting_control_100_fields fields;
83821 struct packet_server_setting_control *old;
83822 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_CONTROL;
83823
83824 if (nullptr == *hash) {
83825 *hash = genhash_new_full(hash_packet_server_setting_control_100, cmp_packet_server_setting_control_100,
83826 nullptr, nullptr, nullptr, destroy_packet_server_setting_control);
83827 }
83828
83829 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
83830 *real_packet = *old;
83831 } else {
83832 /* packet is already initialized empty */
83833 log_packet_detailed(" no old info");
83834 }
83835
83836#ifdef FREECIV_JSON_CONNECTION
83837 field_addr.name = "fields";
83838#endif /* FREECIV_JSON_CONNECTION */
83839 DIO_BV_GET(&din, &field_addr, fields);
83840
83841 if (BV_ISSET(fields, 0)) {
83842 log_packet_detailed(" got field 'settings_num'");
83843
83844#ifdef FREECIV_JSON_CONNECTION
83845 field_addr.name = "settings_num";
83846#endif /* FREECIV_JSON_CONNECTION */
83847
83848 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->settings_num)) {
83849 RECEIVE_PACKET_FIELD_ERROR(settings_num);
83850 }
83851 }
83852
83853 if (BV_ISSET(fields, 1)) {
83854 log_packet_detailed(" got field 'categories_num'");
83855
83856#ifdef FREECIV_JSON_CONNECTION
83857 field_addr.name = "categories_num";
83858#endif /* FREECIV_JSON_CONNECTION */
83859
83860 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->categories_num)) {
83861 RECEIVE_PACKET_FIELD_ERROR(categories_num);
83862 }
83863 }
83864
83865 if (BV_ISSET(fields, 2)) {
83866 log_packet_detailed(" got field 'category_names'");
83867
83868#ifdef FREECIV_JSON_CONNECTION
83869 field_addr.name = "category_names";
83870#endif /* FREECIV_JSON_CONNECTION */
83871
83872 {
83873 int i;
83874
83875 if (real_packet->categories_num > 256) {
83876 RECEIVE_PACKET_FIELD_ERROR(category_names, ": array truncated");
83877 }
83878
83879#ifdef FREECIV_JSON_CONNECTION
83880 /* Enter array. */
83881 field_addr.sub_location = plocation_elem_new(0);
83882#endif /* FREECIV_JSON_CONNECTION */
83883
83884 for (i = 0; i < real_packet->categories_num; i++) {
83885#ifdef FREECIV_JSON_CONNECTION
83886 /* Next array element */
83887 field_addr.sub_location->number = i;
83888#endif /* FREECIV_JSON_CONNECTION */
83889
83890 if (!DIO_GET(string, &din, &field_addr, real_packet->category_names[i], sizeof(real_packet->category_names[i]))) {
83891 RECEIVE_PACKET_FIELD_ERROR(category_names);
83892 }
83893 }
83894
83895#ifdef FREECIV_JSON_CONNECTION
83896 /* Exit array. */
83897 FC_FREE(field_addr.sub_location);
83898#endif /* FREECIV_JSON_CONNECTION */
83899 }
83900 }
83901
83902 if (nullptr == old) {
83903 old = fc_malloc(sizeof(*old));
83904 init_packet_server_setting_control(old);
83905 *old = *real_packet;
83906 genhash_insert(*hash, old, old);
83907 } else {
83908 *old = *real_packet;
83909 }
83910
83911#else /* FREECIV_DELTA_PROTOCOL */
83912#ifdef FREECIV_JSON_CONNECTION
83913 field_addr.name = "settings_num";
83914#endif /* FREECIV_JSON_CONNECTION */
83915
83916 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->settings_num)) {
83917 RECEIVE_PACKET_FIELD_ERROR(settings_num);
83918 }
83919
83920#ifdef FREECIV_JSON_CONNECTION
83921 field_addr.name = "categories_num";
83922#endif /* FREECIV_JSON_CONNECTION */
83923
83924 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->categories_num)) {
83925 RECEIVE_PACKET_FIELD_ERROR(categories_num);
83926 }
83927
83928#ifdef FREECIV_JSON_CONNECTION
83929 field_addr.name = "category_names";
83930#endif /* FREECIV_JSON_CONNECTION */
83931
83932 {
83933 int i;
83934
83935 if (real_packet->categories_num > 256) {
83936 RECEIVE_PACKET_FIELD_ERROR(category_names, ": array truncated");
83937 }
83938
83939#ifdef FREECIV_JSON_CONNECTION
83940 /* Enter array. */
83941 field_addr.sub_location = plocation_elem_new(0);
83942#endif /* FREECIV_JSON_CONNECTION */
83943
83944 for (i = 0; i < real_packet->categories_num; i++) {
83945#ifdef FREECIV_JSON_CONNECTION
83946 /* Next array element */
83947 field_addr.sub_location->number = i;
83948#endif /* FREECIV_JSON_CONNECTION */
83949
83950 if (!DIO_GET(string, &din, &field_addr, real_packet->category_names[i], sizeof(real_packet->category_names[i]))) {
83951 RECEIVE_PACKET_FIELD_ERROR(category_names);
83952 }
83953 }
83954
83955#ifdef FREECIV_JSON_CONNECTION
83956 /* Exit array. */
83957 FC_FREE(field_addr.sub_location);
83958#endif /* FREECIV_JSON_CONNECTION */
83959 }
83960#endif /* FREECIV_DELTA_PROTOCOL */
83961
83962 RECEIVE_PACKET_END(real_packet);
83963#undef FREE_PACKET_STRUCT
83964}
83965
83966 static int send_packet_server_setting_control_100(struct connection *pc, const struct packet_server_setting_control *packet)
83967{
83968 const struct packet_server_setting_control *real_packet = packet;
83969 int e;
83970 SEND_PACKET_START(PACKET_SERVER_SETTING_CONTROL);
83971
83972 log_packet_detailed("packet_server_setting_control_100: sending info about ()");
83973
83974#ifdef FREECIV_DELTA_PROTOCOL
83975 packet_server_setting_control_100_fields fields;
83976 struct packet_server_setting_control *old;
83977 bool differ;
83978 int different = 0;
83979 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_CONTROL;
83980
83981 if (nullptr == *hash) {
83982 *hash = genhash_new_full(hash_packet_server_setting_control_100, cmp_packet_server_setting_control_100,
83983 nullptr, nullptr, nullptr, destroy_packet_server_setting_control);
83984 }
83985 BV_CLR_ALL(fields);
83986
83987 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
83988 old = fc_malloc(sizeof(*old));
83989 /* temporary bitcopy just to insert correctly */
83990 *old = *real_packet;
83991 genhash_insert(*hash, old, old);
83992 init_packet_server_setting_control(old);
83993 different = 1; /* Force to send. */
83994 }
83995
83996 differ = (old->settings_num != real_packet->settings_num);
83997 if (differ) {
83998 different++;
83999 BV_SET(fields, 0);
84000 }
84001
84002 differ = (old->categories_num != real_packet->categories_num);
84003 if (differ) {
84004 different++;
84005 BV_SET(fields, 1);
84006 }
84007
84008 differ = (old->categories_num != real_packet->categories_num);
84009 if (!differ) {
84010 int i;
84011
84012 for (i = 0; i < old->categories_num; i++) {
84013 differ = (strcmp(old->category_names[i], real_packet->category_names[i]) != 0);
84014 if (differ) {
84015 break;
84016 }
84017 }
84018 }
84019 if (differ) {
84020 different++;
84021 BV_SET(fields, 2);
84022 }
84023
84024 if (different == 0) {
84025 log_packet_detailed(" no change -> discard");
84026 SEND_PACKET_DISCARD();
84027 }
84028#endif /* FREECIV_DELTA_PROTOCOL */
84029
84030#ifdef FREECIV_JSON_CONNECTION
84031 struct plocation field_addr;
84032 {
84033 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
84034 field_addr = *field_addr_tmp;
84035 FC_FREE(field_addr_tmp);
84036 }
84037#endif /* FREECIV_JSON_CONNECTION */
84038
84039#ifdef FREECIV_DELTA_PROTOCOL
84040#ifdef FREECIV_JSON_CONNECTION
84041 field_addr.name = "fields";
84042#endif /* FREECIV_JSON_CONNECTION */
84043 e = 0;
84044 e |= DIO_BV_PUT(&dout, &field_addr, fields);
84045 if (e) {
84046 log_packet_detailed("fields bitvector error detected");
84047 }
84048
84049 if (BV_ISSET(fields, 0)) {
84050 log_packet_detailed(" field 'settings_num' has changed");
84051
84052#ifdef FREECIV_JSON_CONNECTION
84053 field_addr.name = "settings_num";
84054#endif /* FREECIV_JSON_CONNECTION */
84055 e = 0;
84056
84057 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->settings_num);
84058
84059 if (e) {
84060 log_packet_detailed("'settings_num' field error detected");
84061 }
84062 }
84063
84064 if (BV_ISSET(fields, 1)) {
84065 log_packet_detailed(" field 'categories_num' has changed");
84066
84067#ifdef FREECIV_JSON_CONNECTION
84068 field_addr.name = "categories_num";
84069#endif /* FREECIV_JSON_CONNECTION */
84070 e = 0;
84071
84072 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->categories_num);
84073
84074 if (e) {
84075 log_packet_detailed("'categories_num' field error detected");
84076 }
84077 }
84078
84079 if (BV_ISSET(fields, 2)) {
84080 log_packet_detailed(" field 'category_names' has changed");
84081
84082#ifdef FREECIV_JSON_CONNECTION
84083 field_addr.name = "category_names";
84084#endif /* FREECIV_JSON_CONNECTION */
84085 e = 0;
84086
84087 {
84088 int i;
84089
84090#ifdef FREECIV_JSON_CONNECTION
84091 /* Create the array. */
84092 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->categories_num);
84093
84094 /* Enter array. */
84095 field_addr.sub_location = plocation_elem_new(0);
84096#endif /* FREECIV_JSON_CONNECTION */
84097
84098 for (i = 0; i < real_packet->categories_num; i++) {
84099#ifdef FREECIV_JSON_CONNECTION
84100 /* Next array element. */
84101 field_addr.sub_location->number = i;
84102#endif /* FREECIV_JSON_CONNECTION */
84103
84104 e |= DIO_PUT(string, &dout, &field_addr, real_packet->category_names[i]);
84105 }
84106
84107#ifdef FREECIV_JSON_CONNECTION
84108 /* Exit array. */
84109 FC_FREE(field_addr.sub_location);
84110#endif /* FREECIV_JSON_CONNECTION */
84111 }
84112
84113 if (e) {
84114 log_packet_detailed("'category_names' field error detected");
84115 }
84116 }
84117
84118 *old = *real_packet;
84119
84120#else /* FREECIV_DELTA_PROTOCOL */
84121#ifdef FREECIV_JSON_CONNECTION
84122 field_addr.name = "settings_num";
84123#endif /* FREECIV_JSON_CONNECTION */
84124 e = 0;
84125
84126 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->settings_num);
84127
84128 if (e) {
84129 log_packet_detailed("'settings_num' field error detected");
84130 }
84131
84132#ifdef FREECIV_JSON_CONNECTION
84133 field_addr.name = "categories_num";
84134#endif /* FREECIV_JSON_CONNECTION */
84135 e = 0;
84136
84137 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->categories_num);
84138
84139 if (e) {
84140 log_packet_detailed("'categories_num' field error detected");
84141 }
84142
84143#ifdef FREECIV_JSON_CONNECTION
84144 field_addr.name = "category_names";
84145#endif /* FREECIV_JSON_CONNECTION */
84146 e = 0;
84147
84148 {
84149 int i;
84150
84151#ifdef FREECIV_JSON_CONNECTION
84152 /* Create the array. */
84153 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->categories_num);
84154
84155 /* Enter array. */
84156 field_addr.sub_location = plocation_elem_new(0);
84157#endif /* FREECIV_JSON_CONNECTION */
84158
84159 for (i = 0; i < real_packet->categories_num; i++) {
84160#ifdef FREECIV_JSON_CONNECTION
84161 /* Next array element. */
84162 field_addr.sub_location->number = i;
84163#endif /* FREECIV_JSON_CONNECTION */
84164
84165 e |= DIO_PUT(string, &dout, &field_addr, real_packet->category_names[i]);
84166 }
84167
84168#ifdef FREECIV_JSON_CONNECTION
84169 /* Exit array. */
84170 FC_FREE(field_addr.sub_location);
84171#endif /* FREECIV_JSON_CONNECTION */
84172 }
84173
84174 if (e) {
84175 log_packet_detailed("'category_names' field error detected");
84176 }
84177#endif /* FREECIV_DELTA_PROTOCOL */
84178
84179 SEND_PACKET_END(PACKET_SERVER_SETTING_CONTROL);
84180}
84181
84182 int send_packet_server_setting_control(struct connection *pc, const struct packet_server_setting_control *packet)
84183{
84184 if (!pc->used) {
84185 log_error("WARNING: trying to send data to the closed connection %s",
84186 conn_description(pc));
84187 return -1;
84188 }
84189 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_CONTROL].packet != nullptr, -1,
84190 "Handler for PACKET_SERVER_SETTING_CONTROL not installed");
84191 return pc->phs.handlers->send[PACKET_SERVER_SETTING_CONTROL].packet(pc, packet);
84192}
84193
84194 static inline void init_packet_server_setting_const(struct packet_server_setting_const *packet)
84195{
84196 memset(packet, 0, sizeof(*packet));
84197}
84198
84199#define free_packet_server_setting_const(_packet) (void) 0
84200#define destroy_packet_server_setting_const free
84201
84202#ifdef FREECIV_DELTA_PROTOCOL
84203static genhash_val_t hash_packet_server_setting_const_100(const void *vkey)
84204{
84205 const struct packet_server_setting_const *key = (const struct packet_server_setting_const *) vkey;
84206 genhash_val_t result = 0;
84207
84208 result += key->id;
84209
84210 result &= 0xFFFFFFFF;
84211 return result;
84212}
84213
84214static bool cmp_packet_server_setting_const_100(const void *vkey1, const void *vkey2)
84215{
84216 const struct packet_server_setting_const *old = (const struct packet_server_setting_const *) vkey1;
84217 const struct packet_server_setting_const *real_packet = (const struct packet_server_setting_const *) vkey2;
84218 bool differ;
84219
84220 differ = (old->id != real_packet->id);
84221
84222 return !differ;
84223}
84224 BV_DEFINE(packet_server_setting_const_100_fields, 4);
84225#endif /* FREECIV_DELTA_PROTOCOL */
84226
84227 static struct packet_server_setting_const *receive_packet_server_setting_const_100(struct connection *pc)
84228{
84229#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_const(_packet)
84230 RECEIVE_PACKET_START(packet_server_setting_const, real_packet);
84231
84232#ifdef FREECIV_JSON_CONNECTION
84233 struct plocation field_addr;
84234 {
84235 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
84236 field_addr = *field_addr_tmp;
84237 FC_FREE(field_addr_tmp);
84238 }
84239#endif /* FREECIV_JSON_CONNECTION */
84240
84241#ifdef FREECIV_JSON_CONNECTION
84242 field_addr.name = "id";
84243#endif /* FREECIV_JSON_CONNECTION */
84244
84245 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
84246 RECEIVE_PACKET_FIELD_ERROR(id);
84247 }
84248
84249 log_packet_detailed("packet_server_setting_const_100: got info about (%d)",
84250 real_packet->id);
84251
84252#ifdef FREECIV_DELTA_PROTOCOL
84253 packet_server_setting_const_100_fields fields;
84254 struct packet_server_setting_const *old;
84255 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_CONST;
84256
84257 if (nullptr == *hash) {
84258 *hash = genhash_new_full(hash_packet_server_setting_const_100, cmp_packet_server_setting_const_100,
84259 nullptr, nullptr, nullptr, destroy_packet_server_setting_const);
84260 }
84261
84262 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
84263 *real_packet = *old;
84264 } else {
84265 /* packet is already initialized empty */
84266 log_packet_detailed(" no old info");
84267 }
84268
84269#ifdef FREECIV_JSON_CONNECTION
84270 field_addr.name = "fields";
84271#endif /* FREECIV_JSON_CONNECTION */
84272 DIO_BV_GET(&din, &field_addr, fields);
84273
84274 if (BV_ISSET(fields, 0)) {
84275 log_packet_detailed(" got field 'name'");
84276
84277#ifdef FREECIV_JSON_CONNECTION
84278 field_addr.name = "name";
84279#endif /* FREECIV_JSON_CONNECTION */
84280
84281 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
84282 RECEIVE_PACKET_FIELD_ERROR(name);
84283 }
84284 }
84285
84286 if (BV_ISSET(fields, 1)) {
84287 log_packet_detailed(" got field 'short_help'");
84288
84289#ifdef FREECIV_JSON_CONNECTION
84290 field_addr.name = "short_help";
84291#endif /* FREECIV_JSON_CONNECTION */
84292
84293 if (!DIO_GET(string, &din, &field_addr, real_packet->short_help, sizeof(real_packet->short_help))) {
84294 RECEIVE_PACKET_FIELD_ERROR(short_help);
84295 }
84296 }
84297
84298 if (BV_ISSET(fields, 2)) {
84299 log_packet_detailed(" got field 'extra_help'");
84300
84301#ifdef FREECIV_JSON_CONNECTION
84302 field_addr.name = "extra_help";
84303#endif /* FREECIV_JSON_CONNECTION */
84304
84305 if (!DIO_GET(string, &din, &field_addr, real_packet->extra_help, sizeof(real_packet->extra_help))) {
84306 RECEIVE_PACKET_FIELD_ERROR(extra_help);
84307 }
84308 }
84309
84310 if (BV_ISSET(fields, 3)) {
84311 log_packet_detailed(" got field 'category'");
84312
84313#ifdef FREECIV_JSON_CONNECTION
84314 field_addr.name = "category";
84315#endif /* FREECIV_JSON_CONNECTION */
84316
84317 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->category)) {
84318 RECEIVE_PACKET_FIELD_ERROR(category);
84319 }
84320 }
84321
84322 if (nullptr == old) {
84323 old = fc_malloc(sizeof(*old));
84324 init_packet_server_setting_const(old);
84325 *old = *real_packet;
84326 genhash_insert(*hash, old, old);
84327 } else {
84328 *old = *real_packet;
84329 }
84330
84331#else /* FREECIV_DELTA_PROTOCOL */
84332#ifdef FREECIV_JSON_CONNECTION
84333 field_addr.name = "name";
84334#endif /* FREECIV_JSON_CONNECTION */
84335
84336 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
84337 RECEIVE_PACKET_FIELD_ERROR(name);
84338 }
84339
84340#ifdef FREECIV_JSON_CONNECTION
84341 field_addr.name = "short_help";
84342#endif /* FREECIV_JSON_CONNECTION */
84343
84344 if (!DIO_GET(string, &din, &field_addr, real_packet->short_help, sizeof(real_packet->short_help))) {
84345 RECEIVE_PACKET_FIELD_ERROR(short_help);
84346 }
84347
84348#ifdef FREECIV_JSON_CONNECTION
84349 field_addr.name = "extra_help";
84350#endif /* FREECIV_JSON_CONNECTION */
84351
84352 if (!DIO_GET(string, &din, &field_addr, real_packet->extra_help, sizeof(real_packet->extra_help))) {
84353 RECEIVE_PACKET_FIELD_ERROR(extra_help);
84354 }
84355
84356#ifdef FREECIV_JSON_CONNECTION
84357 field_addr.name = "category";
84358#endif /* FREECIV_JSON_CONNECTION */
84359
84360 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->category)) {
84361 RECEIVE_PACKET_FIELD_ERROR(category);
84362 }
84363#endif /* FREECIV_DELTA_PROTOCOL */
84364
84365 RECEIVE_PACKET_END(real_packet);
84366#undef FREE_PACKET_STRUCT
84367}
84368
84369 static int send_packet_server_setting_const_100(struct connection *pc, const struct packet_server_setting_const *packet)
84370{
84371 const struct packet_server_setting_const *real_packet = packet;
84372 int e;
84373 SEND_PACKET_START(PACKET_SERVER_SETTING_CONST);
84374
84375 log_packet_detailed("packet_server_setting_const_100: sending info about (%d)",
84376 real_packet->id);
84377
84378#ifdef FREECIV_DELTA_PROTOCOL
84379 packet_server_setting_const_100_fields fields;
84380 struct packet_server_setting_const *old;
84381 bool differ;
84382 int different = 0;
84383 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_CONST;
84384
84385 if (nullptr == *hash) {
84386 *hash = genhash_new_full(hash_packet_server_setting_const_100, cmp_packet_server_setting_const_100,
84387 nullptr, nullptr, nullptr, destroy_packet_server_setting_const);
84388 }
84389 BV_CLR_ALL(fields);
84390
84391 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
84392 old = fc_malloc(sizeof(*old));
84393 /* temporary bitcopy just to insert correctly */
84394 *old = *real_packet;
84395 genhash_insert(*hash, old, old);
84396 init_packet_server_setting_const(old);
84397 different = 1; /* Force to send. */
84398 }
84399
84400 differ = (strcmp(old->name, real_packet->name) != 0);
84401 if (differ) {
84402 different++;
84403 BV_SET(fields, 0);
84404 }
84405
84406 differ = (strcmp(old->short_help, real_packet->short_help) != 0);
84407 if (differ) {
84408 different++;
84409 BV_SET(fields, 1);
84410 }
84411
84412 differ = (strcmp(old->extra_help, real_packet->extra_help) != 0);
84413 if (differ) {
84414 different++;
84415 BV_SET(fields, 2);
84416 }
84417
84418 differ = (old->category != real_packet->category);
84419 if (differ) {
84420 different++;
84421 BV_SET(fields, 3);
84422 }
84423
84424 if (different == 0) {
84425 log_packet_detailed(" no change -> discard");
84426 SEND_PACKET_DISCARD();
84427 }
84428#endif /* FREECIV_DELTA_PROTOCOL */
84429
84430#ifdef FREECIV_JSON_CONNECTION
84431 struct plocation field_addr;
84432 {
84433 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
84434 field_addr = *field_addr_tmp;
84435 FC_FREE(field_addr_tmp);
84436 }
84437#endif /* FREECIV_JSON_CONNECTION */
84438
84439#ifdef FREECIV_JSON_CONNECTION
84440 field_addr.name = "id";
84441#endif /* FREECIV_JSON_CONNECTION */
84442 e = 0;
84443
84444 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
84445
84446 if (e) {
84447 log_packet_detailed("'id' field error detected");
84448 }
84449
84450#ifdef FREECIV_DELTA_PROTOCOL
84451#ifdef FREECIV_JSON_CONNECTION
84452 field_addr.name = "fields";
84453#endif /* FREECIV_JSON_CONNECTION */
84454 e = 0;
84455 e |= DIO_BV_PUT(&dout, &field_addr, fields);
84456 if (e) {
84457 log_packet_detailed("fields bitvector error detected");
84458 }
84459
84460 if (BV_ISSET(fields, 0)) {
84461 log_packet_detailed(" field 'name' has changed");
84462
84463#ifdef FREECIV_JSON_CONNECTION
84464 field_addr.name = "name";
84465#endif /* FREECIV_JSON_CONNECTION */
84466 e = 0;
84467
84468 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
84469
84470 if (e) {
84471 log_packet_detailed("'name' field error detected");
84472 }
84473 }
84474
84475 if (BV_ISSET(fields, 1)) {
84476 log_packet_detailed(" field 'short_help' has changed");
84477
84478#ifdef FREECIV_JSON_CONNECTION
84479 field_addr.name = "short_help";
84480#endif /* FREECIV_JSON_CONNECTION */
84481 e = 0;
84482
84483 e |= DIO_PUT(string, &dout, &field_addr, real_packet->short_help);
84484
84485 if (e) {
84486 log_packet_detailed("'short_help' field error detected");
84487 }
84488 }
84489
84490 if (BV_ISSET(fields, 2)) {
84491 log_packet_detailed(" field 'extra_help' has changed");
84492
84493#ifdef FREECIV_JSON_CONNECTION
84494 field_addr.name = "extra_help";
84495#endif /* FREECIV_JSON_CONNECTION */
84496 e = 0;
84497
84498 e |= DIO_PUT(string, &dout, &field_addr, real_packet->extra_help);
84499
84500 if (e) {
84501 log_packet_detailed("'extra_help' field error detected");
84502 }
84503 }
84504
84505 if (BV_ISSET(fields, 3)) {
84506 log_packet_detailed(" field 'category' has changed");
84507
84508#ifdef FREECIV_JSON_CONNECTION
84509 field_addr.name = "category";
84510#endif /* FREECIV_JSON_CONNECTION */
84511 e = 0;
84512
84513 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->category);
84514
84515 if (e) {
84516 log_packet_detailed("'category' field error detected");
84517 }
84518 }
84519
84520 *old = *real_packet;
84521
84522#else /* FREECIV_DELTA_PROTOCOL */
84523#ifdef FREECIV_JSON_CONNECTION
84524 field_addr.name = "name";
84525#endif /* FREECIV_JSON_CONNECTION */
84526 e = 0;
84527
84528 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
84529
84530 if (e) {
84531 log_packet_detailed("'name' field error detected");
84532 }
84533
84534#ifdef FREECIV_JSON_CONNECTION
84535 field_addr.name = "short_help";
84536#endif /* FREECIV_JSON_CONNECTION */
84537 e = 0;
84538
84539 e |= DIO_PUT(string, &dout, &field_addr, real_packet->short_help);
84540
84541 if (e) {
84542 log_packet_detailed("'short_help' field error detected");
84543 }
84544
84545#ifdef FREECIV_JSON_CONNECTION
84546 field_addr.name = "extra_help";
84547#endif /* FREECIV_JSON_CONNECTION */
84548 e = 0;
84549
84550 e |= DIO_PUT(string, &dout, &field_addr, real_packet->extra_help);
84551
84552 if (e) {
84553 log_packet_detailed("'extra_help' field error detected");
84554 }
84555
84556#ifdef FREECIV_JSON_CONNECTION
84557 field_addr.name = "category";
84558#endif /* FREECIV_JSON_CONNECTION */
84559 e = 0;
84560
84561 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->category);
84562
84563 if (e) {
84564 log_packet_detailed("'category' field error detected");
84565 }
84566#endif /* FREECIV_DELTA_PROTOCOL */
84567
84568 SEND_PACKET_END(PACKET_SERVER_SETTING_CONST);
84569}
84570
84571 int send_packet_server_setting_const(struct connection *pc, const struct packet_server_setting_const *packet)
84572{
84573 if (!pc->used) {
84574 log_error("WARNING: trying to send data to the closed connection %s",
84575 conn_description(pc));
84576 return -1;
84577 }
84578 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_CONST].packet != nullptr, -1,
84579 "Handler for PACKET_SERVER_SETTING_CONST not installed");
84580 return pc->phs.handlers->send[PACKET_SERVER_SETTING_CONST].packet(pc, packet);
84581}
84582
84583 static inline void init_packet_server_setting_bool(struct packet_server_setting_bool *packet)
84584{
84585 memset(packet, 0, sizeof(*packet));
84586}
84587
84588#define free_packet_server_setting_bool(_packet) (void) 0
84589#define destroy_packet_server_setting_bool free
84590
84591#ifdef FREECIV_DELTA_PROTOCOL
84592static genhash_val_t hash_packet_server_setting_bool_100(const void *vkey)
84593{
84594 const struct packet_server_setting_bool *key = (const struct packet_server_setting_bool *) vkey;
84595 genhash_val_t result = 0;
84596
84597 result += key->id;
84598
84599 result &= 0xFFFFFFFF;
84600 return result;
84601}
84602
84603static bool cmp_packet_server_setting_bool_100(const void *vkey1, const void *vkey2)
84604{
84605 const struct packet_server_setting_bool *old = (const struct packet_server_setting_bool *) vkey1;
84606 const struct packet_server_setting_bool *real_packet = (const struct packet_server_setting_bool *) vkey2;
84607 bool differ;
84608
84609 differ = (old->id != real_packet->id);
84610
84611 return !differ;
84612}
84613 BV_DEFINE(packet_server_setting_bool_100_fields, 6);
84614#endif /* FREECIV_DELTA_PROTOCOL */
84615
84616 static struct packet_server_setting_bool *receive_packet_server_setting_bool_100(struct connection *pc)
84617{
84618#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_bool(_packet)
84619 RECEIVE_PACKET_START(packet_server_setting_bool, real_packet);
84620
84621#ifdef FREECIV_JSON_CONNECTION
84622 struct plocation field_addr;
84623 {
84624 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
84625 field_addr = *field_addr_tmp;
84626 FC_FREE(field_addr_tmp);
84627 }
84628#endif /* FREECIV_JSON_CONNECTION */
84629
84630#ifdef FREECIV_JSON_CONNECTION
84631 field_addr.name = "id";
84632#endif /* FREECIV_JSON_CONNECTION */
84633
84634 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
84635 RECEIVE_PACKET_FIELD_ERROR(id);
84636 }
84637
84638 log_packet_detailed("packet_server_setting_bool_100: got info about (%d)",
84639 real_packet->id);
84640
84641#ifdef FREECIV_DELTA_PROTOCOL
84642 packet_server_setting_bool_100_fields fields;
84643 struct packet_server_setting_bool *old;
84644 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_BOOL;
84645
84646 if (nullptr == *hash) {
84647 *hash = genhash_new_full(hash_packet_server_setting_bool_100, cmp_packet_server_setting_bool_100,
84648 nullptr, nullptr, nullptr, destroy_packet_server_setting_bool);
84649 }
84650
84651 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
84652 *real_packet = *old;
84653 } else {
84654 /* packet is already initialized empty */
84655 log_packet_detailed(" no old info");
84656 }
84657
84658#ifdef FREECIV_JSON_CONNECTION
84659 field_addr.name = "fields";
84660#endif /* FREECIV_JSON_CONNECTION */
84661 DIO_BV_GET(&din, &field_addr, fields);
84662
84663 real_packet->is_visible = BV_ISSET(fields, 0);
84664
84665 real_packet->is_changeable = BV_ISSET(fields, 1);
84666
84667 real_packet->initial_setting = BV_ISSET(fields, 2);
84668
84669 if (BV_ISSET(fields, 3)) {
84670 log_packet_detailed(" got field 'setdef'");
84671
84672#ifdef FREECIV_JSON_CONNECTION
84673 field_addr.name = "setdef";
84674#endif /* FREECIV_JSON_CONNECTION */
84675
84676 {
84677 int readin;
84678
84679 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
84680 RECEIVE_PACKET_FIELD_ERROR(setdef);
84681 }
84682 real_packet->setdef = readin;
84683 }
84684 }
84685
84686 real_packet->val = BV_ISSET(fields, 4);
84687
84688 real_packet->default_val = BV_ISSET(fields, 5);
84689
84690 if (nullptr == old) {
84691 old = fc_malloc(sizeof(*old));
84692 init_packet_server_setting_bool(old);
84693 *old = *real_packet;
84694 genhash_insert(*hash, old, old);
84695 } else {
84696 *old = *real_packet;
84697 }
84698
84699#else /* FREECIV_DELTA_PROTOCOL */
84700#ifdef FREECIV_JSON_CONNECTION
84701 field_addr.name = "is_visible";
84702#endif /* FREECIV_JSON_CONNECTION */
84703
84704 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_visible)) {
84705 RECEIVE_PACKET_FIELD_ERROR(is_visible);
84706 }
84707
84708#ifdef FREECIV_JSON_CONNECTION
84709 field_addr.name = "is_changeable";
84710#endif /* FREECIV_JSON_CONNECTION */
84711
84712 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_changeable)) {
84713 RECEIVE_PACKET_FIELD_ERROR(is_changeable);
84714 }
84715
84716#ifdef FREECIV_JSON_CONNECTION
84717 field_addr.name = "initial_setting";
84718#endif /* FREECIV_JSON_CONNECTION */
84719
84720 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->initial_setting)) {
84721 RECEIVE_PACKET_FIELD_ERROR(initial_setting);
84722 }
84723
84724#ifdef FREECIV_JSON_CONNECTION
84725 field_addr.name = "setdef";
84726#endif /* FREECIV_JSON_CONNECTION */
84727
84728 {
84729 int readin;
84730
84731 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
84732 RECEIVE_PACKET_FIELD_ERROR(setdef);
84733 }
84734 real_packet->setdef = readin;
84735 }
84736
84737#ifdef FREECIV_JSON_CONNECTION
84738 field_addr.name = "val";
84739#endif /* FREECIV_JSON_CONNECTION */
84740
84741 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->val)) {
84742 RECEIVE_PACKET_FIELD_ERROR(val);
84743 }
84744
84745#ifdef FREECIV_JSON_CONNECTION
84746 field_addr.name = "default_val";
84747#endif /* FREECIV_JSON_CONNECTION */
84748
84749 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->default_val)) {
84750 RECEIVE_PACKET_FIELD_ERROR(default_val);
84751 }
84752#endif /* FREECIV_DELTA_PROTOCOL */
84753
84754 RECEIVE_PACKET_END(real_packet);
84755#undef FREE_PACKET_STRUCT
84756}
84757
84758 static int send_packet_server_setting_bool_100(struct connection *pc, const struct packet_server_setting_bool *packet)
84759{
84760 const struct packet_server_setting_bool *real_packet = packet;
84761 int e;
84762 SEND_PACKET_START(PACKET_SERVER_SETTING_BOOL);
84763
84764 log_packet_detailed("packet_server_setting_bool_100: sending info about (%d)",
84765 real_packet->id);
84766
84767#ifdef FREECIV_DELTA_PROTOCOL
84768 packet_server_setting_bool_100_fields fields;
84769 struct packet_server_setting_bool *old;
84770 bool differ;
84771 int different = 0;
84772 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_BOOL;
84773
84774 if (nullptr == *hash) {
84775 *hash = genhash_new_full(hash_packet_server_setting_bool_100, cmp_packet_server_setting_bool_100,
84776 nullptr, nullptr, nullptr, destroy_packet_server_setting_bool);
84777 }
84778 BV_CLR_ALL(fields);
84779
84780 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
84781 old = fc_malloc(sizeof(*old));
84782 /* temporary bitcopy just to insert correctly */
84783 *old = *real_packet;
84784 genhash_insert(*hash, old, old);
84785 init_packet_server_setting_bool(old);
84786 different = 1; /* Force to send. */
84787 }
84788
84789 differ = (old->is_visible != real_packet->is_visible);
84790 if (differ) {
84791 different++;
84792 }
84793 /* folded into head */
84794 if (real_packet->is_visible) {
84795 BV_SET(fields, 0);
84796 }
84797
84798 differ = (old->is_changeable != real_packet->is_changeable);
84799 if (differ) {
84800 different++;
84801 }
84802 /* folded into head */
84803 if (real_packet->is_changeable) {
84804 BV_SET(fields, 1);
84805 }
84806
84807 differ = (old->initial_setting != real_packet->initial_setting);
84808 if (differ) {
84809 different++;
84810 }
84811 /* folded into head */
84812 if (real_packet->initial_setting) {
84813 BV_SET(fields, 2);
84814 }
84815
84816 differ = (old->setdef != real_packet->setdef);
84817 if (differ) {
84818 different++;
84819 BV_SET(fields, 3);
84820 }
84821
84822 differ = (old->val != real_packet->val);
84823 if (differ) {
84824 different++;
84825 }
84826 /* folded into head */
84827 if (real_packet->val) {
84828 BV_SET(fields, 4);
84829 }
84830
84831 differ = (old->default_val != real_packet->default_val);
84832 if (differ) {
84833 different++;
84834 }
84835 /* folded into head */
84836 if (real_packet->default_val) {
84837 BV_SET(fields, 5);
84838 }
84839
84840 if (different == 0) {
84841 log_packet_detailed(" no change -> discard");
84842 SEND_PACKET_DISCARD();
84843 }
84844#endif /* FREECIV_DELTA_PROTOCOL */
84845
84846#ifdef FREECIV_JSON_CONNECTION
84847 struct plocation field_addr;
84848 {
84849 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
84850 field_addr = *field_addr_tmp;
84851 FC_FREE(field_addr_tmp);
84852 }
84853#endif /* FREECIV_JSON_CONNECTION */
84854
84855#ifdef FREECIV_JSON_CONNECTION
84856 field_addr.name = "id";
84857#endif /* FREECIV_JSON_CONNECTION */
84858 e = 0;
84859
84860 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
84861
84862 if (e) {
84863 log_packet_detailed("'id' field error detected");
84864 }
84865
84866#ifdef FREECIV_DELTA_PROTOCOL
84867#ifdef FREECIV_JSON_CONNECTION
84868 field_addr.name = "fields";
84869#endif /* FREECIV_JSON_CONNECTION */
84870 e = 0;
84871 e |= DIO_BV_PUT(&dout, &field_addr, fields);
84872 if (e) {
84873 log_packet_detailed("fields bitvector error detected");
84874 }
84875
84876 /* field 0 is folded into the header */
84877
84878 /* field 1 is folded into the header */
84879
84880 /* field 2 is folded into the header */
84881
84882 if (BV_ISSET(fields, 3)) {
84883 log_packet_detailed(" field 'setdef' has changed");
84884
84885#ifdef FREECIV_JSON_CONNECTION
84886 field_addr.name = "setdef";
84887#endif /* FREECIV_JSON_CONNECTION */
84888 e = 0;
84889
84890 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
84891
84892 if (e) {
84893 log_packet_detailed("'setdef' field error detected");
84894 }
84895 }
84896
84897 /* field 4 is folded into the header */
84898
84899 /* field 5 is folded into the header */
84900
84901 *old = *real_packet;
84902
84903#else /* FREECIV_DELTA_PROTOCOL */
84904#ifdef FREECIV_JSON_CONNECTION
84905 field_addr.name = "is_visible";
84906#endif /* FREECIV_JSON_CONNECTION */
84907 e = 0;
84908
84909 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_visible);
84910
84911 if (e) {
84912 log_packet_detailed("'is_visible' field error detected");
84913 }
84914
84915#ifdef FREECIV_JSON_CONNECTION
84916 field_addr.name = "is_changeable";
84917#endif /* FREECIV_JSON_CONNECTION */
84918 e = 0;
84919
84920 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_changeable);
84921
84922 if (e) {
84923 log_packet_detailed("'is_changeable' field error detected");
84924 }
84925
84926#ifdef FREECIV_JSON_CONNECTION
84927 field_addr.name = "initial_setting";
84928#endif /* FREECIV_JSON_CONNECTION */
84929 e = 0;
84930
84931 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->initial_setting);
84932
84933 if (e) {
84934 log_packet_detailed("'initial_setting' field error detected");
84935 }
84936
84937#ifdef FREECIV_JSON_CONNECTION
84938 field_addr.name = "setdef";
84939#endif /* FREECIV_JSON_CONNECTION */
84940 e = 0;
84941
84942 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
84943
84944 if (e) {
84945 log_packet_detailed("'setdef' field error detected");
84946 }
84947
84948#ifdef FREECIV_JSON_CONNECTION
84949 field_addr.name = "val";
84950#endif /* FREECIV_JSON_CONNECTION */
84951 e = 0;
84952
84953 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->val);
84954
84955 if (e) {
84956 log_packet_detailed("'val' field error detected");
84957 }
84958
84959#ifdef FREECIV_JSON_CONNECTION
84960 field_addr.name = "default_val";
84961#endif /* FREECIV_JSON_CONNECTION */
84962 e = 0;
84963
84964 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->default_val);
84965
84966 if (e) {
84967 log_packet_detailed("'default_val' field error detected");
84968 }
84969#endif /* FREECIV_DELTA_PROTOCOL */
84970
84971 SEND_PACKET_END(PACKET_SERVER_SETTING_BOOL);
84972}
84973
84974 int send_packet_server_setting_bool(struct connection *pc, const struct packet_server_setting_bool *packet)
84975{
84976 if (!pc->used) {
84977 log_error("WARNING: trying to send data to the closed connection %s",
84978 conn_description(pc));
84979 return -1;
84980 }
84981 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_BOOL].packet != nullptr, -1,
84982 "Handler for PACKET_SERVER_SETTING_BOOL not installed");
84983 return pc->phs.handlers->send[PACKET_SERVER_SETTING_BOOL].packet(pc, packet);
84984}
84985
84986 static inline void init_packet_server_setting_int(struct packet_server_setting_int *packet)
84987{
84988 memset(packet, 0, sizeof(*packet));
84989}
84990
84991#define free_packet_server_setting_int(_packet) (void) 0
84992#define destroy_packet_server_setting_int free
84993
84994#ifdef FREECIV_DELTA_PROTOCOL
84995static genhash_val_t hash_packet_server_setting_int_100(const void *vkey)
84996{
84997 const struct packet_server_setting_int *key = (const struct packet_server_setting_int *) vkey;
84998 genhash_val_t result = 0;
84999
85000 result += key->id;
85001
85002 result &= 0xFFFFFFFF;
85003 return result;
85004}
85005
85006static bool cmp_packet_server_setting_int_100(const void *vkey1, const void *vkey2)
85007{
85008 const struct packet_server_setting_int *old = (const struct packet_server_setting_int *) vkey1;
85009 const struct packet_server_setting_int *real_packet = (const struct packet_server_setting_int *) vkey2;
85010 bool differ;
85011
85012 differ = (old->id != real_packet->id);
85013
85014 return !differ;
85015}
85016 BV_DEFINE(packet_server_setting_int_100_fields, 8);
85017#endif /* FREECIV_DELTA_PROTOCOL */
85018
85019 static struct packet_server_setting_int *receive_packet_server_setting_int_100(struct connection *pc)
85020{
85021#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_int(_packet)
85022 RECEIVE_PACKET_START(packet_server_setting_int, real_packet);
85023
85024#ifdef FREECIV_JSON_CONNECTION
85025 struct plocation field_addr;
85026 {
85027 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
85028 field_addr = *field_addr_tmp;
85029 FC_FREE(field_addr_tmp);
85030 }
85031#endif /* FREECIV_JSON_CONNECTION */
85032
85033#ifdef FREECIV_JSON_CONNECTION
85034 field_addr.name = "id";
85035#endif /* FREECIV_JSON_CONNECTION */
85036
85037 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
85038 RECEIVE_PACKET_FIELD_ERROR(id);
85039 }
85040
85041 log_packet_detailed("packet_server_setting_int_100: got info about (%d)",
85042 real_packet->id);
85043
85044#ifdef FREECIV_DELTA_PROTOCOL
85045 packet_server_setting_int_100_fields fields;
85046 struct packet_server_setting_int *old;
85047 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_INT;
85048
85049 if (nullptr == *hash) {
85050 *hash = genhash_new_full(hash_packet_server_setting_int_100, cmp_packet_server_setting_int_100,
85051 nullptr, nullptr, nullptr, destroy_packet_server_setting_int);
85052 }
85053
85054 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
85055 *real_packet = *old;
85056 } else {
85057 /* packet is already initialized empty */
85058 log_packet_detailed(" no old info");
85059 }
85060
85061#ifdef FREECIV_JSON_CONNECTION
85062 field_addr.name = "fields";
85063#endif /* FREECIV_JSON_CONNECTION */
85064 DIO_BV_GET(&din, &field_addr, fields);
85065
85066 real_packet->is_visible = BV_ISSET(fields, 0);
85067
85068 real_packet->is_changeable = BV_ISSET(fields, 1);
85069
85070 real_packet->initial_setting = BV_ISSET(fields, 2);
85071
85072 if (BV_ISSET(fields, 3)) {
85073 log_packet_detailed(" got field 'setdef'");
85074
85075#ifdef FREECIV_JSON_CONNECTION
85076 field_addr.name = "setdef";
85077#endif /* FREECIV_JSON_CONNECTION */
85078
85079 {
85080 int readin;
85081
85082 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
85083 RECEIVE_PACKET_FIELD_ERROR(setdef);
85084 }
85085 real_packet->setdef = readin;
85086 }
85087 }
85088
85089 if (BV_ISSET(fields, 4)) {
85090 log_packet_detailed(" got field 'val'");
85091
85092#ifdef FREECIV_JSON_CONNECTION
85093 field_addr.name = "val";
85094#endif /* FREECIV_JSON_CONNECTION */
85095
85096 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->val)) {
85097 RECEIVE_PACKET_FIELD_ERROR(val);
85098 }
85099 }
85100
85101 if (BV_ISSET(fields, 5)) {
85102 log_packet_detailed(" got field 'default_val'");
85103
85104#ifdef FREECIV_JSON_CONNECTION
85105 field_addr.name = "default_val";
85106#endif /* FREECIV_JSON_CONNECTION */
85107
85108 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->default_val)) {
85109 RECEIVE_PACKET_FIELD_ERROR(default_val);
85110 }
85111 }
85112
85113 if (BV_ISSET(fields, 6)) {
85114 log_packet_detailed(" got field 'min_val'");
85115
85116#ifdef FREECIV_JSON_CONNECTION
85117 field_addr.name = "min_val";
85118#endif /* FREECIV_JSON_CONNECTION */
85119
85120 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->min_val)) {
85121 RECEIVE_PACKET_FIELD_ERROR(min_val);
85122 }
85123 }
85124
85125 if (BV_ISSET(fields, 7)) {
85126 log_packet_detailed(" got field 'max_val'");
85127
85128#ifdef FREECIV_JSON_CONNECTION
85129 field_addr.name = "max_val";
85130#endif /* FREECIV_JSON_CONNECTION */
85131
85132 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->max_val)) {
85133 RECEIVE_PACKET_FIELD_ERROR(max_val);
85134 }
85135 }
85136
85137 if (nullptr == old) {
85138 old = fc_malloc(sizeof(*old));
85139 init_packet_server_setting_int(old);
85140 *old = *real_packet;
85141 genhash_insert(*hash, old, old);
85142 } else {
85143 *old = *real_packet;
85144 }
85145
85146#else /* FREECIV_DELTA_PROTOCOL */
85147#ifdef FREECIV_JSON_CONNECTION
85148 field_addr.name = "is_visible";
85149#endif /* FREECIV_JSON_CONNECTION */
85150
85151 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_visible)) {
85152 RECEIVE_PACKET_FIELD_ERROR(is_visible);
85153 }
85154
85155#ifdef FREECIV_JSON_CONNECTION
85156 field_addr.name = "is_changeable";
85157#endif /* FREECIV_JSON_CONNECTION */
85158
85159 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_changeable)) {
85160 RECEIVE_PACKET_FIELD_ERROR(is_changeable);
85161 }
85162
85163#ifdef FREECIV_JSON_CONNECTION
85164 field_addr.name = "initial_setting";
85165#endif /* FREECIV_JSON_CONNECTION */
85166
85167 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->initial_setting)) {
85168 RECEIVE_PACKET_FIELD_ERROR(initial_setting);
85169 }
85170
85171#ifdef FREECIV_JSON_CONNECTION
85172 field_addr.name = "setdef";
85173#endif /* FREECIV_JSON_CONNECTION */
85174
85175 {
85176 int readin;
85177
85178 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
85179 RECEIVE_PACKET_FIELD_ERROR(setdef);
85180 }
85181 real_packet->setdef = readin;
85182 }
85183
85184#ifdef FREECIV_JSON_CONNECTION
85185 field_addr.name = "val";
85186#endif /* FREECIV_JSON_CONNECTION */
85187
85188 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->val)) {
85189 RECEIVE_PACKET_FIELD_ERROR(val);
85190 }
85191
85192#ifdef FREECIV_JSON_CONNECTION
85193 field_addr.name = "default_val";
85194#endif /* FREECIV_JSON_CONNECTION */
85195
85196 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->default_val)) {
85197 RECEIVE_PACKET_FIELD_ERROR(default_val);
85198 }
85199
85200#ifdef FREECIV_JSON_CONNECTION
85201 field_addr.name = "min_val";
85202#endif /* FREECIV_JSON_CONNECTION */
85203
85204 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->min_val)) {
85205 RECEIVE_PACKET_FIELD_ERROR(min_val);
85206 }
85207
85208#ifdef FREECIV_JSON_CONNECTION
85209 field_addr.name = "max_val";
85210#endif /* FREECIV_JSON_CONNECTION */
85211
85212 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->max_val)) {
85213 RECEIVE_PACKET_FIELD_ERROR(max_val);
85214 }
85215#endif /* FREECIV_DELTA_PROTOCOL */
85216
85217 RECEIVE_PACKET_END(real_packet);
85218#undef FREE_PACKET_STRUCT
85219}
85220
85221 static int send_packet_server_setting_int_100(struct connection *pc, const struct packet_server_setting_int *packet)
85222{
85223 const struct packet_server_setting_int *real_packet = packet;
85224 int e;
85225 SEND_PACKET_START(PACKET_SERVER_SETTING_INT);
85226
85227 log_packet_detailed("packet_server_setting_int_100: sending info about (%d)",
85228 real_packet->id);
85229
85230#ifdef FREECIV_DELTA_PROTOCOL
85231 packet_server_setting_int_100_fields fields;
85232 struct packet_server_setting_int *old;
85233 bool differ;
85234 int different = 0;
85235 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_INT;
85236
85237 if (nullptr == *hash) {
85238 *hash = genhash_new_full(hash_packet_server_setting_int_100, cmp_packet_server_setting_int_100,
85239 nullptr, nullptr, nullptr, destroy_packet_server_setting_int);
85240 }
85241 BV_CLR_ALL(fields);
85242
85243 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
85244 old = fc_malloc(sizeof(*old));
85245 /* temporary bitcopy just to insert correctly */
85246 *old = *real_packet;
85247 genhash_insert(*hash, old, old);
85248 init_packet_server_setting_int(old);
85249 different = 1; /* Force to send. */
85250 }
85251
85252 differ = (old->is_visible != real_packet->is_visible);
85253 if (differ) {
85254 different++;
85255 }
85256 /* folded into head */
85257 if (real_packet->is_visible) {
85258 BV_SET(fields, 0);
85259 }
85260
85261 differ = (old->is_changeable != real_packet->is_changeable);
85262 if (differ) {
85263 different++;
85264 }
85265 /* folded into head */
85266 if (real_packet->is_changeable) {
85267 BV_SET(fields, 1);
85268 }
85269
85270 differ = (old->initial_setting != real_packet->initial_setting);
85271 if (differ) {
85272 different++;
85273 }
85274 /* folded into head */
85275 if (real_packet->initial_setting) {
85276 BV_SET(fields, 2);
85277 }
85278
85279 differ = (old->setdef != real_packet->setdef);
85280 if (differ) {
85281 different++;
85282 BV_SET(fields, 3);
85283 }
85284
85285 differ = (old->val != real_packet->val);
85286 if (differ) {
85287 different++;
85288 BV_SET(fields, 4);
85289 }
85290
85291 differ = (old->default_val != real_packet->default_val);
85292 if (differ) {
85293 different++;
85294 BV_SET(fields, 5);
85295 }
85296
85297 differ = (old->min_val != real_packet->min_val);
85298 if (differ) {
85299 different++;
85300 BV_SET(fields, 6);
85301 }
85302
85303 differ = (old->max_val != real_packet->max_val);
85304 if (differ) {
85305 different++;
85306 BV_SET(fields, 7);
85307 }
85308
85309 if (different == 0) {
85310 log_packet_detailed(" no change -> discard");
85311 SEND_PACKET_DISCARD();
85312 }
85313#endif /* FREECIV_DELTA_PROTOCOL */
85314
85315#ifdef FREECIV_JSON_CONNECTION
85316 struct plocation field_addr;
85317 {
85318 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
85319 field_addr = *field_addr_tmp;
85320 FC_FREE(field_addr_tmp);
85321 }
85322#endif /* FREECIV_JSON_CONNECTION */
85323
85324#ifdef FREECIV_JSON_CONNECTION
85325 field_addr.name = "id";
85326#endif /* FREECIV_JSON_CONNECTION */
85327 e = 0;
85328
85329 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
85330
85331 if (e) {
85332 log_packet_detailed("'id' field error detected");
85333 }
85334
85335#ifdef FREECIV_DELTA_PROTOCOL
85336#ifdef FREECIV_JSON_CONNECTION
85337 field_addr.name = "fields";
85338#endif /* FREECIV_JSON_CONNECTION */
85339 e = 0;
85340 e |= DIO_BV_PUT(&dout, &field_addr, fields);
85341 if (e) {
85342 log_packet_detailed("fields bitvector error detected");
85343 }
85344
85345 /* field 0 is folded into the header */
85346
85347 /* field 1 is folded into the header */
85348
85349 /* field 2 is folded into the header */
85350
85351 if (BV_ISSET(fields, 3)) {
85352 log_packet_detailed(" field 'setdef' has changed");
85353
85354#ifdef FREECIV_JSON_CONNECTION
85355 field_addr.name = "setdef";
85356#endif /* FREECIV_JSON_CONNECTION */
85357 e = 0;
85358
85359 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
85360
85361 if (e) {
85362 log_packet_detailed("'setdef' field error detected");
85363 }
85364 }
85365
85366 if (BV_ISSET(fields, 4)) {
85367 log_packet_detailed(" field 'val' has changed");
85368
85369#ifdef FREECIV_JSON_CONNECTION
85370 field_addr.name = "val";
85371#endif /* FREECIV_JSON_CONNECTION */
85372 e = 0;
85373
85374 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->val);
85375
85376 if (e) {
85377 log_packet_detailed("'val' field error detected");
85378 }
85379 }
85380
85381 if (BV_ISSET(fields, 5)) {
85382 log_packet_detailed(" field 'default_val' has changed");
85383
85384#ifdef FREECIV_JSON_CONNECTION
85385 field_addr.name = "default_val";
85386#endif /* FREECIV_JSON_CONNECTION */
85387 e = 0;
85388
85389 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->default_val);
85390
85391 if (e) {
85392 log_packet_detailed("'default_val' field error detected");
85393 }
85394 }
85395
85396 if (BV_ISSET(fields, 6)) {
85397 log_packet_detailed(" field 'min_val' has changed");
85398
85399#ifdef FREECIV_JSON_CONNECTION
85400 field_addr.name = "min_val";
85401#endif /* FREECIV_JSON_CONNECTION */
85402 e = 0;
85403
85404 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->min_val);
85405
85406 if (e) {
85407 log_packet_detailed("'min_val' field error detected");
85408 }
85409 }
85410
85411 if (BV_ISSET(fields, 7)) {
85412 log_packet_detailed(" field 'max_val' has changed");
85413
85414#ifdef FREECIV_JSON_CONNECTION
85415 field_addr.name = "max_val";
85416#endif /* FREECIV_JSON_CONNECTION */
85417 e = 0;
85418
85419 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->max_val);
85420
85421 if (e) {
85422 log_packet_detailed("'max_val' field error detected");
85423 }
85424 }
85425
85426 *old = *real_packet;
85427
85428#else /* FREECIV_DELTA_PROTOCOL */
85429#ifdef FREECIV_JSON_CONNECTION
85430 field_addr.name = "is_visible";
85431#endif /* FREECIV_JSON_CONNECTION */
85432 e = 0;
85433
85434 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_visible);
85435
85436 if (e) {
85437 log_packet_detailed("'is_visible' field error detected");
85438 }
85439
85440#ifdef FREECIV_JSON_CONNECTION
85441 field_addr.name = "is_changeable";
85442#endif /* FREECIV_JSON_CONNECTION */
85443 e = 0;
85444
85445 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_changeable);
85446
85447 if (e) {
85448 log_packet_detailed("'is_changeable' field error detected");
85449 }
85450
85451#ifdef FREECIV_JSON_CONNECTION
85452 field_addr.name = "initial_setting";
85453#endif /* FREECIV_JSON_CONNECTION */
85454 e = 0;
85455
85456 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->initial_setting);
85457
85458 if (e) {
85459 log_packet_detailed("'initial_setting' field error detected");
85460 }
85461
85462#ifdef FREECIV_JSON_CONNECTION
85463 field_addr.name = "setdef";
85464#endif /* FREECIV_JSON_CONNECTION */
85465 e = 0;
85466
85467 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
85468
85469 if (e) {
85470 log_packet_detailed("'setdef' field error detected");
85471 }
85472
85473#ifdef FREECIV_JSON_CONNECTION
85474 field_addr.name = "val";
85475#endif /* FREECIV_JSON_CONNECTION */
85476 e = 0;
85477
85478 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->val);
85479
85480 if (e) {
85481 log_packet_detailed("'val' field error detected");
85482 }
85483
85484#ifdef FREECIV_JSON_CONNECTION
85485 field_addr.name = "default_val";
85486#endif /* FREECIV_JSON_CONNECTION */
85487 e = 0;
85488
85489 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->default_val);
85490
85491 if (e) {
85492 log_packet_detailed("'default_val' field error detected");
85493 }
85494
85495#ifdef FREECIV_JSON_CONNECTION
85496 field_addr.name = "min_val";
85497#endif /* FREECIV_JSON_CONNECTION */
85498 e = 0;
85499
85500 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->min_val);
85501
85502 if (e) {
85503 log_packet_detailed("'min_val' field error detected");
85504 }
85505
85506#ifdef FREECIV_JSON_CONNECTION
85507 field_addr.name = "max_val";
85508#endif /* FREECIV_JSON_CONNECTION */
85509 e = 0;
85510
85511 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->max_val);
85512
85513 if (e) {
85514 log_packet_detailed("'max_val' field error detected");
85515 }
85516#endif /* FREECIV_DELTA_PROTOCOL */
85517
85518 SEND_PACKET_END(PACKET_SERVER_SETTING_INT);
85519}
85520
85521 int send_packet_server_setting_int(struct connection *pc, const struct packet_server_setting_int *packet)
85522{
85523 if (!pc->used) {
85524 log_error("WARNING: trying to send data to the closed connection %s",
85525 conn_description(pc));
85526 return -1;
85527 }
85528 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_INT].packet != nullptr, -1,
85529 "Handler for PACKET_SERVER_SETTING_INT not installed");
85530 return pc->phs.handlers->send[PACKET_SERVER_SETTING_INT].packet(pc, packet);
85531}
85532
85533 static inline void init_packet_server_setting_str(struct packet_server_setting_str *packet)
85534{
85535 memset(packet, 0, sizeof(*packet));
85536}
85537
85538#define free_packet_server_setting_str(_packet) (void) 0
85539#define destroy_packet_server_setting_str free
85540
85541#ifdef FREECIV_DELTA_PROTOCOL
85542static genhash_val_t hash_packet_server_setting_str_100(const void *vkey)
85543{
85544 const struct packet_server_setting_str *key = (const struct packet_server_setting_str *) vkey;
85545 genhash_val_t result = 0;
85546
85547 result += key->id;
85548
85549 result &= 0xFFFFFFFF;
85550 return result;
85551}
85552
85553static bool cmp_packet_server_setting_str_100(const void *vkey1, const void *vkey2)
85554{
85555 const struct packet_server_setting_str *old = (const struct packet_server_setting_str *) vkey1;
85556 const struct packet_server_setting_str *real_packet = (const struct packet_server_setting_str *) vkey2;
85557 bool differ;
85558
85559 differ = (old->id != real_packet->id);
85560
85561 return !differ;
85562}
85563 BV_DEFINE(packet_server_setting_str_100_fields, 6);
85564#endif /* FREECIV_DELTA_PROTOCOL */
85565
85566 static struct packet_server_setting_str *receive_packet_server_setting_str_100(struct connection *pc)
85567{
85568#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_str(_packet)
85569 RECEIVE_PACKET_START(packet_server_setting_str, real_packet);
85570
85571#ifdef FREECIV_JSON_CONNECTION
85572 struct plocation field_addr;
85573 {
85574 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
85575 field_addr = *field_addr_tmp;
85576 FC_FREE(field_addr_tmp);
85577 }
85578#endif /* FREECIV_JSON_CONNECTION */
85579
85580#ifdef FREECIV_JSON_CONNECTION
85581 field_addr.name = "id";
85582#endif /* FREECIV_JSON_CONNECTION */
85583
85584 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
85585 RECEIVE_PACKET_FIELD_ERROR(id);
85586 }
85587
85588 log_packet_detailed("packet_server_setting_str_100: got info about (%d)",
85589 real_packet->id);
85590
85591#ifdef FREECIV_DELTA_PROTOCOL
85592 packet_server_setting_str_100_fields fields;
85593 struct packet_server_setting_str *old;
85594 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_STR;
85595
85596 if (nullptr == *hash) {
85597 *hash = genhash_new_full(hash_packet_server_setting_str_100, cmp_packet_server_setting_str_100,
85598 nullptr, nullptr, nullptr, destroy_packet_server_setting_str);
85599 }
85600
85601 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
85602 *real_packet = *old;
85603 } else {
85604 /* packet is already initialized empty */
85605 log_packet_detailed(" no old info");
85606 }
85607
85608#ifdef FREECIV_JSON_CONNECTION
85609 field_addr.name = "fields";
85610#endif /* FREECIV_JSON_CONNECTION */
85611 DIO_BV_GET(&din, &field_addr, fields);
85612
85613 real_packet->is_visible = BV_ISSET(fields, 0);
85614
85615 real_packet->is_changeable = BV_ISSET(fields, 1);
85616
85617 real_packet->initial_setting = BV_ISSET(fields, 2);
85618
85619 if (BV_ISSET(fields, 3)) {
85620 log_packet_detailed(" got field 'setdef'");
85621
85622#ifdef FREECIV_JSON_CONNECTION
85623 field_addr.name = "setdef";
85624#endif /* FREECIV_JSON_CONNECTION */
85625
85626 {
85627 int readin;
85628
85629 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
85630 RECEIVE_PACKET_FIELD_ERROR(setdef);
85631 }
85632 real_packet->setdef = readin;
85633 }
85634 }
85635
85636 if (BV_ISSET(fields, 4)) {
85637 log_packet_detailed(" got field 'val'");
85638
85639#ifdef FREECIV_JSON_CONNECTION
85640 field_addr.name = "val";
85641#endif /* FREECIV_JSON_CONNECTION */
85642
85643 if (!DIO_GET(string, &din, &field_addr, real_packet->val, sizeof(real_packet->val))) {
85644 RECEIVE_PACKET_FIELD_ERROR(val);
85645 }
85646 }
85647
85648 if (BV_ISSET(fields, 5)) {
85649 log_packet_detailed(" got field 'default_val'");
85650
85651#ifdef FREECIV_JSON_CONNECTION
85652 field_addr.name = "default_val";
85653#endif /* FREECIV_JSON_CONNECTION */
85654
85655 if (!DIO_GET(string, &din, &field_addr, real_packet->default_val, sizeof(real_packet->default_val))) {
85656 RECEIVE_PACKET_FIELD_ERROR(default_val);
85657 }
85658 }
85659
85660 if (nullptr == old) {
85661 old = fc_malloc(sizeof(*old));
85662 init_packet_server_setting_str(old);
85663 *old = *real_packet;
85664 genhash_insert(*hash, old, old);
85665 } else {
85666 *old = *real_packet;
85667 }
85668
85669#else /* FREECIV_DELTA_PROTOCOL */
85670#ifdef FREECIV_JSON_CONNECTION
85671 field_addr.name = "is_visible";
85672#endif /* FREECIV_JSON_CONNECTION */
85673
85674 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_visible)) {
85675 RECEIVE_PACKET_FIELD_ERROR(is_visible);
85676 }
85677
85678#ifdef FREECIV_JSON_CONNECTION
85679 field_addr.name = "is_changeable";
85680#endif /* FREECIV_JSON_CONNECTION */
85681
85682 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_changeable)) {
85683 RECEIVE_PACKET_FIELD_ERROR(is_changeable);
85684 }
85685
85686#ifdef FREECIV_JSON_CONNECTION
85687 field_addr.name = "initial_setting";
85688#endif /* FREECIV_JSON_CONNECTION */
85689
85690 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->initial_setting)) {
85691 RECEIVE_PACKET_FIELD_ERROR(initial_setting);
85692 }
85693
85694#ifdef FREECIV_JSON_CONNECTION
85695 field_addr.name = "setdef";
85696#endif /* FREECIV_JSON_CONNECTION */
85697
85698 {
85699 int readin;
85700
85701 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
85702 RECEIVE_PACKET_FIELD_ERROR(setdef);
85703 }
85704 real_packet->setdef = readin;
85705 }
85706
85707#ifdef FREECIV_JSON_CONNECTION
85708 field_addr.name = "val";
85709#endif /* FREECIV_JSON_CONNECTION */
85710
85711 if (!DIO_GET(string, &din, &field_addr, real_packet->val, sizeof(real_packet->val))) {
85712 RECEIVE_PACKET_FIELD_ERROR(val);
85713 }
85714
85715#ifdef FREECIV_JSON_CONNECTION
85716 field_addr.name = "default_val";
85717#endif /* FREECIV_JSON_CONNECTION */
85718
85719 if (!DIO_GET(string, &din, &field_addr, real_packet->default_val, sizeof(real_packet->default_val))) {
85720 RECEIVE_PACKET_FIELD_ERROR(default_val);
85721 }
85722#endif /* FREECIV_DELTA_PROTOCOL */
85723
85724 RECEIVE_PACKET_END(real_packet);
85725#undef FREE_PACKET_STRUCT
85726}
85727
85728 static int send_packet_server_setting_str_100(struct connection *pc, const struct packet_server_setting_str *packet)
85729{
85730 const struct packet_server_setting_str *real_packet = packet;
85731 int e;
85732 SEND_PACKET_START(PACKET_SERVER_SETTING_STR);
85733
85734 log_packet_detailed("packet_server_setting_str_100: sending info about (%d)",
85735 real_packet->id);
85736
85737#ifdef FREECIV_DELTA_PROTOCOL
85738 packet_server_setting_str_100_fields fields;
85739 struct packet_server_setting_str *old;
85740 bool differ;
85741 int different = 0;
85742 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_STR;
85743
85744 if (nullptr == *hash) {
85745 *hash = genhash_new_full(hash_packet_server_setting_str_100, cmp_packet_server_setting_str_100,
85746 nullptr, nullptr, nullptr, destroy_packet_server_setting_str);
85747 }
85748 BV_CLR_ALL(fields);
85749
85750 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
85751 old = fc_malloc(sizeof(*old));
85752 /* temporary bitcopy just to insert correctly */
85753 *old = *real_packet;
85754 genhash_insert(*hash, old, old);
85755 init_packet_server_setting_str(old);
85756 different = 1; /* Force to send. */
85757 }
85758
85759 differ = (old->is_visible != real_packet->is_visible);
85760 if (differ) {
85761 different++;
85762 }
85763 /* folded into head */
85764 if (real_packet->is_visible) {
85765 BV_SET(fields, 0);
85766 }
85767
85768 differ = (old->is_changeable != real_packet->is_changeable);
85769 if (differ) {
85770 different++;
85771 }
85772 /* folded into head */
85773 if (real_packet->is_changeable) {
85774 BV_SET(fields, 1);
85775 }
85776
85777 differ = (old->initial_setting != real_packet->initial_setting);
85778 if (differ) {
85779 different++;
85780 }
85781 /* folded into head */
85782 if (real_packet->initial_setting) {
85783 BV_SET(fields, 2);
85784 }
85785
85786 differ = (old->setdef != real_packet->setdef);
85787 if (differ) {
85788 different++;
85789 BV_SET(fields, 3);
85790 }
85791
85792 differ = (strcmp(old->val, real_packet->val) != 0);
85793 if (differ) {
85794 different++;
85795 BV_SET(fields, 4);
85796 }
85797
85798 differ = (strcmp(old->default_val, real_packet->default_val) != 0);
85799 if (differ) {
85800 different++;
85801 BV_SET(fields, 5);
85802 }
85803
85804 if (different == 0) {
85805 log_packet_detailed(" no change -> discard");
85806 SEND_PACKET_DISCARD();
85807 }
85808#endif /* FREECIV_DELTA_PROTOCOL */
85809
85810#ifdef FREECIV_JSON_CONNECTION
85811 struct plocation field_addr;
85812 {
85813 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
85814 field_addr = *field_addr_tmp;
85815 FC_FREE(field_addr_tmp);
85816 }
85817#endif /* FREECIV_JSON_CONNECTION */
85818
85819#ifdef FREECIV_JSON_CONNECTION
85820 field_addr.name = "id";
85821#endif /* FREECIV_JSON_CONNECTION */
85822 e = 0;
85823
85824 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
85825
85826 if (e) {
85827 log_packet_detailed("'id' field error detected");
85828 }
85829
85830#ifdef FREECIV_DELTA_PROTOCOL
85831#ifdef FREECIV_JSON_CONNECTION
85832 field_addr.name = "fields";
85833#endif /* FREECIV_JSON_CONNECTION */
85834 e = 0;
85835 e |= DIO_BV_PUT(&dout, &field_addr, fields);
85836 if (e) {
85837 log_packet_detailed("fields bitvector error detected");
85838 }
85839
85840 /* field 0 is folded into the header */
85841
85842 /* field 1 is folded into the header */
85843
85844 /* field 2 is folded into the header */
85845
85846 if (BV_ISSET(fields, 3)) {
85847 log_packet_detailed(" field 'setdef' has changed");
85848
85849#ifdef FREECIV_JSON_CONNECTION
85850 field_addr.name = "setdef";
85851#endif /* FREECIV_JSON_CONNECTION */
85852 e = 0;
85853
85854 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
85855
85856 if (e) {
85857 log_packet_detailed("'setdef' field error detected");
85858 }
85859 }
85860
85861 if (BV_ISSET(fields, 4)) {
85862 log_packet_detailed(" field 'val' has changed");
85863
85864#ifdef FREECIV_JSON_CONNECTION
85865 field_addr.name = "val";
85866#endif /* FREECIV_JSON_CONNECTION */
85867 e = 0;
85868
85869 e |= DIO_PUT(string, &dout, &field_addr, real_packet->val);
85870
85871 if (e) {
85872 log_packet_detailed("'val' field error detected");
85873 }
85874 }
85875
85876 if (BV_ISSET(fields, 5)) {
85877 log_packet_detailed(" field 'default_val' has changed");
85878
85879#ifdef FREECIV_JSON_CONNECTION
85880 field_addr.name = "default_val";
85881#endif /* FREECIV_JSON_CONNECTION */
85882 e = 0;
85883
85884 e |= DIO_PUT(string, &dout, &field_addr, real_packet->default_val);
85885
85886 if (e) {
85887 log_packet_detailed("'default_val' field error detected");
85888 }
85889 }
85890
85891 *old = *real_packet;
85892
85893#else /* FREECIV_DELTA_PROTOCOL */
85894#ifdef FREECIV_JSON_CONNECTION
85895 field_addr.name = "is_visible";
85896#endif /* FREECIV_JSON_CONNECTION */
85897 e = 0;
85898
85899 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_visible);
85900
85901 if (e) {
85902 log_packet_detailed("'is_visible' field error detected");
85903 }
85904
85905#ifdef FREECIV_JSON_CONNECTION
85906 field_addr.name = "is_changeable";
85907#endif /* FREECIV_JSON_CONNECTION */
85908 e = 0;
85909
85910 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_changeable);
85911
85912 if (e) {
85913 log_packet_detailed("'is_changeable' field error detected");
85914 }
85915
85916#ifdef FREECIV_JSON_CONNECTION
85917 field_addr.name = "initial_setting";
85918#endif /* FREECIV_JSON_CONNECTION */
85919 e = 0;
85920
85921 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->initial_setting);
85922
85923 if (e) {
85924 log_packet_detailed("'initial_setting' field error detected");
85925 }
85926
85927#ifdef FREECIV_JSON_CONNECTION
85928 field_addr.name = "setdef";
85929#endif /* FREECIV_JSON_CONNECTION */
85930 e = 0;
85931
85932 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
85933
85934 if (e) {
85935 log_packet_detailed("'setdef' field error detected");
85936 }
85937
85938#ifdef FREECIV_JSON_CONNECTION
85939 field_addr.name = "val";
85940#endif /* FREECIV_JSON_CONNECTION */
85941 e = 0;
85942
85943 e |= DIO_PUT(string, &dout, &field_addr, real_packet->val);
85944
85945 if (e) {
85946 log_packet_detailed("'val' field error detected");
85947 }
85948
85949#ifdef FREECIV_JSON_CONNECTION
85950 field_addr.name = "default_val";
85951#endif /* FREECIV_JSON_CONNECTION */
85952 e = 0;
85953
85954 e |= DIO_PUT(string, &dout, &field_addr, real_packet->default_val);
85955
85956 if (e) {
85957 log_packet_detailed("'default_val' field error detected");
85958 }
85959#endif /* FREECIV_DELTA_PROTOCOL */
85960
85961 SEND_PACKET_END(PACKET_SERVER_SETTING_STR);
85962}
85963
85964 int send_packet_server_setting_str(struct connection *pc, const struct packet_server_setting_str *packet)
85965{
85966 if (!pc->used) {
85967 log_error("WARNING: trying to send data to the closed connection %s",
85968 conn_description(pc));
85969 return -1;
85970 }
85971 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_STR].packet != nullptr, -1,
85972 "Handler for PACKET_SERVER_SETTING_STR not installed");
85973 return pc->phs.handlers->send[PACKET_SERVER_SETTING_STR].packet(pc, packet);
85974}
85975
85976 static inline void init_packet_server_setting_enum(struct packet_server_setting_enum *packet)
85977{
85978 memset(packet, 0, sizeof(*packet));
85979}
85980
85981#define free_packet_server_setting_enum(_packet) (void) 0
85982#define destroy_packet_server_setting_enum free
85983
85984#ifdef FREECIV_DELTA_PROTOCOL
85985static genhash_val_t hash_packet_server_setting_enum_100(const void *vkey)
85986{
85987 const struct packet_server_setting_enum *key = (const struct packet_server_setting_enum *) vkey;
85988 genhash_val_t result = 0;
85989
85990 result += key->id;
85991
85992 result &= 0xFFFFFFFF;
85993 return result;
85994}
85995
85996static bool cmp_packet_server_setting_enum_100(const void *vkey1, const void *vkey2)
85997{
85998 const struct packet_server_setting_enum *old = (const struct packet_server_setting_enum *) vkey1;
85999 const struct packet_server_setting_enum *real_packet = (const struct packet_server_setting_enum *) vkey2;
86000 bool differ;
86001
86002 differ = (old->id != real_packet->id);
86003
86004 return !differ;
86005}
86006 BV_DEFINE(packet_server_setting_enum_100_fields, 9);
86007#endif /* FREECIV_DELTA_PROTOCOL */
86008
86009 static struct packet_server_setting_enum *receive_packet_server_setting_enum_100(struct connection *pc)
86010{
86011#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_enum(_packet)
86012 RECEIVE_PACKET_START(packet_server_setting_enum, real_packet);
86013
86014#ifdef FREECIV_JSON_CONNECTION
86015 struct plocation field_addr;
86016 {
86017 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
86018 field_addr = *field_addr_tmp;
86019 FC_FREE(field_addr_tmp);
86020 }
86021#endif /* FREECIV_JSON_CONNECTION */
86022
86023#ifdef FREECIV_JSON_CONNECTION
86024 field_addr.name = "id";
86025#endif /* FREECIV_JSON_CONNECTION */
86026
86027 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
86028 RECEIVE_PACKET_FIELD_ERROR(id);
86029 }
86030
86031 log_packet_detailed("packet_server_setting_enum_100: got info about (%d)",
86032 real_packet->id);
86033
86034#ifdef FREECIV_DELTA_PROTOCOL
86035 packet_server_setting_enum_100_fields fields;
86036 struct packet_server_setting_enum *old;
86037 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_ENUM;
86038
86039 if (nullptr == *hash) {
86040 *hash = genhash_new_full(hash_packet_server_setting_enum_100, cmp_packet_server_setting_enum_100,
86041 nullptr, nullptr, nullptr, destroy_packet_server_setting_enum);
86042 }
86043
86044 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
86045 *real_packet = *old;
86046 } else {
86047 /* packet is already initialized empty */
86048 log_packet_detailed(" no old info");
86049 }
86050
86051#ifdef FREECIV_JSON_CONNECTION
86052 field_addr.name = "fields";
86053#endif /* FREECIV_JSON_CONNECTION */
86054 DIO_BV_GET(&din, &field_addr, fields);
86055
86056 real_packet->is_visible = BV_ISSET(fields, 0);
86057
86058 real_packet->is_changeable = BV_ISSET(fields, 1);
86059
86060 real_packet->initial_setting = BV_ISSET(fields, 2);
86061
86062 if (BV_ISSET(fields, 3)) {
86063 log_packet_detailed(" got field 'setdef'");
86064
86065#ifdef FREECIV_JSON_CONNECTION
86066 field_addr.name = "setdef";
86067#endif /* FREECIV_JSON_CONNECTION */
86068
86069 {
86070 int readin;
86071
86072 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
86073 RECEIVE_PACKET_FIELD_ERROR(setdef);
86074 }
86075 real_packet->setdef = readin;
86076 }
86077 }
86078
86079 if (BV_ISSET(fields, 4)) {
86080 log_packet_detailed(" got field 'val'");
86081
86082#ifdef FREECIV_JSON_CONNECTION
86083 field_addr.name = "val";
86084#endif /* FREECIV_JSON_CONNECTION */
86085
86086 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->val)) {
86087 RECEIVE_PACKET_FIELD_ERROR(val);
86088 }
86089 }
86090
86091 if (BV_ISSET(fields, 5)) {
86092 log_packet_detailed(" got field 'default_val'");
86093
86094#ifdef FREECIV_JSON_CONNECTION
86095 field_addr.name = "default_val";
86096#endif /* FREECIV_JSON_CONNECTION */
86097
86098 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->default_val)) {
86099 RECEIVE_PACKET_FIELD_ERROR(default_val);
86100 }
86101 }
86102
86103 if (BV_ISSET(fields, 6)) {
86104 log_packet_detailed(" got field 'values_num'");
86105
86106#ifdef FREECIV_JSON_CONNECTION
86107 field_addr.name = "values_num";
86108#endif /* FREECIV_JSON_CONNECTION */
86109
86110 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->values_num)) {
86111 RECEIVE_PACKET_FIELD_ERROR(values_num);
86112 }
86113 }
86114
86115 if (BV_ISSET(fields, 7)) {
86116 log_packet_detailed(" got field 'support_names'");
86117
86118#ifdef FREECIV_JSON_CONNECTION
86119 field_addr.name = "support_names";
86120#endif /* FREECIV_JSON_CONNECTION */
86121
86122 {
86123 int i;
86124
86125 if (real_packet->values_num > 64) {
86126 RECEIVE_PACKET_FIELD_ERROR(support_names, ": array truncated");
86127 }
86128
86129#ifdef FREECIV_JSON_CONNECTION
86130 /* Enter array. */
86131 field_addr.sub_location = plocation_elem_new(0);
86132#endif /* FREECIV_JSON_CONNECTION */
86133
86134 for (i = 0; i < real_packet->values_num; i++) {
86135#ifdef FREECIV_JSON_CONNECTION
86136 /* Next array element */
86137 field_addr.sub_location->number = i;
86138#endif /* FREECIV_JSON_CONNECTION */
86139
86140 if (!DIO_GET(string, &din, &field_addr, real_packet->support_names[i], sizeof(real_packet->support_names[i]))) {
86141 RECEIVE_PACKET_FIELD_ERROR(support_names);
86142 }
86143 }
86144
86145#ifdef FREECIV_JSON_CONNECTION
86146 /* Exit array. */
86147 FC_FREE(field_addr.sub_location);
86148#endif /* FREECIV_JSON_CONNECTION */
86149 }
86150 }
86151
86152 if (BV_ISSET(fields, 8)) {
86153 log_packet_detailed(" got field 'pretty_names'");
86154
86155#ifdef FREECIV_JSON_CONNECTION
86156 field_addr.name = "pretty_names";
86157#endif /* FREECIV_JSON_CONNECTION */
86158
86159 {
86160 int i;
86161
86162 if (real_packet->values_num > 64) {
86163 RECEIVE_PACKET_FIELD_ERROR(pretty_names, ": array truncated");
86164 }
86165
86166#ifdef FREECIV_JSON_CONNECTION
86167 /* Enter array. */
86168 field_addr.sub_location = plocation_elem_new(0);
86169#endif /* FREECIV_JSON_CONNECTION */
86170
86171 for (i = 0; i < real_packet->values_num; i++) {
86172#ifdef FREECIV_JSON_CONNECTION
86173 /* Next array element */
86174 field_addr.sub_location->number = i;
86175#endif /* FREECIV_JSON_CONNECTION */
86176
86177 if (!DIO_GET(string, &din, &field_addr, real_packet->pretty_names[i], sizeof(real_packet->pretty_names[i]))) {
86178 RECEIVE_PACKET_FIELD_ERROR(pretty_names);
86179 }
86180 }
86181
86182#ifdef FREECIV_JSON_CONNECTION
86183 /* Exit array. */
86184 FC_FREE(field_addr.sub_location);
86185#endif /* FREECIV_JSON_CONNECTION */
86186 }
86187 }
86188
86189 if (nullptr == old) {
86190 old = fc_malloc(sizeof(*old));
86191 init_packet_server_setting_enum(old);
86192 *old = *real_packet;
86193 genhash_insert(*hash, old, old);
86194 } else {
86195 *old = *real_packet;
86196 }
86197
86198#else /* FREECIV_DELTA_PROTOCOL */
86199#ifdef FREECIV_JSON_CONNECTION
86200 field_addr.name = "is_visible";
86201#endif /* FREECIV_JSON_CONNECTION */
86202
86203 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_visible)) {
86204 RECEIVE_PACKET_FIELD_ERROR(is_visible);
86205 }
86206
86207#ifdef FREECIV_JSON_CONNECTION
86208 field_addr.name = "is_changeable";
86209#endif /* FREECIV_JSON_CONNECTION */
86210
86211 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_changeable)) {
86212 RECEIVE_PACKET_FIELD_ERROR(is_changeable);
86213 }
86214
86215#ifdef FREECIV_JSON_CONNECTION
86216 field_addr.name = "initial_setting";
86217#endif /* FREECIV_JSON_CONNECTION */
86218
86219 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->initial_setting)) {
86220 RECEIVE_PACKET_FIELD_ERROR(initial_setting);
86221 }
86222
86223#ifdef FREECIV_JSON_CONNECTION
86224 field_addr.name = "setdef";
86225#endif /* FREECIV_JSON_CONNECTION */
86226
86227 {
86228 int readin;
86229
86230 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
86231 RECEIVE_PACKET_FIELD_ERROR(setdef);
86232 }
86233 real_packet->setdef = readin;
86234 }
86235
86236#ifdef FREECIV_JSON_CONNECTION
86237 field_addr.name = "val";
86238#endif /* FREECIV_JSON_CONNECTION */
86239
86240 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->val)) {
86241 RECEIVE_PACKET_FIELD_ERROR(val);
86242 }
86243
86244#ifdef FREECIV_JSON_CONNECTION
86245 field_addr.name = "default_val";
86246#endif /* FREECIV_JSON_CONNECTION */
86247
86248 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->default_val)) {
86249 RECEIVE_PACKET_FIELD_ERROR(default_val);
86250 }
86251
86252#ifdef FREECIV_JSON_CONNECTION
86253 field_addr.name = "values_num";
86254#endif /* FREECIV_JSON_CONNECTION */
86255
86256 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->values_num)) {
86257 RECEIVE_PACKET_FIELD_ERROR(values_num);
86258 }
86259
86260#ifdef FREECIV_JSON_CONNECTION
86261 field_addr.name = "support_names";
86262#endif /* FREECIV_JSON_CONNECTION */
86263
86264 {
86265 int i;
86266
86267 if (real_packet->values_num > 64) {
86268 RECEIVE_PACKET_FIELD_ERROR(support_names, ": array truncated");
86269 }
86270
86271#ifdef FREECIV_JSON_CONNECTION
86272 /* Enter array. */
86273 field_addr.sub_location = plocation_elem_new(0);
86274#endif /* FREECIV_JSON_CONNECTION */
86275
86276 for (i = 0; i < real_packet->values_num; i++) {
86277#ifdef FREECIV_JSON_CONNECTION
86278 /* Next array element */
86279 field_addr.sub_location->number = i;
86280#endif /* FREECIV_JSON_CONNECTION */
86281
86282 if (!DIO_GET(string, &din, &field_addr, real_packet->support_names[i], sizeof(real_packet->support_names[i]))) {
86283 RECEIVE_PACKET_FIELD_ERROR(support_names);
86284 }
86285 }
86286
86287#ifdef FREECIV_JSON_CONNECTION
86288 /* Exit array. */
86289 FC_FREE(field_addr.sub_location);
86290#endif /* FREECIV_JSON_CONNECTION */
86291 }
86292
86293#ifdef FREECIV_JSON_CONNECTION
86294 field_addr.name = "pretty_names";
86295#endif /* FREECIV_JSON_CONNECTION */
86296
86297 {
86298 int i;
86299
86300 if (real_packet->values_num > 64) {
86301 RECEIVE_PACKET_FIELD_ERROR(pretty_names, ": array truncated");
86302 }
86303
86304#ifdef FREECIV_JSON_CONNECTION
86305 /* Enter array. */
86306 field_addr.sub_location = plocation_elem_new(0);
86307#endif /* FREECIV_JSON_CONNECTION */
86308
86309 for (i = 0; i < real_packet->values_num; i++) {
86310#ifdef FREECIV_JSON_CONNECTION
86311 /* Next array element */
86312 field_addr.sub_location->number = i;
86313#endif /* FREECIV_JSON_CONNECTION */
86314
86315 if (!DIO_GET(string, &din, &field_addr, real_packet->pretty_names[i], sizeof(real_packet->pretty_names[i]))) {
86316 RECEIVE_PACKET_FIELD_ERROR(pretty_names);
86317 }
86318 }
86319
86320#ifdef FREECIV_JSON_CONNECTION
86321 /* Exit array. */
86322 FC_FREE(field_addr.sub_location);
86323#endif /* FREECIV_JSON_CONNECTION */
86324 }
86325#endif /* FREECIV_DELTA_PROTOCOL */
86326
86327 RECEIVE_PACKET_END(real_packet);
86328#undef FREE_PACKET_STRUCT
86329}
86330
86331 static int send_packet_server_setting_enum_100(struct connection *pc, const struct packet_server_setting_enum *packet)
86332{
86333 const struct packet_server_setting_enum *real_packet = packet;
86334 int e;
86335 SEND_PACKET_START(PACKET_SERVER_SETTING_ENUM);
86336
86337 log_packet_detailed("packet_server_setting_enum_100: sending info about (%d)",
86338 real_packet->id);
86339
86340#ifdef FREECIV_DELTA_PROTOCOL
86341 packet_server_setting_enum_100_fields fields;
86342 struct packet_server_setting_enum *old;
86343 bool differ;
86344 int different = 0;
86345 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_ENUM;
86346
86347 if (nullptr == *hash) {
86348 *hash = genhash_new_full(hash_packet_server_setting_enum_100, cmp_packet_server_setting_enum_100,
86349 nullptr, nullptr, nullptr, destroy_packet_server_setting_enum);
86350 }
86351 BV_CLR_ALL(fields);
86352
86353 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
86354 old = fc_malloc(sizeof(*old));
86355 /* temporary bitcopy just to insert correctly */
86356 *old = *real_packet;
86357 genhash_insert(*hash, old, old);
86358 init_packet_server_setting_enum(old);
86359 different = 1; /* Force to send. */
86360 }
86361
86362 differ = (old->is_visible != real_packet->is_visible);
86363 if (differ) {
86364 different++;
86365 }
86366 /* folded into head */
86367 if (real_packet->is_visible) {
86368 BV_SET(fields, 0);
86369 }
86370
86371 differ = (old->is_changeable != real_packet->is_changeable);
86372 if (differ) {
86373 different++;
86374 }
86375 /* folded into head */
86376 if (real_packet->is_changeable) {
86377 BV_SET(fields, 1);
86378 }
86379
86380 differ = (old->initial_setting != real_packet->initial_setting);
86381 if (differ) {
86382 different++;
86383 }
86384 /* folded into head */
86385 if (real_packet->initial_setting) {
86386 BV_SET(fields, 2);
86387 }
86388
86389 differ = (old->setdef != real_packet->setdef);
86390 if (differ) {
86391 different++;
86392 BV_SET(fields, 3);
86393 }
86394
86395 differ = (old->val != real_packet->val);
86396 if (differ) {
86397 different++;
86398 BV_SET(fields, 4);
86399 }
86400
86401 differ = (old->default_val != real_packet->default_val);
86402 if (differ) {
86403 different++;
86404 BV_SET(fields, 5);
86405 }
86406
86407 differ = (old->values_num != real_packet->values_num);
86408 if (differ) {
86409 different++;
86410 BV_SET(fields, 6);
86411 }
86412
86413 differ = (old->values_num != real_packet->values_num);
86414 if (!differ) {
86415 int i;
86416
86417 for (i = 0; i < old->values_num; i++) {
86418 differ = (strcmp(old->support_names[i], real_packet->support_names[i]) != 0);
86419 if (differ) {
86420 break;
86421 }
86422 }
86423 }
86424 if (differ) {
86425 different++;
86426 BV_SET(fields, 7);
86427 }
86428
86429 differ = (old->values_num != real_packet->values_num);
86430 if (!differ) {
86431 int i;
86432
86433 for (i = 0; i < old->values_num; i++) {
86434 differ = (strcmp(old->pretty_names[i], real_packet->pretty_names[i]) != 0);
86435 if (differ) {
86436 break;
86437 }
86438 }
86439 }
86440 if (differ) {
86441 different++;
86442 BV_SET(fields, 8);
86443 }
86444
86445 if (different == 0) {
86446 log_packet_detailed(" no change -> discard");
86447 SEND_PACKET_DISCARD();
86448 }
86449#endif /* FREECIV_DELTA_PROTOCOL */
86450
86451#ifdef FREECIV_JSON_CONNECTION
86452 struct plocation field_addr;
86453 {
86454 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
86455 field_addr = *field_addr_tmp;
86456 FC_FREE(field_addr_tmp);
86457 }
86458#endif /* FREECIV_JSON_CONNECTION */
86459
86460#ifdef FREECIV_JSON_CONNECTION
86461 field_addr.name = "id";
86462#endif /* FREECIV_JSON_CONNECTION */
86463 e = 0;
86464
86465 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
86466
86467 if (e) {
86468 log_packet_detailed("'id' field error detected");
86469 }
86470
86471#ifdef FREECIV_DELTA_PROTOCOL
86472#ifdef FREECIV_JSON_CONNECTION
86473 field_addr.name = "fields";
86474#endif /* FREECIV_JSON_CONNECTION */
86475 e = 0;
86476 e |= DIO_BV_PUT(&dout, &field_addr, fields);
86477 if (e) {
86478 log_packet_detailed("fields bitvector error detected");
86479 }
86480
86481 /* field 0 is folded into the header */
86482
86483 /* field 1 is folded into the header */
86484
86485 /* field 2 is folded into the header */
86486
86487 if (BV_ISSET(fields, 3)) {
86488 log_packet_detailed(" field 'setdef' has changed");
86489
86490#ifdef FREECIV_JSON_CONNECTION
86491 field_addr.name = "setdef";
86492#endif /* FREECIV_JSON_CONNECTION */
86493 e = 0;
86494
86495 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
86496
86497 if (e) {
86498 log_packet_detailed("'setdef' field error detected");
86499 }
86500 }
86501
86502 if (BV_ISSET(fields, 4)) {
86503 log_packet_detailed(" field 'val' has changed");
86504
86505#ifdef FREECIV_JSON_CONNECTION
86506 field_addr.name = "val";
86507#endif /* FREECIV_JSON_CONNECTION */
86508 e = 0;
86509
86510 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->val);
86511
86512 if (e) {
86513 log_packet_detailed("'val' field error detected");
86514 }
86515 }
86516
86517 if (BV_ISSET(fields, 5)) {
86518 log_packet_detailed(" field 'default_val' has changed");
86519
86520#ifdef FREECIV_JSON_CONNECTION
86521 field_addr.name = "default_val";
86522#endif /* FREECIV_JSON_CONNECTION */
86523 e = 0;
86524
86525 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->default_val);
86526
86527 if (e) {
86528 log_packet_detailed("'default_val' field error detected");
86529 }
86530 }
86531
86532 if (BV_ISSET(fields, 6)) {
86533 log_packet_detailed(" field 'values_num' has changed");
86534
86535#ifdef FREECIV_JSON_CONNECTION
86536 field_addr.name = "values_num";
86537#endif /* FREECIV_JSON_CONNECTION */
86538 e = 0;
86539
86540 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->values_num);
86541
86542 if (e) {
86543 log_packet_detailed("'values_num' field error detected");
86544 }
86545 }
86546
86547 if (BV_ISSET(fields, 7)) {
86548 log_packet_detailed(" field 'support_names' has changed");
86549
86550#ifdef FREECIV_JSON_CONNECTION
86551 field_addr.name = "support_names";
86552#endif /* FREECIV_JSON_CONNECTION */
86553 e = 0;
86554
86555 {
86556 int i;
86557
86558#ifdef FREECIV_JSON_CONNECTION
86559 /* Create the array. */
86560 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->values_num);
86561
86562 /* Enter array. */
86563 field_addr.sub_location = plocation_elem_new(0);
86564#endif /* FREECIV_JSON_CONNECTION */
86565
86566 for (i = 0; i < real_packet->values_num; i++) {
86567#ifdef FREECIV_JSON_CONNECTION
86568 /* Next array element. */
86569 field_addr.sub_location->number = i;
86570#endif /* FREECIV_JSON_CONNECTION */
86571
86572 e |= DIO_PUT(string, &dout, &field_addr, real_packet->support_names[i]);
86573 }
86574
86575#ifdef FREECIV_JSON_CONNECTION
86576 /* Exit array. */
86577 FC_FREE(field_addr.sub_location);
86578#endif /* FREECIV_JSON_CONNECTION */
86579 }
86580
86581 if (e) {
86582 log_packet_detailed("'support_names' field error detected");
86583 }
86584 }
86585
86586 if (BV_ISSET(fields, 8)) {
86587 log_packet_detailed(" field 'pretty_names' has changed");
86588
86589#ifdef FREECIV_JSON_CONNECTION
86590 field_addr.name = "pretty_names";
86591#endif /* FREECIV_JSON_CONNECTION */
86592 e = 0;
86593
86594 {
86595 int i;
86596
86597#ifdef FREECIV_JSON_CONNECTION
86598 /* Create the array. */
86599 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->values_num);
86600
86601 /* Enter array. */
86602 field_addr.sub_location = plocation_elem_new(0);
86603#endif /* FREECIV_JSON_CONNECTION */
86604
86605 for (i = 0; i < real_packet->values_num; i++) {
86606#ifdef FREECIV_JSON_CONNECTION
86607 /* Next array element. */
86608 field_addr.sub_location->number = i;
86609#endif /* FREECIV_JSON_CONNECTION */
86610
86611 e |= DIO_PUT(string, &dout, &field_addr, real_packet->pretty_names[i]);
86612 }
86613
86614#ifdef FREECIV_JSON_CONNECTION
86615 /* Exit array. */
86616 FC_FREE(field_addr.sub_location);
86617#endif /* FREECIV_JSON_CONNECTION */
86618 }
86619
86620 if (e) {
86621 log_packet_detailed("'pretty_names' field error detected");
86622 }
86623 }
86624
86625 *old = *real_packet;
86626
86627#else /* FREECIV_DELTA_PROTOCOL */
86628#ifdef FREECIV_JSON_CONNECTION
86629 field_addr.name = "is_visible";
86630#endif /* FREECIV_JSON_CONNECTION */
86631 e = 0;
86632
86633 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_visible);
86634
86635 if (e) {
86636 log_packet_detailed("'is_visible' field error detected");
86637 }
86638
86639#ifdef FREECIV_JSON_CONNECTION
86640 field_addr.name = "is_changeable";
86641#endif /* FREECIV_JSON_CONNECTION */
86642 e = 0;
86643
86644 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_changeable);
86645
86646 if (e) {
86647 log_packet_detailed("'is_changeable' field error detected");
86648 }
86649
86650#ifdef FREECIV_JSON_CONNECTION
86651 field_addr.name = "initial_setting";
86652#endif /* FREECIV_JSON_CONNECTION */
86653 e = 0;
86654
86655 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->initial_setting);
86656
86657 if (e) {
86658 log_packet_detailed("'initial_setting' field error detected");
86659 }
86660
86661#ifdef FREECIV_JSON_CONNECTION
86662 field_addr.name = "setdef";
86663#endif /* FREECIV_JSON_CONNECTION */
86664 e = 0;
86665
86666 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
86667
86668 if (e) {
86669 log_packet_detailed("'setdef' field error detected");
86670 }
86671
86672#ifdef FREECIV_JSON_CONNECTION
86673 field_addr.name = "val";
86674#endif /* FREECIV_JSON_CONNECTION */
86675 e = 0;
86676
86677 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->val);
86678
86679 if (e) {
86680 log_packet_detailed("'val' field error detected");
86681 }
86682
86683#ifdef FREECIV_JSON_CONNECTION
86684 field_addr.name = "default_val";
86685#endif /* FREECIV_JSON_CONNECTION */
86686 e = 0;
86687
86688 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->default_val);
86689
86690 if (e) {
86691 log_packet_detailed("'default_val' field error detected");
86692 }
86693
86694#ifdef FREECIV_JSON_CONNECTION
86695 field_addr.name = "values_num";
86696#endif /* FREECIV_JSON_CONNECTION */
86697 e = 0;
86698
86699 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->values_num);
86700
86701 if (e) {
86702 log_packet_detailed("'values_num' field error detected");
86703 }
86704
86705#ifdef FREECIV_JSON_CONNECTION
86706 field_addr.name = "support_names";
86707#endif /* FREECIV_JSON_CONNECTION */
86708 e = 0;
86709
86710 {
86711 int i;
86712
86713#ifdef FREECIV_JSON_CONNECTION
86714 /* Create the array. */
86715 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->values_num);
86716
86717 /* Enter array. */
86718 field_addr.sub_location = plocation_elem_new(0);
86719#endif /* FREECIV_JSON_CONNECTION */
86720
86721 for (i = 0; i < real_packet->values_num; i++) {
86722#ifdef FREECIV_JSON_CONNECTION
86723 /* Next array element. */
86724 field_addr.sub_location->number = i;
86725#endif /* FREECIV_JSON_CONNECTION */
86726
86727 e |= DIO_PUT(string, &dout, &field_addr, real_packet->support_names[i]);
86728 }
86729
86730#ifdef FREECIV_JSON_CONNECTION
86731 /* Exit array. */
86732 FC_FREE(field_addr.sub_location);
86733#endif /* FREECIV_JSON_CONNECTION */
86734 }
86735
86736 if (e) {
86737 log_packet_detailed("'support_names' field error detected");
86738 }
86739
86740#ifdef FREECIV_JSON_CONNECTION
86741 field_addr.name = "pretty_names";
86742#endif /* FREECIV_JSON_CONNECTION */
86743 e = 0;
86744
86745 {
86746 int i;
86747
86748#ifdef FREECIV_JSON_CONNECTION
86749 /* Create the array. */
86750 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->values_num);
86751
86752 /* Enter array. */
86753 field_addr.sub_location = plocation_elem_new(0);
86754#endif /* FREECIV_JSON_CONNECTION */
86755
86756 for (i = 0; i < real_packet->values_num; i++) {
86757#ifdef FREECIV_JSON_CONNECTION
86758 /* Next array element. */
86759 field_addr.sub_location->number = i;
86760#endif /* FREECIV_JSON_CONNECTION */
86761
86762 e |= DIO_PUT(string, &dout, &field_addr, real_packet->pretty_names[i]);
86763 }
86764
86765#ifdef FREECIV_JSON_CONNECTION
86766 /* Exit array. */
86767 FC_FREE(field_addr.sub_location);
86768#endif /* FREECIV_JSON_CONNECTION */
86769 }
86770
86771 if (e) {
86772 log_packet_detailed("'pretty_names' field error detected");
86773 }
86774#endif /* FREECIV_DELTA_PROTOCOL */
86775
86776 SEND_PACKET_END(PACKET_SERVER_SETTING_ENUM);
86777}
86778
86779 int send_packet_server_setting_enum(struct connection *pc, const struct packet_server_setting_enum *packet)
86780{
86781 if (!pc->used) {
86782 log_error("WARNING: trying to send data to the closed connection %s",
86783 conn_description(pc));
86784 return -1;
86785 }
86786 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_ENUM].packet != nullptr, -1,
86787 "Handler for PACKET_SERVER_SETTING_ENUM not installed");
86788 return pc->phs.handlers->send[PACKET_SERVER_SETTING_ENUM].packet(pc, packet);
86789}
86790
86791 static inline void init_packet_server_setting_bitwise(struct packet_server_setting_bitwise *packet)
86792{
86793 memset(packet, 0, sizeof(*packet));
86794}
86795
86796#define free_packet_server_setting_bitwise(_packet) (void) 0
86797#define destroy_packet_server_setting_bitwise free
86798
86799#ifdef FREECIV_DELTA_PROTOCOL
86800static genhash_val_t hash_packet_server_setting_bitwise_100(const void *vkey)
86801{
86802 const struct packet_server_setting_bitwise *key = (const struct packet_server_setting_bitwise *) vkey;
86803 genhash_val_t result = 0;
86804
86805 result += key->id;
86806
86807 result &= 0xFFFFFFFF;
86808 return result;
86809}
86810
86811static bool cmp_packet_server_setting_bitwise_100(const void *vkey1, const void *vkey2)
86812{
86813 const struct packet_server_setting_bitwise *old = (const struct packet_server_setting_bitwise *) vkey1;
86814 const struct packet_server_setting_bitwise *real_packet = (const struct packet_server_setting_bitwise *) vkey2;
86815 bool differ;
86816
86817 differ = (old->id != real_packet->id);
86818
86819 return !differ;
86820}
86821 BV_DEFINE(packet_server_setting_bitwise_100_fields, 9);
86822#endif /* FREECIV_DELTA_PROTOCOL */
86823
86824 static struct packet_server_setting_bitwise *receive_packet_server_setting_bitwise_100(struct connection *pc)
86825{
86826#define FREE_PACKET_STRUCT(_packet) free_packet_server_setting_bitwise(_packet)
86827 RECEIVE_PACKET_START(packet_server_setting_bitwise, real_packet);
86828
86829#ifdef FREECIV_JSON_CONNECTION
86830 struct plocation field_addr;
86831 {
86832 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
86833 field_addr = *field_addr_tmp;
86834 FC_FREE(field_addr_tmp);
86835 }
86836#endif /* FREECIV_JSON_CONNECTION */
86837
86838#ifdef FREECIV_JSON_CONNECTION
86839 field_addr.name = "id";
86840#endif /* FREECIV_JSON_CONNECTION */
86841
86842 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->id)) {
86843 RECEIVE_PACKET_FIELD_ERROR(id);
86844 }
86845
86846 log_packet_detailed("packet_server_setting_bitwise_100: got info about (%d)",
86847 real_packet->id);
86848
86849#ifdef FREECIV_DELTA_PROTOCOL
86850 packet_server_setting_bitwise_100_fields fields;
86851 struct packet_server_setting_bitwise *old;
86852 struct genhash **hash = pc->phs.received + PACKET_SERVER_SETTING_BITWISE;
86853
86854 if (nullptr == *hash) {
86855 *hash = genhash_new_full(hash_packet_server_setting_bitwise_100, cmp_packet_server_setting_bitwise_100,
86856 nullptr, nullptr, nullptr, destroy_packet_server_setting_bitwise);
86857 }
86858
86859 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
86860 *real_packet = *old;
86861 } else {
86862 /* packet is already initialized empty */
86863 log_packet_detailed(" no old info");
86864 }
86865
86866#ifdef FREECIV_JSON_CONNECTION
86867 field_addr.name = "fields";
86868#endif /* FREECIV_JSON_CONNECTION */
86869 DIO_BV_GET(&din, &field_addr, fields);
86870
86871 real_packet->is_visible = BV_ISSET(fields, 0);
86872
86873 real_packet->is_changeable = BV_ISSET(fields, 1);
86874
86875 real_packet->initial_setting = BV_ISSET(fields, 2);
86876
86877 if (BV_ISSET(fields, 3)) {
86878 log_packet_detailed(" got field 'setdef'");
86879
86880#ifdef FREECIV_JSON_CONNECTION
86881 field_addr.name = "setdef";
86882#endif /* FREECIV_JSON_CONNECTION */
86883
86884 {
86885 int readin;
86886
86887 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
86888 RECEIVE_PACKET_FIELD_ERROR(setdef);
86889 }
86890 real_packet->setdef = readin;
86891 }
86892 }
86893
86894 if (BV_ISSET(fields, 4)) {
86895 log_packet_detailed(" got field 'val'");
86896
86897#ifdef FREECIV_JSON_CONNECTION
86898 field_addr.name = "val";
86899#endif /* FREECIV_JSON_CONNECTION */
86900
86901 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->val)) {
86902 RECEIVE_PACKET_FIELD_ERROR(val);
86903 }
86904 }
86905
86906 if (BV_ISSET(fields, 5)) {
86907 log_packet_detailed(" got field 'default_val'");
86908
86909#ifdef FREECIV_JSON_CONNECTION
86910 field_addr.name = "default_val";
86911#endif /* FREECIV_JSON_CONNECTION */
86912
86913 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->default_val)) {
86914 RECEIVE_PACKET_FIELD_ERROR(default_val);
86915 }
86916 }
86917
86918 if (BV_ISSET(fields, 6)) {
86919 log_packet_detailed(" got field 'bits_num'");
86920
86921#ifdef FREECIV_JSON_CONNECTION
86922 field_addr.name = "bits_num";
86923#endif /* FREECIV_JSON_CONNECTION */
86924
86925 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->bits_num)) {
86926 RECEIVE_PACKET_FIELD_ERROR(bits_num);
86927 }
86928 }
86929
86930 if (BV_ISSET(fields, 7)) {
86931 log_packet_detailed(" got field 'support_names'");
86932
86933#ifdef FREECIV_JSON_CONNECTION
86934 field_addr.name = "support_names";
86935#endif /* FREECIV_JSON_CONNECTION */
86936
86937 {
86938 int i;
86939
86940 if (real_packet->bits_num > 64) {
86941 RECEIVE_PACKET_FIELD_ERROR(support_names, ": array truncated");
86942 }
86943
86944#ifdef FREECIV_JSON_CONNECTION
86945 /* Enter array. */
86946 field_addr.sub_location = plocation_elem_new(0);
86947#endif /* FREECIV_JSON_CONNECTION */
86948
86949 for (i = 0; i < real_packet->bits_num; i++) {
86950#ifdef FREECIV_JSON_CONNECTION
86951 /* Next array element */
86952 field_addr.sub_location->number = i;
86953#endif /* FREECIV_JSON_CONNECTION */
86954
86955 if (!DIO_GET(string, &din, &field_addr, real_packet->support_names[i], sizeof(real_packet->support_names[i]))) {
86956 RECEIVE_PACKET_FIELD_ERROR(support_names);
86957 }
86958 }
86959
86960#ifdef FREECIV_JSON_CONNECTION
86961 /* Exit array. */
86962 FC_FREE(field_addr.sub_location);
86963#endif /* FREECIV_JSON_CONNECTION */
86964 }
86965 }
86966
86967 if (BV_ISSET(fields, 8)) {
86968 log_packet_detailed(" got field 'pretty_names'");
86969
86970#ifdef FREECIV_JSON_CONNECTION
86971 field_addr.name = "pretty_names";
86972#endif /* FREECIV_JSON_CONNECTION */
86973
86974 {
86975 int i;
86976
86977 if (real_packet->bits_num > 64) {
86978 RECEIVE_PACKET_FIELD_ERROR(pretty_names, ": array truncated");
86979 }
86980
86981#ifdef FREECIV_JSON_CONNECTION
86982 /* Enter array. */
86983 field_addr.sub_location = plocation_elem_new(0);
86984#endif /* FREECIV_JSON_CONNECTION */
86985
86986 for (i = 0; i < real_packet->bits_num; i++) {
86987#ifdef FREECIV_JSON_CONNECTION
86988 /* Next array element */
86989 field_addr.sub_location->number = i;
86990#endif /* FREECIV_JSON_CONNECTION */
86991
86992 if (!DIO_GET(string, &din, &field_addr, real_packet->pretty_names[i], sizeof(real_packet->pretty_names[i]))) {
86993 RECEIVE_PACKET_FIELD_ERROR(pretty_names);
86994 }
86995 }
86996
86997#ifdef FREECIV_JSON_CONNECTION
86998 /* Exit array. */
86999 FC_FREE(field_addr.sub_location);
87000#endif /* FREECIV_JSON_CONNECTION */
87001 }
87002 }
87003
87004 if (nullptr == old) {
87005 old = fc_malloc(sizeof(*old));
87006 init_packet_server_setting_bitwise(old);
87007 *old = *real_packet;
87008 genhash_insert(*hash, old, old);
87009 } else {
87010 *old = *real_packet;
87011 }
87012
87013#else /* FREECIV_DELTA_PROTOCOL */
87014#ifdef FREECIV_JSON_CONNECTION
87015 field_addr.name = "is_visible";
87016#endif /* FREECIV_JSON_CONNECTION */
87017
87018 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_visible)) {
87019 RECEIVE_PACKET_FIELD_ERROR(is_visible);
87020 }
87021
87022#ifdef FREECIV_JSON_CONNECTION
87023 field_addr.name = "is_changeable";
87024#endif /* FREECIV_JSON_CONNECTION */
87025
87026 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_changeable)) {
87027 RECEIVE_PACKET_FIELD_ERROR(is_changeable);
87028 }
87029
87030#ifdef FREECIV_JSON_CONNECTION
87031 field_addr.name = "initial_setting";
87032#endif /* FREECIV_JSON_CONNECTION */
87033
87034 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->initial_setting)) {
87035 RECEIVE_PACKET_FIELD_ERROR(initial_setting);
87036 }
87037
87038#ifdef FREECIV_JSON_CONNECTION
87039 field_addr.name = "setdef";
87040#endif /* FREECIV_JSON_CONNECTION */
87041
87042 {
87043 int readin;
87044
87045 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
87046 RECEIVE_PACKET_FIELD_ERROR(setdef);
87047 }
87048 real_packet->setdef = readin;
87049 }
87050
87051#ifdef FREECIV_JSON_CONNECTION
87052 field_addr.name = "val";
87053#endif /* FREECIV_JSON_CONNECTION */
87054
87055 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->val)) {
87056 RECEIVE_PACKET_FIELD_ERROR(val);
87057 }
87058
87059#ifdef FREECIV_JSON_CONNECTION
87060 field_addr.name = "default_val";
87061#endif /* FREECIV_JSON_CONNECTION */
87062
87063 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->default_val)) {
87064 RECEIVE_PACKET_FIELD_ERROR(default_val);
87065 }
87066
87067#ifdef FREECIV_JSON_CONNECTION
87068 field_addr.name = "bits_num";
87069#endif /* FREECIV_JSON_CONNECTION */
87070
87071 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->bits_num)) {
87072 RECEIVE_PACKET_FIELD_ERROR(bits_num);
87073 }
87074
87075#ifdef FREECIV_JSON_CONNECTION
87076 field_addr.name = "support_names";
87077#endif /* FREECIV_JSON_CONNECTION */
87078
87079 {
87080 int i;
87081
87082 if (real_packet->bits_num > 64) {
87083 RECEIVE_PACKET_FIELD_ERROR(support_names, ": array truncated");
87084 }
87085
87086#ifdef FREECIV_JSON_CONNECTION
87087 /* Enter array. */
87088 field_addr.sub_location = plocation_elem_new(0);
87089#endif /* FREECIV_JSON_CONNECTION */
87090
87091 for (i = 0; i < real_packet->bits_num; i++) {
87092#ifdef FREECIV_JSON_CONNECTION
87093 /* Next array element */
87094 field_addr.sub_location->number = i;
87095#endif /* FREECIV_JSON_CONNECTION */
87096
87097 if (!DIO_GET(string, &din, &field_addr, real_packet->support_names[i], sizeof(real_packet->support_names[i]))) {
87098 RECEIVE_PACKET_FIELD_ERROR(support_names);
87099 }
87100 }
87101
87102#ifdef FREECIV_JSON_CONNECTION
87103 /* Exit array. */
87104 FC_FREE(field_addr.sub_location);
87105#endif /* FREECIV_JSON_CONNECTION */
87106 }
87107
87108#ifdef FREECIV_JSON_CONNECTION
87109 field_addr.name = "pretty_names";
87110#endif /* FREECIV_JSON_CONNECTION */
87111
87112 {
87113 int i;
87114
87115 if (real_packet->bits_num > 64) {
87116 RECEIVE_PACKET_FIELD_ERROR(pretty_names, ": array truncated");
87117 }
87118
87119#ifdef FREECIV_JSON_CONNECTION
87120 /* Enter array. */
87121 field_addr.sub_location = plocation_elem_new(0);
87122#endif /* FREECIV_JSON_CONNECTION */
87123
87124 for (i = 0; i < real_packet->bits_num; i++) {
87125#ifdef FREECIV_JSON_CONNECTION
87126 /* Next array element */
87127 field_addr.sub_location->number = i;
87128#endif /* FREECIV_JSON_CONNECTION */
87129
87130 if (!DIO_GET(string, &din, &field_addr, real_packet->pretty_names[i], sizeof(real_packet->pretty_names[i]))) {
87131 RECEIVE_PACKET_FIELD_ERROR(pretty_names);
87132 }
87133 }
87134
87135#ifdef FREECIV_JSON_CONNECTION
87136 /* Exit array. */
87137 FC_FREE(field_addr.sub_location);
87138#endif /* FREECIV_JSON_CONNECTION */
87139 }
87140#endif /* FREECIV_DELTA_PROTOCOL */
87141
87142 RECEIVE_PACKET_END(real_packet);
87143#undef FREE_PACKET_STRUCT
87144}
87145
87146 static int send_packet_server_setting_bitwise_100(struct connection *pc, const struct packet_server_setting_bitwise *packet)
87147{
87148 const struct packet_server_setting_bitwise *real_packet = packet;
87149 int e;
87150 SEND_PACKET_START(PACKET_SERVER_SETTING_BITWISE);
87151
87152 log_packet_detailed("packet_server_setting_bitwise_100: sending info about (%d)",
87153 real_packet->id);
87154
87155#ifdef FREECIV_DELTA_PROTOCOL
87156 packet_server_setting_bitwise_100_fields fields;
87157 struct packet_server_setting_bitwise *old;
87158 bool differ;
87159 int different = 0;
87160 struct genhash **hash = pc->phs.sent + PACKET_SERVER_SETTING_BITWISE;
87161
87162 if (nullptr == *hash) {
87163 *hash = genhash_new_full(hash_packet_server_setting_bitwise_100, cmp_packet_server_setting_bitwise_100,
87164 nullptr, nullptr, nullptr, destroy_packet_server_setting_bitwise);
87165 }
87166 BV_CLR_ALL(fields);
87167
87168 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
87169 old = fc_malloc(sizeof(*old));
87170 /* temporary bitcopy just to insert correctly */
87171 *old = *real_packet;
87172 genhash_insert(*hash, old, old);
87173 init_packet_server_setting_bitwise(old);
87174 different = 1; /* Force to send. */
87175 }
87176
87177 differ = (old->is_visible != real_packet->is_visible);
87178 if (differ) {
87179 different++;
87180 }
87181 /* folded into head */
87182 if (real_packet->is_visible) {
87183 BV_SET(fields, 0);
87184 }
87185
87186 differ = (old->is_changeable != real_packet->is_changeable);
87187 if (differ) {
87188 different++;
87189 }
87190 /* folded into head */
87191 if (real_packet->is_changeable) {
87192 BV_SET(fields, 1);
87193 }
87194
87195 differ = (old->initial_setting != real_packet->initial_setting);
87196 if (differ) {
87197 different++;
87198 }
87199 /* folded into head */
87200 if (real_packet->initial_setting) {
87201 BV_SET(fields, 2);
87202 }
87203
87204 differ = (old->setdef != real_packet->setdef);
87205 if (differ) {
87206 different++;
87207 BV_SET(fields, 3);
87208 }
87209
87210 differ = (old->val != real_packet->val);
87211 if (differ) {
87212 different++;
87213 BV_SET(fields, 4);
87214 }
87215
87216 differ = (old->default_val != real_packet->default_val);
87217 if (differ) {
87218 different++;
87219 BV_SET(fields, 5);
87220 }
87221
87222 differ = (old->bits_num != real_packet->bits_num);
87223 if (differ) {
87224 different++;
87225 BV_SET(fields, 6);
87226 }
87227
87228 differ = (old->bits_num != real_packet->bits_num);
87229 if (!differ) {
87230 int i;
87231
87232 for (i = 0; i < old->bits_num; i++) {
87233 differ = (strcmp(old->support_names[i], real_packet->support_names[i]) != 0);
87234 if (differ) {
87235 break;
87236 }
87237 }
87238 }
87239 if (differ) {
87240 different++;
87241 BV_SET(fields, 7);
87242 }
87243
87244 differ = (old->bits_num != real_packet->bits_num);
87245 if (!differ) {
87246 int i;
87247
87248 for (i = 0; i < old->bits_num; i++) {
87249 differ = (strcmp(old->pretty_names[i], real_packet->pretty_names[i]) != 0);
87250 if (differ) {
87251 break;
87252 }
87253 }
87254 }
87255 if (differ) {
87256 different++;
87257 BV_SET(fields, 8);
87258 }
87259
87260 if (different == 0) {
87261 log_packet_detailed(" no change -> discard");
87262 SEND_PACKET_DISCARD();
87263 }
87264#endif /* FREECIV_DELTA_PROTOCOL */
87265
87266#ifdef FREECIV_JSON_CONNECTION
87267 struct plocation field_addr;
87268 {
87269 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
87270 field_addr = *field_addr_tmp;
87271 FC_FREE(field_addr_tmp);
87272 }
87273#endif /* FREECIV_JSON_CONNECTION */
87274
87275#ifdef FREECIV_JSON_CONNECTION
87276 field_addr.name = "id";
87277#endif /* FREECIV_JSON_CONNECTION */
87278 e = 0;
87279
87280 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
87281
87282 if (e) {
87283 log_packet_detailed("'id' field error detected");
87284 }
87285
87286#ifdef FREECIV_DELTA_PROTOCOL
87287#ifdef FREECIV_JSON_CONNECTION
87288 field_addr.name = "fields";
87289#endif /* FREECIV_JSON_CONNECTION */
87290 e = 0;
87291 e |= DIO_BV_PUT(&dout, &field_addr, fields);
87292 if (e) {
87293 log_packet_detailed("fields bitvector error detected");
87294 }
87295
87296 /* field 0 is folded into the header */
87297
87298 /* field 1 is folded into the header */
87299
87300 /* field 2 is folded into the header */
87301
87302 if (BV_ISSET(fields, 3)) {
87303 log_packet_detailed(" field 'setdef' has changed");
87304
87305#ifdef FREECIV_JSON_CONNECTION
87306 field_addr.name = "setdef";
87307#endif /* FREECIV_JSON_CONNECTION */
87308 e = 0;
87309
87310 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
87311
87312 if (e) {
87313 log_packet_detailed("'setdef' field error detected");
87314 }
87315 }
87316
87317 if (BV_ISSET(fields, 4)) {
87318 log_packet_detailed(" field 'val' has changed");
87319
87320#ifdef FREECIV_JSON_CONNECTION
87321 field_addr.name = "val";
87322#endif /* FREECIV_JSON_CONNECTION */
87323 e = 0;
87324
87325 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->val);
87326
87327 if (e) {
87328 log_packet_detailed("'val' field error detected");
87329 }
87330 }
87331
87332 if (BV_ISSET(fields, 5)) {
87333 log_packet_detailed(" field 'default_val' has changed");
87334
87335#ifdef FREECIV_JSON_CONNECTION
87336 field_addr.name = "default_val";
87337#endif /* FREECIV_JSON_CONNECTION */
87338 e = 0;
87339
87340 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->default_val);
87341
87342 if (e) {
87343 log_packet_detailed("'default_val' field error detected");
87344 }
87345 }
87346
87347 if (BV_ISSET(fields, 6)) {
87348 log_packet_detailed(" field 'bits_num' has changed");
87349
87350#ifdef FREECIV_JSON_CONNECTION
87351 field_addr.name = "bits_num";
87352#endif /* FREECIV_JSON_CONNECTION */
87353 e = 0;
87354
87355 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->bits_num);
87356
87357 if (e) {
87358 log_packet_detailed("'bits_num' field error detected");
87359 }
87360 }
87361
87362 if (BV_ISSET(fields, 7)) {
87363 log_packet_detailed(" field 'support_names' has changed");
87364
87365#ifdef FREECIV_JSON_CONNECTION
87366 field_addr.name = "support_names";
87367#endif /* FREECIV_JSON_CONNECTION */
87368 e = 0;
87369
87370 {
87371 int i;
87372
87373#ifdef FREECIV_JSON_CONNECTION
87374 /* Create the array. */
87375 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->bits_num);
87376
87377 /* Enter array. */
87378 field_addr.sub_location = plocation_elem_new(0);
87379#endif /* FREECIV_JSON_CONNECTION */
87380
87381 for (i = 0; i < real_packet->bits_num; i++) {
87382#ifdef FREECIV_JSON_CONNECTION
87383 /* Next array element. */
87384 field_addr.sub_location->number = i;
87385#endif /* FREECIV_JSON_CONNECTION */
87386
87387 e |= DIO_PUT(string, &dout, &field_addr, real_packet->support_names[i]);
87388 }
87389
87390#ifdef FREECIV_JSON_CONNECTION
87391 /* Exit array. */
87392 FC_FREE(field_addr.sub_location);
87393#endif /* FREECIV_JSON_CONNECTION */
87394 }
87395
87396 if (e) {
87397 log_packet_detailed("'support_names' field error detected");
87398 }
87399 }
87400
87401 if (BV_ISSET(fields, 8)) {
87402 log_packet_detailed(" field 'pretty_names' has changed");
87403
87404#ifdef FREECIV_JSON_CONNECTION
87405 field_addr.name = "pretty_names";
87406#endif /* FREECIV_JSON_CONNECTION */
87407 e = 0;
87408
87409 {
87410 int i;
87411
87412#ifdef FREECIV_JSON_CONNECTION
87413 /* Create the array. */
87414 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->bits_num);
87415
87416 /* Enter array. */
87417 field_addr.sub_location = plocation_elem_new(0);
87418#endif /* FREECIV_JSON_CONNECTION */
87419
87420 for (i = 0; i < real_packet->bits_num; i++) {
87421#ifdef FREECIV_JSON_CONNECTION
87422 /* Next array element. */
87423 field_addr.sub_location->number = i;
87424#endif /* FREECIV_JSON_CONNECTION */
87425
87426 e |= DIO_PUT(string, &dout, &field_addr, real_packet->pretty_names[i]);
87427 }
87428
87429#ifdef FREECIV_JSON_CONNECTION
87430 /* Exit array. */
87431 FC_FREE(field_addr.sub_location);
87432#endif /* FREECIV_JSON_CONNECTION */
87433 }
87434
87435 if (e) {
87436 log_packet_detailed("'pretty_names' field error detected");
87437 }
87438 }
87439
87440 *old = *real_packet;
87441
87442#else /* FREECIV_DELTA_PROTOCOL */
87443#ifdef FREECIV_JSON_CONNECTION
87444 field_addr.name = "is_visible";
87445#endif /* FREECIV_JSON_CONNECTION */
87446 e = 0;
87447
87448 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_visible);
87449
87450 if (e) {
87451 log_packet_detailed("'is_visible' field error detected");
87452 }
87453
87454#ifdef FREECIV_JSON_CONNECTION
87455 field_addr.name = "is_changeable";
87456#endif /* FREECIV_JSON_CONNECTION */
87457 e = 0;
87458
87459 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_changeable);
87460
87461 if (e) {
87462 log_packet_detailed("'is_changeable' field error detected");
87463 }
87464
87465#ifdef FREECIV_JSON_CONNECTION
87466 field_addr.name = "initial_setting";
87467#endif /* FREECIV_JSON_CONNECTION */
87468 e = 0;
87469
87470 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->initial_setting);
87471
87472 if (e) {
87473 log_packet_detailed("'initial_setting' field error detected");
87474 }
87475
87476#ifdef FREECIV_JSON_CONNECTION
87477 field_addr.name = "setdef";
87478#endif /* FREECIV_JSON_CONNECTION */
87479 e = 0;
87480
87481 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->setdef);
87482
87483 if (e) {
87484 log_packet_detailed("'setdef' field error detected");
87485 }
87486
87487#ifdef FREECIV_JSON_CONNECTION
87488 field_addr.name = "val";
87489#endif /* FREECIV_JSON_CONNECTION */
87490 e = 0;
87491
87492 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->val);
87493
87494 if (e) {
87495 log_packet_detailed("'val' field error detected");
87496 }
87497
87498#ifdef FREECIV_JSON_CONNECTION
87499 field_addr.name = "default_val";
87500#endif /* FREECIV_JSON_CONNECTION */
87501 e = 0;
87502
87503 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->default_val);
87504
87505 if (e) {
87506 log_packet_detailed("'default_val' field error detected");
87507 }
87508
87509#ifdef FREECIV_JSON_CONNECTION
87510 field_addr.name = "bits_num";
87511#endif /* FREECIV_JSON_CONNECTION */
87512 e = 0;
87513
87514 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->bits_num);
87515
87516 if (e) {
87517 log_packet_detailed("'bits_num' field error detected");
87518 }
87519
87520#ifdef FREECIV_JSON_CONNECTION
87521 field_addr.name = "support_names";
87522#endif /* FREECIV_JSON_CONNECTION */
87523 e = 0;
87524
87525 {
87526 int i;
87527
87528#ifdef FREECIV_JSON_CONNECTION
87529 /* Create the array. */
87530 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->bits_num);
87531
87532 /* Enter array. */
87533 field_addr.sub_location = plocation_elem_new(0);
87534#endif /* FREECIV_JSON_CONNECTION */
87535
87536 for (i = 0; i < real_packet->bits_num; i++) {
87537#ifdef FREECIV_JSON_CONNECTION
87538 /* Next array element. */
87539 field_addr.sub_location->number = i;
87540#endif /* FREECIV_JSON_CONNECTION */
87541
87542 e |= DIO_PUT(string, &dout, &field_addr, real_packet->support_names[i]);
87543 }
87544
87545#ifdef FREECIV_JSON_CONNECTION
87546 /* Exit array. */
87547 FC_FREE(field_addr.sub_location);
87548#endif /* FREECIV_JSON_CONNECTION */
87549 }
87550
87551 if (e) {
87552 log_packet_detailed("'support_names' field error detected");
87553 }
87554
87555#ifdef FREECIV_JSON_CONNECTION
87556 field_addr.name = "pretty_names";
87557#endif /* FREECIV_JSON_CONNECTION */
87558 e = 0;
87559
87560 {
87561 int i;
87562
87563#ifdef FREECIV_JSON_CONNECTION
87564 /* Create the array. */
87565 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->bits_num);
87566
87567 /* Enter array. */
87568 field_addr.sub_location = plocation_elem_new(0);
87569#endif /* FREECIV_JSON_CONNECTION */
87570
87571 for (i = 0; i < real_packet->bits_num; i++) {
87572#ifdef FREECIV_JSON_CONNECTION
87573 /* Next array element. */
87574 field_addr.sub_location->number = i;
87575#endif /* FREECIV_JSON_CONNECTION */
87576
87577 e |= DIO_PUT(string, &dout, &field_addr, real_packet->pretty_names[i]);
87578 }
87579
87580#ifdef FREECIV_JSON_CONNECTION
87581 /* Exit array. */
87582 FC_FREE(field_addr.sub_location);
87583#endif /* FREECIV_JSON_CONNECTION */
87584 }
87585
87586 if (e) {
87587 log_packet_detailed("'pretty_names' field error detected");
87588 }
87589#endif /* FREECIV_DELTA_PROTOCOL */
87590
87591 SEND_PACKET_END(PACKET_SERVER_SETTING_BITWISE);
87592}
87593
87594 int send_packet_server_setting_bitwise(struct connection *pc, const struct packet_server_setting_bitwise *packet)
87595{
87596 if (!pc->used) {
87597 log_error("WARNING: trying to send data to the closed connection %s",
87598 conn_description(pc));
87599 return -1;
87600 }
87601 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SERVER_SETTING_BITWISE].packet != nullptr, -1,
87602 "Handler for PACKET_SERVER_SETTING_BITWISE not installed");
87603 return pc->phs.handlers->send[PACKET_SERVER_SETTING_BITWISE].packet(pc, packet);
87604}
87605
87606 static inline void init_packet_set_topology(struct packet_set_topology *packet)
87607{
87608 memset(packet, 0, sizeof(*packet));
87609}
87610
87611#define free_packet_set_topology(_packet) (void) 0
87612#define destroy_packet_set_topology free
87613
87614#ifdef FREECIV_DELTA_PROTOCOL
87615#define hash_packet_set_topology_100 hash_const
87616#define cmp_packet_set_topology_100 cmp_const
87617 BV_DEFINE(packet_set_topology_100_fields, 2);
87618#endif /* FREECIV_DELTA_PROTOCOL */
87619
87620 static struct packet_set_topology *receive_packet_set_topology_100(struct connection *pc)
87621{
87622#define FREE_PACKET_STRUCT(_packet) free_packet_set_topology(_packet)
87623 RECEIVE_PACKET_START(packet_set_topology, real_packet);
87624
87625#ifdef FREECIV_JSON_CONNECTION
87626 struct plocation field_addr;
87627 {
87628 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
87629 field_addr = *field_addr_tmp;
87630 FC_FREE(field_addr_tmp);
87631 }
87632#endif /* FREECIV_JSON_CONNECTION */
87633
87634 log_packet_detailed("packet_set_topology_100: got info about ()");
87635
87636#ifdef FREECIV_DELTA_PROTOCOL
87637 packet_set_topology_100_fields fields;
87638 struct packet_set_topology *old;
87639 struct genhash **hash = pc->phs.received + PACKET_SET_TOPOLOGY;
87640
87641 if (nullptr == *hash) {
87642 *hash = genhash_new_full(hash_packet_set_topology_100, cmp_packet_set_topology_100,
87643 nullptr, nullptr, nullptr, destroy_packet_set_topology);
87644 }
87645
87646 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
87647 *real_packet = *old;
87648 } else {
87649 /* packet is already initialized empty */
87650 log_packet_detailed(" no old info");
87651 }
87652
87653#ifdef FREECIV_JSON_CONNECTION
87654 field_addr.name = "fields";
87655#endif /* FREECIV_JSON_CONNECTION */
87656 DIO_BV_GET(&din, &field_addr, fields);
87657
87658 if (BV_ISSET(fields, 0)) {
87659 log_packet_detailed(" got field 'topology_id'");
87660
87661#ifdef FREECIV_JSON_CONNECTION
87662 field_addr.name = "topology_id";
87663#endif /* FREECIV_JSON_CONNECTION */
87664
87665 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->topology_id)) {
87666 RECEIVE_PACKET_FIELD_ERROR(topology_id);
87667 }
87668 }
87669
87670 if (BV_ISSET(fields, 1)) {
87671 log_packet_detailed(" got field 'wrap_id'");
87672
87673#ifdef FREECIV_JSON_CONNECTION
87674 field_addr.name = "wrap_id";
87675#endif /* FREECIV_JSON_CONNECTION */
87676
87677 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->wrap_id)) {
87678 RECEIVE_PACKET_FIELD_ERROR(wrap_id);
87679 }
87680 }
87681
87682 if (nullptr == old) {
87683 old = fc_malloc(sizeof(*old));
87684 init_packet_set_topology(old);
87685 *old = *real_packet;
87686 genhash_insert(*hash, old, old);
87687 } else {
87688 *old = *real_packet;
87689 }
87690
87691#else /* FREECIV_DELTA_PROTOCOL */
87692#ifdef FREECIV_JSON_CONNECTION
87693 field_addr.name = "topology_id";
87694#endif /* FREECIV_JSON_CONNECTION */
87695
87696 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->topology_id)) {
87697 RECEIVE_PACKET_FIELD_ERROR(topology_id);
87698 }
87699
87700#ifdef FREECIV_JSON_CONNECTION
87701 field_addr.name = "wrap_id";
87702#endif /* FREECIV_JSON_CONNECTION */
87703
87704 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->wrap_id)) {
87705 RECEIVE_PACKET_FIELD_ERROR(wrap_id);
87706 }
87707#endif /* FREECIV_DELTA_PROTOCOL */
87708
87709 RECEIVE_PACKET_END(real_packet);
87710#undef FREE_PACKET_STRUCT
87711}
87712
87713 static int send_packet_set_topology_100(struct connection *pc, const struct packet_set_topology *packet)
87714{
87715 const struct packet_set_topology *real_packet = packet;
87716 int e;
87717 SEND_PACKET_START(PACKET_SET_TOPOLOGY);
87718
87719 log_packet_detailed("packet_set_topology_100: sending info about ()");
87720
87721#ifdef FREECIV_DELTA_PROTOCOL
87722 packet_set_topology_100_fields fields;
87723 struct packet_set_topology *old;
87724 bool differ;
87725 struct genhash **hash = pc->phs.sent + PACKET_SET_TOPOLOGY;
87726
87727 if (nullptr == *hash) {
87728 *hash = genhash_new_full(hash_packet_set_topology_100, cmp_packet_set_topology_100,
87729 nullptr, nullptr, nullptr, destroy_packet_set_topology);
87730 }
87731 BV_CLR_ALL(fields);
87732
87733 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
87734 old = fc_malloc(sizeof(*old));
87735 /* temporary bitcopy just to insert correctly */
87736 *old = *real_packet;
87737 genhash_insert(*hash, old, old);
87738 init_packet_set_topology(old);
87739 }
87740
87741 differ = (old->topology_id != real_packet->topology_id);
87742 if (differ) {
87743 BV_SET(fields, 0);
87744 }
87745
87746 differ = (old->wrap_id != real_packet->wrap_id);
87747 if (differ) {
87748 BV_SET(fields, 1);
87749 }
87750#endif /* FREECIV_DELTA_PROTOCOL */
87751
87752#ifdef FREECIV_JSON_CONNECTION
87753 struct plocation field_addr;
87754 {
87755 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
87756 field_addr = *field_addr_tmp;
87757 FC_FREE(field_addr_tmp);
87758 }
87759#endif /* FREECIV_JSON_CONNECTION */
87760
87761#ifdef FREECIV_DELTA_PROTOCOL
87762#ifdef FREECIV_JSON_CONNECTION
87763 field_addr.name = "fields";
87764#endif /* FREECIV_JSON_CONNECTION */
87765 e = 0;
87766 e |= DIO_BV_PUT(&dout, &field_addr, fields);
87767 if (e) {
87768 log_packet_detailed("fields bitvector error detected");
87769 }
87770
87771 if (BV_ISSET(fields, 0)) {
87772 log_packet_detailed(" field 'topology_id' has changed");
87773
87774#ifdef FREECIV_JSON_CONNECTION
87775 field_addr.name = "topology_id";
87776#endif /* FREECIV_JSON_CONNECTION */
87777 e = 0;
87778
87779 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->topology_id);
87780
87781 if (e) {
87782 log_packet_detailed("'topology_id' field error detected");
87783 }
87784 }
87785
87786 if (BV_ISSET(fields, 1)) {
87787 log_packet_detailed(" field 'wrap_id' has changed");
87788
87789#ifdef FREECIV_JSON_CONNECTION
87790 field_addr.name = "wrap_id";
87791#endif /* FREECIV_JSON_CONNECTION */
87792 e = 0;
87793
87794 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->wrap_id);
87795
87796 if (e) {
87797 log_packet_detailed("'wrap_id' field error detected");
87798 }
87799 }
87800
87801 *old = *real_packet;
87802
87803#else /* FREECIV_DELTA_PROTOCOL */
87804#ifdef FREECIV_JSON_CONNECTION
87805 field_addr.name = "topology_id";
87806#endif /* FREECIV_JSON_CONNECTION */
87807 e = 0;
87808
87809 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->topology_id);
87810
87811 if (e) {
87812 log_packet_detailed("'topology_id' field error detected");
87813 }
87814
87815#ifdef FREECIV_JSON_CONNECTION
87816 field_addr.name = "wrap_id";
87817#endif /* FREECIV_JSON_CONNECTION */
87818 e = 0;
87819
87820 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->wrap_id);
87821
87822 if (e) {
87823 log_packet_detailed("'wrap_id' field error detected");
87824 }
87825#endif /* FREECIV_DELTA_PROTOCOL */
87826
87827 SEND_PACKET_END(PACKET_SET_TOPOLOGY);
87828}
87829
87830 int send_packet_set_topology(struct connection *pc, const struct packet_set_topology *packet)
87831{
87832 if (!pc->used) {
87833 log_error("WARNING: trying to send data to the closed connection %s",
87834 conn_description(pc));
87835 return -1;
87836 }
87837 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SET_TOPOLOGY].packet != nullptr, -1,
87838 "Handler for PACKET_SET_TOPOLOGY not installed");
87839 return pc->phs.handlers->send[PACKET_SET_TOPOLOGY].packet(pc, packet);
87840}
87841
87842 static inline void init_packet_ruleset_effect(struct packet_ruleset_effect *packet)
87843{
87844 memset(packet, 0, sizeof(*packet));
87845
87846 requirement_vector_init(&packet->reqs);
87847}
87848
87849 static inline void free_packet_ruleset_effect(struct packet_ruleset_effect *packet)
87850{
87851 requirement_vector_free(&packet->reqs);
87852}
87853
87854 static inline void destroy_packet_ruleset_effect(void *packet)
87855{
87856 free_packet_ruleset_effect((struct packet_ruleset_effect *) packet);
87857 free(packet);
87858}
87859
87860#ifdef FREECIV_DELTA_PROTOCOL
87861#define hash_packet_ruleset_effect_100 hash_const
87862#define cmp_packet_ruleset_effect_100 cmp_const
87863 BV_DEFINE(packet_ruleset_effect_100_fields, 5);
87864#endif /* FREECIV_DELTA_PROTOCOL */
87865
87866 static struct packet_ruleset_effect *receive_packet_ruleset_effect_100(struct connection *pc)
87867{
87868#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_effect(_packet)
87869 RECEIVE_PACKET_START(packet_ruleset_effect, real_packet);
87870
87871#ifdef FREECIV_JSON_CONNECTION
87872 struct plocation field_addr;
87873 {
87874 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
87875 field_addr = *field_addr_tmp;
87876 FC_FREE(field_addr_tmp);
87877 }
87878#endif /* FREECIV_JSON_CONNECTION */
87879
87880 log_packet_detailed("packet_ruleset_effect_100: got info about ()");
87881
87882#ifdef FREECIV_DELTA_PROTOCOL
87883 packet_ruleset_effect_100_fields fields;
87884 struct packet_ruleset_effect *old;
87885 struct genhash **hash = pc->phs.received + PACKET_RULESET_EFFECT;
87886
87887 if (nullptr == *hash) {
87888 *hash = genhash_new_full(hash_packet_ruleset_effect_100, cmp_packet_ruleset_effect_100,
87889 nullptr, nullptr, nullptr, destroy_packet_ruleset_effect);
87890 }
87891
87892 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
87893 real_packet->effect_type = old->effect_type;
87894 real_packet->effect_value = old->effect_value;
87895 real_packet->has_multiplier = old->has_multiplier;
87896 real_packet->multiplier = old->multiplier;
87897 requirement_vector_copy(&real_packet->reqs, &old->reqs);
87898 } else {
87899 /* packet is already initialized empty */
87900 log_packet_detailed(" no old info");
87901 }
87902
87903#ifdef FREECIV_JSON_CONNECTION
87904 field_addr.name = "fields";
87905#endif /* FREECIV_JSON_CONNECTION */
87906 DIO_BV_GET(&din, &field_addr, fields);
87907
87908 if (BV_ISSET(fields, 0)) {
87909 log_packet_detailed(" got field 'effect_type'");
87910
87911#ifdef FREECIV_JSON_CONNECTION
87912 field_addr.name = "effect_type";
87913#endif /* FREECIV_JSON_CONNECTION */
87914
87915 {
87916 int readin;
87917
87918 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
87919 RECEIVE_PACKET_FIELD_ERROR(effect_type);
87920 }
87921 real_packet->effect_type = readin;
87922 }
87923 }
87924
87925 if (BV_ISSET(fields, 1)) {
87926 log_packet_detailed(" got field 'effect_value'");
87927
87928#ifdef FREECIV_JSON_CONNECTION
87929 field_addr.name = "effect_value";
87930#endif /* FREECIV_JSON_CONNECTION */
87931
87932 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->effect_value)) {
87933 RECEIVE_PACKET_FIELD_ERROR(effect_value);
87934 }
87935 }
87936
87937 real_packet->has_multiplier = BV_ISSET(fields, 2);
87938
87939 if (BV_ISSET(fields, 3)) {
87940 log_packet_detailed(" got field 'multiplier'");
87941
87942#ifdef FREECIV_JSON_CONNECTION
87943 field_addr.name = "multiplier";
87944#endif /* FREECIV_JSON_CONNECTION */
87945
87946 {
87947 int readin;
87948
87949 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
87950 RECEIVE_PACKET_FIELD_ERROR(multiplier);
87951 }
87952 real_packet->multiplier = readin;
87953 }
87954 }
87955
87956 if (BV_ISSET(fields, 4)) {
87957 log_packet_detailed(" got field 'reqs'");
87958
87959#ifdef FREECIV_JSON_CONNECTION
87960 field_addr.name = "reqs";
87961#endif /* FREECIV_JSON_CONNECTION */
87962
87963 {
87964 int i;
87965
87966 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
87967 RECEIVE_PACKET_FIELD_ERROR(reqs);
87968 }
87969 requirement_vector_reserve(&real_packet->reqs, i);
87970
87971#ifdef FREECIV_JSON_CONNECTION
87972 /* Enter array. */
87973 field_addr.sub_location = plocation_elem_new(0);
87974#endif /* FREECIV_JSON_CONNECTION */
87975
87976 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
87977#ifdef FREECIV_JSON_CONNECTION
87978 /* Next array element */
87979 field_addr.sub_location->number = i;
87980#endif /* FREECIV_JSON_CONNECTION */
87981
87982 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
87983 RECEIVE_PACKET_FIELD_ERROR(reqs);
87984 }
87985 }
87986
87987#ifdef FREECIV_JSON_CONNECTION
87988 /* Exit array. */
87989 FC_FREE(field_addr.sub_location);
87990#endif /* FREECIV_JSON_CONNECTION */
87991 }
87992 }
87993
87994 if (nullptr == old) {
87995 old = fc_malloc(sizeof(*old));
87996 init_packet_ruleset_effect(old);
87997 old->effect_type = real_packet->effect_type;
87998 old->effect_value = real_packet->effect_value;
87999 old->has_multiplier = real_packet->has_multiplier;
88000 old->multiplier = real_packet->multiplier;
88001 requirement_vector_copy(&old->reqs, &real_packet->reqs);
88002 genhash_insert(*hash, old, old);
88003 } else {
88004 old->effect_type = real_packet->effect_type;
88005 old->effect_value = real_packet->effect_value;
88006 old->has_multiplier = real_packet->has_multiplier;
88007 old->multiplier = real_packet->multiplier;
88008 requirement_vector_copy(&old->reqs, &real_packet->reqs);
88009 }
88010
88011#else /* FREECIV_DELTA_PROTOCOL */
88012#ifdef FREECIV_JSON_CONNECTION
88013 field_addr.name = "effect_type";
88014#endif /* FREECIV_JSON_CONNECTION */
88015
88016 {
88017 int readin;
88018
88019 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
88020 RECEIVE_PACKET_FIELD_ERROR(effect_type);
88021 }
88022 real_packet->effect_type = readin;
88023 }
88024
88025#ifdef FREECIV_JSON_CONNECTION
88026 field_addr.name = "effect_value";
88027#endif /* FREECIV_JSON_CONNECTION */
88028
88029 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->effect_value)) {
88030 RECEIVE_PACKET_FIELD_ERROR(effect_value);
88031 }
88032
88033#ifdef FREECIV_JSON_CONNECTION
88034 field_addr.name = "has_multiplier";
88035#endif /* FREECIV_JSON_CONNECTION */
88036
88037 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->has_multiplier)) {
88038 RECEIVE_PACKET_FIELD_ERROR(has_multiplier);
88039 }
88040
88041#ifdef FREECIV_JSON_CONNECTION
88042 field_addr.name = "multiplier";
88043#endif /* FREECIV_JSON_CONNECTION */
88044
88045 {
88046 int readin;
88047
88048 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
88049 RECEIVE_PACKET_FIELD_ERROR(multiplier);
88050 }
88051 real_packet->multiplier = readin;
88052 }
88053
88054#ifdef FREECIV_JSON_CONNECTION
88055 field_addr.name = "reqs";
88056#endif /* FREECIV_JSON_CONNECTION */
88057
88058 {
88059 int i;
88060
88061 if (!DIO_GET(arraylen, &din, &field_addr, &i)) {
88062 RECEIVE_PACKET_FIELD_ERROR(reqs);
88063 }
88064 requirement_vector_reserve(&real_packet->reqs, i);
88065
88066#ifdef FREECIV_JSON_CONNECTION
88067 /* Enter array. */
88068 field_addr.sub_location = plocation_elem_new(0);
88069#endif /* FREECIV_JSON_CONNECTION */
88070
88071 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
88072#ifdef FREECIV_JSON_CONNECTION
88073 /* Next array element */
88074 field_addr.sub_location->number = i;
88075#endif /* FREECIV_JSON_CONNECTION */
88076
88077 if (!DIO_GET(requirement, &din, &field_addr, &real_packet->reqs.p[i])) {
88078 RECEIVE_PACKET_FIELD_ERROR(reqs);
88079 }
88080 }
88081
88082#ifdef FREECIV_JSON_CONNECTION
88083 /* Exit array. */
88084 FC_FREE(field_addr.sub_location);
88085#endif /* FREECIV_JSON_CONNECTION */
88086 }
88087#endif /* FREECIV_DELTA_PROTOCOL */
88088
88089 RECEIVE_PACKET_END(real_packet);
88090#undef FREE_PACKET_STRUCT
88091}
88092
88093 static int send_packet_ruleset_effect_100(struct connection *pc, const struct packet_ruleset_effect *packet)
88094{
88095 const struct packet_ruleset_effect *real_packet = packet;
88096 int e;
88097 SEND_PACKET_START(PACKET_RULESET_EFFECT);
88098
88099 log_packet_detailed("packet_ruleset_effect_100: sending info about ()");
88100
88101#ifdef FREECIV_DELTA_PROTOCOL
88102 packet_ruleset_effect_100_fields fields;
88103 struct packet_ruleset_effect *old;
88104 bool differ;
88105 struct genhash **hash = pc->phs.sent + PACKET_RULESET_EFFECT;
88106
88107 if (nullptr == *hash) {
88108 *hash = genhash_new_full(hash_packet_ruleset_effect_100, cmp_packet_ruleset_effect_100,
88109 nullptr, nullptr, nullptr, destroy_packet_ruleset_effect);
88110 }
88111 BV_CLR_ALL(fields);
88112
88113 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
88114 old = fc_malloc(sizeof(*old));
88115 /* temporary bitcopy just to insert correctly */
88116 *old = *real_packet;
88117 genhash_insert(*hash, old, old);
88118 init_packet_ruleset_effect(old);
88119 }
88120
88121 differ = (old->effect_type != real_packet->effect_type);
88122 if (differ) {
88123 BV_SET(fields, 0);
88124 }
88125
88126 differ = (old->effect_value != real_packet->effect_value);
88127 if (differ) {
88128 BV_SET(fields, 1);
88129 }
88130
88131 /* folded into head */
88132 if (real_packet->has_multiplier) {
88133 BV_SET(fields, 2);
88134 }
88135
88136 differ = (old->multiplier != real_packet->multiplier);
88137 if (differ) {
88138 BV_SET(fields, 3);
88139 }
88140
88141 differ = (requirement_vector_size(&old->reqs) != requirement_vector_size(&real_packet->reqs));
88142 if (!differ) {
88143 int i;
88144
88145 for (i = 0; i < requirement_vector_size(&old->reqs); i++) {
88146 differ = !are_requirements_equal(&old->reqs.p[i], &real_packet->reqs.p[i]);
88147 if (differ) {
88148 break;
88149 }
88150 }
88151 }
88152 if (differ) {
88153 BV_SET(fields, 4);
88154 }
88155#endif /* FREECIV_DELTA_PROTOCOL */
88156
88157#ifdef FREECIV_JSON_CONNECTION
88158 struct plocation field_addr;
88159 {
88160 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
88161 field_addr = *field_addr_tmp;
88162 FC_FREE(field_addr_tmp);
88163 }
88164#endif /* FREECIV_JSON_CONNECTION */
88165
88166#ifdef FREECIV_DELTA_PROTOCOL
88167#ifdef FREECIV_JSON_CONNECTION
88168 field_addr.name = "fields";
88169#endif /* FREECIV_JSON_CONNECTION */
88170 e = 0;
88171 e |= DIO_BV_PUT(&dout, &field_addr, fields);
88172 if (e) {
88173 log_packet_detailed("fields bitvector error detected");
88174 }
88175
88176 if (BV_ISSET(fields, 0)) {
88177 log_packet_detailed(" field 'effect_type' has changed");
88178
88179#ifdef FREECIV_JSON_CONNECTION
88180 field_addr.name = "effect_type";
88181#endif /* FREECIV_JSON_CONNECTION */
88182 e = 0;
88183
88184 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->effect_type);
88185
88186 if (e) {
88187 log_packet_detailed("'effect_type' field error detected");
88188 }
88189 }
88190
88191 if (BV_ISSET(fields, 1)) {
88192 log_packet_detailed(" field 'effect_value' has changed");
88193
88194#ifdef FREECIV_JSON_CONNECTION
88195 field_addr.name = "effect_value";
88196#endif /* FREECIV_JSON_CONNECTION */
88197 e = 0;
88198
88199 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->effect_value);
88200
88201 if (e) {
88202 log_packet_detailed("'effect_value' field error detected");
88203 }
88204 }
88205
88206 /* field 2 is folded into the header */
88207
88208 if (BV_ISSET(fields, 3)) {
88209 log_packet_detailed(" field 'multiplier' has changed");
88210
88211#ifdef FREECIV_JSON_CONNECTION
88212 field_addr.name = "multiplier";
88213#endif /* FREECIV_JSON_CONNECTION */
88214 e = 0;
88215
88216 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->multiplier);
88217
88218 if (e) {
88219 log_packet_detailed("'multiplier' field error detected");
88220 }
88221 }
88222
88223 if (BV_ISSET(fields, 4)) {
88224 log_packet_detailed(" field 'reqs' has changed");
88225
88226#ifdef FREECIV_JSON_CONNECTION
88227 field_addr.name = "reqs";
88228#endif /* FREECIV_JSON_CONNECTION */
88229 e = 0;
88230
88231 {
88232 int i;
88233
88234 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
88235 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
88236
88237#ifdef FREECIV_JSON_CONNECTION
88238 /* Enter array. */
88239 field_addr.sub_location = plocation_elem_new(0);
88240#endif /* FREECIV_JSON_CONNECTION */
88241
88242 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
88243#ifdef FREECIV_JSON_CONNECTION
88244 /* Next array element. */
88245 field_addr.sub_location->number = i;
88246#endif /* FREECIV_JSON_CONNECTION */
88247
88248 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
88249 }
88250
88251#ifdef FREECIV_JSON_CONNECTION
88252 /* Exit array. */
88253 FC_FREE(field_addr.sub_location);
88254#endif /* FREECIV_JSON_CONNECTION */
88255 }
88256
88257 if (e) {
88258 log_packet_detailed("'reqs' field error detected");
88259 }
88260 }
88261
88262 old->effect_type = real_packet->effect_type;
88263 old->effect_value = real_packet->effect_value;
88264 old->has_multiplier = real_packet->has_multiplier;
88265 old->multiplier = real_packet->multiplier;
88266 requirement_vector_copy(&old->reqs, &real_packet->reqs);
88267
88268#else /* FREECIV_DELTA_PROTOCOL */
88269#ifdef FREECIV_JSON_CONNECTION
88270 field_addr.name = "effect_type";
88271#endif /* FREECIV_JSON_CONNECTION */
88272 e = 0;
88273
88274 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->effect_type);
88275
88276 if (e) {
88277 log_packet_detailed("'effect_type' field error detected");
88278 }
88279
88280#ifdef FREECIV_JSON_CONNECTION
88281 field_addr.name = "effect_value";
88282#endif /* FREECIV_JSON_CONNECTION */
88283 e = 0;
88284
88285 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->effect_value);
88286
88287 if (e) {
88288 log_packet_detailed("'effect_value' field error detected");
88289 }
88290
88291#ifdef FREECIV_JSON_CONNECTION
88292 field_addr.name = "has_multiplier";
88293#endif /* FREECIV_JSON_CONNECTION */
88294 e = 0;
88295
88296 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->has_multiplier);
88297
88298 if (e) {
88299 log_packet_detailed("'has_multiplier' field error detected");
88300 }
88301
88302#ifdef FREECIV_JSON_CONNECTION
88303 field_addr.name = "multiplier";
88304#endif /* FREECIV_JSON_CONNECTION */
88305 e = 0;
88306
88307 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->multiplier);
88308
88309 if (e) {
88310 log_packet_detailed("'multiplier' field error detected");
88311 }
88312
88313#ifdef FREECIV_JSON_CONNECTION
88314 field_addr.name = "reqs";
88315#endif /* FREECIV_JSON_CONNECTION */
88316 e = 0;
88317
88318 {
88319 int i;
88320
88321 fc_assert(requirement_vector_size(&real_packet->reqs) < MAX_UINT16);
88322 e |= DIO_PUT(arraylen, &dout, &field_addr, requirement_vector_size(&real_packet->reqs));
88323
88324#ifdef FREECIV_JSON_CONNECTION
88325 /* Enter array. */
88326 field_addr.sub_location = plocation_elem_new(0);
88327#endif /* FREECIV_JSON_CONNECTION */
88328
88329 for (i = 0; i < requirement_vector_size(&real_packet->reqs); i++) {
88330#ifdef FREECIV_JSON_CONNECTION
88331 /* Next array element. */
88332 field_addr.sub_location->number = i;
88333#endif /* FREECIV_JSON_CONNECTION */
88334
88335 e |= DIO_PUT(requirement, &dout, &field_addr, &real_packet->reqs.p[i]);
88336 }
88337
88338#ifdef FREECIV_JSON_CONNECTION
88339 /* Exit array. */
88340 FC_FREE(field_addr.sub_location);
88341#endif /* FREECIV_JSON_CONNECTION */
88342 }
88343
88344 if (e) {
88345 log_packet_detailed("'reqs' field error detected");
88346 }
88347#endif /* FREECIV_DELTA_PROTOCOL */
88348
88349 SEND_PACKET_END(PACKET_RULESET_EFFECT);
88350}
88351
88352 int send_packet_ruleset_effect(struct connection *pc, const struct packet_ruleset_effect *packet)
88353{
88354 if (!pc->used) {
88355 log_error("WARNING: trying to send data to the closed connection %s",
88356 conn_description(pc));
88357 return -1;
88358 }
88359 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_EFFECT].packet != nullptr, -1,
88360 "Handler for PACKET_RULESET_EFFECT not installed");
88361 return pc->phs.handlers->send[PACKET_RULESET_EFFECT].packet(pc, packet);
88362}
88363
88364 void lsend_packet_ruleset_effect(struct conn_list *dest, const struct packet_ruleset_effect *packet)
88365{
88366 conn_list_iterate(dest, pconn) {
88367 send_packet_ruleset_effect(pconn, packet);
88368 } conn_list_iterate_end;
88369}
88370
88371 static inline void init_packet_ruleset_resource(struct packet_ruleset_resource *packet)
88372{
88373 memset(packet, 0, sizeof(*packet));
88374}
88375
88376#define free_packet_ruleset_resource(_packet) (void) 0
88377#define destroy_packet_ruleset_resource free
88378
88379#ifdef FREECIV_DELTA_PROTOCOL
88380#define hash_packet_ruleset_resource_100 hash_const
88381#define cmp_packet_ruleset_resource_100 cmp_const
88382 BV_DEFINE(packet_ruleset_resource_100_fields, 2);
88383#endif /* FREECIV_DELTA_PROTOCOL */
88384
88385 static struct packet_ruleset_resource *receive_packet_ruleset_resource_100(struct connection *pc)
88386{
88387#define FREE_PACKET_STRUCT(_packet) free_packet_ruleset_resource(_packet)
88388 RECEIVE_PACKET_START(packet_ruleset_resource, real_packet);
88389
88390#ifdef FREECIV_JSON_CONNECTION
88391 struct plocation field_addr;
88392 {
88393 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
88394 field_addr = *field_addr_tmp;
88395 FC_FREE(field_addr_tmp);
88396 }
88397#endif /* FREECIV_JSON_CONNECTION */
88398
88399 log_packet_detailed("packet_ruleset_resource_100: got info about ()");
88400
88401#ifdef FREECIV_DELTA_PROTOCOL
88402 packet_ruleset_resource_100_fields fields;
88403 struct packet_ruleset_resource *old;
88404 struct genhash **hash = pc->phs.received + PACKET_RULESET_RESOURCE;
88405
88406 if (nullptr == *hash) {
88407 *hash = genhash_new_full(hash_packet_ruleset_resource_100, cmp_packet_ruleset_resource_100,
88408 nullptr, nullptr, nullptr, destroy_packet_ruleset_resource);
88409 }
88410
88411 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
88412 *real_packet = *old;
88413 } else {
88414 /* packet is already initialized empty */
88415 log_packet_detailed(" no old info");
88416 }
88417
88418#ifdef FREECIV_JSON_CONNECTION
88419 field_addr.name = "fields";
88420#endif /* FREECIV_JSON_CONNECTION */
88421 DIO_BV_GET(&din, &field_addr, fields);
88422
88423 if (BV_ISSET(fields, 0)) {
88424 log_packet_detailed(" got field 'id'");
88425
88426#ifdef FREECIV_JSON_CONNECTION
88427 field_addr.name = "id";
88428#endif /* FREECIV_JSON_CONNECTION */
88429
88430 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
88431 RECEIVE_PACKET_FIELD_ERROR(id);
88432 }
88433 }
88434
88435 if (BV_ISSET(fields, 1)) {
88436 log_packet_detailed(" got field 'output'");
88437
88438#ifdef FREECIV_JSON_CONNECTION
88439 field_addr.name = "output";
88440#endif /* FREECIV_JSON_CONNECTION */
88441
88442 {
88443 int i;
88444
88445
88446#ifdef FREECIV_JSON_CONNECTION
88447 /* Enter array. */
88448 field_addr.sub_location = plocation_elem_new(0);
88449#endif /* FREECIV_JSON_CONNECTION */
88450
88451 for (i = 0; i < O_LAST; i++) {
88452#ifdef FREECIV_JSON_CONNECTION
88453 /* Next array element */
88454 field_addr.sub_location->number = i;
88455#endif /* FREECIV_JSON_CONNECTION */
88456
88457 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output[i])) {
88458 RECEIVE_PACKET_FIELD_ERROR(output);
88459 }
88460 }
88461
88462#ifdef FREECIV_JSON_CONNECTION
88463 /* Exit array. */
88464 FC_FREE(field_addr.sub_location);
88465#endif /* FREECIV_JSON_CONNECTION */
88466 }
88467 }
88468
88469 if (nullptr == old) {
88470 old = fc_malloc(sizeof(*old));
88471 init_packet_ruleset_resource(old);
88472 *old = *real_packet;
88473 genhash_insert(*hash, old, old);
88474 } else {
88475 *old = *real_packet;
88476 }
88477
88478#else /* FREECIV_DELTA_PROTOCOL */
88479#ifdef FREECIV_JSON_CONNECTION
88480 field_addr.name = "id";
88481#endif /* FREECIV_JSON_CONNECTION */
88482
88483 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->id)) {
88484 RECEIVE_PACKET_FIELD_ERROR(id);
88485 }
88486
88487#ifdef FREECIV_JSON_CONNECTION
88488 field_addr.name = "output";
88489#endif /* FREECIV_JSON_CONNECTION */
88490
88491 {
88492 int i;
88493
88494
88495#ifdef FREECIV_JSON_CONNECTION
88496 /* Enter array. */
88497 field_addr.sub_location = plocation_elem_new(0);
88498#endif /* FREECIV_JSON_CONNECTION */
88499
88500 for (i = 0; i < O_LAST; i++) {
88501#ifdef FREECIV_JSON_CONNECTION
88502 /* Next array element */
88503 field_addr.sub_location->number = i;
88504#endif /* FREECIV_JSON_CONNECTION */
88505
88506 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output[i])) {
88507 RECEIVE_PACKET_FIELD_ERROR(output);
88508 }
88509 }
88510
88511#ifdef FREECIV_JSON_CONNECTION
88512 /* Exit array. */
88513 FC_FREE(field_addr.sub_location);
88514#endif /* FREECIV_JSON_CONNECTION */
88515 }
88516#endif /* FREECIV_DELTA_PROTOCOL */
88517
88518 RECEIVE_PACKET_END(real_packet);
88519#undef FREE_PACKET_STRUCT
88520}
88521
88522 static int send_packet_ruleset_resource_100(struct connection *pc, const struct packet_ruleset_resource *packet)
88523{
88524 const struct packet_ruleset_resource *real_packet = packet;
88525 int e;
88526 SEND_PACKET_START(PACKET_RULESET_RESOURCE);
88527
88528 log_packet_detailed("packet_ruleset_resource_100: sending info about ()");
88529
88530#ifdef FREECIV_DELTA_PROTOCOL
88531 packet_ruleset_resource_100_fields fields;
88532 struct packet_ruleset_resource *old;
88533 bool differ;
88534 struct genhash **hash = pc->phs.sent + PACKET_RULESET_RESOURCE;
88535
88536 if (nullptr == *hash) {
88537 *hash = genhash_new_full(hash_packet_ruleset_resource_100, cmp_packet_ruleset_resource_100,
88538 nullptr, nullptr, nullptr, destroy_packet_ruleset_resource);
88539 }
88540 BV_CLR_ALL(fields);
88541
88542 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
88543 old = fc_malloc(sizeof(*old));
88544 /* temporary bitcopy just to insert correctly */
88545 *old = *real_packet;
88546 genhash_insert(*hash, old, old);
88547 init_packet_ruleset_resource(old);
88548 }
88549
88550 differ = (old->id != real_packet->id);
88551 if (differ) {
88552 BV_SET(fields, 0);
88553 }
88554
88555 differ = FALSE;
88556 {
88557 int i;
88558
88559 for (i = 0; i < O_LAST; i++) {
88560 differ = (old->output[i] != real_packet->output[i]);
88561 if (differ) {
88562 break;
88563 }
88564 }
88565 }
88566 if (differ) {
88567 BV_SET(fields, 1);
88568 }
88569#endif /* FREECIV_DELTA_PROTOCOL */
88570
88571#ifdef FREECIV_JSON_CONNECTION
88572 struct plocation field_addr;
88573 {
88574 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
88575 field_addr = *field_addr_tmp;
88576 FC_FREE(field_addr_tmp);
88577 }
88578#endif /* FREECIV_JSON_CONNECTION */
88579
88580#ifdef FREECIV_DELTA_PROTOCOL
88581#ifdef FREECIV_JSON_CONNECTION
88582 field_addr.name = "fields";
88583#endif /* FREECIV_JSON_CONNECTION */
88584 e = 0;
88585 e |= DIO_BV_PUT(&dout, &field_addr, fields);
88586 if (e) {
88587 log_packet_detailed("fields bitvector error detected");
88588 }
88589
88590 if (BV_ISSET(fields, 0)) {
88591 log_packet_detailed(" field 'id' has changed");
88592
88593#ifdef FREECIV_JSON_CONNECTION
88594 field_addr.name = "id";
88595#endif /* FREECIV_JSON_CONNECTION */
88596 e = 0;
88597
88598 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
88599
88600 if (e) {
88601 log_packet_detailed("'id' field error detected");
88602 }
88603 }
88604
88605 if (BV_ISSET(fields, 1)) {
88606 log_packet_detailed(" field 'output' has changed");
88607
88608#ifdef FREECIV_JSON_CONNECTION
88609 field_addr.name = "output";
88610#endif /* FREECIV_JSON_CONNECTION */
88611 e = 0;
88612
88613 {
88614 int i;
88615
88616#ifdef FREECIV_JSON_CONNECTION
88617 /* Create the array. */
88618 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
88619
88620 /* Enter array. */
88621 field_addr.sub_location = plocation_elem_new(0);
88622#endif /* FREECIV_JSON_CONNECTION */
88623
88624 for (i = 0; i < O_LAST; i++) {
88625#ifdef FREECIV_JSON_CONNECTION
88626 /* Next array element. */
88627 field_addr.sub_location->number = i;
88628#endif /* FREECIV_JSON_CONNECTION */
88629
88630 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output[i]);
88631 }
88632
88633#ifdef FREECIV_JSON_CONNECTION
88634 /* Exit array. */
88635 FC_FREE(field_addr.sub_location);
88636#endif /* FREECIV_JSON_CONNECTION */
88637 }
88638
88639 if (e) {
88640 log_packet_detailed("'output' field error detected");
88641 }
88642 }
88643
88644 *old = *real_packet;
88645
88646#else /* FREECIV_DELTA_PROTOCOL */
88647#ifdef FREECIV_JSON_CONNECTION
88648 field_addr.name = "id";
88649#endif /* FREECIV_JSON_CONNECTION */
88650 e = 0;
88651
88652 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->id);
88653
88654 if (e) {
88655 log_packet_detailed("'id' field error detected");
88656 }
88657
88658#ifdef FREECIV_JSON_CONNECTION
88659 field_addr.name = "output";
88660#endif /* FREECIV_JSON_CONNECTION */
88661 e = 0;
88662
88663 {
88664 int i;
88665
88666#ifdef FREECIV_JSON_CONNECTION
88667 /* Create the array. */
88668 e |= DIO_PUT(farray, &dout, &field_addr, O_LAST);
88669
88670 /* Enter array. */
88671 field_addr.sub_location = plocation_elem_new(0);
88672#endif /* FREECIV_JSON_CONNECTION */
88673
88674 for (i = 0; i < O_LAST; i++) {
88675#ifdef FREECIV_JSON_CONNECTION
88676 /* Next array element. */
88677 field_addr.sub_location->number = i;
88678#endif /* FREECIV_JSON_CONNECTION */
88679
88680 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output[i]);
88681 }
88682
88683#ifdef FREECIV_JSON_CONNECTION
88684 /* Exit array. */
88685 FC_FREE(field_addr.sub_location);
88686#endif /* FREECIV_JSON_CONNECTION */
88687 }
88688
88689 if (e) {
88690 log_packet_detailed("'output' field error detected");
88691 }
88692#endif /* FREECIV_DELTA_PROTOCOL */
88693
88694 SEND_PACKET_END(PACKET_RULESET_RESOURCE);
88695}
88696
88697 int send_packet_ruleset_resource(struct connection *pc, const struct packet_ruleset_resource *packet)
88698{
88699 if (!pc->used) {
88700 log_error("WARNING: trying to send data to the closed connection %s",
88701 conn_description(pc));
88702 return -1;
88703 }
88704 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_RULESET_RESOURCE].packet != nullptr, -1,
88705 "Handler for PACKET_RULESET_RESOURCE not installed");
88706 return pc->phs.handlers->send[PACKET_RULESET_RESOURCE].packet(pc, packet);
88707}
88708
88709 void lsend_packet_ruleset_resource(struct conn_list *dest, const struct packet_ruleset_resource *packet)
88710{
88711 conn_list_iterate(dest, pconn) {
88712 send_packet_ruleset_resource(pconn, packet);
88713 } conn_list_iterate_end;
88714}
88715
88716 static inline void init_packet_scenario_info(struct packet_scenario_info *packet)
88717{
88718 memset(packet, 0, sizeof(*packet));
88719}
88720
88721#define free_packet_scenario_info(_packet) (void) 0
88722#define destroy_packet_scenario_info free
88723
88724#ifdef FREECIV_DELTA_PROTOCOL
88725#define hash_packet_scenario_info_100 hash_const
88726#define cmp_packet_scenario_info_100 cmp_const
88727 BV_DEFINE(packet_scenario_info_100_fields, 14);
88728#endif /* FREECIV_DELTA_PROTOCOL */
88729
88730 static struct packet_scenario_info *receive_packet_scenario_info_100(struct connection *pc)
88731{
88732#define FREE_PACKET_STRUCT(_packet) free_packet_scenario_info(_packet)
88733 RECEIVE_PACKET_START(packet_scenario_info, real_packet);
88734
88735#ifdef FREECIV_JSON_CONNECTION
88736 struct plocation field_addr;
88737 {
88738 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
88739 field_addr = *field_addr_tmp;
88740 FC_FREE(field_addr_tmp);
88741 }
88742#endif /* FREECIV_JSON_CONNECTION */
88743
88744 log_packet_detailed("packet_scenario_info_100: got info about ()");
88745
88746#ifdef FREECIV_DELTA_PROTOCOL
88747 packet_scenario_info_100_fields fields;
88748 struct packet_scenario_info *old;
88749 struct genhash **hash = pc->phs.received + PACKET_SCENARIO_INFO;
88750
88751 if (nullptr == *hash) {
88752 *hash = genhash_new_full(hash_packet_scenario_info_100, cmp_packet_scenario_info_100,
88753 nullptr, nullptr, nullptr, destroy_packet_scenario_info);
88754 }
88755
88756 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
88757 *real_packet = *old;
88758 } else {
88759 /* packet is already initialized empty */
88760 log_packet_detailed(" no old info");
88761 }
88762
88763#ifdef FREECIV_JSON_CONNECTION
88764 field_addr.name = "fields";
88765#endif /* FREECIV_JSON_CONNECTION */
88766 DIO_BV_GET(&din, &field_addr, fields);
88767
88768 real_packet->is_scenario = BV_ISSET(fields, 0);
88769
88770 if (BV_ISSET(fields, 1)) {
88771 log_packet_detailed(" got field 'name'");
88772
88773#ifdef FREECIV_JSON_CONNECTION
88774 field_addr.name = "name";
88775#endif /* FREECIV_JSON_CONNECTION */
88776
88777 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
88778 RECEIVE_PACKET_FIELD_ERROR(name);
88779 }
88780 }
88781
88782 if (BV_ISSET(fields, 2)) {
88783 log_packet_detailed(" got field 'authors'");
88784
88785#ifdef FREECIV_JSON_CONNECTION
88786 field_addr.name = "authors";
88787#endif /* FREECIV_JSON_CONNECTION */
88788
88789 if (!DIO_GET(string, &din, &field_addr, real_packet->authors, sizeof(real_packet->authors))) {
88790 RECEIVE_PACKET_FIELD_ERROR(authors);
88791 }
88792 }
88793
88794 real_packet->players = BV_ISSET(fields, 3);
88795
88796 real_packet->startpos_nations = BV_ISSET(fields, 4);
88797
88798 real_packet->save_random = BV_ISSET(fields, 5);
88799
88800 real_packet->prevent_new_cities = BV_ISSET(fields, 6);
88801
88802 real_packet->lake_flooding = BV_ISSET(fields, 7);
88803
88804 real_packet->handmade = BV_ISSET(fields, 8);
88805
88806 real_packet->allow_ai_type_fallback = BV_ISSET(fields, 9);
88807
88808 real_packet->ruleset_locked = BV_ISSET(fields, 10);
88809
88810 if (BV_ISSET(fields, 11)) {
88811 log_packet_detailed(" got field 'datafile'");
88812
88813#ifdef FREECIV_JSON_CONNECTION
88814 field_addr.name = "datafile";
88815#endif /* FREECIV_JSON_CONNECTION */
88816
88817 if (!DIO_GET(string, &din, &field_addr, real_packet->datafile, sizeof(real_packet->datafile))) {
88818 RECEIVE_PACKET_FIELD_ERROR(datafile);
88819 }
88820 }
88821
88822 real_packet->have_resources = BV_ISSET(fields, 12);
88823
88824 if (BV_ISSET(fields, 13)) {
88825 log_packet_detailed(" got field 'req_caps'");
88826
88827#ifdef FREECIV_JSON_CONNECTION
88828 field_addr.name = "req_caps";
88829#endif /* FREECIV_JSON_CONNECTION */
88830
88831 if (!DIO_GET(string, &din, &field_addr, real_packet->req_caps, sizeof(real_packet->req_caps))) {
88832 RECEIVE_PACKET_FIELD_ERROR(req_caps);
88833 }
88834 }
88835
88836 if (nullptr == old) {
88837 old = fc_malloc(sizeof(*old));
88838 init_packet_scenario_info(old);
88839 *old = *real_packet;
88840 genhash_insert(*hash, old, old);
88841 } else {
88842 *old = *real_packet;
88843 }
88844
88845#else /* FREECIV_DELTA_PROTOCOL */
88846#ifdef FREECIV_JSON_CONNECTION
88847 field_addr.name = "is_scenario";
88848#endif /* FREECIV_JSON_CONNECTION */
88849
88850 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_scenario)) {
88851 RECEIVE_PACKET_FIELD_ERROR(is_scenario);
88852 }
88853
88854#ifdef FREECIV_JSON_CONNECTION
88855 field_addr.name = "name";
88856#endif /* FREECIV_JSON_CONNECTION */
88857
88858 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
88859 RECEIVE_PACKET_FIELD_ERROR(name);
88860 }
88861
88862#ifdef FREECIV_JSON_CONNECTION
88863 field_addr.name = "authors";
88864#endif /* FREECIV_JSON_CONNECTION */
88865
88866 if (!DIO_GET(string, &din, &field_addr, real_packet->authors, sizeof(real_packet->authors))) {
88867 RECEIVE_PACKET_FIELD_ERROR(authors);
88868 }
88869
88870#ifdef FREECIV_JSON_CONNECTION
88871 field_addr.name = "players";
88872#endif /* FREECIV_JSON_CONNECTION */
88873
88874 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->players)) {
88875 RECEIVE_PACKET_FIELD_ERROR(players);
88876 }
88877
88878#ifdef FREECIV_JSON_CONNECTION
88879 field_addr.name = "startpos_nations";
88880#endif /* FREECIV_JSON_CONNECTION */
88881
88882 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->startpos_nations)) {
88883 RECEIVE_PACKET_FIELD_ERROR(startpos_nations);
88884 }
88885
88886#ifdef FREECIV_JSON_CONNECTION
88887 field_addr.name = "save_random";
88888#endif /* FREECIV_JSON_CONNECTION */
88889
88890 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->save_random)) {
88891 RECEIVE_PACKET_FIELD_ERROR(save_random);
88892 }
88893
88894#ifdef FREECIV_JSON_CONNECTION
88895 field_addr.name = "prevent_new_cities";
88896#endif /* FREECIV_JSON_CONNECTION */
88897
88898 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->prevent_new_cities)) {
88899 RECEIVE_PACKET_FIELD_ERROR(prevent_new_cities);
88900 }
88901
88902#ifdef FREECIV_JSON_CONNECTION
88903 field_addr.name = "lake_flooding";
88904#endif /* FREECIV_JSON_CONNECTION */
88905
88906 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->lake_flooding)) {
88907 RECEIVE_PACKET_FIELD_ERROR(lake_flooding);
88908 }
88909
88910#ifdef FREECIV_JSON_CONNECTION
88911 field_addr.name = "handmade";
88912#endif /* FREECIV_JSON_CONNECTION */
88913
88914 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->handmade)) {
88915 RECEIVE_PACKET_FIELD_ERROR(handmade);
88916 }
88917
88918#ifdef FREECIV_JSON_CONNECTION
88919 field_addr.name = "allow_ai_type_fallback";
88920#endif /* FREECIV_JSON_CONNECTION */
88921
88922 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->allow_ai_type_fallback)) {
88923 RECEIVE_PACKET_FIELD_ERROR(allow_ai_type_fallback);
88924 }
88925
88926#ifdef FREECIV_JSON_CONNECTION
88927 field_addr.name = "ruleset_locked";
88928#endif /* FREECIV_JSON_CONNECTION */
88929
88930 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->ruleset_locked)) {
88931 RECEIVE_PACKET_FIELD_ERROR(ruleset_locked);
88932 }
88933
88934#ifdef FREECIV_JSON_CONNECTION
88935 field_addr.name = "datafile";
88936#endif /* FREECIV_JSON_CONNECTION */
88937
88938 if (!DIO_GET(string, &din, &field_addr, real_packet->datafile, sizeof(real_packet->datafile))) {
88939 RECEIVE_PACKET_FIELD_ERROR(datafile);
88940 }
88941
88942#ifdef FREECIV_JSON_CONNECTION
88943 field_addr.name = "have_resources";
88944#endif /* FREECIV_JSON_CONNECTION */
88945
88946 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->have_resources)) {
88947 RECEIVE_PACKET_FIELD_ERROR(have_resources);
88948 }
88949
88950#ifdef FREECIV_JSON_CONNECTION
88951 field_addr.name = "req_caps";
88952#endif /* FREECIV_JSON_CONNECTION */
88953
88954 if (!DIO_GET(string, &din, &field_addr, real_packet->req_caps, sizeof(real_packet->req_caps))) {
88955 RECEIVE_PACKET_FIELD_ERROR(req_caps);
88956 }
88957#endif /* FREECIV_DELTA_PROTOCOL */
88958
88959 RECEIVE_PACKET_END(real_packet);
88960#undef FREE_PACKET_STRUCT
88961}
88962
88963 static int send_packet_scenario_info_100(struct connection *pc, const struct packet_scenario_info *packet)
88964{
88965 const struct packet_scenario_info *real_packet = packet;
88966 int e;
88967 SEND_PACKET_START(PACKET_SCENARIO_INFO);
88968
88969 log_packet_detailed("packet_scenario_info_100: sending info about ()");
88970
88971#ifdef FREECIV_DELTA_PROTOCOL
88972 packet_scenario_info_100_fields fields;
88973 struct packet_scenario_info *old;
88974 bool differ;
88975 struct genhash **hash = pc->phs.sent + PACKET_SCENARIO_INFO;
88976
88977 if (nullptr == *hash) {
88978 *hash = genhash_new_full(hash_packet_scenario_info_100, cmp_packet_scenario_info_100,
88979 nullptr, nullptr, nullptr, destroy_packet_scenario_info);
88980 }
88981 BV_CLR_ALL(fields);
88982
88983 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
88984 old = fc_malloc(sizeof(*old));
88985 /* temporary bitcopy just to insert correctly */
88986 *old = *real_packet;
88987 genhash_insert(*hash, old, old);
88988 init_packet_scenario_info(old);
88989 }
88990
88991 /* folded into head */
88992 if (real_packet->is_scenario) {
88993 BV_SET(fields, 0);
88994 }
88995
88996 differ = (strcmp(old->name, real_packet->name) != 0);
88997 if (differ) {
88998 BV_SET(fields, 1);
88999 }
89000
89001 differ = (strcmp(old->authors, real_packet->authors) != 0);
89002 if (differ) {
89003 BV_SET(fields, 2);
89004 }
89005
89006 /* folded into head */
89007 if (real_packet->players) {
89008 BV_SET(fields, 3);
89009 }
89010
89011 /* folded into head */
89012 if (real_packet->startpos_nations) {
89013 BV_SET(fields, 4);
89014 }
89015
89016 /* folded into head */
89017 if (real_packet->save_random) {
89018 BV_SET(fields, 5);
89019 }
89020
89021 /* folded into head */
89022 if (real_packet->prevent_new_cities) {
89023 BV_SET(fields, 6);
89024 }
89025
89026 /* folded into head */
89027 if (real_packet->lake_flooding) {
89028 BV_SET(fields, 7);
89029 }
89030
89031 /* folded into head */
89032 if (real_packet->handmade) {
89033 BV_SET(fields, 8);
89034 }
89035
89036 /* folded into head */
89037 if (real_packet->allow_ai_type_fallback) {
89038 BV_SET(fields, 9);
89039 }
89040
89041 /* folded into head */
89042 if (real_packet->ruleset_locked) {
89043 BV_SET(fields, 10);
89044 }
89045
89046 differ = (strcmp(old->datafile, real_packet->datafile) != 0);
89047 if (differ) {
89048 BV_SET(fields, 11);
89049 }
89050
89051 /* folded into head */
89052 if (real_packet->have_resources) {
89053 BV_SET(fields, 12);
89054 }
89055
89056 differ = (strcmp(old->req_caps, real_packet->req_caps) != 0);
89057 if (differ) {
89058 BV_SET(fields, 13);
89059 }
89060#endif /* FREECIV_DELTA_PROTOCOL */
89061
89062#ifdef FREECIV_JSON_CONNECTION
89063 struct plocation field_addr;
89064 {
89065 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89066 field_addr = *field_addr_tmp;
89067 FC_FREE(field_addr_tmp);
89068 }
89069#endif /* FREECIV_JSON_CONNECTION */
89070
89071#ifdef FREECIV_DELTA_PROTOCOL
89072#ifdef FREECIV_JSON_CONNECTION
89073 field_addr.name = "fields";
89074#endif /* FREECIV_JSON_CONNECTION */
89075 e = 0;
89076 e |= DIO_BV_PUT(&dout, &field_addr, fields);
89077 if (e) {
89078 log_packet_detailed("fields bitvector error detected");
89079 }
89080
89081 /* field 0 is folded into the header */
89082
89083 if (BV_ISSET(fields, 1)) {
89084 log_packet_detailed(" field 'name' has changed");
89085
89086#ifdef FREECIV_JSON_CONNECTION
89087 field_addr.name = "name";
89088#endif /* FREECIV_JSON_CONNECTION */
89089 e = 0;
89090
89091 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
89092
89093 if (e) {
89094 log_packet_detailed("'name' field error detected");
89095 }
89096 }
89097
89098 if (BV_ISSET(fields, 2)) {
89099 log_packet_detailed(" field 'authors' has changed");
89100
89101#ifdef FREECIV_JSON_CONNECTION
89102 field_addr.name = "authors";
89103#endif /* FREECIV_JSON_CONNECTION */
89104 e = 0;
89105
89106 e |= DIO_PUT(string, &dout, &field_addr, real_packet->authors);
89107
89108 if (e) {
89109 log_packet_detailed("'authors' field error detected");
89110 }
89111 }
89112
89113 /* field 3 is folded into the header */
89114
89115 /* field 4 is folded into the header */
89116
89117 /* field 5 is folded into the header */
89118
89119 /* field 6 is folded into the header */
89120
89121 /* field 7 is folded into the header */
89122
89123 /* field 8 is folded into the header */
89124
89125 /* field 9 is folded into the header */
89126
89127 /* field 10 is folded into the header */
89128
89129 if (BV_ISSET(fields, 11)) {
89130 log_packet_detailed(" field 'datafile' has changed");
89131
89132#ifdef FREECIV_JSON_CONNECTION
89133 field_addr.name = "datafile";
89134#endif /* FREECIV_JSON_CONNECTION */
89135 e = 0;
89136
89137 e |= DIO_PUT(string, &dout, &field_addr, real_packet->datafile);
89138
89139 if (e) {
89140 log_packet_detailed("'datafile' field error detected");
89141 }
89142 }
89143
89144 /* field 12 is folded into the header */
89145
89146 if (BV_ISSET(fields, 13)) {
89147 log_packet_detailed(" field 'req_caps' has changed");
89148
89149#ifdef FREECIV_JSON_CONNECTION
89150 field_addr.name = "req_caps";
89151#endif /* FREECIV_JSON_CONNECTION */
89152 e = 0;
89153
89154 e |= DIO_PUT(string, &dout, &field_addr, real_packet->req_caps);
89155
89156 if (e) {
89157 log_packet_detailed("'req_caps' field error detected");
89158 }
89159 }
89160
89161 *old = *real_packet;
89162
89163#else /* FREECIV_DELTA_PROTOCOL */
89164#ifdef FREECIV_JSON_CONNECTION
89165 field_addr.name = "is_scenario";
89166#endif /* FREECIV_JSON_CONNECTION */
89167 e = 0;
89168
89169 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_scenario);
89170
89171 if (e) {
89172 log_packet_detailed("'is_scenario' field error detected");
89173 }
89174
89175#ifdef FREECIV_JSON_CONNECTION
89176 field_addr.name = "name";
89177#endif /* FREECIV_JSON_CONNECTION */
89178 e = 0;
89179
89180 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
89181
89182 if (e) {
89183 log_packet_detailed("'name' field error detected");
89184 }
89185
89186#ifdef FREECIV_JSON_CONNECTION
89187 field_addr.name = "authors";
89188#endif /* FREECIV_JSON_CONNECTION */
89189 e = 0;
89190
89191 e |= DIO_PUT(string, &dout, &field_addr, real_packet->authors);
89192
89193 if (e) {
89194 log_packet_detailed("'authors' field error detected");
89195 }
89196
89197#ifdef FREECIV_JSON_CONNECTION
89198 field_addr.name = "players";
89199#endif /* FREECIV_JSON_CONNECTION */
89200 e = 0;
89201
89202 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->players);
89203
89204 if (e) {
89205 log_packet_detailed("'players' field error detected");
89206 }
89207
89208#ifdef FREECIV_JSON_CONNECTION
89209 field_addr.name = "startpos_nations";
89210#endif /* FREECIV_JSON_CONNECTION */
89211 e = 0;
89212
89213 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->startpos_nations);
89214
89215 if (e) {
89216 log_packet_detailed("'startpos_nations' field error detected");
89217 }
89218
89219#ifdef FREECIV_JSON_CONNECTION
89220 field_addr.name = "save_random";
89221#endif /* FREECIV_JSON_CONNECTION */
89222 e = 0;
89223
89224 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->save_random);
89225
89226 if (e) {
89227 log_packet_detailed("'save_random' field error detected");
89228 }
89229
89230#ifdef FREECIV_JSON_CONNECTION
89231 field_addr.name = "prevent_new_cities";
89232#endif /* FREECIV_JSON_CONNECTION */
89233 e = 0;
89234
89235 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->prevent_new_cities);
89236
89237 if (e) {
89238 log_packet_detailed("'prevent_new_cities' field error detected");
89239 }
89240
89241#ifdef FREECIV_JSON_CONNECTION
89242 field_addr.name = "lake_flooding";
89243#endif /* FREECIV_JSON_CONNECTION */
89244 e = 0;
89245
89246 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->lake_flooding);
89247
89248 if (e) {
89249 log_packet_detailed("'lake_flooding' field error detected");
89250 }
89251
89252#ifdef FREECIV_JSON_CONNECTION
89253 field_addr.name = "handmade";
89254#endif /* FREECIV_JSON_CONNECTION */
89255 e = 0;
89256
89257 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->handmade);
89258
89259 if (e) {
89260 log_packet_detailed("'handmade' field error detected");
89261 }
89262
89263#ifdef FREECIV_JSON_CONNECTION
89264 field_addr.name = "allow_ai_type_fallback";
89265#endif /* FREECIV_JSON_CONNECTION */
89266 e = 0;
89267
89268 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->allow_ai_type_fallback);
89269
89270 if (e) {
89271 log_packet_detailed("'allow_ai_type_fallback' field error detected");
89272 }
89273
89274#ifdef FREECIV_JSON_CONNECTION
89275 field_addr.name = "ruleset_locked";
89276#endif /* FREECIV_JSON_CONNECTION */
89277 e = 0;
89278
89279 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->ruleset_locked);
89280
89281 if (e) {
89282 log_packet_detailed("'ruleset_locked' field error detected");
89283 }
89284
89285#ifdef FREECIV_JSON_CONNECTION
89286 field_addr.name = "datafile";
89287#endif /* FREECIV_JSON_CONNECTION */
89288 e = 0;
89289
89290 e |= DIO_PUT(string, &dout, &field_addr, real_packet->datafile);
89291
89292 if (e) {
89293 log_packet_detailed("'datafile' field error detected");
89294 }
89295
89296#ifdef FREECIV_JSON_CONNECTION
89297 field_addr.name = "have_resources";
89298#endif /* FREECIV_JSON_CONNECTION */
89299 e = 0;
89300
89301 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->have_resources);
89302
89303 if (e) {
89304 log_packet_detailed("'have_resources' field error detected");
89305 }
89306
89307#ifdef FREECIV_JSON_CONNECTION
89308 field_addr.name = "req_caps";
89309#endif /* FREECIV_JSON_CONNECTION */
89310 e = 0;
89311
89312 e |= DIO_PUT(string, &dout, &field_addr, real_packet->req_caps);
89313
89314 if (e) {
89315 log_packet_detailed("'req_caps' field error detected");
89316 }
89317#endif /* FREECIV_DELTA_PROTOCOL */
89318
89319 SEND_PACKET_END(PACKET_SCENARIO_INFO);
89320}
89321
89322 int send_packet_scenario_info(struct connection *pc, const struct packet_scenario_info *packet)
89323{
89324 if (!pc->used) {
89325 log_error("WARNING: trying to send data to the closed connection %s",
89326 conn_description(pc));
89327 return -1;
89328 }
89329 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SCENARIO_INFO].packet != nullptr, -1,
89330 "Handler for PACKET_SCENARIO_INFO not installed");
89331 return pc->phs.handlers->send[PACKET_SCENARIO_INFO].packet(pc, packet);
89332}
89333
89334 static inline void init_packet_scenario_description(struct packet_scenario_description *packet)
89335{
89336 memset(packet, 0, sizeof(*packet));
89337}
89338
89339#define free_packet_scenario_description(_packet) (void) 0
89340#define destroy_packet_scenario_description free
89341
89342#ifdef FREECIV_DELTA_PROTOCOL
89343#define hash_packet_scenario_description_100 hash_const
89344#define cmp_packet_scenario_description_100 cmp_const
89345 BV_DEFINE(packet_scenario_description_100_fields, 1);
89346#endif /* FREECIV_DELTA_PROTOCOL */
89347
89348 static struct packet_scenario_description *receive_packet_scenario_description_100(struct connection *pc)
89349{
89350#define FREE_PACKET_STRUCT(_packet) free_packet_scenario_description(_packet)
89351 RECEIVE_PACKET_START(packet_scenario_description, real_packet);
89352
89353#ifdef FREECIV_JSON_CONNECTION
89354 struct plocation field_addr;
89355 {
89356 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89357 field_addr = *field_addr_tmp;
89358 FC_FREE(field_addr_tmp);
89359 }
89360#endif /* FREECIV_JSON_CONNECTION */
89361
89362 log_packet_detailed("packet_scenario_description_100: got info about ()");
89363
89364#ifdef FREECIV_DELTA_PROTOCOL
89365 packet_scenario_description_100_fields fields;
89366 struct packet_scenario_description *old;
89367 struct genhash **hash = pc->phs.received + PACKET_SCENARIO_DESCRIPTION;
89368
89369 if (nullptr == *hash) {
89370 *hash = genhash_new_full(hash_packet_scenario_description_100, cmp_packet_scenario_description_100,
89371 nullptr, nullptr, nullptr, destroy_packet_scenario_description);
89372 }
89373
89374 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
89375 *real_packet = *old;
89376 } else {
89377 /* packet is already initialized empty */
89378 log_packet_detailed(" no old info");
89379 }
89380
89381#ifdef FREECIV_JSON_CONNECTION
89382 field_addr.name = "fields";
89383#endif /* FREECIV_JSON_CONNECTION */
89384 DIO_BV_GET(&din, &field_addr, fields);
89385
89386 if (BV_ISSET(fields, 0)) {
89387 log_packet_detailed(" got field 'description'");
89388
89389#ifdef FREECIV_JSON_CONNECTION
89390 field_addr.name = "description";
89391#endif /* FREECIV_JSON_CONNECTION */
89392
89393 if (!DIO_GET(string, &din, &field_addr, real_packet->description, sizeof(real_packet->description))) {
89394 RECEIVE_PACKET_FIELD_ERROR(description);
89395 }
89396 }
89397
89398 if (nullptr == old) {
89399 old = fc_malloc(sizeof(*old));
89400 init_packet_scenario_description(old);
89401 *old = *real_packet;
89402 genhash_insert(*hash, old, old);
89403 } else {
89404 *old = *real_packet;
89405 }
89406
89407#else /* FREECIV_DELTA_PROTOCOL */
89408#ifdef FREECIV_JSON_CONNECTION
89409 field_addr.name = "description";
89410#endif /* FREECIV_JSON_CONNECTION */
89411
89412 if (!DIO_GET(string, &din, &field_addr, real_packet->description, sizeof(real_packet->description))) {
89413 RECEIVE_PACKET_FIELD_ERROR(description);
89414 }
89415#endif /* FREECIV_DELTA_PROTOCOL */
89416
89417 RECEIVE_PACKET_END(real_packet);
89418#undef FREE_PACKET_STRUCT
89419}
89420
89421 static int send_packet_scenario_description_100(struct connection *pc, const struct packet_scenario_description *packet)
89422{
89423 const struct packet_scenario_description *real_packet = packet;
89424 int e;
89425 SEND_PACKET_START(PACKET_SCENARIO_DESCRIPTION);
89426
89427 log_packet_detailed("packet_scenario_description_100: sending info about ()");
89428
89429#ifdef FREECIV_DELTA_PROTOCOL
89430 packet_scenario_description_100_fields fields;
89431 struct packet_scenario_description *old;
89432 bool differ;
89433 struct genhash **hash = pc->phs.sent + PACKET_SCENARIO_DESCRIPTION;
89434
89435 if (nullptr == *hash) {
89436 *hash = genhash_new_full(hash_packet_scenario_description_100, cmp_packet_scenario_description_100,
89437 nullptr, nullptr, nullptr, destroy_packet_scenario_description);
89438 }
89439 BV_CLR_ALL(fields);
89440
89441 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
89442 old = fc_malloc(sizeof(*old));
89443 /* temporary bitcopy just to insert correctly */
89444 *old = *real_packet;
89445 genhash_insert(*hash, old, old);
89446 init_packet_scenario_description(old);
89447 }
89448
89449 differ = (strcmp(old->description, real_packet->description) != 0);
89450 if (differ) {
89451 BV_SET(fields, 0);
89452 }
89453#endif /* FREECIV_DELTA_PROTOCOL */
89454
89455#ifdef FREECIV_JSON_CONNECTION
89456 struct plocation field_addr;
89457 {
89458 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89459 field_addr = *field_addr_tmp;
89460 FC_FREE(field_addr_tmp);
89461 }
89462#endif /* FREECIV_JSON_CONNECTION */
89463
89464#ifdef FREECIV_DELTA_PROTOCOL
89465#ifdef FREECIV_JSON_CONNECTION
89466 field_addr.name = "fields";
89467#endif /* FREECIV_JSON_CONNECTION */
89468 e = 0;
89469 e |= DIO_BV_PUT(&dout, &field_addr, fields);
89470 if (e) {
89471 log_packet_detailed("fields bitvector error detected");
89472 }
89473
89474 if (BV_ISSET(fields, 0)) {
89475 log_packet_detailed(" field 'description' has changed");
89476
89477#ifdef FREECIV_JSON_CONNECTION
89478 field_addr.name = "description";
89479#endif /* FREECIV_JSON_CONNECTION */
89480 e = 0;
89481
89482 e |= DIO_PUT(string, &dout, &field_addr, real_packet->description);
89483
89484 if (e) {
89485 log_packet_detailed("'description' field error detected");
89486 }
89487 }
89488
89489 *old = *real_packet;
89490
89491#else /* FREECIV_DELTA_PROTOCOL */
89492#ifdef FREECIV_JSON_CONNECTION
89493 field_addr.name = "description";
89494#endif /* FREECIV_JSON_CONNECTION */
89495 e = 0;
89496
89497 e |= DIO_PUT(string, &dout, &field_addr, real_packet->description);
89498
89499 if (e) {
89500 log_packet_detailed("'description' field error detected");
89501 }
89502#endif /* FREECIV_DELTA_PROTOCOL */
89503
89504 SEND_PACKET_END(PACKET_SCENARIO_DESCRIPTION);
89505}
89506
89507 int send_packet_scenario_description(struct connection *pc, const struct packet_scenario_description *packet)
89508{
89509 if (!pc->used) {
89510 log_error("WARNING: trying to send data to the closed connection %s",
89511 conn_description(pc));
89512 return -1;
89513 }
89514 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SCENARIO_DESCRIPTION].packet != nullptr, -1,
89515 "Handler for PACKET_SCENARIO_DESCRIPTION not installed");
89516 return pc->phs.handlers->send[PACKET_SCENARIO_DESCRIPTION].packet(pc, packet);
89517}
89518
89519 static inline void init_packet_save_scenario(struct packet_save_scenario *packet)
89520{
89521 memset(packet, 0, sizeof(*packet));
89522}
89523
89524#define free_packet_save_scenario(_packet) (void) 0
89525#define destroy_packet_save_scenario free
89526
89527#ifdef FREECIV_DELTA_PROTOCOL
89528#define hash_packet_save_scenario_100 hash_const
89529#define cmp_packet_save_scenario_100 cmp_const
89530 BV_DEFINE(packet_save_scenario_100_fields, 1);
89531#endif /* FREECIV_DELTA_PROTOCOL */
89532
89533 static struct packet_save_scenario *receive_packet_save_scenario_100(struct connection *pc)
89534{
89535#define FREE_PACKET_STRUCT(_packet) free_packet_save_scenario(_packet)
89536 RECEIVE_PACKET_START(packet_save_scenario, real_packet);
89537
89538#ifdef FREECIV_JSON_CONNECTION
89539 struct plocation field_addr;
89540 {
89541 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89542 field_addr = *field_addr_tmp;
89543 FC_FREE(field_addr_tmp);
89544 }
89545#endif /* FREECIV_JSON_CONNECTION */
89546
89547 log_packet_detailed("packet_save_scenario_100: got info about ()");
89548
89549#ifdef FREECIV_DELTA_PROTOCOL
89550 packet_save_scenario_100_fields fields;
89551 struct packet_save_scenario *old;
89552 struct genhash **hash = pc->phs.received + PACKET_SAVE_SCENARIO;
89553
89554 if (nullptr == *hash) {
89555 *hash = genhash_new_full(hash_packet_save_scenario_100, cmp_packet_save_scenario_100,
89556 nullptr, nullptr, nullptr, destroy_packet_save_scenario);
89557 }
89558
89559 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
89560 *real_packet = *old;
89561 } else {
89562 /* packet is already initialized empty */
89563 log_packet_detailed(" no old info");
89564 }
89565
89566#ifdef FREECIV_JSON_CONNECTION
89567 field_addr.name = "fields";
89568#endif /* FREECIV_JSON_CONNECTION */
89569 DIO_BV_GET(&din, &field_addr, fields);
89570
89571 if (BV_ISSET(fields, 0)) {
89572 log_packet_detailed(" got field 'name'");
89573
89574#ifdef FREECIV_JSON_CONNECTION
89575 field_addr.name = "name";
89576#endif /* FREECIV_JSON_CONNECTION */
89577
89578 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
89579 RECEIVE_PACKET_FIELD_ERROR(name);
89580 }
89581 }
89582
89583 if (nullptr == old) {
89584 old = fc_malloc(sizeof(*old));
89585 init_packet_save_scenario(old);
89586 *old = *real_packet;
89587 genhash_insert(*hash, old, old);
89588 } else {
89589 *old = *real_packet;
89590 }
89591
89592#else /* FREECIV_DELTA_PROTOCOL */
89593#ifdef FREECIV_JSON_CONNECTION
89594 field_addr.name = "name";
89595#endif /* FREECIV_JSON_CONNECTION */
89596
89597 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
89598 RECEIVE_PACKET_FIELD_ERROR(name);
89599 }
89600#endif /* FREECIV_DELTA_PROTOCOL */
89601
89602 RECEIVE_PACKET_END(real_packet);
89603#undef FREE_PACKET_STRUCT
89604}
89605
89606 static int send_packet_save_scenario_100(struct connection *pc, const struct packet_save_scenario *packet)
89607{
89608 const struct packet_save_scenario *real_packet = packet;
89609 int e;
89610 SEND_PACKET_START(PACKET_SAVE_SCENARIO);
89611
89612 log_packet_detailed("packet_save_scenario_100: sending info about ()");
89613
89614#ifdef FREECIV_DELTA_PROTOCOL
89615 packet_save_scenario_100_fields fields;
89616 struct packet_save_scenario *old;
89617 bool differ;
89618 struct genhash **hash = pc->phs.sent + PACKET_SAVE_SCENARIO;
89619
89620 if (nullptr == *hash) {
89621 *hash = genhash_new_full(hash_packet_save_scenario_100, cmp_packet_save_scenario_100,
89622 nullptr, nullptr, nullptr, destroy_packet_save_scenario);
89623 }
89624 BV_CLR_ALL(fields);
89625
89626 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
89627 old = fc_malloc(sizeof(*old));
89628 /* temporary bitcopy just to insert correctly */
89629 *old = *real_packet;
89630 genhash_insert(*hash, old, old);
89631 init_packet_save_scenario(old);
89632 }
89633
89634 differ = (strcmp(old->name, real_packet->name) != 0);
89635 if (differ) {
89636 BV_SET(fields, 0);
89637 }
89638#endif /* FREECIV_DELTA_PROTOCOL */
89639
89640#ifdef FREECIV_JSON_CONNECTION
89641 struct plocation field_addr;
89642 {
89643 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89644 field_addr = *field_addr_tmp;
89645 FC_FREE(field_addr_tmp);
89646 }
89647#endif /* FREECIV_JSON_CONNECTION */
89648
89649#ifdef FREECIV_DELTA_PROTOCOL
89650#ifdef FREECIV_JSON_CONNECTION
89651 field_addr.name = "fields";
89652#endif /* FREECIV_JSON_CONNECTION */
89653 e = 0;
89654 e |= DIO_BV_PUT(&dout, &field_addr, fields);
89655 if (e) {
89656 log_packet_detailed("fields bitvector error detected");
89657 }
89658
89659 if (BV_ISSET(fields, 0)) {
89660 log_packet_detailed(" field 'name' has changed");
89661
89662#ifdef FREECIV_JSON_CONNECTION
89663 field_addr.name = "name";
89664#endif /* FREECIV_JSON_CONNECTION */
89665 e = 0;
89666
89667 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
89668
89669 if (e) {
89670 log_packet_detailed("'name' field error detected");
89671 }
89672 }
89673
89674 *old = *real_packet;
89675
89676#else /* FREECIV_DELTA_PROTOCOL */
89677#ifdef FREECIV_JSON_CONNECTION
89678 field_addr.name = "name";
89679#endif /* FREECIV_JSON_CONNECTION */
89680 e = 0;
89681
89682 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
89683
89684 if (e) {
89685 log_packet_detailed("'name' field error detected");
89686 }
89687#endif /* FREECIV_DELTA_PROTOCOL */
89688
89689 SEND_PACKET_END(PACKET_SAVE_SCENARIO);
89690}
89691
89692 int send_packet_save_scenario(struct connection *pc, const struct packet_save_scenario *packet)
89693{
89694 if (!pc->used) {
89695 log_error("WARNING: trying to send data to the closed connection %s",
89696 conn_description(pc));
89697 return -1;
89698 }
89699 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_SAVE_SCENARIO].packet != nullptr, -1,
89700 "Handler for PACKET_SAVE_SCENARIO not installed");
89701 return pc->phs.handlers->send[PACKET_SAVE_SCENARIO].packet(pc, packet);
89702}
89703
89704 int dsend_packet_save_scenario(struct connection *pc, const char *name)
89705{
89706 struct packet_save_scenario packet, *real_packet = &packet;
89707
89708 sz_strlcpy(real_packet->name, name);
89709
89710 return send_packet_save_scenario(pc, real_packet);
89711}
89712
89713 static inline void init_packet_vote_new(struct packet_vote_new *packet)
89714{
89715 memset(packet, 0, sizeof(*packet));
89716}
89717
89718#define free_packet_vote_new(_packet) (void) 0
89719#define destroy_packet_vote_new free
89720
89721#ifdef FREECIV_DELTA_PROTOCOL
89722#define hash_packet_vote_new_100 hash_const
89723#define cmp_packet_vote_new_100 cmp_const
89724 BV_DEFINE(packet_vote_new_100_fields, 5);
89725#endif /* FREECIV_DELTA_PROTOCOL */
89726
89727 static struct packet_vote_new *receive_packet_vote_new_100(struct connection *pc)
89728{
89729#define FREE_PACKET_STRUCT(_packet) free_packet_vote_new(_packet)
89730 RECEIVE_PACKET_START(packet_vote_new, real_packet);
89731
89732#ifdef FREECIV_JSON_CONNECTION
89733 struct plocation field_addr;
89734 {
89735 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89736 field_addr = *field_addr_tmp;
89737 FC_FREE(field_addr_tmp);
89738 }
89739#endif /* FREECIV_JSON_CONNECTION */
89740
89741 log_packet_detailed("packet_vote_new_100: got info about ()");
89742
89743#ifdef FREECIV_DELTA_PROTOCOL
89744 packet_vote_new_100_fields fields;
89745 struct packet_vote_new *old;
89746 struct genhash **hash = pc->phs.received + PACKET_VOTE_NEW;
89747
89748 if (nullptr == *hash) {
89749 *hash = genhash_new_full(hash_packet_vote_new_100, cmp_packet_vote_new_100,
89750 nullptr, nullptr, nullptr, destroy_packet_vote_new);
89751 }
89752
89753 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
89754 *real_packet = *old;
89755 } else {
89756 /* packet is already initialized empty */
89757 log_packet_detailed(" no old info");
89758 }
89759
89760#ifdef FREECIV_JSON_CONNECTION
89761 field_addr.name = "fields";
89762#endif /* FREECIV_JSON_CONNECTION */
89763 DIO_BV_GET(&din, &field_addr, fields);
89764
89765 if (BV_ISSET(fields, 0)) {
89766 log_packet_detailed(" got field 'vote_no'");
89767
89768#ifdef FREECIV_JSON_CONNECTION
89769 field_addr.name = "vote_no";
89770#endif /* FREECIV_JSON_CONNECTION */
89771
89772 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
89773 RECEIVE_PACKET_FIELD_ERROR(vote_no);
89774 }
89775 }
89776
89777 if (BV_ISSET(fields, 1)) {
89778 log_packet_detailed(" got field 'user'");
89779
89780#ifdef FREECIV_JSON_CONNECTION
89781 field_addr.name = "user";
89782#endif /* FREECIV_JSON_CONNECTION */
89783
89784 if (!DIO_GET(string, &din, &field_addr, real_packet->user, sizeof(real_packet->user))) {
89785 RECEIVE_PACKET_FIELD_ERROR(user);
89786 }
89787 }
89788
89789 if (BV_ISSET(fields, 2)) {
89790 log_packet_detailed(" got field 'desc'");
89791
89792#ifdef FREECIV_JSON_CONNECTION
89793 field_addr.name = "desc";
89794#endif /* FREECIV_JSON_CONNECTION */
89795
89796 if (!DIO_GET(string, &din, &field_addr, real_packet->desc, sizeof(real_packet->desc))) {
89797 RECEIVE_PACKET_FIELD_ERROR(desc);
89798 }
89799 }
89800
89801 if (BV_ISSET(fields, 3)) {
89802 log_packet_detailed(" got field 'percent_required'");
89803
89804#ifdef FREECIV_JSON_CONNECTION
89805 field_addr.name = "percent_required";
89806#endif /* FREECIV_JSON_CONNECTION */
89807
89808 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->percent_required)) {
89809 RECEIVE_PACKET_FIELD_ERROR(percent_required);
89810 }
89811 }
89812
89813 if (BV_ISSET(fields, 4)) {
89814 log_packet_detailed(" got field 'flags'");
89815
89816#ifdef FREECIV_JSON_CONNECTION
89817 field_addr.name = "flags";
89818#endif /* FREECIV_JSON_CONNECTION */
89819
89820 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->flags)) {
89821 RECEIVE_PACKET_FIELD_ERROR(flags);
89822 }
89823 }
89824
89825 if (nullptr == old) {
89826 old = fc_malloc(sizeof(*old));
89827 init_packet_vote_new(old);
89828 *old = *real_packet;
89829 genhash_insert(*hash, old, old);
89830 } else {
89831 *old = *real_packet;
89832 }
89833
89834#else /* FREECIV_DELTA_PROTOCOL */
89835#ifdef FREECIV_JSON_CONNECTION
89836 field_addr.name = "vote_no";
89837#endif /* FREECIV_JSON_CONNECTION */
89838
89839 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
89840 RECEIVE_PACKET_FIELD_ERROR(vote_no);
89841 }
89842
89843#ifdef FREECIV_JSON_CONNECTION
89844 field_addr.name = "user";
89845#endif /* FREECIV_JSON_CONNECTION */
89846
89847 if (!DIO_GET(string, &din, &field_addr, real_packet->user, sizeof(real_packet->user))) {
89848 RECEIVE_PACKET_FIELD_ERROR(user);
89849 }
89850
89851#ifdef FREECIV_JSON_CONNECTION
89852 field_addr.name = "desc";
89853#endif /* FREECIV_JSON_CONNECTION */
89854
89855 if (!DIO_GET(string, &din, &field_addr, real_packet->desc, sizeof(real_packet->desc))) {
89856 RECEIVE_PACKET_FIELD_ERROR(desc);
89857 }
89858
89859#ifdef FREECIV_JSON_CONNECTION
89860 field_addr.name = "percent_required";
89861#endif /* FREECIV_JSON_CONNECTION */
89862
89863 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->percent_required)) {
89864 RECEIVE_PACKET_FIELD_ERROR(percent_required);
89865 }
89866
89867#ifdef FREECIV_JSON_CONNECTION
89868 field_addr.name = "flags";
89869#endif /* FREECIV_JSON_CONNECTION */
89870
89871 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->flags)) {
89872 RECEIVE_PACKET_FIELD_ERROR(flags);
89873 }
89874#endif /* FREECIV_DELTA_PROTOCOL */
89875
89876 RECEIVE_PACKET_END(real_packet);
89877#undef FREE_PACKET_STRUCT
89878}
89879
89880 static int send_packet_vote_new_100(struct connection *pc, const struct packet_vote_new *packet)
89881{
89882 const struct packet_vote_new *real_packet = packet;
89883 int e;
89884 SEND_PACKET_START(PACKET_VOTE_NEW);
89885
89886 log_packet_detailed("packet_vote_new_100: sending info about ()");
89887
89888#ifdef FREECIV_DELTA_PROTOCOL
89889 packet_vote_new_100_fields fields;
89890 struct packet_vote_new *old;
89891 bool differ;
89892 struct genhash **hash = pc->phs.sent + PACKET_VOTE_NEW;
89893
89894 if (nullptr == *hash) {
89895 *hash = genhash_new_full(hash_packet_vote_new_100, cmp_packet_vote_new_100,
89896 nullptr, nullptr, nullptr, destroy_packet_vote_new);
89897 }
89898 BV_CLR_ALL(fields);
89899
89900 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
89901 old = fc_malloc(sizeof(*old));
89902 /* temporary bitcopy just to insert correctly */
89903 *old = *real_packet;
89904 genhash_insert(*hash, old, old);
89905 init_packet_vote_new(old);
89906 }
89907
89908 differ = (old->vote_no != real_packet->vote_no);
89909 if (differ) {
89910 BV_SET(fields, 0);
89911 }
89912
89913 differ = (strcmp(old->user, real_packet->user) != 0);
89914 if (differ) {
89915 BV_SET(fields, 1);
89916 }
89917
89918 differ = (strcmp(old->desc, real_packet->desc) != 0);
89919 if (differ) {
89920 BV_SET(fields, 2);
89921 }
89922
89923 differ = (old->percent_required != real_packet->percent_required);
89924 if (differ) {
89925 BV_SET(fields, 3);
89926 }
89927
89928 differ = (old->flags != real_packet->flags);
89929 if (differ) {
89930 BV_SET(fields, 4);
89931 }
89932#endif /* FREECIV_DELTA_PROTOCOL */
89933
89934#ifdef FREECIV_JSON_CONNECTION
89935 struct plocation field_addr;
89936 {
89937 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
89938 field_addr = *field_addr_tmp;
89939 FC_FREE(field_addr_tmp);
89940 }
89941#endif /* FREECIV_JSON_CONNECTION */
89942
89943#ifdef FREECIV_DELTA_PROTOCOL
89944#ifdef FREECIV_JSON_CONNECTION
89945 field_addr.name = "fields";
89946#endif /* FREECIV_JSON_CONNECTION */
89947 e = 0;
89948 e |= DIO_BV_PUT(&dout, &field_addr, fields);
89949 if (e) {
89950 log_packet_detailed("fields bitvector error detected");
89951 }
89952
89953 if (BV_ISSET(fields, 0)) {
89954 log_packet_detailed(" field 'vote_no' has changed");
89955
89956#ifdef FREECIV_JSON_CONNECTION
89957 field_addr.name = "vote_no";
89958#endif /* FREECIV_JSON_CONNECTION */
89959 e = 0;
89960
89961 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
89962
89963 if (e) {
89964 log_packet_detailed("'vote_no' field error detected");
89965 }
89966 }
89967
89968 if (BV_ISSET(fields, 1)) {
89969 log_packet_detailed(" field 'user' has changed");
89970
89971#ifdef FREECIV_JSON_CONNECTION
89972 field_addr.name = "user";
89973#endif /* FREECIV_JSON_CONNECTION */
89974 e = 0;
89975
89976 e |= DIO_PUT(string, &dout, &field_addr, real_packet->user);
89977
89978 if (e) {
89979 log_packet_detailed("'user' field error detected");
89980 }
89981 }
89982
89983 if (BV_ISSET(fields, 2)) {
89984 log_packet_detailed(" field 'desc' has changed");
89985
89986#ifdef FREECIV_JSON_CONNECTION
89987 field_addr.name = "desc";
89988#endif /* FREECIV_JSON_CONNECTION */
89989 e = 0;
89990
89991 e |= DIO_PUT(string, &dout, &field_addr, real_packet->desc);
89992
89993 if (e) {
89994 log_packet_detailed("'desc' field error detected");
89995 }
89996 }
89997
89998 if (BV_ISSET(fields, 3)) {
89999 log_packet_detailed(" field 'percent_required' has changed");
90000
90001#ifdef FREECIV_JSON_CONNECTION
90002 field_addr.name = "percent_required";
90003#endif /* FREECIV_JSON_CONNECTION */
90004 e = 0;
90005
90006 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->percent_required);
90007
90008 if (e) {
90009 log_packet_detailed("'percent_required' field error detected");
90010 }
90011 }
90012
90013 if (BV_ISSET(fields, 4)) {
90014 log_packet_detailed(" field 'flags' has changed");
90015
90016#ifdef FREECIV_JSON_CONNECTION
90017 field_addr.name = "flags";
90018#endif /* FREECIV_JSON_CONNECTION */
90019 e = 0;
90020
90021 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->flags);
90022
90023 if (e) {
90024 log_packet_detailed("'flags' field error detected");
90025 }
90026 }
90027
90028 *old = *real_packet;
90029
90030#else /* FREECIV_DELTA_PROTOCOL */
90031#ifdef FREECIV_JSON_CONNECTION
90032 field_addr.name = "vote_no";
90033#endif /* FREECIV_JSON_CONNECTION */
90034 e = 0;
90035
90036 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90037
90038 if (e) {
90039 log_packet_detailed("'vote_no' field error detected");
90040 }
90041
90042#ifdef FREECIV_JSON_CONNECTION
90043 field_addr.name = "user";
90044#endif /* FREECIV_JSON_CONNECTION */
90045 e = 0;
90046
90047 e |= DIO_PUT(string, &dout, &field_addr, real_packet->user);
90048
90049 if (e) {
90050 log_packet_detailed("'user' field error detected");
90051 }
90052
90053#ifdef FREECIV_JSON_CONNECTION
90054 field_addr.name = "desc";
90055#endif /* FREECIV_JSON_CONNECTION */
90056 e = 0;
90057
90058 e |= DIO_PUT(string, &dout, &field_addr, real_packet->desc);
90059
90060 if (e) {
90061 log_packet_detailed("'desc' field error detected");
90062 }
90063
90064#ifdef FREECIV_JSON_CONNECTION
90065 field_addr.name = "percent_required";
90066#endif /* FREECIV_JSON_CONNECTION */
90067 e = 0;
90068
90069 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->percent_required);
90070
90071 if (e) {
90072 log_packet_detailed("'percent_required' field error detected");
90073 }
90074
90075#ifdef FREECIV_JSON_CONNECTION
90076 field_addr.name = "flags";
90077#endif /* FREECIV_JSON_CONNECTION */
90078 e = 0;
90079
90080 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->flags);
90081
90082 if (e) {
90083 log_packet_detailed("'flags' field error detected");
90084 }
90085#endif /* FREECIV_DELTA_PROTOCOL */
90086
90087 SEND_PACKET_END(PACKET_VOTE_NEW);
90088}
90089
90090 int send_packet_vote_new(struct connection *pc, const struct packet_vote_new *packet)
90091{
90092 if (!pc->used) {
90093 log_error("WARNING: trying to send data to the closed connection %s",
90094 conn_description(pc));
90095 return -1;
90096 }
90097 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_NEW].packet != nullptr, -1,
90098 "Handler for PACKET_VOTE_NEW not installed");
90099 return pc->phs.handlers->send[PACKET_VOTE_NEW].packet(pc, packet);
90100}
90101
90102 static inline void init_packet_vote_update(struct packet_vote_update *packet)
90103{
90104 memset(packet, 0, sizeof(*packet));
90105}
90106
90107#define free_packet_vote_update(_packet) (void) 0
90108#define destroy_packet_vote_update free
90109
90110#ifdef FREECIV_DELTA_PROTOCOL
90111static genhash_val_t hash_packet_vote_update_100(const void *vkey)
90112{
90113 const struct packet_vote_update *key = (const struct packet_vote_update *) vkey;
90114 genhash_val_t result = 0;
90115
90116 result += key->vote_no;
90117
90118 result &= 0xFFFFFFFF;
90119 return result;
90120}
90121
90122static bool cmp_packet_vote_update_100(const void *vkey1, const void *vkey2)
90123{
90124 const struct packet_vote_update *old = (const struct packet_vote_update *) vkey1;
90125 const struct packet_vote_update *real_packet = (const struct packet_vote_update *) vkey2;
90126 bool differ;
90127
90128 differ = (old->vote_no != real_packet->vote_no);
90129
90130 return !differ;
90131}
90132 BV_DEFINE(packet_vote_update_100_fields, 4);
90133#endif /* FREECIV_DELTA_PROTOCOL */
90134
90135 static struct packet_vote_update *receive_packet_vote_update_100(struct connection *pc)
90136{
90137#define FREE_PACKET_STRUCT(_packet) free_packet_vote_update(_packet)
90138 RECEIVE_PACKET_START(packet_vote_update, real_packet);
90139
90140#ifdef FREECIV_JSON_CONNECTION
90141 struct plocation field_addr;
90142 {
90143 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90144 field_addr = *field_addr_tmp;
90145 FC_FREE(field_addr_tmp);
90146 }
90147#endif /* FREECIV_JSON_CONNECTION */
90148
90149#ifdef FREECIV_JSON_CONNECTION
90150 field_addr.name = "vote_no";
90151#endif /* FREECIV_JSON_CONNECTION */
90152
90153 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
90154 RECEIVE_PACKET_FIELD_ERROR(vote_no);
90155 }
90156
90157 log_packet_detailed("packet_vote_update_100: got info about (%d)",
90158 real_packet->vote_no);
90159
90160#ifdef FREECIV_DELTA_PROTOCOL
90161 packet_vote_update_100_fields fields;
90162 struct packet_vote_update *old;
90163 struct genhash **hash = pc->phs.received + PACKET_VOTE_UPDATE;
90164
90165 if (nullptr == *hash) {
90166 *hash = genhash_new_full(hash_packet_vote_update_100, cmp_packet_vote_update_100,
90167 nullptr, nullptr, nullptr, destroy_packet_vote_update);
90168 }
90169
90170 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
90171 *real_packet = *old;
90172 } else {
90173 /* packet is already initialized empty */
90174 log_packet_detailed(" no old info");
90175 }
90176
90177#ifdef FREECIV_JSON_CONNECTION
90178 field_addr.name = "fields";
90179#endif /* FREECIV_JSON_CONNECTION */
90180 DIO_BV_GET(&din, &field_addr, fields);
90181
90182 if (BV_ISSET(fields, 0)) {
90183 log_packet_detailed(" got field 'yes'");
90184
90185#ifdef FREECIV_JSON_CONNECTION
90186 field_addr.name = "yes";
90187#endif /* FREECIV_JSON_CONNECTION */
90188
90189 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->yes)) {
90190 RECEIVE_PACKET_FIELD_ERROR(yes);
90191 }
90192 }
90193
90194 if (BV_ISSET(fields, 1)) {
90195 log_packet_detailed(" got field 'no'");
90196
90197#ifdef FREECIV_JSON_CONNECTION
90198 field_addr.name = "no";
90199#endif /* FREECIV_JSON_CONNECTION */
90200
90201 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->no)) {
90202 RECEIVE_PACKET_FIELD_ERROR(no);
90203 }
90204 }
90205
90206 if (BV_ISSET(fields, 2)) {
90207 log_packet_detailed(" got field 'abstain'");
90208
90209#ifdef FREECIV_JSON_CONNECTION
90210 field_addr.name = "abstain";
90211#endif /* FREECIV_JSON_CONNECTION */
90212
90213 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->abstain)) {
90214 RECEIVE_PACKET_FIELD_ERROR(abstain);
90215 }
90216 }
90217
90218 if (BV_ISSET(fields, 3)) {
90219 log_packet_detailed(" got field 'num_voters'");
90220
90221#ifdef FREECIV_JSON_CONNECTION
90222 field_addr.name = "num_voters";
90223#endif /* FREECIV_JSON_CONNECTION */
90224
90225 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->num_voters)) {
90226 RECEIVE_PACKET_FIELD_ERROR(num_voters);
90227 }
90228 }
90229
90230 if (nullptr == old) {
90231 old = fc_malloc(sizeof(*old));
90232 init_packet_vote_update(old);
90233 *old = *real_packet;
90234 genhash_insert(*hash, old, old);
90235 } else {
90236 *old = *real_packet;
90237 }
90238
90239#else /* FREECIV_DELTA_PROTOCOL */
90240#ifdef FREECIV_JSON_CONNECTION
90241 field_addr.name = "yes";
90242#endif /* FREECIV_JSON_CONNECTION */
90243
90244 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->yes)) {
90245 RECEIVE_PACKET_FIELD_ERROR(yes);
90246 }
90247
90248#ifdef FREECIV_JSON_CONNECTION
90249 field_addr.name = "no";
90250#endif /* FREECIV_JSON_CONNECTION */
90251
90252 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->no)) {
90253 RECEIVE_PACKET_FIELD_ERROR(no);
90254 }
90255
90256#ifdef FREECIV_JSON_CONNECTION
90257 field_addr.name = "abstain";
90258#endif /* FREECIV_JSON_CONNECTION */
90259
90260 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->abstain)) {
90261 RECEIVE_PACKET_FIELD_ERROR(abstain);
90262 }
90263
90264#ifdef FREECIV_JSON_CONNECTION
90265 field_addr.name = "num_voters";
90266#endif /* FREECIV_JSON_CONNECTION */
90267
90268 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->num_voters)) {
90269 RECEIVE_PACKET_FIELD_ERROR(num_voters);
90270 }
90271#endif /* FREECIV_DELTA_PROTOCOL */
90272
90273 RECEIVE_PACKET_END(real_packet);
90274#undef FREE_PACKET_STRUCT
90275}
90276
90277 static int send_packet_vote_update_100(struct connection *pc, const struct packet_vote_update *packet)
90278{
90279 const struct packet_vote_update *real_packet = packet;
90280 int e;
90281 SEND_PACKET_START(PACKET_VOTE_UPDATE);
90282
90283 log_packet_detailed("packet_vote_update_100: sending info about (%d)",
90284 real_packet->vote_no);
90285
90286#ifdef FREECIV_DELTA_PROTOCOL
90287 packet_vote_update_100_fields fields;
90288 struct packet_vote_update *old;
90289 bool differ;
90290 int different = 0;
90291 struct genhash **hash = pc->phs.sent + PACKET_VOTE_UPDATE;
90292
90293 if (nullptr == *hash) {
90294 *hash = genhash_new_full(hash_packet_vote_update_100, cmp_packet_vote_update_100,
90295 nullptr, nullptr, nullptr, destroy_packet_vote_update);
90296 }
90297 BV_CLR_ALL(fields);
90298
90299 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
90300 old = fc_malloc(sizeof(*old));
90301 /* temporary bitcopy just to insert correctly */
90302 *old = *real_packet;
90303 genhash_insert(*hash, old, old);
90304 init_packet_vote_update(old);
90305 different = 1; /* Force to send. */
90306 }
90307
90308 differ = (old->yes != real_packet->yes);
90309 if (differ) {
90310 different++;
90311 BV_SET(fields, 0);
90312 }
90313
90314 differ = (old->no != real_packet->no);
90315 if (differ) {
90316 different++;
90317 BV_SET(fields, 1);
90318 }
90319
90320 differ = (old->abstain != real_packet->abstain);
90321 if (differ) {
90322 different++;
90323 BV_SET(fields, 2);
90324 }
90325
90326 differ = (old->num_voters != real_packet->num_voters);
90327 if (differ) {
90328 different++;
90329 BV_SET(fields, 3);
90330 }
90331
90332 if (different == 0) {
90333 log_packet_detailed(" no change -> discard");
90334 SEND_PACKET_DISCARD();
90335 }
90336#endif /* FREECIV_DELTA_PROTOCOL */
90337
90338#ifdef FREECIV_JSON_CONNECTION
90339 struct plocation field_addr;
90340 {
90341 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90342 field_addr = *field_addr_tmp;
90343 FC_FREE(field_addr_tmp);
90344 }
90345#endif /* FREECIV_JSON_CONNECTION */
90346
90347#ifdef FREECIV_JSON_CONNECTION
90348 field_addr.name = "vote_no";
90349#endif /* FREECIV_JSON_CONNECTION */
90350 e = 0;
90351
90352 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90353
90354 if (e) {
90355 log_packet_detailed("'vote_no' field error detected");
90356 }
90357
90358#ifdef FREECIV_DELTA_PROTOCOL
90359#ifdef FREECIV_JSON_CONNECTION
90360 field_addr.name = "fields";
90361#endif /* FREECIV_JSON_CONNECTION */
90362 e = 0;
90363 e |= DIO_BV_PUT(&dout, &field_addr, fields);
90364 if (e) {
90365 log_packet_detailed("fields bitvector error detected");
90366 }
90367
90368 if (BV_ISSET(fields, 0)) {
90369 log_packet_detailed(" field 'yes' has changed");
90370
90371#ifdef FREECIV_JSON_CONNECTION
90372 field_addr.name = "yes";
90373#endif /* FREECIV_JSON_CONNECTION */
90374 e = 0;
90375
90376 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->yes);
90377
90378 if (e) {
90379 log_packet_detailed("'yes' field error detected");
90380 }
90381 }
90382
90383 if (BV_ISSET(fields, 1)) {
90384 log_packet_detailed(" field 'no' has changed");
90385
90386#ifdef FREECIV_JSON_CONNECTION
90387 field_addr.name = "no";
90388#endif /* FREECIV_JSON_CONNECTION */
90389 e = 0;
90390
90391 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->no);
90392
90393 if (e) {
90394 log_packet_detailed("'no' field error detected");
90395 }
90396 }
90397
90398 if (BV_ISSET(fields, 2)) {
90399 log_packet_detailed(" field 'abstain' has changed");
90400
90401#ifdef FREECIV_JSON_CONNECTION
90402 field_addr.name = "abstain";
90403#endif /* FREECIV_JSON_CONNECTION */
90404 e = 0;
90405
90406 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->abstain);
90407
90408 if (e) {
90409 log_packet_detailed("'abstain' field error detected");
90410 }
90411 }
90412
90413 if (BV_ISSET(fields, 3)) {
90414 log_packet_detailed(" field 'num_voters' has changed");
90415
90416#ifdef FREECIV_JSON_CONNECTION
90417 field_addr.name = "num_voters";
90418#endif /* FREECIV_JSON_CONNECTION */
90419 e = 0;
90420
90421 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->num_voters);
90422
90423 if (e) {
90424 log_packet_detailed("'num_voters' field error detected");
90425 }
90426 }
90427
90428 *old = *real_packet;
90429
90430#else /* FREECIV_DELTA_PROTOCOL */
90431#ifdef FREECIV_JSON_CONNECTION
90432 field_addr.name = "yes";
90433#endif /* FREECIV_JSON_CONNECTION */
90434 e = 0;
90435
90436 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->yes);
90437
90438 if (e) {
90439 log_packet_detailed("'yes' field error detected");
90440 }
90441
90442#ifdef FREECIV_JSON_CONNECTION
90443 field_addr.name = "no";
90444#endif /* FREECIV_JSON_CONNECTION */
90445 e = 0;
90446
90447 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->no);
90448
90449 if (e) {
90450 log_packet_detailed("'no' field error detected");
90451 }
90452
90453#ifdef FREECIV_JSON_CONNECTION
90454 field_addr.name = "abstain";
90455#endif /* FREECIV_JSON_CONNECTION */
90456 e = 0;
90457
90458 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->abstain);
90459
90460 if (e) {
90461 log_packet_detailed("'abstain' field error detected");
90462 }
90463
90464#ifdef FREECIV_JSON_CONNECTION
90465 field_addr.name = "num_voters";
90466#endif /* FREECIV_JSON_CONNECTION */
90467 e = 0;
90468
90469 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->num_voters);
90470
90471 if (e) {
90472 log_packet_detailed("'num_voters' field error detected");
90473 }
90474#endif /* FREECIV_DELTA_PROTOCOL */
90475
90476 SEND_PACKET_END(PACKET_VOTE_UPDATE);
90477}
90478
90479 int send_packet_vote_update(struct connection *pc, const struct packet_vote_update *packet)
90480{
90481 if (!pc->used) {
90482 log_error("WARNING: trying to send data to the closed connection %s",
90483 conn_description(pc));
90484 return -1;
90485 }
90486 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_UPDATE].packet != nullptr, -1,
90487 "Handler for PACKET_VOTE_UPDATE not installed");
90488 return pc->phs.handlers->send[PACKET_VOTE_UPDATE].packet(pc, packet);
90489}
90490
90491 static inline void init_packet_vote_remove(struct packet_vote_remove *packet)
90492{
90493 memset(packet, 0, sizeof(*packet));
90494}
90495
90496#define free_packet_vote_remove(_packet) (void) 0
90497#define destroy_packet_vote_remove free
90498
90499#ifdef FREECIV_DELTA_PROTOCOL
90500#define hash_packet_vote_remove_100 hash_const
90501#define cmp_packet_vote_remove_100 cmp_const
90502 BV_DEFINE(packet_vote_remove_100_fields, 1);
90503#endif /* FREECIV_DELTA_PROTOCOL */
90504
90505 static struct packet_vote_remove *receive_packet_vote_remove_100(struct connection *pc)
90506{
90507#define FREE_PACKET_STRUCT(_packet) free_packet_vote_remove(_packet)
90508 RECEIVE_PACKET_START(packet_vote_remove, real_packet);
90509
90510#ifdef FREECIV_JSON_CONNECTION
90511 struct plocation field_addr;
90512 {
90513 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90514 field_addr = *field_addr_tmp;
90515 FC_FREE(field_addr_tmp);
90516 }
90517#endif /* FREECIV_JSON_CONNECTION */
90518
90519 log_packet_detailed("packet_vote_remove_100: got info about ()");
90520
90521#ifdef FREECIV_DELTA_PROTOCOL
90522 packet_vote_remove_100_fields fields;
90523 struct packet_vote_remove *old;
90524 struct genhash **hash = pc->phs.received + PACKET_VOTE_REMOVE;
90525
90526 if (nullptr == *hash) {
90527 *hash = genhash_new_full(hash_packet_vote_remove_100, cmp_packet_vote_remove_100,
90528 nullptr, nullptr, nullptr, destroy_packet_vote_remove);
90529 }
90530
90531 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
90532 *real_packet = *old;
90533 } else {
90534 /* packet is already initialized empty */
90535 log_packet_detailed(" no old info");
90536 }
90537
90538#ifdef FREECIV_JSON_CONNECTION
90539 field_addr.name = "fields";
90540#endif /* FREECIV_JSON_CONNECTION */
90541 DIO_BV_GET(&din, &field_addr, fields);
90542
90543 if (BV_ISSET(fields, 0)) {
90544 log_packet_detailed(" got field 'vote_no'");
90545
90546#ifdef FREECIV_JSON_CONNECTION
90547 field_addr.name = "vote_no";
90548#endif /* FREECIV_JSON_CONNECTION */
90549
90550 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
90551 RECEIVE_PACKET_FIELD_ERROR(vote_no);
90552 }
90553 }
90554
90555 if (nullptr == old) {
90556 old = fc_malloc(sizeof(*old));
90557 init_packet_vote_remove(old);
90558 *old = *real_packet;
90559 genhash_insert(*hash, old, old);
90560 } else {
90561 *old = *real_packet;
90562 }
90563
90564#else /* FREECIV_DELTA_PROTOCOL */
90565#ifdef FREECIV_JSON_CONNECTION
90566 field_addr.name = "vote_no";
90567#endif /* FREECIV_JSON_CONNECTION */
90568
90569 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
90570 RECEIVE_PACKET_FIELD_ERROR(vote_no);
90571 }
90572#endif /* FREECIV_DELTA_PROTOCOL */
90573
90574 RECEIVE_PACKET_END(real_packet);
90575#undef FREE_PACKET_STRUCT
90576}
90577
90578 static int send_packet_vote_remove_100(struct connection *pc, const struct packet_vote_remove *packet)
90579{
90580 const struct packet_vote_remove *real_packet = packet;
90581 int e;
90582 SEND_PACKET_START(PACKET_VOTE_REMOVE);
90583
90584 log_packet_detailed("packet_vote_remove_100: sending info about ()");
90585
90586#ifdef FREECIV_DELTA_PROTOCOL
90587 packet_vote_remove_100_fields fields;
90588 struct packet_vote_remove *old;
90589 bool differ;
90590 struct genhash **hash = pc->phs.sent + PACKET_VOTE_REMOVE;
90591
90592 if (nullptr == *hash) {
90593 *hash = genhash_new_full(hash_packet_vote_remove_100, cmp_packet_vote_remove_100,
90594 nullptr, nullptr, nullptr, destroy_packet_vote_remove);
90595 }
90596 BV_CLR_ALL(fields);
90597
90598 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
90599 old = fc_malloc(sizeof(*old));
90600 /* temporary bitcopy just to insert correctly */
90601 *old = *real_packet;
90602 genhash_insert(*hash, old, old);
90603 init_packet_vote_remove(old);
90604 }
90605
90606 differ = (old->vote_no != real_packet->vote_no);
90607 if (differ) {
90608 BV_SET(fields, 0);
90609 }
90610#endif /* FREECIV_DELTA_PROTOCOL */
90611
90612#ifdef FREECIV_JSON_CONNECTION
90613 struct plocation field_addr;
90614 {
90615 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90616 field_addr = *field_addr_tmp;
90617 FC_FREE(field_addr_tmp);
90618 }
90619#endif /* FREECIV_JSON_CONNECTION */
90620
90621#ifdef FREECIV_DELTA_PROTOCOL
90622#ifdef FREECIV_JSON_CONNECTION
90623 field_addr.name = "fields";
90624#endif /* FREECIV_JSON_CONNECTION */
90625 e = 0;
90626 e |= DIO_BV_PUT(&dout, &field_addr, fields);
90627 if (e) {
90628 log_packet_detailed("fields bitvector error detected");
90629 }
90630
90631 if (BV_ISSET(fields, 0)) {
90632 log_packet_detailed(" field 'vote_no' has changed");
90633
90634#ifdef FREECIV_JSON_CONNECTION
90635 field_addr.name = "vote_no";
90636#endif /* FREECIV_JSON_CONNECTION */
90637 e = 0;
90638
90639 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90640
90641 if (e) {
90642 log_packet_detailed("'vote_no' field error detected");
90643 }
90644 }
90645
90646 *old = *real_packet;
90647
90648#else /* FREECIV_DELTA_PROTOCOL */
90649#ifdef FREECIV_JSON_CONNECTION
90650 field_addr.name = "vote_no";
90651#endif /* FREECIV_JSON_CONNECTION */
90652 e = 0;
90653
90654 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90655
90656 if (e) {
90657 log_packet_detailed("'vote_no' field error detected");
90658 }
90659#endif /* FREECIV_DELTA_PROTOCOL */
90660
90661 SEND_PACKET_END(PACKET_VOTE_REMOVE);
90662}
90663
90664 int send_packet_vote_remove(struct connection *pc, const struct packet_vote_remove *packet)
90665{
90666 if (!pc->used) {
90667 log_error("WARNING: trying to send data to the closed connection %s",
90668 conn_description(pc));
90669 return -1;
90670 }
90671 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_REMOVE].packet != nullptr, -1,
90672 "Handler for PACKET_VOTE_REMOVE not installed");
90673 return pc->phs.handlers->send[PACKET_VOTE_REMOVE].packet(pc, packet);
90674}
90675
90676 static inline void init_packet_vote_resolve(struct packet_vote_resolve *packet)
90677{
90678 memset(packet, 0, sizeof(*packet));
90679}
90680
90681#define free_packet_vote_resolve(_packet) (void) 0
90682#define destroy_packet_vote_resolve free
90683
90684#ifdef FREECIV_DELTA_PROTOCOL
90685#define hash_packet_vote_resolve_100 hash_const
90686#define cmp_packet_vote_resolve_100 cmp_const
90687 BV_DEFINE(packet_vote_resolve_100_fields, 2);
90688#endif /* FREECIV_DELTA_PROTOCOL */
90689
90690 static struct packet_vote_resolve *receive_packet_vote_resolve_100(struct connection *pc)
90691{
90692#define FREE_PACKET_STRUCT(_packet) free_packet_vote_resolve(_packet)
90693 RECEIVE_PACKET_START(packet_vote_resolve, real_packet);
90694
90695#ifdef FREECIV_JSON_CONNECTION
90696 struct plocation field_addr;
90697 {
90698 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90699 field_addr = *field_addr_tmp;
90700 FC_FREE(field_addr_tmp);
90701 }
90702#endif /* FREECIV_JSON_CONNECTION */
90703
90704 log_packet_detailed("packet_vote_resolve_100: got info about ()");
90705
90706#ifdef FREECIV_DELTA_PROTOCOL
90707 packet_vote_resolve_100_fields fields;
90708 struct packet_vote_resolve *old;
90709 struct genhash **hash = pc->phs.received + PACKET_VOTE_RESOLVE;
90710
90711 if (nullptr == *hash) {
90712 *hash = genhash_new_full(hash_packet_vote_resolve_100, cmp_packet_vote_resolve_100,
90713 nullptr, nullptr, nullptr, destroy_packet_vote_resolve);
90714 }
90715
90716 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
90717 *real_packet = *old;
90718 } else {
90719 /* packet is already initialized empty */
90720 log_packet_detailed(" no old info");
90721 }
90722
90723#ifdef FREECIV_JSON_CONNECTION
90724 field_addr.name = "fields";
90725#endif /* FREECIV_JSON_CONNECTION */
90726 DIO_BV_GET(&din, &field_addr, fields);
90727
90728 if (BV_ISSET(fields, 0)) {
90729 log_packet_detailed(" got field 'vote_no'");
90730
90731#ifdef FREECIV_JSON_CONNECTION
90732 field_addr.name = "vote_no";
90733#endif /* FREECIV_JSON_CONNECTION */
90734
90735 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
90736 RECEIVE_PACKET_FIELD_ERROR(vote_no);
90737 }
90738 }
90739
90740 real_packet->passed = BV_ISSET(fields, 1);
90741
90742 if (nullptr == old) {
90743 old = fc_malloc(sizeof(*old));
90744 init_packet_vote_resolve(old);
90745 *old = *real_packet;
90746 genhash_insert(*hash, old, old);
90747 } else {
90748 *old = *real_packet;
90749 }
90750
90751#else /* FREECIV_DELTA_PROTOCOL */
90752#ifdef FREECIV_JSON_CONNECTION
90753 field_addr.name = "vote_no";
90754#endif /* FREECIV_JSON_CONNECTION */
90755
90756 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
90757 RECEIVE_PACKET_FIELD_ERROR(vote_no);
90758 }
90759
90760#ifdef FREECIV_JSON_CONNECTION
90761 field_addr.name = "passed";
90762#endif /* FREECIV_JSON_CONNECTION */
90763
90764 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->passed)) {
90765 RECEIVE_PACKET_FIELD_ERROR(passed);
90766 }
90767#endif /* FREECIV_DELTA_PROTOCOL */
90768
90769 RECEIVE_PACKET_END(real_packet);
90770#undef FREE_PACKET_STRUCT
90771}
90772
90773 static int send_packet_vote_resolve_100(struct connection *pc, const struct packet_vote_resolve *packet)
90774{
90775 const struct packet_vote_resolve *real_packet = packet;
90776 int e;
90777 SEND_PACKET_START(PACKET_VOTE_RESOLVE);
90778
90779 log_packet_detailed("packet_vote_resolve_100: sending info about ()");
90780
90781#ifdef FREECIV_DELTA_PROTOCOL
90782 packet_vote_resolve_100_fields fields;
90783 struct packet_vote_resolve *old;
90784 bool differ;
90785 struct genhash **hash = pc->phs.sent + PACKET_VOTE_RESOLVE;
90786
90787 if (nullptr == *hash) {
90788 *hash = genhash_new_full(hash_packet_vote_resolve_100, cmp_packet_vote_resolve_100,
90789 nullptr, nullptr, nullptr, destroy_packet_vote_resolve);
90790 }
90791 BV_CLR_ALL(fields);
90792
90793 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
90794 old = fc_malloc(sizeof(*old));
90795 /* temporary bitcopy just to insert correctly */
90796 *old = *real_packet;
90797 genhash_insert(*hash, old, old);
90798 init_packet_vote_resolve(old);
90799 }
90800
90801 differ = (old->vote_no != real_packet->vote_no);
90802 if (differ) {
90803 BV_SET(fields, 0);
90804 }
90805
90806 /* folded into head */
90807 if (real_packet->passed) {
90808 BV_SET(fields, 1);
90809 }
90810#endif /* FREECIV_DELTA_PROTOCOL */
90811
90812#ifdef FREECIV_JSON_CONNECTION
90813 struct plocation field_addr;
90814 {
90815 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90816 field_addr = *field_addr_tmp;
90817 FC_FREE(field_addr_tmp);
90818 }
90819#endif /* FREECIV_JSON_CONNECTION */
90820
90821#ifdef FREECIV_DELTA_PROTOCOL
90822#ifdef FREECIV_JSON_CONNECTION
90823 field_addr.name = "fields";
90824#endif /* FREECIV_JSON_CONNECTION */
90825 e = 0;
90826 e |= DIO_BV_PUT(&dout, &field_addr, fields);
90827 if (e) {
90828 log_packet_detailed("fields bitvector error detected");
90829 }
90830
90831 if (BV_ISSET(fields, 0)) {
90832 log_packet_detailed(" field 'vote_no' has changed");
90833
90834#ifdef FREECIV_JSON_CONNECTION
90835 field_addr.name = "vote_no";
90836#endif /* FREECIV_JSON_CONNECTION */
90837 e = 0;
90838
90839 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90840
90841 if (e) {
90842 log_packet_detailed("'vote_no' field error detected");
90843 }
90844 }
90845
90846 /* field 1 is folded into the header */
90847
90848 *old = *real_packet;
90849
90850#else /* FREECIV_DELTA_PROTOCOL */
90851#ifdef FREECIV_JSON_CONNECTION
90852 field_addr.name = "vote_no";
90853#endif /* FREECIV_JSON_CONNECTION */
90854 e = 0;
90855
90856 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90857
90858 if (e) {
90859 log_packet_detailed("'vote_no' field error detected");
90860 }
90861
90862#ifdef FREECIV_JSON_CONNECTION
90863 field_addr.name = "passed";
90864#endif /* FREECIV_JSON_CONNECTION */
90865 e = 0;
90866
90867 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->passed);
90868
90869 if (e) {
90870 log_packet_detailed("'passed' field error detected");
90871 }
90872#endif /* FREECIV_DELTA_PROTOCOL */
90873
90874 SEND_PACKET_END(PACKET_VOTE_RESOLVE);
90875}
90876
90877 int send_packet_vote_resolve(struct connection *pc, const struct packet_vote_resolve *packet)
90878{
90879 if (!pc->used) {
90880 log_error("WARNING: trying to send data to the closed connection %s",
90881 conn_description(pc));
90882 return -1;
90883 }
90884 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_RESOLVE].packet != nullptr, -1,
90885 "Handler for PACKET_VOTE_RESOLVE not installed");
90886 return pc->phs.handlers->send[PACKET_VOTE_RESOLVE].packet(pc, packet);
90887}
90888
90889 static inline void init_packet_vote_submit(struct packet_vote_submit *packet)
90890{
90891 memset(packet, 0, sizeof(*packet));
90892}
90893
90894#define free_packet_vote_submit(_packet) (void) 0
90895#define destroy_packet_vote_submit free
90896
90897 static struct packet_vote_submit *receive_packet_vote_submit_100(struct connection *pc)
90898{
90899#define FREE_PACKET_STRUCT(_packet) free_packet_vote_submit(_packet)
90900 RECEIVE_PACKET_START(packet_vote_submit, real_packet);
90901
90902#ifdef FREECIV_JSON_CONNECTION
90903 struct plocation field_addr;
90904 {
90905 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90906 field_addr = *field_addr_tmp;
90907 FC_FREE(field_addr_tmp);
90908 }
90909#endif /* FREECIV_JSON_CONNECTION */
90910
90911 log_packet_detailed("packet_vote_submit_100: got info about ()");
90912
90913#ifdef FREECIV_JSON_CONNECTION
90914 field_addr.name = "vote_no";
90915#endif /* FREECIV_JSON_CONNECTION */
90916
90917 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->vote_no)) {
90918 RECEIVE_PACKET_FIELD_ERROR(vote_no);
90919 }
90920
90921#ifdef FREECIV_JSON_CONNECTION
90922 field_addr.name = "value";
90923#endif /* FREECIV_JSON_CONNECTION */
90924
90925 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->value)) {
90926 RECEIVE_PACKET_FIELD_ERROR(value);
90927 }
90928
90929 RECEIVE_PACKET_END(real_packet);
90930#undef FREE_PACKET_STRUCT
90931}
90932
90933 static int send_packet_vote_submit_100(struct connection *pc, const struct packet_vote_submit *packet)
90934{
90935 const struct packet_vote_submit *real_packet = packet;
90936 int e;
90937 SEND_PACKET_START(PACKET_VOTE_SUBMIT);
90938
90939 log_packet_detailed("packet_vote_submit_100: sending info about ()");
90940
90941#ifdef FREECIV_JSON_CONNECTION
90942 struct plocation field_addr;
90943 {
90944 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
90945 field_addr = *field_addr_tmp;
90946 FC_FREE(field_addr_tmp);
90947 }
90948#endif /* FREECIV_JSON_CONNECTION */
90949
90950#ifdef FREECIV_JSON_CONNECTION
90951 field_addr.name = "vote_no";
90952#endif /* FREECIV_JSON_CONNECTION */
90953 e = 0;
90954
90955 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->vote_no);
90956
90957 if (e) {
90958 log_packet_detailed("'vote_no' field error detected");
90959 }
90960
90961#ifdef FREECIV_JSON_CONNECTION
90962 field_addr.name = "value";
90963#endif /* FREECIV_JSON_CONNECTION */
90964 e = 0;
90965
90966 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->value);
90967
90968 if (e) {
90969 log_packet_detailed("'value' field error detected");
90970 }
90971
90972 SEND_PACKET_END(PACKET_VOTE_SUBMIT);
90973}
90974
90975 int send_packet_vote_submit(struct connection *pc, const struct packet_vote_submit *packet)
90976{
90977 if (!pc->used) {
90978 log_error("WARNING: trying to send data to the closed connection %s",
90979 conn_description(pc));
90980 return -1;
90981 }
90982 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_VOTE_SUBMIT].packet != nullptr, -1,
90983 "Handler for PACKET_VOTE_SUBMIT not installed");
90984 return pc->phs.handlers->send[PACKET_VOTE_SUBMIT].packet(pc, packet);
90985}
90986
90987 static inline void init_packet_edit_mode(struct packet_edit_mode *packet)
90988{
90989 memset(packet, 0, sizeof(*packet));
90990}
90991
90992#define free_packet_edit_mode(_packet) (void) 0
90993#define destroy_packet_edit_mode free
90994
90995#ifdef FREECIV_DELTA_PROTOCOL
90996#define hash_packet_edit_mode_100 hash_const
90997#define cmp_packet_edit_mode_100 cmp_const
90998 BV_DEFINE(packet_edit_mode_100_fields, 1);
90999#endif /* FREECIV_DELTA_PROTOCOL */
91000
91001 static struct packet_edit_mode *receive_packet_edit_mode_100(struct connection *pc)
91002{
91003#define FREE_PACKET_STRUCT(_packet) free_packet_edit_mode(_packet)
91004 RECEIVE_PACKET_START(packet_edit_mode, real_packet);
91005
91006#ifdef FREECIV_JSON_CONNECTION
91007 struct plocation field_addr;
91008 {
91009 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91010 field_addr = *field_addr_tmp;
91011 FC_FREE(field_addr_tmp);
91012 }
91013#endif /* FREECIV_JSON_CONNECTION */
91014
91015 log_packet_detailed("packet_edit_mode_100: got info about ()");
91016
91017#ifdef FREECIV_DELTA_PROTOCOL
91018 packet_edit_mode_100_fields fields;
91019 struct packet_edit_mode *old;
91020 struct genhash **hash = pc->phs.received + PACKET_EDIT_MODE;
91021
91022 if (nullptr == *hash) {
91023 *hash = genhash_new_full(hash_packet_edit_mode_100, cmp_packet_edit_mode_100,
91024 nullptr, nullptr, nullptr, destroy_packet_edit_mode);
91025 }
91026
91027 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
91028 *real_packet = *old;
91029 } else {
91030 /* packet is already initialized empty */
91031 log_packet_detailed(" no old info");
91032 }
91033
91034#ifdef FREECIV_JSON_CONNECTION
91035 field_addr.name = "fields";
91036#endif /* FREECIV_JSON_CONNECTION */
91037 DIO_BV_GET(&din, &field_addr, fields);
91038
91039 real_packet->state = BV_ISSET(fields, 0);
91040
91041 if (nullptr == old) {
91042 old = fc_malloc(sizeof(*old));
91043 init_packet_edit_mode(old);
91044 *old = *real_packet;
91045 genhash_insert(*hash, old, old);
91046 } else {
91047 *old = *real_packet;
91048 }
91049
91050#else /* FREECIV_DELTA_PROTOCOL */
91051#ifdef FREECIV_JSON_CONNECTION
91052 field_addr.name = "state";
91053#endif /* FREECIV_JSON_CONNECTION */
91054
91055 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->state)) {
91056 RECEIVE_PACKET_FIELD_ERROR(state);
91057 }
91058#endif /* FREECIV_DELTA_PROTOCOL */
91059
91060 RECEIVE_PACKET_END(real_packet);
91061#undef FREE_PACKET_STRUCT
91062}
91063
91064 static int send_packet_edit_mode_100(struct connection *pc, const struct packet_edit_mode *packet)
91065{
91066 const struct packet_edit_mode *real_packet = packet;
91067 int e;
91068 SEND_PACKET_START(PACKET_EDIT_MODE);
91069
91070 log_packet_detailed("packet_edit_mode_100: sending info about ()");
91071
91072#ifdef FREECIV_DELTA_PROTOCOL
91073 packet_edit_mode_100_fields fields;
91074 struct packet_edit_mode *old;
91075 struct genhash **hash = pc->phs.sent + PACKET_EDIT_MODE;
91076
91077 if (nullptr == *hash) {
91078 *hash = genhash_new_full(hash_packet_edit_mode_100, cmp_packet_edit_mode_100,
91079 nullptr, nullptr, nullptr, destroy_packet_edit_mode);
91080 }
91081 BV_CLR_ALL(fields);
91082
91083 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
91084 old = fc_malloc(sizeof(*old));
91085 /* temporary bitcopy just to insert correctly */
91086 *old = *real_packet;
91087 genhash_insert(*hash, old, old);
91088 init_packet_edit_mode(old);
91089 }
91090
91091 /* folded into head */
91092 if (real_packet->state) {
91093 BV_SET(fields, 0);
91094 }
91095#endif /* FREECIV_DELTA_PROTOCOL */
91096
91097#ifdef FREECIV_JSON_CONNECTION
91098 struct plocation field_addr;
91099 {
91100 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91101 field_addr = *field_addr_tmp;
91102 FC_FREE(field_addr_tmp);
91103 }
91104#endif /* FREECIV_JSON_CONNECTION */
91105
91106#ifdef FREECIV_DELTA_PROTOCOL
91107#ifdef FREECIV_JSON_CONNECTION
91108 field_addr.name = "fields";
91109#endif /* FREECIV_JSON_CONNECTION */
91110 e = 0;
91111 e |= DIO_BV_PUT(&dout, &field_addr, fields);
91112 if (e) {
91113 log_packet_detailed("fields bitvector error detected");
91114 }
91115
91116 /* field 0 is folded into the header */
91117
91118 *old = *real_packet;
91119
91120#else /* FREECIV_DELTA_PROTOCOL */
91121#ifdef FREECIV_JSON_CONNECTION
91122 field_addr.name = "state";
91123#endif /* FREECIV_JSON_CONNECTION */
91124 e = 0;
91125
91126 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->state);
91127
91128 if (e) {
91129 log_packet_detailed("'state' field error detected");
91130 }
91131#endif /* FREECIV_DELTA_PROTOCOL */
91132
91133 SEND_PACKET_END(PACKET_EDIT_MODE);
91134}
91135
91136 int send_packet_edit_mode(struct connection *pc, const struct packet_edit_mode *packet)
91137{
91138 if (!pc->used) {
91139 log_error("WARNING: trying to send data to the closed connection %s",
91140 conn_description(pc));
91141 return -1;
91142 }
91143 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_MODE].packet != nullptr, -1,
91144 "Handler for PACKET_EDIT_MODE not installed");
91145 return pc->phs.handlers->send[PACKET_EDIT_MODE].packet(pc, packet);
91146}
91147
91148 int dsend_packet_edit_mode(struct connection *pc, bool state)
91149{
91150 struct packet_edit_mode packet, *real_packet = &packet;
91151
91152 real_packet->state = state;
91153
91154 return send_packet_edit_mode(pc, real_packet);
91155}
91156
91157 static inline void init_packet_edit_recalculate_borders(struct packet_edit_recalculate_borders *packet)
91158{
91159 memset(packet, 0, sizeof(*packet));
91160}
91161
91162#define free_packet_edit_recalculate_borders(_packet) (void) 0
91163#define destroy_packet_edit_recalculate_borders free
91164
91165 static struct packet_edit_recalculate_borders *receive_packet_edit_recalculate_borders_100(struct connection *pc)
91166{
91167#define FREE_PACKET_STRUCT(_packet) free_packet_edit_recalculate_borders(_packet)
91168 RECEIVE_PACKET_START(packet_edit_recalculate_borders, real_packet);
91169
91170 log_packet_detailed("packet_edit_recalculate_borders_100: got info about ()");
91171
91172 real_packet->__dummy = 0xff;
91173
91174 RECEIVE_PACKET_END(real_packet);
91175#undef FREE_PACKET_STRUCT
91176}
91177
91178 static int send_packet_edit_recalculate_borders_100(struct connection *pc)
91179{
91180 SEND_PACKET_START(PACKET_EDIT_RECALCULATE_BORDERS);
91181
91182 log_packet_detailed("packet_edit_recalculate_borders_100: sending info about ()");
91183
91184 SEND_PACKET_END(PACKET_EDIT_RECALCULATE_BORDERS);
91185}
91186
91187 int send_packet_edit_recalculate_borders(struct connection *pc)
91188{
91189 if (!pc->used) {
91190 log_error("WARNING: trying to send data to the closed connection %s",
91191 conn_description(pc));
91192 return -1;
91193 }
91194 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_RECALCULATE_BORDERS].no_packet != nullptr, -1,
91195 "Handler for PACKET_EDIT_RECALCULATE_BORDERS not installed");
91196 return pc->phs.handlers->send[PACKET_EDIT_RECALCULATE_BORDERS].no_packet(pc);
91197}
91198
91199 static inline void init_packet_edit_check_tiles(struct packet_edit_check_tiles *packet)
91200{
91201 memset(packet, 0, sizeof(*packet));
91202}
91203
91204#define free_packet_edit_check_tiles(_packet) (void) 0
91205#define destroy_packet_edit_check_tiles free
91206
91207 static struct packet_edit_check_tiles *receive_packet_edit_check_tiles_100(struct connection *pc)
91208{
91209#define FREE_PACKET_STRUCT(_packet) free_packet_edit_check_tiles(_packet)
91210 RECEIVE_PACKET_START(packet_edit_check_tiles, real_packet);
91211
91212 log_packet_detailed("packet_edit_check_tiles_100: got info about ()");
91213
91214 real_packet->__dummy = 0xff;
91215
91216 RECEIVE_PACKET_END(real_packet);
91217#undef FREE_PACKET_STRUCT
91218}
91219
91220 static int send_packet_edit_check_tiles_100(struct connection *pc)
91221{
91222 SEND_PACKET_START(PACKET_EDIT_CHECK_TILES);
91223
91224 log_packet_detailed("packet_edit_check_tiles_100: sending info about ()");
91225
91226 SEND_PACKET_END(PACKET_EDIT_CHECK_TILES);
91227}
91228
91229 int send_packet_edit_check_tiles(struct connection *pc)
91230{
91231 if (!pc->used) {
91232 log_error("WARNING: trying to send data to the closed connection %s",
91233 conn_description(pc));
91234 return -1;
91235 }
91236 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CHECK_TILES].no_packet != nullptr, -1,
91237 "Handler for PACKET_EDIT_CHECK_TILES not installed");
91238 return pc->phs.handlers->send[PACKET_EDIT_CHECK_TILES].no_packet(pc);
91239}
91240
91241 static inline void init_packet_edit_toggle_fogofwar(struct packet_edit_toggle_fogofwar *packet)
91242{
91243 memset(packet, 0, sizeof(*packet));
91244}
91245
91246#define free_packet_edit_toggle_fogofwar(_packet) (void) 0
91247#define destroy_packet_edit_toggle_fogofwar free
91248
91249#ifdef FREECIV_DELTA_PROTOCOL
91250#define hash_packet_edit_toggle_fogofwar_100 hash_const
91251#define cmp_packet_edit_toggle_fogofwar_100 cmp_const
91252 BV_DEFINE(packet_edit_toggle_fogofwar_100_fields, 1);
91253#endif /* FREECIV_DELTA_PROTOCOL */
91254
91255 static struct packet_edit_toggle_fogofwar *receive_packet_edit_toggle_fogofwar_100(struct connection *pc)
91256{
91257#define FREE_PACKET_STRUCT(_packet) free_packet_edit_toggle_fogofwar(_packet)
91258 RECEIVE_PACKET_START(packet_edit_toggle_fogofwar, real_packet);
91259
91260#ifdef FREECIV_JSON_CONNECTION
91261 struct plocation field_addr;
91262 {
91263 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91264 field_addr = *field_addr_tmp;
91265 FC_FREE(field_addr_tmp);
91266 }
91267#endif /* FREECIV_JSON_CONNECTION */
91268
91269 log_packet_detailed("packet_edit_toggle_fogofwar_100: got info about ()");
91270
91271#ifdef FREECIV_DELTA_PROTOCOL
91272 packet_edit_toggle_fogofwar_100_fields fields;
91273 struct packet_edit_toggle_fogofwar *old;
91274 struct genhash **hash = pc->phs.received + PACKET_EDIT_TOGGLE_FOGOFWAR;
91275
91276 if (nullptr == *hash) {
91277 *hash = genhash_new_full(hash_packet_edit_toggle_fogofwar_100, cmp_packet_edit_toggle_fogofwar_100,
91278 nullptr, nullptr, nullptr, destroy_packet_edit_toggle_fogofwar);
91279 }
91280
91281 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
91282 *real_packet = *old;
91283 } else {
91284 /* packet is already initialized empty */
91285 log_packet_detailed(" no old info");
91286 }
91287
91288#ifdef FREECIV_JSON_CONNECTION
91289 field_addr.name = "fields";
91290#endif /* FREECIV_JSON_CONNECTION */
91291 DIO_BV_GET(&din, &field_addr, fields);
91292
91293 if (BV_ISSET(fields, 0)) {
91294 log_packet_detailed(" got field 'player'");
91295
91296#ifdef FREECIV_JSON_CONNECTION
91297 field_addr.name = "player";
91298#endif /* FREECIV_JSON_CONNECTION */
91299
91300 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player)) {
91301 RECEIVE_PACKET_FIELD_ERROR(player);
91302 }
91303 }
91304
91305 if (nullptr == old) {
91306 old = fc_malloc(sizeof(*old));
91307 init_packet_edit_toggle_fogofwar(old);
91308 *old = *real_packet;
91309 genhash_insert(*hash, old, old);
91310 } else {
91311 *old = *real_packet;
91312 }
91313
91314#else /* FREECIV_DELTA_PROTOCOL */
91315#ifdef FREECIV_JSON_CONNECTION
91316 field_addr.name = "player";
91317#endif /* FREECIV_JSON_CONNECTION */
91318
91319 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player)) {
91320 RECEIVE_PACKET_FIELD_ERROR(player);
91321 }
91322#endif /* FREECIV_DELTA_PROTOCOL */
91323
91324 RECEIVE_PACKET_END(real_packet);
91325#undef FREE_PACKET_STRUCT
91326}
91327
91328 static int send_packet_edit_toggle_fogofwar_100(struct connection *pc, const struct packet_edit_toggle_fogofwar *packet)
91329{
91330 const struct packet_edit_toggle_fogofwar *real_packet = packet;
91331 int e;
91332 SEND_PACKET_START(PACKET_EDIT_TOGGLE_FOGOFWAR);
91333
91334 log_packet_detailed("packet_edit_toggle_fogofwar_100: sending info about ()");
91335
91336#ifdef FREECIV_DELTA_PROTOCOL
91337 packet_edit_toggle_fogofwar_100_fields fields;
91338 struct packet_edit_toggle_fogofwar *old;
91339 bool differ;
91340 struct genhash **hash = pc->phs.sent + PACKET_EDIT_TOGGLE_FOGOFWAR;
91341
91342 if (nullptr == *hash) {
91343 *hash = genhash_new_full(hash_packet_edit_toggle_fogofwar_100, cmp_packet_edit_toggle_fogofwar_100,
91344 nullptr, nullptr, nullptr, destroy_packet_edit_toggle_fogofwar);
91345 }
91346 BV_CLR_ALL(fields);
91347
91348 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
91349 old = fc_malloc(sizeof(*old));
91350 /* temporary bitcopy just to insert correctly */
91351 *old = *real_packet;
91352 genhash_insert(*hash, old, old);
91353 init_packet_edit_toggle_fogofwar(old);
91354 }
91355
91356 differ = (old->player != real_packet->player);
91357 if (differ) {
91358 BV_SET(fields, 0);
91359 }
91360#endif /* FREECIV_DELTA_PROTOCOL */
91361
91362#ifdef FREECIV_JSON_CONNECTION
91363 struct plocation field_addr;
91364 {
91365 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91366 field_addr = *field_addr_tmp;
91367 FC_FREE(field_addr_tmp);
91368 }
91369#endif /* FREECIV_JSON_CONNECTION */
91370
91371#ifdef FREECIV_DELTA_PROTOCOL
91372#ifdef FREECIV_JSON_CONNECTION
91373 field_addr.name = "fields";
91374#endif /* FREECIV_JSON_CONNECTION */
91375 e = 0;
91376 e |= DIO_BV_PUT(&dout, &field_addr, fields);
91377 if (e) {
91378 log_packet_detailed("fields bitvector error detected");
91379 }
91380
91381 if (BV_ISSET(fields, 0)) {
91382 log_packet_detailed(" field 'player' has changed");
91383
91384#ifdef FREECIV_JSON_CONNECTION
91385 field_addr.name = "player";
91386#endif /* FREECIV_JSON_CONNECTION */
91387 e = 0;
91388
91389 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player);
91390
91391 if (e) {
91392 log_packet_detailed("'player' field error detected");
91393 }
91394 }
91395
91396 *old = *real_packet;
91397
91398#else /* FREECIV_DELTA_PROTOCOL */
91399#ifdef FREECIV_JSON_CONNECTION
91400 field_addr.name = "player";
91401#endif /* FREECIV_JSON_CONNECTION */
91402 e = 0;
91403
91404 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player);
91405
91406 if (e) {
91407 log_packet_detailed("'player' field error detected");
91408 }
91409#endif /* FREECIV_DELTA_PROTOCOL */
91410
91411 SEND_PACKET_END(PACKET_EDIT_TOGGLE_FOGOFWAR);
91412}
91413
91414 int send_packet_edit_toggle_fogofwar(struct connection *pc, const struct packet_edit_toggle_fogofwar *packet)
91415{
91416 if (!pc->used) {
91417 log_error("WARNING: trying to send data to the closed connection %s",
91418 conn_description(pc));
91419 return -1;
91420 }
91421 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TOGGLE_FOGOFWAR].packet != nullptr, -1,
91422 "Handler for PACKET_EDIT_TOGGLE_FOGOFWAR not installed");
91423 return pc->phs.handlers->send[PACKET_EDIT_TOGGLE_FOGOFWAR].packet(pc, packet);
91424}
91425
91426 int dsend_packet_edit_toggle_fogofwar(struct connection *pc, int player)
91427{
91428 struct packet_edit_toggle_fogofwar packet, *real_packet = &packet;
91429
91430 real_packet->player = player;
91431
91432 return send_packet_edit_toggle_fogofwar(pc, real_packet);
91433}
91434
91435 static inline void init_packet_edit_tile_terrain(struct packet_edit_tile_terrain *packet)
91436{
91437 memset(packet, 0, sizeof(*packet));
91438}
91439
91440#define free_packet_edit_tile_terrain(_packet) (void) 0
91441#define destroy_packet_edit_tile_terrain free
91442
91443#ifdef FREECIV_DELTA_PROTOCOL
91444static genhash_val_t hash_packet_edit_tile_terrain_100(const void *vkey)
91445{
91446 const struct packet_edit_tile_terrain *key = (const struct packet_edit_tile_terrain *) vkey;
91447 genhash_val_t result = 0;
91448
91449 result += key->tile;
91450
91451 result &= 0xFFFFFFFF;
91452 return result;
91453}
91454
91455static bool cmp_packet_edit_tile_terrain_100(const void *vkey1, const void *vkey2)
91456{
91457 const struct packet_edit_tile_terrain *old = (const struct packet_edit_tile_terrain *) vkey1;
91458 const struct packet_edit_tile_terrain *real_packet = (const struct packet_edit_tile_terrain *) vkey2;
91459 bool differ;
91460
91461 differ = (old->tile != real_packet->tile);
91462
91463 return !differ;
91464}
91465 BV_DEFINE(packet_edit_tile_terrain_100_fields, 2);
91466#endif /* FREECIV_DELTA_PROTOCOL */
91467
91468 static struct packet_edit_tile_terrain *receive_packet_edit_tile_terrain_100(struct connection *pc)
91469{
91470#define FREE_PACKET_STRUCT(_packet) free_packet_edit_tile_terrain(_packet)
91471 RECEIVE_PACKET_START(packet_edit_tile_terrain, real_packet);
91472
91473#ifdef FREECIV_JSON_CONNECTION
91474 struct plocation field_addr;
91475 {
91476 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91477 field_addr = *field_addr_tmp;
91478 FC_FREE(field_addr_tmp);
91479 }
91480#endif /* FREECIV_JSON_CONNECTION */
91481
91482#ifdef FREECIV_JSON_CONNECTION
91483 field_addr.name = "tile";
91484#endif /* FREECIV_JSON_CONNECTION */
91485
91486 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
91487 RECEIVE_PACKET_FIELD_ERROR(tile);
91488 }
91489
91490 log_packet_detailed("packet_edit_tile_terrain_100: got info about (%d)",
91491 real_packet->tile);
91492
91493#ifdef FREECIV_DELTA_PROTOCOL
91494 packet_edit_tile_terrain_100_fields fields;
91495 struct packet_edit_tile_terrain *old;
91496 struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE_TERRAIN;
91497
91498 if (nullptr == *hash) {
91499 *hash = genhash_new_full(hash_packet_edit_tile_terrain_100, cmp_packet_edit_tile_terrain_100,
91500 nullptr, nullptr, nullptr, destroy_packet_edit_tile_terrain);
91501 }
91502
91503 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
91504 *real_packet = *old;
91505 } else {
91506 /* packet is already initialized empty */
91507 log_packet_detailed(" no old info");
91508 }
91509
91510#ifdef FREECIV_JSON_CONNECTION
91511 field_addr.name = "fields";
91512#endif /* FREECIV_JSON_CONNECTION */
91513 DIO_BV_GET(&din, &field_addr, fields);
91514
91515 if (BV_ISSET(fields, 0)) {
91516 log_packet_detailed(" got field 'terrain'");
91517
91518#ifdef FREECIV_JSON_CONNECTION
91519 field_addr.name = "terrain";
91520#endif /* FREECIV_JSON_CONNECTION */
91521
91522 {
91523 int readin;
91524
91525 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
91526 RECEIVE_PACKET_FIELD_ERROR(terrain);
91527 }
91528 real_packet->terrain = readin;
91529 }
91530 }
91531
91532 if (BV_ISSET(fields, 1)) {
91533 log_packet_detailed(" got field 'size'");
91534
91535#ifdef FREECIV_JSON_CONNECTION
91536 field_addr.name = "size";
91537#endif /* FREECIV_JSON_CONNECTION */
91538
91539 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
91540 RECEIVE_PACKET_FIELD_ERROR(size);
91541 }
91542 }
91543
91544 if (nullptr == old) {
91545 old = fc_malloc(sizeof(*old));
91546 init_packet_edit_tile_terrain(old);
91547 *old = *real_packet;
91548 genhash_insert(*hash, old, old);
91549 } else {
91550 *old = *real_packet;
91551 }
91552
91553#else /* FREECIV_DELTA_PROTOCOL */
91554#ifdef FREECIV_JSON_CONNECTION
91555 field_addr.name = "terrain";
91556#endif /* FREECIV_JSON_CONNECTION */
91557
91558 {
91559 int readin;
91560
91561 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
91562 RECEIVE_PACKET_FIELD_ERROR(terrain);
91563 }
91564 real_packet->terrain = readin;
91565 }
91566
91567#ifdef FREECIV_JSON_CONNECTION
91568 field_addr.name = "size";
91569#endif /* FREECIV_JSON_CONNECTION */
91570
91571 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
91572 RECEIVE_PACKET_FIELD_ERROR(size);
91573 }
91574#endif /* FREECIV_DELTA_PROTOCOL */
91575
91576 RECEIVE_PACKET_END(real_packet);
91577#undef FREE_PACKET_STRUCT
91578}
91579
91580 static int send_packet_edit_tile_terrain_100(struct connection *pc, const struct packet_edit_tile_terrain *packet)
91581{
91582 const struct packet_edit_tile_terrain *real_packet = packet;
91583 int e;
91584 SEND_PACKET_START(PACKET_EDIT_TILE_TERRAIN);
91585
91586 log_packet_detailed("packet_edit_tile_terrain_100: sending info about (%d)",
91587 real_packet->tile);
91588
91589#ifdef FREECIV_DELTA_PROTOCOL
91590 packet_edit_tile_terrain_100_fields fields;
91591 struct packet_edit_tile_terrain *old;
91592 bool differ;
91593 struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE_TERRAIN;
91594
91595 if (nullptr == *hash) {
91596 *hash = genhash_new_full(hash_packet_edit_tile_terrain_100, cmp_packet_edit_tile_terrain_100,
91597 nullptr, nullptr, nullptr, destroy_packet_edit_tile_terrain);
91598 }
91599 BV_CLR_ALL(fields);
91600
91601 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
91602 old = fc_malloc(sizeof(*old));
91603 /* temporary bitcopy just to insert correctly */
91604 *old = *real_packet;
91605 genhash_insert(*hash, old, old);
91606 init_packet_edit_tile_terrain(old);
91607 }
91608
91609 differ = (old->terrain != real_packet->terrain);
91610 if (differ) {
91611 BV_SET(fields, 0);
91612 }
91613
91614 differ = (old->size != real_packet->size);
91615 if (differ) {
91616 BV_SET(fields, 1);
91617 }
91618#endif /* FREECIV_DELTA_PROTOCOL */
91619
91620#ifdef FREECIV_JSON_CONNECTION
91621 struct plocation field_addr;
91622 {
91623 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91624 field_addr = *field_addr_tmp;
91625 FC_FREE(field_addr_tmp);
91626 }
91627#endif /* FREECIV_JSON_CONNECTION */
91628
91629#ifdef FREECIV_JSON_CONNECTION
91630 field_addr.name = "tile";
91631#endif /* FREECIV_JSON_CONNECTION */
91632 e = 0;
91633
91634 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
91635
91636 if (e) {
91637 log_packet_detailed("'tile' field error detected");
91638 }
91639
91640#ifdef FREECIV_DELTA_PROTOCOL
91641#ifdef FREECIV_JSON_CONNECTION
91642 field_addr.name = "fields";
91643#endif /* FREECIV_JSON_CONNECTION */
91644 e = 0;
91645 e |= DIO_BV_PUT(&dout, &field_addr, fields);
91646 if (e) {
91647 log_packet_detailed("fields bitvector error detected");
91648 }
91649
91650 if (BV_ISSET(fields, 0)) {
91651 log_packet_detailed(" field 'terrain' has changed");
91652
91653#ifdef FREECIV_JSON_CONNECTION
91654 field_addr.name = "terrain";
91655#endif /* FREECIV_JSON_CONNECTION */
91656 e = 0;
91657
91658 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain);
91659
91660 if (e) {
91661 log_packet_detailed("'terrain' field error detected");
91662 }
91663 }
91664
91665 if (BV_ISSET(fields, 1)) {
91666 log_packet_detailed(" field 'size' has changed");
91667
91668#ifdef FREECIV_JSON_CONNECTION
91669 field_addr.name = "size";
91670#endif /* FREECIV_JSON_CONNECTION */
91671 e = 0;
91672
91673 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
91674
91675 if (e) {
91676 log_packet_detailed("'size' field error detected");
91677 }
91678 }
91679
91680 *old = *real_packet;
91681
91682#else /* FREECIV_DELTA_PROTOCOL */
91683#ifdef FREECIV_JSON_CONNECTION
91684 field_addr.name = "terrain";
91685#endif /* FREECIV_JSON_CONNECTION */
91686 e = 0;
91687
91688 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain);
91689
91690 if (e) {
91691 log_packet_detailed("'terrain' field error detected");
91692 }
91693
91694#ifdef FREECIV_JSON_CONNECTION
91695 field_addr.name = "size";
91696#endif /* FREECIV_JSON_CONNECTION */
91697 e = 0;
91698
91699 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
91700
91701 if (e) {
91702 log_packet_detailed("'size' field error detected");
91703 }
91704#endif /* FREECIV_DELTA_PROTOCOL */
91705
91706 SEND_PACKET_END(PACKET_EDIT_TILE_TERRAIN);
91707}
91708
91709 int send_packet_edit_tile_terrain(struct connection *pc, const struct packet_edit_tile_terrain *packet)
91710{
91711 if (!pc->used) {
91712 log_error("WARNING: trying to send data to the closed connection %s",
91713 conn_description(pc));
91714 return -1;
91715 }
91716 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE_TERRAIN].packet != nullptr, -1,
91717 "Handler for PACKET_EDIT_TILE_TERRAIN not installed");
91718 return pc->phs.handlers->send[PACKET_EDIT_TILE_TERRAIN].packet(pc, packet);
91719}
91720
91721 int dsend_packet_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
91722{
91723 struct packet_edit_tile_terrain packet, *real_packet = &packet;
91724
91725 real_packet->tile = tile;
91726 real_packet->terrain = terrain;
91727 real_packet->size = size;
91728
91729 return send_packet_edit_tile_terrain(pc, real_packet);
91730}
91731
91732 static inline void init_packet_edit_tile_extra(struct packet_edit_tile_extra *packet)
91733{
91734 memset(packet, 0, sizeof(*packet));
91735}
91736
91737#define free_packet_edit_tile_extra(_packet) (void) 0
91738#define destroy_packet_edit_tile_extra free
91739
91740#ifdef FREECIV_DELTA_PROTOCOL
91741static genhash_val_t hash_packet_edit_tile_extra_100(const void *vkey)
91742{
91743 const struct packet_edit_tile_extra *key = (const struct packet_edit_tile_extra *) vkey;
91744 genhash_val_t result = 0;
91745
91746 result += key->tile;
91747
91748 result &= 0xFFFFFFFF;
91749 return result;
91750}
91751
91752static bool cmp_packet_edit_tile_extra_100(const void *vkey1, const void *vkey2)
91753{
91754 const struct packet_edit_tile_extra *old = (const struct packet_edit_tile_extra *) vkey1;
91755 const struct packet_edit_tile_extra *real_packet = (const struct packet_edit_tile_extra *) vkey2;
91756 bool differ;
91757
91758 differ = (old->tile != real_packet->tile);
91759
91760 return !differ;
91761}
91762 BV_DEFINE(packet_edit_tile_extra_100_fields, 4);
91763#endif /* FREECIV_DELTA_PROTOCOL */
91764
91765 static struct packet_edit_tile_extra *receive_packet_edit_tile_extra_100(struct connection *pc)
91766{
91767#define FREE_PACKET_STRUCT(_packet) free_packet_edit_tile_extra(_packet)
91768 RECEIVE_PACKET_START(packet_edit_tile_extra, real_packet);
91769
91770#ifdef FREECIV_JSON_CONNECTION
91771 struct plocation field_addr;
91772 {
91773 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91774 field_addr = *field_addr_tmp;
91775 FC_FREE(field_addr_tmp);
91776 }
91777#endif /* FREECIV_JSON_CONNECTION */
91778
91779#ifdef FREECIV_JSON_CONNECTION
91780 field_addr.name = "tile";
91781#endif /* FREECIV_JSON_CONNECTION */
91782
91783 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
91784 RECEIVE_PACKET_FIELD_ERROR(tile);
91785 }
91786
91787 log_packet_detailed("packet_edit_tile_extra_100: got info about (%d)",
91788 real_packet->tile);
91789
91790#ifdef FREECIV_DELTA_PROTOCOL
91791 packet_edit_tile_extra_100_fields fields;
91792 struct packet_edit_tile_extra *old;
91793 struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE_EXTRA;
91794
91795 if (nullptr == *hash) {
91796 *hash = genhash_new_full(hash_packet_edit_tile_extra_100, cmp_packet_edit_tile_extra_100,
91797 nullptr, nullptr, nullptr, destroy_packet_edit_tile_extra);
91798 }
91799
91800 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
91801 *real_packet = *old;
91802 } else {
91803 /* packet is already initialized empty */
91804 log_packet_detailed(" no old info");
91805 }
91806
91807#ifdef FREECIV_JSON_CONNECTION
91808 field_addr.name = "fields";
91809#endif /* FREECIV_JSON_CONNECTION */
91810 DIO_BV_GET(&din, &field_addr, fields);
91811
91812 if (BV_ISSET(fields, 0)) {
91813 log_packet_detailed(" got field 'extra_type_id'");
91814
91815#ifdef FREECIV_JSON_CONNECTION
91816 field_addr.name = "extra_type_id";
91817#endif /* FREECIV_JSON_CONNECTION */
91818
91819 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->extra_type_id)) {
91820 RECEIVE_PACKET_FIELD_ERROR(extra_type_id);
91821 }
91822 }
91823
91824 real_packet->removal = BV_ISSET(fields, 1);
91825
91826 if (BV_ISSET(fields, 2)) {
91827 log_packet_detailed(" got field 'eowner'");
91828
91829#ifdef FREECIV_JSON_CONNECTION
91830 field_addr.name = "eowner";
91831#endif /* FREECIV_JSON_CONNECTION */
91832
91833 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->eowner)) {
91834 RECEIVE_PACKET_FIELD_ERROR(eowner);
91835 }
91836 }
91837
91838 if (BV_ISSET(fields, 3)) {
91839 log_packet_detailed(" got field 'size'");
91840
91841#ifdef FREECIV_JSON_CONNECTION
91842 field_addr.name = "size";
91843#endif /* FREECIV_JSON_CONNECTION */
91844
91845 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
91846 RECEIVE_PACKET_FIELD_ERROR(size);
91847 }
91848 }
91849
91850 if (nullptr == old) {
91851 old = fc_malloc(sizeof(*old));
91852 init_packet_edit_tile_extra(old);
91853 *old = *real_packet;
91854 genhash_insert(*hash, old, old);
91855 } else {
91856 *old = *real_packet;
91857 }
91858
91859#else /* FREECIV_DELTA_PROTOCOL */
91860#ifdef FREECIV_JSON_CONNECTION
91861 field_addr.name = "extra_type_id";
91862#endif /* FREECIV_JSON_CONNECTION */
91863
91864 if (!DIO_GET(sint8, &din, &field_addr, &real_packet->extra_type_id)) {
91865 RECEIVE_PACKET_FIELD_ERROR(extra_type_id);
91866 }
91867
91868#ifdef FREECIV_JSON_CONNECTION
91869 field_addr.name = "removal";
91870#endif /* FREECIV_JSON_CONNECTION */
91871
91872 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->removal)) {
91873 RECEIVE_PACKET_FIELD_ERROR(removal);
91874 }
91875
91876#ifdef FREECIV_JSON_CONNECTION
91877 field_addr.name = "eowner";
91878#endif /* FREECIV_JSON_CONNECTION */
91879
91880 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->eowner)) {
91881 RECEIVE_PACKET_FIELD_ERROR(eowner);
91882 }
91883
91884#ifdef FREECIV_JSON_CONNECTION
91885 field_addr.name = "size";
91886#endif /* FREECIV_JSON_CONNECTION */
91887
91888 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
91889 RECEIVE_PACKET_FIELD_ERROR(size);
91890 }
91891#endif /* FREECIV_DELTA_PROTOCOL */
91892
91893 RECEIVE_PACKET_END(real_packet);
91894#undef FREE_PACKET_STRUCT
91895}
91896
91897 static int send_packet_edit_tile_extra_100(struct connection *pc, const struct packet_edit_tile_extra *packet)
91898{
91899 const struct packet_edit_tile_extra *real_packet = packet;
91900 int e;
91901 SEND_PACKET_START(PACKET_EDIT_TILE_EXTRA);
91902
91903 log_packet_detailed("packet_edit_tile_extra_100: sending info about (%d)",
91904 real_packet->tile);
91905
91906#ifdef FREECIV_DELTA_PROTOCOL
91907 packet_edit_tile_extra_100_fields fields;
91908 struct packet_edit_tile_extra *old;
91909 bool differ;
91910 struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE_EXTRA;
91911
91912 if (nullptr == *hash) {
91913 *hash = genhash_new_full(hash_packet_edit_tile_extra_100, cmp_packet_edit_tile_extra_100,
91914 nullptr, nullptr, nullptr, destroy_packet_edit_tile_extra);
91915 }
91916 BV_CLR_ALL(fields);
91917
91918 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
91919 old = fc_malloc(sizeof(*old));
91920 /* temporary bitcopy just to insert correctly */
91921 *old = *real_packet;
91922 genhash_insert(*hash, old, old);
91923 init_packet_edit_tile_extra(old);
91924 }
91925
91926 differ = (old->extra_type_id != real_packet->extra_type_id);
91927 if (differ) {
91928 BV_SET(fields, 0);
91929 }
91930
91931 /* folded into head */
91932 if (real_packet->removal) {
91933 BV_SET(fields, 1);
91934 }
91935
91936 differ = (old->eowner != real_packet->eowner);
91937 if (differ) {
91938 BV_SET(fields, 2);
91939 }
91940
91941 differ = (old->size != real_packet->size);
91942 if (differ) {
91943 BV_SET(fields, 3);
91944 }
91945#endif /* FREECIV_DELTA_PROTOCOL */
91946
91947#ifdef FREECIV_JSON_CONNECTION
91948 struct plocation field_addr;
91949 {
91950 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
91951 field_addr = *field_addr_tmp;
91952 FC_FREE(field_addr_tmp);
91953 }
91954#endif /* FREECIV_JSON_CONNECTION */
91955
91956#ifdef FREECIV_JSON_CONNECTION
91957 field_addr.name = "tile";
91958#endif /* FREECIV_JSON_CONNECTION */
91959 e = 0;
91960
91961 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
91962
91963 if (e) {
91964 log_packet_detailed("'tile' field error detected");
91965 }
91966
91967#ifdef FREECIV_DELTA_PROTOCOL
91968#ifdef FREECIV_JSON_CONNECTION
91969 field_addr.name = "fields";
91970#endif /* FREECIV_JSON_CONNECTION */
91971 e = 0;
91972 e |= DIO_BV_PUT(&dout, &field_addr, fields);
91973 if (e) {
91974 log_packet_detailed("fields bitvector error detected");
91975 }
91976
91977 if (BV_ISSET(fields, 0)) {
91978 log_packet_detailed(" field 'extra_type_id' has changed");
91979
91980#ifdef FREECIV_JSON_CONNECTION
91981 field_addr.name = "extra_type_id";
91982#endif /* FREECIV_JSON_CONNECTION */
91983 e = 0;
91984
91985 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->extra_type_id);
91986
91987 if (e) {
91988 log_packet_detailed("'extra_type_id' field error detected");
91989 }
91990 }
91991
91992 /* field 1 is folded into the header */
91993
91994 if (BV_ISSET(fields, 2)) {
91995 log_packet_detailed(" field 'eowner' has changed");
91996
91997#ifdef FREECIV_JSON_CONNECTION
91998 field_addr.name = "eowner";
91999#endif /* FREECIV_JSON_CONNECTION */
92000 e = 0;
92001
92002 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->eowner);
92003
92004 if (e) {
92005 log_packet_detailed("'eowner' field error detected");
92006 }
92007 }
92008
92009 if (BV_ISSET(fields, 3)) {
92010 log_packet_detailed(" field 'size' has changed");
92011
92012#ifdef FREECIV_JSON_CONNECTION
92013 field_addr.name = "size";
92014#endif /* FREECIV_JSON_CONNECTION */
92015 e = 0;
92016
92017 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
92018
92019 if (e) {
92020 log_packet_detailed("'size' field error detected");
92021 }
92022 }
92023
92024 *old = *real_packet;
92025
92026#else /* FREECIV_DELTA_PROTOCOL */
92027#ifdef FREECIV_JSON_CONNECTION
92028 field_addr.name = "extra_type_id";
92029#endif /* FREECIV_JSON_CONNECTION */
92030 e = 0;
92031
92032 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->extra_type_id);
92033
92034 if (e) {
92035 log_packet_detailed("'extra_type_id' field error detected");
92036 }
92037
92038#ifdef FREECIV_JSON_CONNECTION
92039 field_addr.name = "removal";
92040#endif /* FREECIV_JSON_CONNECTION */
92041 e = 0;
92042
92043 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->removal);
92044
92045 if (e) {
92046 log_packet_detailed("'removal' field error detected");
92047 }
92048
92049#ifdef FREECIV_JSON_CONNECTION
92050 field_addr.name = "eowner";
92051#endif /* FREECIV_JSON_CONNECTION */
92052 e = 0;
92053
92054 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->eowner);
92055
92056 if (e) {
92057 log_packet_detailed("'eowner' field error detected");
92058 }
92059
92060#ifdef FREECIV_JSON_CONNECTION
92061 field_addr.name = "size";
92062#endif /* FREECIV_JSON_CONNECTION */
92063 e = 0;
92064
92065 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
92066
92067 if (e) {
92068 log_packet_detailed("'size' field error detected");
92069 }
92070#endif /* FREECIV_DELTA_PROTOCOL */
92071
92072 SEND_PACKET_END(PACKET_EDIT_TILE_EXTRA);
92073}
92074
92075 int send_packet_edit_tile_extra(struct connection *pc, const struct packet_edit_tile_extra *packet)
92076{
92077 if (!pc->used) {
92078 log_error("WARNING: trying to send data to the closed connection %s",
92079 conn_description(pc));
92080 return -1;
92081 }
92082 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE_EXTRA].packet != nullptr, -1,
92083 "Handler for PACKET_EDIT_TILE_EXTRA not installed");
92084 return pc->phs.handlers->send[PACKET_EDIT_TILE_EXTRA].packet(pc, packet);
92085}
92086
92087 int dsend_packet_edit_tile_extra(struct connection *pc, int tile, int extra_type_id, bool removal, int eowner, int size)
92088{
92089 struct packet_edit_tile_extra packet, *real_packet = &packet;
92090
92091 real_packet->tile = tile;
92092 real_packet->extra_type_id = extra_type_id;
92093 real_packet->removal = removal;
92094 real_packet->eowner = eowner;
92095 real_packet->size = size;
92096
92097 return send_packet_edit_tile_extra(pc, real_packet);
92098}
92099
92100 static inline void init_packet_edit_startpos(struct packet_edit_startpos *packet)
92101{
92102 memset(packet, 0, sizeof(*packet));
92103}
92104
92105#define free_packet_edit_startpos(_packet) (void) 0
92106#define destroy_packet_edit_startpos free
92107
92108 static struct packet_edit_startpos *receive_packet_edit_startpos_100(struct connection *pc)
92109{
92110#define FREE_PACKET_STRUCT(_packet) free_packet_edit_startpos(_packet)
92111 RECEIVE_PACKET_START(packet_edit_startpos, real_packet);
92112
92113#ifdef FREECIV_JSON_CONNECTION
92114 struct plocation field_addr;
92115 {
92116 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92117 field_addr = *field_addr_tmp;
92118 FC_FREE(field_addr_tmp);
92119 }
92120#endif /* FREECIV_JSON_CONNECTION */
92121
92122 log_packet_detailed("packet_edit_startpos_100: got info about ()");
92123
92124#ifdef FREECIV_JSON_CONNECTION
92125 field_addr.name = "id";
92126#endif /* FREECIV_JSON_CONNECTION */
92127
92128 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->id)) {
92129 RECEIVE_PACKET_FIELD_ERROR(id);
92130 }
92131
92132#ifdef FREECIV_JSON_CONNECTION
92133 field_addr.name = "removal";
92134#endif /* FREECIV_JSON_CONNECTION */
92135
92136 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->removal)) {
92137 RECEIVE_PACKET_FIELD_ERROR(removal);
92138 }
92139
92140#ifdef FREECIV_JSON_CONNECTION
92141 field_addr.name = "tag";
92142#endif /* FREECIV_JSON_CONNECTION */
92143
92144 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
92145 RECEIVE_PACKET_FIELD_ERROR(tag);
92146 }
92147
92148 RECEIVE_PACKET_END(real_packet);
92149#undef FREE_PACKET_STRUCT
92150}
92151
92152 static int send_packet_edit_startpos_100(struct connection *pc, const struct packet_edit_startpos *packet)
92153{
92154 const struct packet_edit_startpos *real_packet = packet;
92155 int e;
92156 SEND_PACKET_START(PACKET_EDIT_STARTPOS);
92157
92158 log_packet_detailed("packet_edit_startpos_100: sending info about ()");
92159
92160#ifdef FREECIV_JSON_CONNECTION
92161 struct plocation field_addr;
92162 {
92163 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92164 field_addr = *field_addr_tmp;
92165 FC_FREE(field_addr_tmp);
92166 }
92167#endif /* FREECIV_JSON_CONNECTION */
92168
92169#ifdef FREECIV_JSON_CONNECTION
92170 field_addr.name = "id";
92171#endif /* FREECIV_JSON_CONNECTION */
92172 e = 0;
92173
92174 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->id);
92175
92176 if (e) {
92177 log_packet_detailed("'id' field error detected");
92178 }
92179
92180#ifdef FREECIV_JSON_CONNECTION
92181 field_addr.name = "removal";
92182#endif /* FREECIV_JSON_CONNECTION */
92183 e = 0;
92184
92185 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->removal);
92186
92187 if (e) {
92188 log_packet_detailed("'removal' field error detected");
92189 }
92190
92191#ifdef FREECIV_JSON_CONNECTION
92192 field_addr.name = "tag";
92193#endif /* FREECIV_JSON_CONNECTION */
92194 e = 0;
92195
92196 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
92197
92198 if (e) {
92199 log_packet_detailed("'tag' field error detected");
92200 }
92201
92202 SEND_PACKET_END(PACKET_EDIT_STARTPOS);
92203}
92204
92205 int send_packet_edit_startpos(struct connection *pc, const struct packet_edit_startpos *packet)
92206{
92207 if (!pc->used) {
92208 log_error("WARNING: trying to send data to the closed connection %s",
92209 conn_description(pc));
92210 return -1;
92211 }
92212 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_STARTPOS].packet != nullptr, -1,
92213 "Handler for PACKET_EDIT_STARTPOS not installed");
92214 return pc->phs.handlers->send[PACKET_EDIT_STARTPOS].packet(pc, packet);
92215}
92216
92217 int dsend_packet_edit_startpos(struct connection *pc, int id, bool removal, int tag)
92218{
92219 struct packet_edit_startpos packet, *real_packet = &packet;
92220
92221 real_packet->id = id;
92222 real_packet->removal = removal;
92223 real_packet->tag = tag;
92224
92225 return send_packet_edit_startpos(pc, real_packet);
92226}
92227
92228 static inline void init_packet_edit_startpos_full(struct packet_edit_startpos_full *packet)
92229{
92230 memset(packet, 0, sizeof(*packet));
92231}
92232
92233#define free_packet_edit_startpos_full(_packet) (void) 0
92234#define destroy_packet_edit_startpos_full free
92235
92236 static struct packet_edit_startpos_full *receive_packet_edit_startpos_full_100(struct connection *pc)
92237{
92238#define FREE_PACKET_STRUCT(_packet) free_packet_edit_startpos_full(_packet)
92239 RECEIVE_PACKET_START(packet_edit_startpos_full, real_packet);
92240
92241#ifdef FREECIV_JSON_CONNECTION
92242 struct plocation field_addr;
92243 {
92244 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92245 field_addr = *field_addr_tmp;
92246 FC_FREE(field_addr_tmp);
92247 }
92248#endif /* FREECIV_JSON_CONNECTION */
92249
92250 log_packet_detailed("packet_edit_startpos_full_100: got info about ()");
92251
92252#ifdef FREECIV_JSON_CONNECTION
92253 field_addr.name = "id";
92254#endif /* FREECIV_JSON_CONNECTION */
92255
92256 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->id)) {
92257 RECEIVE_PACKET_FIELD_ERROR(id);
92258 }
92259
92260#ifdef FREECIV_JSON_CONNECTION
92261 field_addr.name = "exclude";
92262#endif /* FREECIV_JSON_CONNECTION */
92263
92264 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->exclude)) {
92265 RECEIVE_PACKET_FIELD_ERROR(exclude);
92266 }
92267
92268#ifdef FREECIV_JSON_CONNECTION
92269 field_addr.name = "nations";
92270#endif /* FREECIV_JSON_CONNECTION */
92271
92272 if (!DIO_BV_GET(&din, &field_addr, real_packet->nations)) {
92273 RECEIVE_PACKET_FIELD_ERROR(nations);
92274 }
92275
92276 RECEIVE_PACKET_END(real_packet);
92277#undef FREE_PACKET_STRUCT
92278}
92279
92280 static int send_packet_edit_startpos_full_100(struct connection *pc, const struct packet_edit_startpos_full *packet)
92281{
92282 const struct packet_edit_startpos_full *real_packet = packet;
92283 int e;
92284 SEND_PACKET_START(PACKET_EDIT_STARTPOS_FULL);
92285
92286 log_packet_detailed("packet_edit_startpos_full_100: sending info about ()");
92287
92288#ifdef FREECIV_JSON_CONNECTION
92289 struct plocation field_addr;
92290 {
92291 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92292 field_addr = *field_addr_tmp;
92293 FC_FREE(field_addr_tmp);
92294 }
92295#endif /* FREECIV_JSON_CONNECTION */
92296
92297#ifdef FREECIV_JSON_CONNECTION
92298 field_addr.name = "id";
92299#endif /* FREECIV_JSON_CONNECTION */
92300 e = 0;
92301
92302 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->id);
92303
92304 if (e) {
92305 log_packet_detailed("'id' field error detected");
92306 }
92307
92308#ifdef FREECIV_JSON_CONNECTION
92309 field_addr.name = "exclude";
92310#endif /* FREECIV_JSON_CONNECTION */
92311 e = 0;
92312
92313 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->exclude);
92314
92315 if (e) {
92316 log_packet_detailed("'exclude' field error detected");
92317 }
92318
92319#ifdef FREECIV_JSON_CONNECTION
92320 field_addr.name = "nations";
92321#endif /* FREECIV_JSON_CONNECTION */
92322 e = 0;
92323
92324 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->nations);
92325
92326 if (e) {
92327 log_packet_detailed("'nations' field error detected");
92328 }
92329
92330 SEND_PACKET_END(PACKET_EDIT_STARTPOS_FULL);
92331}
92332
92333 int send_packet_edit_startpos_full(struct connection *pc, const struct packet_edit_startpos_full *packet)
92334{
92335 if (!pc->used) {
92336 log_error("WARNING: trying to send data to the closed connection %s",
92337 conn_description(pc));
92338 return -1;
92339 }
92340 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_STARTPOS_FULL].packet != nullptr, -1,
92341 "Handler for PACKET_EDIT_STARTPOS_FULL not installed");
92342 return pc->phs.handlers->send[PACKET_EDIT_STARTPOS_FULL].packet(pc, packet);
92343}
92344
92345 static inline void init_packet_edit_tile(struct packet_edit_tile *packet)
92346{
92347 memset(packet, 0, sizeof(*packet));
92348}
92349
92350#define free_packet_edit_tile(_packet) (void) 0
92351#define destroy_packet_edit_tile free
92352
92353#ifdef FREECIV_DELTA_PROTOCOL
92354static genhash_val_t hash_packet_edit_tile_100(const void *vkey)
92355{
92356 const struct packet_edit_tile *key = (const struct packet_edit_tile *) vkey;
92357 genhash_val_t result = 0;
92358
92359 result += key->tile;
92360
92361 result &= 0xFFFFFFFF;
92362 return result;
92363}
92364
92365static bool cmp_packet_edit_tile_100(const void *vkey1, const void *vkey2)
92366{
92367 const struct packet_edit_tile *old = (const struct packet_edit_tile *) vkey1;
92368 const struct packet_edit_tile *real_packet = (const struct packet_edit_tile *) vkey2;
92369 bool differ;
92370
92371 differ = (old->tile != real_packet->tile);
92372
92373 return !differ;
92374}
92375 BV_DEFINE(packet_edit_tile_100_fields, 6);
92376#endif /* FREECIV_DELTA_PROTOCOL */
92377
92378 static struct packet_edit_tile *receive_packet_edit_tile_100(struct connection *pc)
92379{
92380#define FREE_PACKET_STRUCT(_packet) free_packet_edit_tile(_packet)
92381 RECEIVE_PACKET_START(packet_edit_tile, real_packet);
92382
92383#ifdef FREECIV_JSON_CONNECTION
92384 struct plocation field_addr;
92385 {
92386 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92387 field_addr = *field_addr_tmp;
92388 FC_FREE(field_addr_tmp);
92389 }
92390#endif /* FREECIV_JSON_CONNECTION */
92391
92392#ifdef FREECIV_JSON_CONNECTION
92393 field_addr.name = "tile";
92394#endif /* FREECIV_JSON_CONNECTION */
92395
92396 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
92397 RECEIVE_PACKET_FIELD_ERROR(tile);
92398 }
92399
92400 log_packet_detailed("packet_edit_tile_100: got info about (%d)",
92401 real_packet->tile);
92402
92403#ifdef FREECIV_DELTA_PROTOCOL
92404 packet_edit_tile_100_fields fields;
92405 struct packet_edit_tile *old;
92406 struct genhash **hash = pc->phs.received + PACKET_EDIT_TILE;
92407
92408 if (nullptr == *hash) {
92409 *hash = genhash_new_full(hash_packet_edit_tile_100, cmp_packet_edit_tile_100,
92410 nullptr, nullptr, nullptr, destroy_packet_edit_tile);
92411 }
92412
92413 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
92414 *real_packet = *old;
92415 } else {
92416 /* packet is already initialized empty */
92417 log_packet_detailed(" no old info");
92418 }
92419
92420#ifdef FREECIV_JSON_CONNECTION
92421 field_addr.name = "fields";
92422#endif /* FREECIV_JSON_CONNECTION */
92423 DIO_BV_GET(&din, &field_addr, fields);
92424
92425 if (BV_ISSET(fields, 0)) {
92426 log_packet_detailed(" got field 'extras'");
92427
92428#ifdef FREECIV_JSON_CONNECTION
92429 field_addr.name = "extras";
92430#endif /* FREECIV_JSON_CONNECTION */
92431
92432 if (!DIO_BV_GET(&din, &field_addr, real_packet->extras)) {
92433 RECEIVE_PACKET_FIELD_ERROR(extras);
92434 }
92435 }
92436
92437 if (BV_ISSET(fields, 1)) {
92438 log_packet_detailed(" got field 'resource'");
92439
92440#ifdef FREECIV_JSON_CONNECTION
92441 field_addr.name = "resource";
92442#endif /* FREECIV_JSON_CONNECTION */
92443
92444 {
92445 int readin;
92446
92447 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
92448 RECEIVE_PACKET_FIELD_ERROR(resource);
92449 }
92450 real_packet->resource = readin;
92451 }
92452 }
92453
92454 if (BV_ISSET(fields, 2)) {
92455 log_packet_detailed(" got field 'terrain'");
92456
92457#ifdef FREECIV_JSON_CONNECTION
92458 field_addr.name = "terrain";
92459#endif /* FREECIV_JSON_CONNECTION */
92460
92461 {
92462 int readin;
92463
92464 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
92465 RECEIVE_PACKET_FIELD_ERROR(terrain);
92466 }
92467 real_packet->terrain = readin;
92468 }
92469 }
92470
92471 if (BV_ISSET(fields, 3)) {
92472 log_packet_detailed(" got field 'startpos_nation'");
92473
92474#ifdef FREECIV_JSON_CONNECTION
92475 field_addr.name = "startpos_nation";
92476#endif /* FREECIV_JSON_CONNECTION */
92477
92478 {
92479 int readin;
92480
92481 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
92482 RECEIVE_PACKET_FIELD_ERROR(startpos_nation);
92483 }
92484 real_packet->startpos_nation = readin;
92485 }
92486 }
92487
92488 if (BV_ISSET(fields, 4)) {
92489 log_packet_detailed(" got field 'eowner'");
92490
92491#ifdef FREECIV_JSON_CONNECTION
92492 field_addr.name = "eowner";
92493#endif /* FREECIV_JSON_CONNECTION */
92494
92495 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->eowner)) {
92496 RECEIVE_PACKET_FIELD_ERROR(eowner);
92497 }
92498 }
92499
92500 if (BV_ISSET(fields, 5)) {
92501 log_packet_detailed(" got field 'label'");
92502
92503#ifdef FREECIV_JSON_CONNECTION
92504 field_addr.name = "label";
92505#endif /* FREECIV_JSON_CONNECTION */
92506
92507 if (!DIO_GET(string, &din, &field_addr, real_packet->label, sizeof(real_packet->label))) {
92508 RECEIVE_PACKET_FIELD_ERROR(label);
92509 }
92510 }
92511
92512 if (nullptr == old) {
92513 old = fc_malloc(sizeof(*old));
92514 init_packet_edit_tile(old);
92515 *old = *real_packet;
92516 genhash_insert(*hash, old, old);
92517 } else {
92518 *old = *real_packet;
92519 }
92520
92521#else /* FREECIV_DELTA_PROTOCOL */
92522#ifdef FREECIV_JSON_CONNECTION
92523 field_addr.name = "extras";
92524#endif /* FREECIV_JSON_CONNECTION */
92525
92526 if (!DIO_BV_GET(&din, &field_addr, real_packet->extras)) {
92527 RECEIVE_PACKET_FIELD_ERROR(extras);
92528 }
92529
92530#ifdef FREECIV_JSON_CONNECTION
92531 field_addr.name = "resource";
92532#endif /* FREECIV_JSON_CONNECTION */
92533
92534 {
92535 int readin;
92536
92537 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
92538 RECEIVE_PACKET_FIELD_ERROR(resource);
92539 }
92540 real_packet->resource = readin;
92541 }
92542
92543#ifdef FREECIV_JSON_CONNECTION
92544 field_addr.name = "terrain";
92545#endif /* FREECIV_JSON_CONNECTION */
92546
92547 {
92548 int readin;
92549
92550 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
92551 RECEIVE_PACKET_FIELD_ERROR(terrain);
92552 }
92553 real_packet->terrain = readin;
92554 }
92555
92556#ifdef FREECIV_JSON_CONNECTION
92557 field_addr.name = "startpos_nation";
92558#endif /* FREECIV_JSON_CONNECTION */
92559
92560 {
92561 int readin;
92562
92563 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
92564 RECEIVE_PACKET_FIELD_ERROR(startpos_nation);
92565 }
92566 real_packet->startpos_nation = readin;
92567 }
92568
92569#ifdef FREECIV_JSON_CONNECTION
92570 field_addr.name = "eowner";
92571#endif /* FREECIV_JSON_CONNECTION */
92572
92573 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->eowner)) {
92574 RECEIVE_PACKET_FIELD_ERROR(eowner);
92575 }
92576
92577#ifdef FREECIV_JSON_CONNECTION
92578 field_addr.name = "label";
92579#endif /* FREECIV_JSON_CONNECTION */
92580
92581 if (!DIO_GET(string, &din, &field_addr, real_packet->label, sizeof(real_packet->label))) {
92582 RECEIVE_PACKET_FIELD_ERROR(label);
92583 }
92584#endif /* FREECIV_DELTA_PROTOCOL */
92585
92586 RECEIVE_PACKET_END(real_packet);
92587#undef FREE_PACKET_STRUCT
92588}
92589
92590 static int send_packet_edit_tile_100(struct connection *pc, const struct packet_edit_tile *packet)
92591{
92592 const struct packet_edit_tile *real_packet = packet;
92593 int e;
92594 SEND_PACKET_START(PACKET_EDIT_TILE);
92595
92596 log_packet_detailed("packet_edit_tile_100: sending info about (%d)",
92597 real_packet->tile);
92598
92599#ifdef FREECIV_DELTA_PROTOCOL
92600 packet_edit_tile_100_fields fields;
92601 struct packet_edit_tile *old;
92602 bool differ;
92603 struct genhash **hash = pc->phs.sent + PACKET_EDIT_TILE;
92604
92605 if (nullptr == *hash) {
92606 *hash = genhash_new_full(hash_packet_edit_tile_100, cmp_packet_edit_tile_100,
92607 nullptr, nullptr, nullptr, destroy_packet_edit_tile);
92608 }
92609 BV_CLR_ALL(fields);
92610
92611 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
92612 old = fc_malloc(sizeof(*old));
92613 /* temporary bitcopy just to insert correctly */
92614 *old = *real_packet;
92615 genhash_insert(*hash, old, old);
92616 init_packet_edit_tile(old);
92617 }
92618
92619 differ = !BV_ARE_EQUAL(old->extras, real_packet->extras);
92620 if (differ) {
92621 BV_SET(fields, 0);
92622 }
92623
92624 differ = (old->resource != real_packet->resource);
92625 if (differ) {
92626 BV_SET(fields, 1);
92627 }
92628
92629 differ = (old->terrain != real_packet->terrain);
92630 if (differ) {
92631 BV_SET(fields, 2);
92632 }
92633
92634 differ = (old->startpos_nation != real_packet->startpos_nation);
92635 if (differ) {
92636 BV_SET(fields, 3);
92637 }
92638
92639 differ = (old->eowner != real_packet->eowner);
92640 if (differ) {
92641 BV_SET(fields, 4);
92642 }
92643
92644 differ = (strcmp(old->label, real_packet->label) != 0);
92645 if (differ) {
92646 BV_SET(fields, 5);
92647 }
92648#endif /* FREECIV_DELTA_PROTOCOL */
92649
92650#ifdef FREECIV_JSON_CONNECTION
92651 struct plocation field_addr;
92652 {
92653 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92654 field_addr = *field_addr_tmp;
92655 FC_FREE(field_addr_tmp);
92656 }
92657#endif /* FREECIV_JSON_CONNECTION */
92658
92659#ifdef FREECIV_JSON_CONNECTION
92660 field_addr.name = "tile";
92661#endif /* FREECIV_JSON_CONNECTION */
92662 e = 0;
92663
92664 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
92665
92666 if (e) {
92667 log_packet_detailed("'tile' field error detected");
92668 }
92669
92670#ifdef FREECIV_DELTA_PROTOCOL
92671#ifdef FREECIV_JSON_CONNECTION
92672 field_addr.name = "fields";
92673#endif /* FREECIV_JSON_CONNECTION */
92674 e = 0;
92675 e |= DIO_BV_PUT(&dout, &field_addr, fields);
92676 if (e) {
92677 log_packet_detailed("fields bitvector error detected");
92678 }
92679
92680 if (BV_ISSET(fields, 0)) {
92681 log_packet_detailed(" field 'extras' has changed");
92682
92683#ifdef FREECIV_JSON_CONNECTION
92684 field_addr.name = "extras";
92685#endif /* FREECIV_JSON_CONNECTION */
92686 e = 0;
92687
92688 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->extras);
92689
92690 if (e) {
92691 log_packet_detailed("'extras' field error detected");
92692 }
92693 }
92694
92695 if (BV_ISSET(fields, 1)) {
92696 log_packet_detailed(" field 'resource' has changed");
92697
92698#ifdef FREECIV_JSON_CONNECTION
92699 field_addr.name = "resource";
92700#endif /* FREECIV_JSON_CONNECTION */
92701 e = 0;
92702
92703 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resource);
92704
92705 if (e) {
92706 log_packet_detailed("'resource' field error detected");
92707 }
92708 }
92709
92710 if (BV_ISSET(fields, 2)) {
92711 log_packet_detailed(" field 'terrain' has changed");
92712
92713#ifdef FREECIV_JSON_CONNECTION
92714 field_addr.name = "terrain";
92715#endif /* FREECIV_JSON_CONNECTION */
92716 e = 0;
92717
92718 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain);
92719
92720 if (e) {
92721 log_packet_detailed("'terrain' field error detected");
92722 }
92723 }
92724
92725 if (BV_ISSET(fields, 3)) {
92726 log_packet_detailed(" field 'startpos_nation' has changed");
92727
92728#ifdef FREECIV_JSON_CONNECTION
92729 field_addr.name = "startpos_nation";
92730#endif /* FREECIV_JSON_CONNECTION */
92731 e = 0;
92732
92733 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->startpos_nation);
92734
92735 if (e) {
92736 log_packet_detailed("'startpos_nation' field error detected");
92737 }
92738 }
92739
92740 if (BV_ISSET(fields, 4)) {
92741 log_packet_detailed(" field 'eowner' has changed");
92742
92743#ifdef FREECIV_JSON_CONNECTION
92744 field_addr.name = "eowner";
92745#endif /* FREECIV_JSON_CONNECTION */
92746 e = 0;
92747
92748 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->eowner);
92749
92750 if (e) {
92751 log_packet_detailed("'eowner' field error detected");
92752 }
92753 }
92754
92755 if (BV_ISSET(fields, 5)) {
92756 log_packet_detailed(" field 'label' has changed");
92757
92758#ifdef FREECIV_JSON_CONNECTION
92759 field_addr.name = "label";
92760#endif /* FREECIV_JSON_CONNECTION */
92761 e = 0;
92762
92763 e |= DIO_PUT(string, &dout, &field_addr, real_packet->label);
92764
92765 if (e) {
92766 log_packet_detailed("'label' field error detected");
92767 }
92768 }
92769
92770 *old = *real_packet;
92771
92772#else /* FREECIV_DELTA_PROTOCOL */
92773#ifdef FREECIV_JSON_CONNECTION
92774 field_addr.name = "extras";
92775#endif /* FREECIV_JSON_CONNECTION */
92776 e = 0;
92777
92778 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->extras);
92779
92780 if (e) {
92781 log_packet_detailed("'extras' field error detected");
92782 }
92783
92784#ifdef FREECIV_JSON_CONNECTION
92785 field_addr.name = "resource";
92786#endif /* FREECIV_JSON_CONNECTION */
92787 e = 0;
92788
92789 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->resource);
92790
92791 if (e) {
92792 log_packet_detailed("'resource' field error detected");
92793 }
92794
92795#ifdef FREECIV_JSON_CONNECTION
92796 field_addr.name = "terrain";
92797#endif /* FREECIV_JSON_CONNECTION */
92798 e = 0;
92799
92800 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->terrain);
92801
92802 if (e) {
92803 log_packet_detailed("'terrain' field error detected");
92804 }
92805
92806#ifdef FREECIV_JSON_CONNECTION
92807 field_addr.name = "startpos_nation";
92808#endif /* FREECIV_JSON_CONNECTION */
92809 e = 0;
92810
92811 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->startpos_nation);
92812
92813 if (e) {
92814 log_packet_detailed("'startpos_nation' field error detected");
92815 }
92816
92817#ifdef FREECIV_JSON_CONNECTION
92818 field_addr.name = "eowner";
92819#endif /* FREECIV_JSON_CONNECTION */
92820 e = 0;
92821
92822 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->eowner);
92823
92824 if (e) {
92825 log_packet_detailed("'eowner' field error detected");
92826 }
92827
92828#ifdef FREECIV_JSON_CONNECTION
92829 field_addr.name = "label";
92830#endif /* FREECIV_JSON_CONNECTION */
92831 e = 0;
92832
92833 e |= DIO_PUT(string, &dout, &field_addr, real_packet->label);
92834
92835 if (e) {
92836 log_packet_detailed("'label' field error detected");
92837 }
92838#endif /* FREECIV_DELTA_PROTOCOL */
92839
92840 SEND_PACKET_END(PACKET_EDIT_TILE);
92841}
92842
92843 int send_packet_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
92844{
92845 if (!pc->used) {
92846 log_error("WARNING: trying to send data to the closed connection %s",
92847 conn_description(pc));
92848 return -1;
92849 }
92850 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_TILE].packet != nullptr, -1,
92851 "Handler for PACKET_EDIT_TILE not installed");
92852 return pc->phs.handlers->send[PACKET_EDIT_TILE].packet(pc, packet);
92853}
92854
92855 static inline void init_packet_edit_unit_create(struct packet_edit_unit_create *packet)
92856{
92857 memset(packet, 0, sizeof(*packet));
92858}
92859
92860#define free_packet_edit_unit_create(_packet) (void) 0
92861#define destroy_packet_edit_unit_create free
92862
92863#ifdef FREECIV_DELTA_PROTOCOL
92864#define hash_packet_edit_unit_create_100 hash_const
92865#define cmp_packet_edit_unit_create_100 cmp_const
92866 BV_DEFINE(packet_edit_unit_create_100_fields, 5);
92867#endif /* FREECIV_DELTA_PROTOCOL */
92868
92869 static struct packet_edit_unit_create *receive_packet_edit_unit_create_100(struct connection *pc)
92870{
92871#define FREE_PACKET_STRUCT(_packet) free_packet_edit_unit_create(_packet)
92872 RECEIVE_PACKET_START(packet_edit_unit_create, real_packet);
92873
92874#ifdef FREECIV_JSON_CONNECTION
92875 struct plocation field_addr;
92876 {
92877 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
92878 field_addr = *field_addr_tmp;
92879 FC_FREE(field_addr_tmp);
92880 }
92881#endif /* FREECIV_JSON_CONNECTION */
92882
92883 log_packet_detailed("packet_edit_unit_create_100: got info about ()");
92884
92885#ifdef FREECIV_DELTA_PROTOCOL
92886 packet_edit_unit_create_100_fields fields;
92887 struct packet_edit_unit_create *old;
92888 struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT_CREATE;
92889
92890 if (nullptr == *hash) {
92891 *hash = genhash_new_full(hash_packet_edit_unit_create_100, cmp_packet_edit_unit_create_100,
92892 nullptr, nullptr, nullptr, destroy_packet_edit_unit_create);
92893 }
92894
92895 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
92896 *real_packet = *old;
92897 } else {
92898 /* packet is already initialized empty */
92899 log_packet_detailed(" no old info");
92900 }
92901
92902#ifdef FREECIV_JSON_CONNECTION
92903 field_addr.name = "fields";
92904#endif /* FREECIV_JSON_CONNECTION */
92905 DIO_BV_GET(&din, &field_addr, fields);
92906
92907 if (BV_ISSET(fields, 0)) {
92908 log_packet_detailed(" got field 'owner'");
92909
92910#ifdef FREECIV_JSON_CONNECTION
92911 field_addr.name = "owner";
92912#endif /* FREECIV_JSON_CONNECTION */
92913
92914 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
92915 RECEIVE_PACKET_FIELD_ERROR(owner);
92916 }
92917 }
92918
92919 if (BV_ISSET(fields, 1)) {
92920 log_packet_detailed(" got field 'tile'");
92921
92922#ifdef FREECIV_JSON_CONNECTION
92923 field_addr.name = "tile";
92924#endif /* FREECIV_JSON_CONNECTION */
92925
92926 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
92927 RECEIVE_PACKET_FIELD_ERROR(tile);
92928 }
92929 }
92930
92931 if (BV_ISSET(fields, 2)) {
92932 log_packet_detailed(" got field 'type'");
92933
92934#ifdef FREECIV_JSON_CONNECTION
92935 field_addr.name = "type";
92936#endif /* FREECIV_JSON_CONNECTION */
92937
92938 {
92939 int readin;
92940
92941 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
92942 RECEIVE_PACKET_FIELD_ERROR(type);
92943 }
92944 real_packet->type = readin;
92945 }
92946 }
92947
92948 if (BV_ISSET(fields, 3)) {
92949 log_packet_detailed(" got field 'count'");
92950
92951#ifdef FREECIV_JSON_CONNECTION
92952 field_addr.name = "count";
92953#endif /* FREECIV_JSON_CONNECTION */
92954
92955 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->count)) {
92956 RECEIVE_PACKET_FIELD_ERROR(count);
92957 }
92958 }
92959
92960 if (BV_ISSET(fields, 4)) {
92961 log_packet_detailed(" got field 'tag'");
92962
92963#ifdef FREECIV_JSON_CONNECTION
92964 field_addr.name = "tag";
92965#endif /* FREECIV_JSON_CONNECTION */
92966
92967 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
92968 RECEIVE_PACKET_FIELD_ERROR(tag);
92969 }
92970 }
92971
92972 if (nullptr == old) {
92973 old = fc_malloc(sizeof(*old));
92974 init_packet_edit_unit_create(old);
92975 *old = *real_packet;
92976 genhash_insert(*hash, old, old);
92977 } else {
92978 *old = *real_packet;
92979 }
92980
92981#else /* FREECIV_DELTA_PROTOCOL */
92982#ifdef FREECIV_JSON_CONNECTION
92983 field_addr.name = "owner";
92984#endif /* FREECIV_JSON_CONNECTION */
92985
92986 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
92987 RECEIVE_PACKET_FIELD_ERROR(owner);
92988 }
92989
92990#ifdef FREECIV_JSON_CONNECTION
92991 field_addr.name = "tile";
92992#endif /* FREECIV_JSON_CONNECTION */
92993
92994 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
92995 RECEIVE_PACKET_FIELD_ERROR(tile);
92996 }
92997
92998#ifdef FREECIV_JSON_CONNECTION
92999 field_addr.name = "type";
93000#endif /* FREECIV_JSON_CONNECTION */
93001
93002 {
93003 int readin;
93004
93005 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
93006 RECEIVE_PACKET_FIELD_ERROR(type);
93007 }
93008 real_packet->type = readin;
93009 }
93010
93011#ifdef FREECIV_JSON_CONNECTION
93012 field_addr.name = "count";
93013#endif /* FREECIV_JSON_CONNECTION */
93014
93015 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->count)) {
93016 RECEIVE_PACKET_FIELD_ERROR(count);
93017 }
93018
93019#ifdef FREECIV_JSON_CONNECTION
93020 field_addr.name = "tag";
93021#endif /* FREECIV_JSON_CONNECTION */
93022
93023 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
93024 RECEIVE_PACKET_FIELD_ERROR(tag);
93025 }
93026#endif /* FREECIV_DELTA_PROTOCOL */
93027
93028 RECEIVE_PACKET_END(real_packet);
93029#undef FREE_PACKET_STRUCT
93030}
93031
93032 static int send_packet_edit_unit_create_100(struct connection *pc, const struct packet_edit_unit_create *packet)
93033{
93034 const struct packet_edit_unit_create *real_packet = packet;
93035 int e;
93036 SEND_PACKET_START(PACKET_EDIT_UNIT_CREATE);
93037
93038 log_packet_detailed("packet_edit_unit_create_100: sending info about ()");
93039
93040#ifdef FREECIV_DELTA_PROTOCOL
93041 packet_edit_unit_create_100_fields fields;
93042 struct packet_edit_unit_create *old;
93043 bool differ;
93044 struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT_CREATE;
93045
93046 if (nullptr == *hash) {
93047 *hash = genhash_new_full(hash_packet_edit_unit_create_100, cmp_packet_edit_unit_create_100,
93048 nullptr, nullptr, nullptr, destroy_packet_edit_unit_create);
93049 }
93050 BV_CLR_ALL(fields);
93051
93052 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
93053 old = fc_malloc(sizeof(*old));
93054 /* temporary bitcopy just to insert correctly */
93055 *old = *real_packet;
93056 genhash_insert(*hash, old, old);
93057 init_packet_edit_unit_create(old);
93058 }
93059
93060 differ = (old->owner != real_packet->owner);
93061 if (differ) {
93062 BV_SET(fields, 0);
93063 }
93064
93065 differ = (old->tile != real_packet->tile);
93066 if (differ) {
93067 BV_SET(fields, 1);
93068 }
93069
93070 differ = (old->type != real_packet->type);
93071 if (differ) {
93072 BV_SET(fields, 2);
93073 }
93074
93075 differ = (old->count != real_packet->count);
93076 if (differ) {
93077 BV_SET(fields, 3);
93078 }
93079
93080 differ = (old->tag != real_packet->tag);
93081 if (differ) {
93082 BV_SET(fields, 4);
93083 }
93084#endif /* FREECIV_DELTA_PROTOCOL */
93085
93086#ifdef FREECIV_JSON_CONNECTION
93087 struct plocation field_addr;
93088 {
93089 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
93090 field_addr = *field_addr_tmp;
93091 FC_FREE(field_addr_tmp);
93092 }
93093#endif /* FREECIV_JSON_CONNECTION */
93094
93095#ifdef FREECIV_DELTA_PROTOCOL
93096#ifdef FREECIV_JSON_CONNECTION
93097 field_addr.name = "fields";
93098#endif /* FREECIV_JSON_CONNECTION */
93099 e = 0;
93100 e |= DIO_BV_PUT(&dout, &field_addr, fields);
93101 if (e) {
93102 log_packet_detailed("fields bitvector error detected");
93103 }
93104
93105 if (BV_ISSET(fields, 0)) {
93106 log_packet_detailed(" field 'owner' has changed");
93107
93108#ifdef FREECIV_JSON_CONNECTION
93109 field_addr.name = "owner";
93110#endif /* FREECIV_JSON_CONNECTION */
93111 e = 0;
93112
93113 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
93114
93115 if (e) {
93116 log_packet_detailed("'owner' field error detected");
93117 }
93118 }
93119
93120 if (BV_ISSET(fields, 1)) {
93121 log_packet_detailed(" field 'tile' has changed");
93122
93123#ifdef FREECIV_JSON_CONNECTION
93124 field_addr.name = "tile";
93125#endif /* FREECIV_JSON_CONNECTION */
93126 e = 0;
93127
93128 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
93129
93130 if (e) {
93131 log_packet_detailed("'tile' field error detected");
93132 }
93133 }
93134
93135 if (BV_ISSET(fields, 2)) {
93136 log_packet_detailed(" field 'type' has changed");
93137
93138#ifdef FREECIV_JSON_CONNECTION
93139 field_addr.name = "type";
93140#endif /* FREECIV_JSON_CONNECTION */
93141 e = 0;
93142
93143 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
93144
93145 if (e) {
93146 log_packet_detailed("'type' field error detected");
93147 }
93148 }
93149
93150 if (BV_ISSET(fields, 3)) {
93151 log_packet_detailed(" field 'count' has changed");
93152
93153#ifdef FREECIV_JSON_CONNECTION
93154 field_addr.name = "count";
93155#endif /* FREECIV_JSON_CONNECTION */
93156 e = 0;
93157
93158 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->count);
93159
93160 if (e) {
93161 log_packet_detailed("'count' field error detected");
93162 }
93163 }
93164
93165 if (BV_ISSET(fields, 4)) {
93166 log_packet_detailed(" field 'tag' has changed");
93167
93168#ifdef FREECIV_JSON_CONNECTION
93169 field_addr.name = "tag";
93170#endif /* FREECIV_JSON_CONNECTION */
93171 e = 0;
93172
93173 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
93174
93175 if (e) {
93176 log_packet_detailed("'tag' field error detected");
93177 }
93178 }
93179
93180 *old = *real_packet;
93181
93182#else /* FREECIV_DELTA_PROTOCOL */
93183#ifdef FREECIV_JSON_CONNECTION
93184 field_addr.name = "owner";
93185#endif /* FREECIV_JSON_CONNECTION */
93186 e = 0;
93187
93188 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
93189
93190 if (e) {
93191 log_packet_detailed("'owner' field error detected");
93192 }
93193
93194#ifdef FREECIV_JSON_CONNECTION
93195 field_addr.name = "tile";
93196#endif /* FREECIV_JSON_CONNECTION */
93197 e = 0;
93198
93199 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
93200
93201 if (e) {
93202 log_packet_detailed("'tile' field error detected");
93203 }
93204
93205#ifdef FREECIV_JSON_CONNECTION
93206 field_addr.name = "type";
93207#endif /* FREECIV_JSON_CONNECTION */
93208 e = 0;
93209
93210 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
93211
93212 if (e) {
93213 log_packet_detailed("'type' field error detected");
93214 }
93215
93216#ifdef FREECIV_JSON_CONNECTION
93217 field_addr.name = "count";
93218#endif /* FREECIV_JSON_CONNECTION */
93219 e = 0;
93220
93221 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->count);
93222
93223 if (e) {
93224 log_packet_detailed("'count' field error detected");
93225 }
93226
93227#ifdef FREECIV_JSON_CONNECTION
93228 field_addr.name = "tag";
93229#endif /* FREECIV_JSON_CONNECTION */
93230 e = 0;
93231
93232 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
93233
93234 if (e) {
93235 log_packet_detailed("'tag' field error detected");
93236 }
93237#endif /* FREECIV_DELTA_PROTOCOL */
93238
93239 SEND_PACKET_END(PACKET_EDIT_UNIT_CREATE);
93240}
93241
93242 int send_packet_edit_unit_create(struct connection *pc, const struct packet_edit_unit_create *packet)
93243{
93244 if (!pc->used) {
93245 log_error("WARNING: trying to send data to the closed connection %s",
93246 conn_description(pc));
93247 return -1;
93248 }
93249 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT_CREATE].packet != nullptr, -1,
93250 "Handler for PACKET_EDIT_UNIT_CREATE not installed");
93251 return pc->phs.handlers->send[PACKET_EDIT_UNIT_CREATE].packet(pc, packet);
93252}
93253
93254 int dsend_packet_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id type, int count, int tag)
93255{
93256 struct packet_edit_unit_create packet, *real_packet = &packet;
93257
93258 real_packet->owner = owner;
93259 real_packet->tile = tile;
93260 real_packet->type = type;
93261 real_packet->count = count;
93262 real_packet->tag = tag;
93263
93264 return send_packet_edit_unit_create(pc, real_packet);
93265}
93266
93267 static inline void init_packet_edit_unit_remove(struct packet_edit_unit_remove *packet)
93268{
93269 memset(packet, 0, sizeof(*packet));
93270}
93271
93272#define free_packet_edit_unit_remove(_packet) (void) 0
93273#define destroy_packet_edit_unit_remove free
93274
93275#ifdef FREECIV_DELTA_PROTOCOL
93276#define hash_packet_edit_unit_remove_100 hash_const
93277#define cmp_packet_edit_unit_remove_100 cmp_const
93278 BV_DEFINE(packet_edit_unit_remove_100_fields, 4);
93279#endif /* FREECIV_DELTA_PROTOCOL */
93280
93281 static struct packet_edit_unit_remove *receive_packet_edit_unit_remove_100(struct connection *pc)
93282{
93283#define FREE_PACKET_STRUCT(_packet) free_packet_edit_unit_remove(_packet)
93284 RECEIVE_PACKET_START(packet_edit_unit_remove, real_packet);
93285
93286#ifdef FREECIV_JSON_CONNECTION
93287 struct plocation field_addr;
93288 {
93289 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
93290 field_addr = *field_addr_tmp;
93291 FC_FREE(field_addr_tmp);
93292 }
93293#endif /* FREECIV_JSON_CONNECTION */
93294
93295 log_packet_detailed("packet_edit_unit_remove_100: got info about ()");
93296
93297#ifdef FREECIV_DELTA_PROTOCOL
93298 packet_edit_unit_remove_100_fields fields;
93299 struct packet_edit_unit_remove *old;
93300 struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT_REMOVE;
93301
93302 if (nullptr == *hash) {
93303 *hash = genhash_new_full(hash_packet_edit_unit_remove_100, cmp_packet_edit_unit_remove_100,
93304 nullptr, nullptr, nullptr, destroy_packet_edit_unit_remove);
93305 }
93306
93307 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
93308 *real_packet = *old;
93309 } else {
93310 /* packet is already initialized empty */
93311 log_packet_detailed(" no old info");
93312 }
93313
93314#ifdef FREECIV_JSON_CONNECTION
93315 field_addr.name = "fields";
93316#endif /* FREECIV_JSON_CONNECTION */
93317 DIO_BV_GET(&din, &field_addr, fields);
93318
93319 if (BV_ISSET(fields, 0)) {
93320 log_packet_detailed(" got field 'owner'");
93321
93322#ifdef FREECIV_JSON_CONNECTION
93323 field_addr.name = "owner";
93324#endif /* FREECIV_JSON_CONNECTION */
93325
93326 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
93327 RECEIVE_PACKET_FIELD_ERROR(owner);
93328 }
93329 }
93330
93331 if (BV_ISSET(fields, 1)) {
93332 log_packet_detailed(" got field 'tile'");
93333
93334#ifdef FREECIV_JSON_CONNECTION
93335 field_addr.name = "tile";
93336#endif /* FREECIV_JSON_CONNECTION */
93337
93338 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
93339 RECEIVE_PACKET_FIELD_ERROR(tile);
93340 }
93341 }
93342
93343 if (BV_ISSET(fields, 2)) {
93344 log_packet_detailed(" got field 'type'");
93345
93346#ifdef FREECIV_JSON_CONNECTION
93347 field_addr.name = "type";
93348#endif /* FREECIV_JSON_CONNECTION */
93349
93350 {
93351 int readin;
93352
93353 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
93354 RECEIVE_PACKET_FIELD_ERROR(type);
93355 }
93356 real_packet->type = readin;
93357 }
93358 }
93359
93360 if (BV_ISSET(fields, 3)) {
93361 log_packet_detailed(" got field 'count'");
93362
93363#ifdef FREECIV_JSON_CONNECTION
93364 field_addr.name = "count";
93365#endif /* FREECIV_JSON_CONNECTION */
93366
93367 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->count)) {
93368 RECEIVE_PACKET_FIELD_ERROR(count);
93369 }
93370 }
93371
93372 if (nullptr == old) {
93373 old = fc_malloc(sizeof(*old));
93374 init_packet_edit_unit_remove(old);
93375 *old = *real_packet;
93376 genhash_insert(*hash, old, old);
93377 } else {
93378 *old = *real_packet;
93379 }
93380
93381#else /* FREECIV_DELTA_PROTOCOL */
93382#ifdef FREECIV_JSON_CONNECTION
93383 field_addr.name = "owner";
93384#endif /* FREECIV_JSON_CONNECTION */
93385
93386 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
93387 RECEIVE_PACKET_FIELD_ERROR(owner);
93388 }
93389
93390#ifdef FREECIV_JSON_CONNECTION
93391 field_addr.name = "tile";
93392#endif /* FREECIV_JSON_CONNECTION */
93393
93394 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
93395 RECEIVE_PACKET_FIELD_ERROR(tile);
93396 }
93397
93398#ifdef FREECIV_JSON_CONNECTION
93399 field_addr.name = "type";
93400#endif /* FREECIV_JSON_CONNECTION */
93401
93402 {
93403 int readin;
93404
93405 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
93406 RECEIVE_PACKET_FIELD_ERROR(type);
93407 }
93408 real_packet->type = readin;
93409 }
93410
93411#ifdef FREECIV_JSON_CONNECTION
93412 field_addr.name = "count";
93413#endif /* FREECIV_JSON_CONNECTION */
93414
93415 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->count)) {
93416 RECEIVE_PACKET_FIELD_ERROR(count);
93417 }
93418#endif /* FREECIV_DELTA_PROTOCOL */
93419
93420 RECEIVE_PACKET_END(real_packet);
93421#undef FREE_PACKET_STRUCT
93422}
93423
93424 static int send_packet_edit_unit_remove_100(struct connection *pc, const struct packet_edit_unit_remove *packet)
93425{
93426 const struct packet_edit_unit_remove *real_packet = packet;
93427 int e;
93428 SEND_PACKET_START(PACKET_EDIT_UNIT_REMOVE);
93429
93430 log_packet_detailed("packet_edit_unit_remove_100: sending info about ()");
93431
93432#ifdef FREECIV_DELTA_PROTOCOL
93433 packet_edit_unit_remove_100_fields fields;
93434 struct packet_edit_unit_remove *old;
93435 bool differ;
93436 struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT_REMOVE;
93437
93438 if (nullptr == *hash) {
93439 *hash = genhash_new_full(hash_packet_edit_unit_remove_100, cmp_packet_edit_unit_remove_100,
93440 nullptr, nullptr, nullptr, destroy_packet_edit_unit_remove);
93441 }
93442 BV_CLR_ALL(fields);
93443
93444 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
93445 old = fc_malloc(sizeof(*old));
93446 /* temporary bitcopy just to insert correctly */
93447 *old = *real_packet;
93448 genhash_insert(*hash, old, old);
93449 init_packet_edit_unit_remove(old);
93450 }
93451
93452 differ = (old->owner != real_packet->owner);
93453 if (differ) {
93454 BV_SET(fields, 0);
93455 }
93456
93457 differ = (old->tile != real_packet->tile);
93458 if (differ) {
93459 BV_SET(fields, 1);
93460 }
93461
93462 differ = (old->type != real_packet->type);
93463 if (differ) {
93464 BV_SET(fields, 2);
93465 }
93466
93467 differ = (old->count != real_packet->count);
93468 if (differ) {
93469 BV_SET(fields, 3);
93470 }
93471#endif /* FREECIV_DELTA_PROTOCOL */
93472
93473#ifdef FREECIV_JSON_CONNECTION
93474 struct plocation field_addr;
93475 {
93476 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
93477 field_addr = *field_addr_tmp;
93478 FC_FREE(field_addr_tmp);
93479 }
93480#endif /* FREECIV_JSON_CONNECTION */
93481
93482#ifdef FREECIV_DELTA_PROTOCOL
93483#ifdef FREECIV_JSON_CONNECTION
93484 field_addr.name = "fields";
93485#endif /* FREECIV_JSON_CONNECTION */
93486 e = 0;
93487 e |= DIO_BV_PUT(&dout, &field_addr, fields);
93488 if (e) {
93489 log_packet_detailed("fields bitvector error detected");
93490 }
93491
93492 if (BV_ISSET(fields, 0)) {
93493 log_packet_detailed(" field 'owner' has changed");
93494
93495#ifdef FREECIV_JSON_CONNECTION
93496 field_addr.name = "owner";
93497#endif /* FREECIV_JSON_CONNECTION */
93498 e = 0;
93499
93500 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
93501
93502 if (e) {
93503 log_packet_detailed("'owner' field error detected");
93504 }
93505 }
93506
93507 if (BV_ISSET(fields, 1)) {
93508 log_packet_detailed(" field 'tile' has changed");
93509
93510#ifdef FREECIV_JSON_CONNECTION
93511 field_addr.name = "tile";
93512#endif /* FREECIV_JSON_CONNECTION */
93513 e = 0;
93514
93515 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
93516
93517 if (e) {
93518 log_packet_detailed("'tile' field error detected");
93519 }
93520 }
93521
93522 if (BV_ISSET(fields, 2)) {
93523 log_packet_detailed(" field 'type' has changed");
93524
93525#ifdef FREECIV_JSON_CONNECTION
93526 field_addr.name = "type";
93527#endif /* FREECIV_JSON_CONNECTION */
93528 e = 0;
93529
93530 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
93531
93532 if (e) {
93533 log_packet_detailed("'type' field error detected");
93534 }
93535 }
93536
93537 if (BV_ISSET(fields, 3)) {
93538 log_packet_detailed(" field 'count' has changed");
93539
93540#ifdef FREECIV_JSON_CONNECTION
93541 field_addr.name = "count";
93542#endif /* FREECIV_JSON_CONNECTION */
93543 e = 0;
93544
93545 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->count);
93546
93547 if (e) {
93548 log_packet_detailed("'count' field error detected");
93549 }
93550 }
93551
93552 *old = *real_packet;
93553
93554#else /* FREECIV_DELTA_PROTOCOL */
93555#ifdef FREECIV_JSON_CONNECTION
93556 field_addr.name = "owner";
93557#endif /* FREECIV_JSON_CONNECTION */
93558 e = 0;
93559
93560 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
93561
93562 if (e) {
93563 log_packet_detailed("'owner' field error detected");
93564 }
93565
93566#ifdef FREECIV_JSON_CONNECTION
93567 field_addr.name = "tile";
93568#endif /* FREECIV_JSON_CONNECTION */
93569 e = 0;
93570
93571 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
93572
93573 if (e) {
93574 log_packet_detailed("'tile' field error detected");
93575 }
93576
93577#ifdef FREECIV_JSON_CONNECTION
93578 field_addr.name = "type";
93579#endif /* FREECIV_JSON_CONNECTION */
93580 e = 0;
93581
93582 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->type);
93583
93584 if (e) {
93585 log_packet_detailed("'type' field error detected");
93586 }
93587
93588#ifdef FREECIV_JSON_CONNECTION
93589 field_addr.name = "count";
93590#endif /* FREECIV_JSON_CONNECTION */
93591 e = 0;
93592
93593 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->count);
93594
93595 if (e) {
93596 log_packet_detailed("'count' field error detected");
93597 }
93598#endif /* FREECIV_DELTA_PROTOCOL */
93599
93600 SEND_PACKET_END(PACKET_EDIT_UNIT_REMOVE);
93601}
93602
93603 int send_packet_edit_unit_remove(struct connection *pc, const struct packet_edit_unit_remove *packet)
93604{
93605 if (!pc->used) {
93606 log_error("WARNING: trying to send data to the closed connection %s",
93607 conn_description(pc));
93608 return -1;
93609 }
93610 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE].packet != nullptr, -1,
93611 "Handler for PACKET_EDIT_UNIT_REMOVE not installed");
93612 return pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE].packet(pc, packet);
93613}
93614
93615 int dsend_packet_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id type, int count)
93616{
93617 struct packet_edit_unit_remove packet, *real_packet = &packet;
93618
93619 real_packet->owner = owner;
93620 real_packet->tile = tile;
93621 real_packet->type = type;
93622 real_packet->count = count;
93623
93624 return send_packet_edit_unit_remove(pc, real_packet);
93625}
93626
93627 static inline void init_packet_edit_unit_remove_by_id(struct packet_edit_unit_remove_by_id *packet)
93628{
93629 memset(packet, 0, sizeof(*packet));
93630}
93631
93632#define free_packet_edit_unit_remove_by_id(_packet) (void) 0
93633#define destroy_packet_edit_unit_remove_by_id free
93634
93635#ifdef FREECIV_DELTA_PROTOCOL
93636#define hash_packet_edit_unit_remove_by_id_100 hash_const
93637#define cmp_packet_edit_unit_remove_by_id_100 cmp_const
93638 BV_DEFINE(packet_edit_unit_remove_by_id_100_fields, 1);
93639#endif /* FREECIV_DELTA_PROTOCOL */
93640
93641 static struct packet_edit_unit_remove_by_id *receive_packet_edit_unit_remove_by_id_100(struct connection *pc)
93642{
93643#define FREE_PACKET_STRUCT(_packet) free_packet_edit_unit_remove_by_id(_packet)
93644 RECEIVE_PACKET_START(packet_edit_unit_remove_by_id, real_packet);
93645
93646#ifdef FREECIV_JSON_CONNECTION
93647 struct plocation field_addr;
93648 {
93649 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
93650 field_addr = *field_addr_tmp;
93651 FC_FREE(field_addr_tmp);
93652 }
93653#endif /* FREECIV_JSON_CONNECTION */
93654
93655 log_packet_detailed("packet_edit_unit_remove_by_id_100: got info about ()");
93656
93657#ifdef FREECIV_DELTA_PROTOCOL
93658 packet_edit_unit_remove_by_id_100_fields fields;
93659 struct packet_edit_unit_remove_by_id *old;
93660 struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT_REMOVE_BY_ID;
93661
93662 if (nullptr == *hash) {
93663 *hash = genhash_new_full(hash_packet_edit_unit_remove_by_id_100, cmp_packet_edit_unit_remove_by_id_100,
93664 nullptr, nullptr, nullptr, destroy_packet_edit_unit_remove_by_id);
93665 }
93666
93667 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
93668 *real_packet = *old;
93669 } else {
93670 /* packet is already initialized empty */
93671 log_packet_detailed(" no old info");
93672 }
93673
93674#ifdef FREECIV_JSON_CONNECTION
93675 field_addr.name = "fields";
93676#endif /* FREECIV_JSON_CONNECTION */
93677 DIO_BV_GET(&din, &field_addr, fields);
93678
93679 if (BV_ISSET(fields, 0)) {
93680 log_packet_detailed(" got field 'id'");
93681
93682#ifdef FREECIV_JSON_CONNECTION
93683 field_addr.name = "id";
93684#endif /* FREECIV_JSON_CONNECTION */
93685
93686 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
93687 RECEIVE_PACKET_FIELD_ERROR(id);
93688 }
93689 }
93690
93691 if (nullptr == old) {
93692 old = fc_malloc(sizeof(*old));
93693 init_packet_edit_unit_remove_by_id(old);
93694 *old = *real_packet;
93695 genhash_insert(*hash, old, old);
93696 } else {
93697 *old = *real_packet;
93698 }
93699
93700#else /* FREECIV_DELTA_PROTOCOL */
93701#ifdef FREECIV_JSON_CONNECTION
93702 field_addr.name = "id";
93703#endif /* FREECIV_JSON_CONNECTION */
93704
93705 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
93706 RECEIVE_PACKET_FIELD_ERROR(id);
93707 }
93708#endif /* FREECIV_DELTA_PROTOCOL */
93709
93710 RECEIVE_PACKET_END(real_packet);
93711#undef FREE_PACKET_STRUCT
93712}
93713
93714 static int send_packet_edit_unit_remove_by_id_100(struct connection *pc, const struct packet_edit_unit_remove_by_id *packet)
93715{
93716 const struct packet_edit_unit_remove_by_id *real_packet = packet;
93717 int e;
93718 SEND_PACKET_START(PACKET_EDIT_UNIT_REMOVE_BY_ID);
93719
93720 log_packet_detailed("packet_edit_unit_remove_by_id_100: sending info about ()");
93721
93722#ifdef FREECIV_DELTA_PROTOCOL
93723 packet_edit_unit_remove_by_id_100_fields fields;
93724 struct packet_edit_unit_remove_by_id *old;
93725 bool differ;
93726 struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT_REMOVE_BY_ID;
93727
93728 if (nullptr == *hash) {
93729 *hash = genhash_new_full(hash_packet_edit_unit_remove_by_id_100, cmp_packet_edit_unit_remove_by_id_100,
93730 nullptr, nullptr, nullptr, destroy_packet_edit_unit_remove_by_id);
93731 }
93732 BV_CLR_ALL(fields);
93733
93734 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
93735 old = fc_malloc(sizeof(*old));
93736 /* temporary bitcopy just to insert correctly */
93737 *old = *real_packet;
93738 genhash_insert(*hash, old, old);
93739 init_packet_edit_unit_remove_by_id(old);
93740 }
93741
93742 differ = (old->id != real_packet->id);
93743 if (differ) {
93744 BV_SET(fields, 0);
93745 }
93746#endif /* FREECIV_DELTA_PROTOCOL */
93747
93748#ifdef FREECIV_JSON_CONNECTION
93749 struct plocation field_addr;
93750 {
93751 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
93752 field_addr = *field_addr_tmp;
93753 FC_FREE(field_addr_tmp);
93754 }
93755#endif /* FREECIV_JSON_CONNECTION */
93756
93757#ifdef FREECIV_DELTA_PROTOCOL
93758#ifdef FREECIV_JSON_CONNECTION
93759 field_addr.name = "fields";
93760#endif /* FREECIV_JSON_CONNECTION */
93761 e = 0;
93762 e |= DIO_BV_PUT(&dout, &field_addr, fields);
93763 if (e) {
93764 log_packet_detailed("fields bitvector error detected");
93765 }
93766
93767 if (BV_ISSET(fields, 0)) {
93768 log_packet_detailed(" field 'id' has changed");
93769
93770#ifdef FREECIV_JSON_CONNECTION
93771 field_addr.name = "id";
93772#endif /* FREECIV_JSON_CONNECTION */
93773 e = 0;
93774
93775 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
93776
93777 if (e) {
93778 log_packet_detailed("'id' field error detected");
93779 }
93780 }
93781
93782 *old = *real_packet;
93783
93784#else /* FREECIV_DELTA_PROTOCOL */
93785#ifdef FREECIV_JSON_CONNECTION
93786 field_addr.name = "id";
93787#endif /* FREECIV_JSON_CONNECTION */
93788 e = 0;
93789
93790 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
93791
93792 if (e) {
93793 log_packet_detailed("'id' field error detected");
93794 }
93795#endif /* FREECIV_DELTA_PROTOCOL */
93796
93797 SEND_PACKET_END(PACKET_EDIT_UNIT_REMOVE_BY_ID);
93798}
93799
93800 int send_packet_edit_unit_remove_by_id(struct connection *pc, const struct packet_edit_unit_remove_by_id *packet)
93801{
93802 if (!pc->used) {
93803 log_error("WARNING: trying to send data to the closed connection %s",
93804 conn_description(pc));
93805 return -1;
93806 }
93807 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE_BY_ID].packet != nullptr, -1,
93808 "Handler for PACKET_EDIT_UNIT_REMOVE_BY_ID not installed");
93809 return pc->phs.handlers->send[PACKET_EDIT_UNIT_REMOVE_BY_ID].packet(pc, packet);
93810}
93811
93812 int dsend_packet_edit_unit_remove_by_id(struct connection *pc, int id)
93813{
93814 struct packet_edit_unit_remove_by_id packet, *real_packet = &packet;
93815
93816 real_packet->id = id;
93817
93818 return send_packet_edit_unit_remove_by_id(pc, real_packet);
93819}
93820
93821 static inline void init_packet_edit_unit(struct packet_edit_unit *packet)
93822{
93823 memset(packet, 0, sizeof(*packet));
93824}
93825
93826#define free_packet_edit_unit(_packet) (void) 0
93827#define destroy_packet_edit_unit free
93828
93829#ifdef FREECIV_DELTA_PROTOCOL
93830static genhash_val_t hash_packet_edit_unit_100(const void *vkey)
93831{
93832 const struct packet_edit_unit *key = (const struct packet_edit_unit *) vkey;
93833 genhash_val_t result = 0;
93834
93835 result += key->id;
93836
93837 result &= 0xFFFFFFFF;
93838 return result;
93839}
93840
93841static bool cmp_packet_edit_unit_100(const void *vkey1, const void *vkey2)
93842{
93843 const struct packet_edit_unit *old = (const struct packet_edit_unit *) vkey1;
93844 const struct packet_edit_unit *real_packet = (const struct packet_edit_unit *) vkey2;
93845 bool differ;
93846
93847 differ = (old->id != real_packet->id);
93848
93849 return !differ;
93850}
93851 BV_DEFINE(packet_edit_unit_100_fields, 16);
93852#endif /* FREECIV_DELTA_PROTOCOL */
93853
93854 static struct packet_edit_unit *receive_packet_edit_unit_100(struct connection *pc)
93855{
93856#define FREE_PACKET_STRUCT(_packet) free_packet_edit_unit(_packet)
93857 RECEIVE_PACKET_START(packet_edit_unit, real_packet);
93858
93859#ifdef FREECIV_JSON_CONNECTION
93860 struct plocation field_addr;
93861 {
93862 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
93863 field_addr = *field_addr_tmp;
93864 FC_FREE(field_addr_tmp);
93865 }
93866#endif /* FREECIV_JSON_CONNECTION */
93867
93868#ifdef FREECIV_JSON_CONNECTION
93869 field_addr.name = "id";
93870#endif /* FREECIV_JSON_CONNECTION */
93871
93872 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
93873 RECEIVE_PACKET_FIELD_ERROR(id);
93874 }
93875
93876 log_packet_detailed("packet_edit_unit_100: got info about (%d)",
93877 real_packet->id);
93878
93879#ifdef FREECIV_DELTA_PROTOCOL
93880 packet_edit_unit_100_fields fields;
93881 struct packet_edit_unit *old;
93882 struct genhash **hash = pc->phs.received + PACKET_EDIT_UNIT;
93883
93884 if (nullptr == *hash) {
93885 *hash = genhash_new_full(hash_packet_edit_unit_100, cmp_packet_edit_unit_100,
93886 nullptr, nullptr, nullptr, destroy_packet_edit_unit);
93887 }
93888
93889 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
93890 *real_packet = *old;
93891 } else {
93892 /* packet is already initialized empty */
93893 log_packet_detailed(" no old info");
93894 }
93895
93896#ifdef FREECIV_JSON_CONNECTION
93897 field_addr.name = "fields";
93898#endif /* FREECIV_JSON_CONNECTION */
93899 DIO_BV_GET(&din, &field_addr, fields);
93900
93901 if (BV_ISSET(fields, 0)) {
93902 log_packet_detailed(" got field 'utype'");
93903
93904#ifdef FREECIV_JSON_CONNECTION
93905 field_addr.name = "utype";
93906#endif /* FREECIV_JSON_CONNECTION */
93907
93908 {
93909 int readin;
93910
93911 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
93912 RECEIVE_PACKET_FIELD_ERROR(utype);
93913 }
93914 real_packet->utype = readin;
93915 }
93916 }
93917
93918 if (BV_ISSET(fields, 1)) {
93919 log_packet_detailed(" got field 'owner'");
93920
93921#ifdef FREECIV_JSON_CONNECTION
93922 field_addr.name = "owner";
93923#endif /* FREECIV_JSON_CONNECTION */
93924
93925 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
93926 RECEIVE_PACKET_FIELD_ERROR(owner);
93927 }
93928 }
93929
93930 if (BV_ISSET(fields, 2)) {
93931 log_packet_detailed(" got field 'homecity'");
93932
93933#ifdef FREECIV_JSON_CONNECTION
93934 field_addr.name = "homecity";
93935#endif /* FREECIV_JSON_CONNECTION */
93936
93937 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->homecity)) {
93938 RECEIVE_PACKET_FIELD_ERROR(homecity);
93939 }
93940 }
93941
93942 if (BV_ISSET(fields, 3)) {
93943 log_packet_detailed(" got field 'moves_left'");
93944
93945#ifdef FREECIV_JSON_CONNECTION
93946 field_addr.name = "moves_left";
93947#endif /* FREECIV_JSON_CONNECTION */
93948
93949 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->moves_left)) {
93950 RECEIVE_PACKET_FIELD_ERROR(moves_left);
93951 }
93952 }
93953
93954 if (BV_ISSET(fields, 4)) {
93955 log_packet_detailed(" got field 'hp'");
93956
93957#ifdef FREECIV_JSON_CONNECTION
93958 field_addr.name = "hp";
93959#endif /* FREECIV_JSON_CONNECTION */
93960
93961 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
93962 RECEIVE_PACKET_FIELD_ERROR(hp);
93963 }
93964 }
93965
93966 if (BV_ISSET(fields, 5)) {
93967 log_packet_detailed(" got field 'veteran'");
93968
93969#ifdef FREECIV_JSON_CONNECTION
93970 field_addr.name = "veteran";
93971#endif /* FREECIV_JSON_CONNECTION */
93972
93973 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran)) {
93974 RECEIVE_PACKET_FIELD_ERROR(veteran);
93975 }
93976 }
93977
93978 if (BV_ISSET(fields, 6)) {
93979 log_packet_detailed(" got field 'fuel'");
93980
93981#ifdef FREECIV_JSON_CONNECTION
93982 field_addr.name = "fuel";
93983#endif /* FREECIV_JSON_CONNECTION */
93984
93985 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
93986 RECEIVE_PACKET_FIELD_ERROR(fuel);
93987 }
93988 }
93989
93990 if (BV_ISSET(fields, 7)) {
93991 log_packet_detailed(" got field 'activity'");
93992
93993#ifdef FREECIV_JSON_CONNECTION
93994 field_addr.name = "activity";
93995#endif /* FREECIV_JSON_CONNECTION */
93996
93997 {
93998 int readin;
93999
94000 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
94001 RECEIVE_PACKET_FIELD_ERROR(activity);
94002 }
94003 real_packet->activity = readin;
94004 }
94005 }
94006
94007 if (BV_ISSET(fields, 8)) {
94008 log_packet_detailed(" got field 'activity_count'");
94009
94010#ifdef FREECIV_JSON_CONNECTION
94011 field_addr.name = "activity_count";
94012#endif /* FREECIV_JSON_CONNECTION */
94013
94014 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->activity_count)) {
94015 RECEIVE_PACKET_FIELD_ERROR(activity_count);
94016 }
94017 }
94018
94019 if (BV_ISSET(fields, 9)) {
94020 log_packet_detailed(" got field 'activity_base'");
94021
94022#ifdef FREECIV_JSON_CONNECTION
94023 field_addr.name = "activity_base";
94024#endif /* FREECIV_JSON_CONNECTION */
94025
94026 {
94027 int readin;
94028
94029 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
94030 RECEIVE_PACKET_FIELD_ERROR(activity_base);
94031 }
94032 real_packet->activity_base = readin;
94033 }
94034 }
94035
94036 real_packet->debug = BV_ISSET(fields, 10);
94037
94038 real_packet->moved = BV_ISSET(fields, 11);
94039
94040 real_packet->paradropped = BV_ISSET(fields, 12);
94041
94042 real_packet->done_moving = BV_ISSET(fields, 13);
94043
94044 if (BV_ISSET(fields, 14)) {
94045 log_packet_detailed(" got field 'transported_by'");
94046
94047#ifdef FREECIV_JSON_CONNECTION
94048 field_addr.name = "transported_by";
94049#endif /* FREECIV_JSON_CONNECTION */
94050
94051 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->transported_by)) {
94052 RECEIVE_PACKET_FIELD_ERROR(transported_by);
94053 }
94054 }
94055
94056 real_packet->stay = BV_ISSET(fields, 15);
94057
94058 if (nullptr == old) {
94059 old = fc_malloc(sizeof(*old));
94060 init_packet_edit_unit(old);
94061 *old = *real_packet;
94062 genhash_insert(*hash, old, old);
94063 } else {
94064 *old = *real_packet;
94065 }
94066
94067#else /* FREECIV_DELTA_PROTOCOL */
94068#ifdef FREECIV_JSON_CONNECTION
94069 field_addr.name = "utype";
94070#endif /* FREECIV_JSON_CONNECTION */
94071
94072 {
94073 int readin;
94074
94075 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
94076 RECEIVE_PACKET_FIELD_ERROR(utype);
94077 }
94078 real_packet->utype = readin;
94079 }
94080
94081#ifdef FREECIV_JSON_CONNECTION
94082 field_addr.name = "owner";
94083#endif /* FREECIV_JSON_CONNECTION */
94084
94085 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
94086 RECEIVE_PACKET_FIELD_ERROR(owner);
94087 }
94088
94089#ifdef FREECIV_JSON_CONNECTION
94090 field_addr.name = "homecity";
94091#endif /* FREECIV_JSON_CONNECTION */
94092
94093 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->homecity)) {
94094 RECEIVE_PACKET_FIELD_ERROR(homecity);
94095 }
94096
94097#ifdef FREECIV_JSON_CONNECTION
94098 field_addr.name = "moves_left";
94099#endif /* FREECIV_JSON_CONNECTION */
94100
94101 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->moves_left)) {
94102 RECEIVE_PACKET_FIELD_ERROR(moves_left);
94103 }
94104
94105#ifdef FREECIV_JSON_CONNECTION
94106 field_addr.name = "hp";
94107#endif /* FREECIV_JSON_CONNECTION */
94108
94109 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->hp)) {
94110 RECEIVE_PACKET_FIELD_ERROR(hp);
94111 }
94112
94113#ifdef FREECIV_JSON_CONNECTION
94114 field_addr.name = "veteran";
94115#endif /* FREECIV_JSON_CONNECTION */
94116
94117 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->veteran)) {
94118 RECEIVE_PACKET_FIELD_ERROR(veteran);
94119 }
94120
94121#ifdef FREECIV_JSON_CONNECTION
94122 field_addr.name = "fuel";
94123#endif /* FREECIV_JSON_CONNECTION */
94124
94125 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->fuel)) {
94126 RECEIVE_PACKET_FIELD_ERROR(fuel);
94127 }
94128
94129#ifdef FREECIV_JSON_CONNECTION
94130 field_addr.name = "activity";
94131#endif /* FREECIV_JSON_CONNECTION */
94132
94133 {
94134 int readin;
94135
94136 if (!DIO_GET(uint8, &din, &field_addr, &readin)) {
94137 RECEIVE_PACKET_FIELD_ERROR(activity);
94138 }
94139 real_packet->activity = readin;
94140 }
94141
94142#ifdef FREECIV_JSON_CONNECTION
94143 field_addr.name = "activity_count";
94144#endif /* FREECIV_JSON_CONNECTION */
94145
94146 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->activity_count)) {
94147 RECEIVE_PACKET_FIELD_ERROR(activity_count);
94148 }
94149
94150#ifdef FREECIV_JSON_CONNECTION
94151 field_addr.name = "activity_base";
94152#endif /* FREECIV_JSON_CONNECTION */
94153
94154 {
94155 int readin;
94156
94157 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
94158 RECEIVE_PACKET_FIELD_ERROR(activity_base);
94159 }
94160 real_packet->activity_base = readin;
94161 }
94162
94163#ifdef FREECIV_JSON_CONNECTION
94164 field_addr.name = "debug";
94165#endif /* FREECIV_JSON_CONNECTION */
94166
94167 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->debug)) {
94168 RECEIVE_PACKET_FIELD_ERROR(debug);
94169 }
94170
94171#ifdef FREECIV_JSON_CONNECTION
94172 field_addr.name = "moved";
94173#endif /* FREECIV_JSON_CONNECTION */
94174
94175 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->moved)) {
94176 RECEIVE_PACKET_FIELD_ERROR(moved);
94177 }
94178
94179#ifdef FREECIV_JSON_CONNECTION
94180 field_addr.name = "paradropped";
94181#endif /* FREECIV_JSON_CONNECTION */
94182
94183 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->paradropped)) {
94184 RECEIVE_PACKET_FIELD_ERROR(paradropped);
94185 }
94186
94187#ifdef FREECIV_JSON_CONNECTION
94188 field_addr.name = "done_moving";
94189#endif /* FREECIV_JSON_CONNECTION */
94190
94191 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->done_moving)) {
94192 RECEIVE_PACKET_FIELD_ERROR(done_moving);
94193 }
94194
94195#ifdef FREECIV_JSON_CONNECTION
94196 field_addr.name = "transported_by";
94197#endif /* FREECIV_JSON_CONNECTION */
94198
94199 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->transported_by)) {
94200 RECEIVE_PACKET_FIELD_ERROR(transported_by);
94201 }
94202
94203#ifdef FREECIV_JSON_CONNECTION
94204 field_addr.name = "stay";
94205#endif /* FREECIV_JSON_CONNECTION */
94206
94207 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->stay)) {
94208 RECEIVE_PACKET_FIELD_ERROR(stay);
94209 }
94210#endif /* FREECIV_DELTA_PROTOCOL */
94211
94212 RECEIVE_PACKET_END(real_packet);
94213#undef FREE_PACKET_STRUCT
94214}
94215
94216 static int send_packet_edit_unit_100(struct connection *pc, const struct packet_edit_unit *packet)
94217{
94218 const struct packet_edit_unit *real_packet = packet;
94219 int e;
94220 SEND_PACKET_START(PACKET_EDIT_UNIT);
94221
94222 log_packet_detailed("packet_edit_unit_100: sending info about (%d)",
94223 real_packet->id);
94224
94225#ifdef FREECIV_DELTA_PROTOCOL
94226 packet_edit_unit_100_fields fields;
94227 struct packet_edit_unit *old;
94228 bool differ;
94229 struct genhash **hash = pc->phs.sent + PACKET_EDIT_UNIT;
94230
94231 if (nullptr == *hash) {
94232 *hash = genhash_new_full(hash_packet_edit_unit_100, cmp_packet_edit_unit_100,
94233 nullptr, nullptr, nullptr, destroy_packet_edit_unit);
94234 }
94235 BV_CLR_ALL(fields);
94236
94237 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
94238 old = fc_malloc(sizeof(*old));
94239 /* temporary bitcopy just to insert correctly */
94240 *old = *real_packet;
94241 genhash_insert(*hash, old, old);
94242 init_packet_edit_unit(old);
94243 }
94244
94245 differ = (old->utype != real_packet->utype);
94246 if (differ) {
94247 BV_SET(fields, 0);
94248 }
94249
94250 differ = (old->owner != real_packet->owner);
94251 if (differ) {
94252 BV_SET(fields, 1);
94253 }
94254
94255 differ = (old->homecity != real_packet->homecity);
94256 if (differ) {
94257 BV_SET(fields, 2);
94258 }
94259
94260 differ = (old->moves_left != real_packet->moves_left);
94261 if (differ) {
94262 BV_SET(fields, 3);
94263 }
94264
94265 differ = (old->hp != real_packet->hp);
94266 if (differ) {
94267 BV_SET(fields, 4);
94268 }
94269
94270 differ = (old->veteran != real_packet->veteran);
94271 if (differ) {
94272 BV_SET(fields, 5);
94273 }
94274
94275 differ = (old->fuel != real_packet->fuel);
94276 if (differ) {
94277 BV_SET(fields, 6);
94278 }
94279
94280 differ = (old->activity != real_packet->activity);
94281 if (differ) {
94282 BV_SET(fields, 7);
94283 }
94284
94285 differ = (old->activity_count != real_packet->activity_count);
94286 if (differ) {
94287 BV_SET(fields, 8);
94288 }
94289
94290 differ = (old->activity_base != real_packet->activity_base);
94291 if (differ) {
94292 BV_SET(fields, 9);
94293 }
94294
94295 /* folded into head */
94296 if (real_packet->debug) {
94297 BV_SET(fields, 10);
94298 }
94299
94300 /* folded into head */
94301 if (real_packet->moved) {
94302 BV_SET(fields, 11);
94303 }
94304
94305 /* folded into head */
94306 if (real_packet->paradropped) {
94307 BV_SET(fields, 12);
94308 }
94309
94310 /* folded into head */
94311 if (real_packet->done_moving) {
94312 BV_SET(fields, 13);
94313 }
94314
94315 differ = (old->transported_by != real_packet->transported_by);
94316 if (differ) {
94317 BV_SET(fields, 14);
94318 }
94319
94320 /* folded into head */
94321 if (real_packet->stay) {
94322 BV_SET(fields, 15);
94323 }
94324#endif /* FREECIV_DELTA_PROTOCOL */
94325
94326#ifdef FREECIV_JSON_CONNECTION
94327 struct plocation field_addr;
94328 {
94329 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
94330 field_addr = *field_addr_tmp;
94331 FC_FREE(field_addr_tmp);
94332 }
94333#endif /* FREECIV_JSON_CONNECTION */
94334
94335#ifdef FREECIV_JSON_CONNECTION
94336 field_addr.name = "id";
94337#endif /* FREECIV_JSON_CONNECTION */
94338 e = 0;
94339
94340 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
94341
94342 if (e) {
94343 log_packet_detailed("'id' field error detected");
94344 }
94345
94346#ifdef FREECIV_DELTA_PROTOCOL
94347#ifdef FREECIV_JSON_CONNECTION
94348 field_addr.name = "fields";
94349#endif /* FREECIV_JSON_CONNECTION */
94350 e = 0;
94351 e |= DIO_BV_PUT(&dout, &field_addr, fields);
94352 if (e) {
94353 log_packet_detailed("fields bitvector error detected");
94354 }
94355
94356 if (BV_ISSET(fields, 0)) {
94357 log_packet_detailed(" field 'utype' has changed");
94358
94359#ifdef FREECIV_JSON_CONNECTION
94360 field_addr.name = "utype";
94361#endif /* FREECIV_JSON_CONNECTION */
94362 e = 0;
94363
94364 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->utype);
94365
94366 if (e) {
94367 log_packet_detailed("'utype' field error detected");
94368 }
94369 }
94370
94371 if (BV_ISSET(fields, 1)) {
94372 log_packet_detailed(" field 'owner' has changed");
94373
94374#ifdef FREECIV_JSON_CONNECTION
94375 field_addr.name = "owner";
94376#endif /* FREECIV_JSON_CONNECTION */
94377 e = 0;
94378
94379 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
94380
94381 if (e) {
94382 log_packet_detailed("'owner' field error detected");
94383 }
94384 }
94385
94386 if (BV_ISSET(fields, 2)) {
94387 log_packet_detailed(" field 'homecity' has changed");
94388
94389#ifdef FREECIV_JSON_CONNECTION
94390 field_addr.name = "homecity";
94391#endif /* FREECIV_JSON_CONNECTION */
94392 e = 0;
94393
94394 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->homecity);
94395
94396 if (e) {
94397 log_packet_detailed("'homecity' field error detected");
94398 }
94399 }
94400
94401 if (BV_ISSET(fields, 3)) {
94402 log_packet_detailed(" field 'moves_left' has changed");
94403
94404#ifdef FREECIV_JSON_CONNECTION
94405 field_addr.name = "moves_left";
94406#endif /* FREECIV_JSON_CONNECTION */
94407 e = 0;
94408
94409 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->moves_left);
94410
94411 if (e) {
94412 log_packet_detailed("'moves_left' field error detected");
94413 }
94414 }
94415
94416 if (BV_ISSET(fields, 4)) {
94417 log_packet_detailed(" field 'hp' has changed");
94418
94419#ifdef FREECIV_JSON_CONNECTION
94420 field_addr.name = "hp";
94421#endif /* FREECIV_JSON_CONNECTION */
94422 e = 0;
94423
94424 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
94425
94426 if (e) {
94427 log_packet_detailed("'hp' field error detected");
94428 }
94429 }
94430
94431 if (BV_ISSET(fields, 5)) {
94432 log_packet_detailed(" field 'veteran' has changed");
94433
94434#ifdef FREECIV_JSON_CONNECTION
94435 field_addr.name = "veteran";
94436#endif /* FREECIV_JSON_CONNECTION */
94437 e = 0;
94438
94439 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran);
94440
94441 if (e) {
94442 log_packet_detailed("'veteran' field error detected");
94443 }
94444 }
94445
94446 if (BV_ISSET(fields, 6)) {
94447 log_packet_detailed(" field 'fuel' has changed");
94448
94449#ifdef FREECIV_JSON_CONNECTION
94450 field_addr.name = "fuel";
94451#endif /* FREECIV_JSON_CONNECTION */
94452 e = 0;
94453
94454 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
94455
94456 if (e) {
94457 log_packet_detailed("'fuel' field error detected");
94458 }
94459 }
94460
94461 if (BV_ISSET(fields, 7)) {
94462 log_packet_detailed(" field 'activity' has changed");
94463
94464#ifdef FREECIV_JSON_CONNECTION
94465 field_addr.name = "activity";
94466#endif /* FREECIV_JSON_CONNECTION */
94467 e = 0;
94468
94469 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
94470
94471 if (e) {
94472 log_packet_detailed("'activity' field error detected");
94473 }
94474 }
94475
94476 if (BV_ISSET(fields, 8)) {
94477 log_packet_detailed(" field 'activity_count' has changed");
94478
94479#ifdef FREECIV_JSON_CONNECTION
94480 field_addr.name = "activity_count";
94481#endif /* FREECIV_JSON_CONNECTION */
94482 e = 0;
94483
94484 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->activity_count);
94485
94486 if (e) {
94487 log_packet_detailed("'activity_count' field error detected");
94488 }
94489 }
94490
94491 if (BV_ISSET(fields, 9)) {
94492 log_packet_detailed(" field 'activity_base' has changed");
94493
94494#ifdef FREECIV_JSON_CONNECTION
94495 field_addr.name = "activity_base";
94496#endif /* FREECIV_JSON_CONNECTION */
94497 e = 0;
94498
94499 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->activity_base);
94500
94501 if (e) {
94502 log_packet_detailed("'activity_base' field error detected");
94503 }
94504 }
94505
94506 /* field 10 is folded into the header */
94507
94508 /* field 11 is folded into the header */
94509
94510 /* field 12 is folded into the header */
94511
94512 /* field 13 is folded into the header */
94513
94514 if (BV_ISSET(fields, 14)) {
94515 log_packet_detailed(" field 'transported_by' has changed");
94516
94517#ifdef FREECIV_JSON_CONNECTION
94518 field_addr.name = "transported_by";
94519#endif /* FREECIV_JSON_CONNECTION */
94520 e = 0;
94521
94522 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->transported_by);
94523
94524 if (e) {
94525 log_packet_detailed("'transported_by' field error detected");
94526 }
94527 }
94528
94529 /* field 15 is folded into the header */
94530
94531 *old = *real_packet;
94532
94533#else /* FREECIV_DELTA_PROTOCOL */
94534#ifdef FREECIV_JSON_CONNECTION
94535 field_addr.name = "utype";
94536#endif /* FREECIV_JSON_CONNECTION */
94537 e = 0;
94538
94539 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->utype);
94540
94541 if (e) {
94542 log_packet_detailed("'utype' field error detected");
94543 }
94544
94545#ifdef FREECIV_JSON_CONNECTION
94546 field_addr.name = "owner";
94547#endif /* FREECIV_JSON_CONNECTION */
94548 e = 0;
94549
94550 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
94551
94552 if (e) {
94553 log_packet_detailed("'owner' field error detected");
94554 }
94555
94556#ifdef FREECIV_JSON_CONNECTION
94557 field_addr.name = "homecity";
94558#endif /* FREECIV_JSON_CONNECTION */
94559 e = 0;
94560
94561 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->homecity);
94562
94563 if (e) {
94564 log_packet_detailed("'homecity' field error detected");
94565 }
94566
94567#ifdef FREECIV_JSON_CONNECTION
94568 field_addr.name = "moves_left";
94569#endif /* FREECIV_JSON_CONNECTION */
94570 e = 0;
94571
94572 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->moves_left);
94573
94574 if (e) {
94575 log_packet_detailed("'moves_left' field error detected");
94576 }
94577
94578#ifdef FREECIV_JSON_CONNECTION
94579 field_addr.name = "hp";
94580#endif /* FREECIV_JSON_CONNECTION */
94581 e = 0;
94582
94583 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->hp);
94584
94585 if (e) {
94586 log_packet_detailed("'hp' field error detected");
94587 }
94588
94589#ifdef FREECIV_JSON_CONNECTION
94590 field_addr.name = "veteran";
94591#endif /* FREECIV_JSON_CONNECTION */
94592 e = 0;
94593
94594 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->veteran);
94595
94596 if (e) {
94597 log_packet_detailed("'veteran' field error detected");
94598 }
94599
94600#ifdef FREECIV_JSON_CONNECTION
94601 field_addr.name = "fuel";
94602#endif /* FREECIV_JSON_CONNECTION */
94603 e = 0;
94604
94605 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->fuel);
94606
94607 if (e) {
94608 log_packet_detailed("'fuel' field error detected");
94609 }
94610
94611#ifdef FREECIV_JSON_CONNECTION
94612 field_addr.name = "activity";
94613#endif /* FREECIV_JSON_CONNECTION */
94614 e = 0;
94615
94616 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->activity);
94617
94618 if (e) {
94619 log_packet_detailed("'activity' field error detected");
94620 }
94621
94622#ifdef FREECIV_JSON_CONNECTION
94623 field_addr.name = "activity_count";
94624#endif /* FREECIV_JSON_CONNECTION */
94625 e = 0;
94626
94627 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->activity_count);
94628
94629 if (e) {
94630 log_packet_detailed("'activity_count' field error detected");
94631 }
94632
94633#ifdef FREECIV_JSON_CONNECTION
94634 field_addr.name = "activity_base";
94635#endif /* FREECIV_JSON_CONNECTION */
94636 e = 0;
94637
94638 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->activity_base);
94639
94640 if (e) {
94641 log_packet_detailed("'activity_base' field error detected");
94642 }
94643
94644#ifdef FREECIV_JSON_CONNECTION
94645 field_addr.name = "debug";
94646#endif /* FREECIV_JSON_CONNECTION */
94647 e = 0;
94648
94649 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->debug);
94650
94651 if (e) {
94652 log_packet_detailed("'debug' field error detected");
94653 }
94654
94655#ifdef FREECIV_JSON_CONNECTION
94656 field_addr.name = "moved";
94657#endif /* FREECIV_JSON_CONNECTION */
94658 e = 0;
94659
94660 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->moved);
94661
94662 if (e) {
94663 log_packet_detailed("'moved' field error detected");
94664 }
94665
94666#ifdef FREECIV_JSON_CONNECTION
94667 field_addr.name = "paradropped";
94668#endif /* FREECIV_JSON_CONNECTION */
94669 e = 0;
94670
94671 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->paradropped);
94672
94673 if (e) {
94674 log_packet_detailed("'paradropped' field error detected");
94675 }
94676
94677#ifdef FREECIV_JSON_CONNECTION
94678 field_addr.name = "done_moving";
94679#endif /* FREECIV_JSON_CONNECTION */
94680 e = 0;
94681
94682 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->done_moving);
94683
94684 if (e) {
94685 log_packet_detailed("'done_moving' field error detected");
94686 }
94687
94688#ifdef FREECIV_JSON_CONNECTION
94689 field_addr.name = "transported_by";
94690#endif /* FREECIV_JSON_CONNECTION */
94691 e = 0;
94692
94693 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->transported_by);
94694
94695 if (e) {
94696 log_packet_detailed("'transported_by' field error detected");
94697 }
94698
94699#ifdef FREECIV_JSON_CONNECTION
94700 field_addr.name = "stay";
94701#endif /* FREECIV_JSON_CONNECTION */
94702 e = 0;
94703
94704 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->stay);
94705
94706 if (e) {
94707 log_packet_detailed("'stay' field error detected");
94708 }
94709#endif /* FREECIV_DELTA_PROTOCOL */
94710
94711 SEND_PACKET_END(PACKET_EDIT_UNIT);
94712}
94713
94714 int send_packet_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
94715{
94716 if (!pc->used) {
94717 log_error("WARNING: trying to send data to the closed connection %s",
94718 conn_description(pc));
94719 return -1;
94720 }
94721 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_UNIT].packet != nullptr, -1,
94722 "Handler for PACKET_EDIT_UNIT not installed");
94723 return pc->phs.handlers->send[PACKET_EDIT_UNIT].packet(pc, packet);
94724}
94725
94726 static inline void init_packet_edit_city_create(struct packet_edit_city_create *packet)
94727{
94728 memset(packet, 0, sizeof(*packet));
94729}
94730
94731#define free_packet_edit_city_create(_packet) (void) 0
94732#define destroy_packet_edit_city_create free
94733
94734#ifdef FREECIV_DELTA_PROTOCOL
94735#define hash_packet_edit_city_create_100 hash_const
94736#define cmp_packet_edit_city_create_100 cmp_const
94737 BV_DEFINE(packet_edit_city_create_100_fields, 4);
94738#endif /* FREECIV_DELTA_PROTOCOL */
94739
94740 static struct packet_edit_city_create *receive_packet_edit_city_create_100(struct connection *pc)
94741{
94742#define FREE_PACKET_STRUCT(_packet) free_packet_edit_city_create(_packet)
94743 RECEIVE_PACKET_START(packet_edit_city_create, real_packet);
94744
94745#ifdef FREECIV_JSON_CONNECTION
94746 struct plocation field_addr;
94747 {
94748 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
94749 field_addr = *field_addr_tmp;
94750 FC_FREE(field_addr_tmp);
94751 }
94752#endif /* FREECIV_JSON_CONNECTION */
94753
94754 log_packet_detailed("packet_edit_city_create_100: got info about ()");
94755
94756#ifdef FREECIV_DELTA_PROTOCOL
94757 packet_edit_city_create_100_fields fields;
94758 struct packet_edit_city_create *old;
94759 struct genhash **hash = pc->phs.received + PACKET_EDIT_CITY_CREATE;
94760
94761 if (nullptr == *hash) {
94762 *hash = genhash_new_full(hash_packet_edit_city_create_100, cmp_packet_edit_city_create_100,
94763 nullptr, nullptr, nullptr, destroy_packet_edit_city_create);
94764 }
94765
94766 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
94767 *real_packet = *old;
94768 } else {
94769 /* packet is already initialized empty */
94770 log_packet_detailed(" no old info");
94771 }
94772
94773#ifdef FREECIV_JSON_CONNECTION
94774 field_addr.name = "fields";
94775#endif /* FREECIV_JSON_CONNECTION */
94776 DIO_BV_GET(&din, &field_addr, fields);
94777
94778 if (BV_ISSET(fields, 0)) {
94779 log_packet_detailed(" got field 'owner'");
94780
94781#ifdef FREECIV_JSON_CONNECTION
94782 field_addr.name = "owner";
94783#endif /* FREECIV_JSON_CONNECTION */
94784
94785 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
94786 RECEIVE_PACKET_FIELD_ERROR(owner);
94787 }
94788 }
94789
94790 if (BV_ISSET(fields, 1)) {
94791 log_packet_detailed(" got field 'tile'");
94792
94793#ifdef FREECIV_JSON_CONNECTION
94794 field_addr.name = "tile";
94795#endif /* FREECIV_JSON_CONNECTION */
94796
94797 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
94798 RECEIVE_PACKET_FIELD_ERROR(tile);
94799 }
94800 }
94801
94802 if (BV_ISSET(fields, 2)) {
94803 log_packet_detailed(" got field 'size'");
94804
94805#ifdef FREECIV_JSON_CONNECTION
94806 field_addr.name = "size";
94807#endif /* FREECIV_JSON_CONNECTION */
94808
94809 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
94810 RECEIVE_PACKET_FIELD_ERROR(size);
94811 }
94812 }
94813
94814 if (BV_ISSET(fields, 3)) {
94815 log_packet_detailed(" got field 'tag'");
94816
94817#ifdef FREECIV_JSON_CONNECTION
94818 field_addr.name = "tag";
94819#endif /* FREECIV_JSON_CONNECTION */
94820
94821 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
94822 RECEIVE_PACKET_FIELD_ERROR(tag);
94823 }
94824 }
94825
94826 if (nullptr == old) {
94827 old = fc_malloc(sizeof(*old));
94828 init_packet_edit_city_create(old);
94829 *old = *real_packet;
94830 genhash_insert(*hash, old, old);
94831 } else {
94832 *old = *real_packet;
94833 }
94834
94835#else /* FREECIV_DELTA_PROTOCOL */
94836#ifdef FREECIV_JSON_CONNECTION
94837 field_addr.name = "owner";
94838#endif /* FREECIV_JSON_CONNECTION */
94839
94840 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
94841 RECEIVE_PACKET_FIELD_ERROR(owner);
94842 }
94843
94844#ifdef FREECIV_JSON_CONNECTION
94845 field_addr.name = "tile";
94846#endif /* FREECIV_JSON_CONNECTION */
94847
94848 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
94849 RECEIVE_PACKET_FIELD_ERROR(tile);
94850 }
94851
94852#ifdef FREECIV_JSON_CONNECTION
94853 field_addr.name = "size";
94854#endif /* FREECIV_JSON_CONNECTION */
94855
94856 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
94857 RECEIVE_PACKET_FIELD_ERROR(size);
94858 }
94859
94860#ifdef FREECIV_JSON_CONNECTION
94861 field_addr.name = "tag";
94862#endif /* FREECIV_JSON_CONNECTION */
94863
94864 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
94865 RECEIVE_PACKET_FIELD_ERROR(tag);
94866 }
94867#endif /* FREECIV_DELTA_PROTOCOL */
94868
94869 RECEIVE_PACKET_END(real_packet);
94870#undef FREE_PACKET_STRUCT
94871}
94872
94873 static int send_packet_edit_city_create_100(struct connection *pc, const struct packet_edit_city_create *packet)
94874{
94875 const struct packet_edit_city_create *real_packet = packet;
94876 int e;
94877 SEND_PACKET_START(PACKET_EDIT_CITY_CREATE);
94878
94879 log_packet_detailed("packet_edit_city_create_100: sending info about ()");
94880
94881#ifdef FREECIV_DELTA_PROTOCOL
94882 packet_edit_city_create_100_fields fields;
94883 struct packet_edit_city_create *old;
94884 bool differ;
94885 struct genhash **hash = pc->phs.sent + PACKET_EDIT_CITY_CREATE;
94886
94887 if (nullptr == *hash) {
94888 *hash = genhash_new_full(hash_packet_edit_city_create_100, cmp_packet_edit_city_create_100,
94889 nullptr, nullptr, nullptr, destroy_packet_edit_city_create);
94890 }
94891 BV_CLR_ALL(fields);
94892
94893 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
94894 old = fc_malloc(sizeof(*old));
94895 /* temporary bitcopy just to insert correctly */
94896 *old = *real_packet;
94897 genhash_insert(*hash, old, old);
94898 init_packet_edit_city_create(old);
94899 }
94900
94901 differ = (old->owner != real_packet->owner);
94902 if (differ) {
94903 BV_SET(fields, 0);
94904 }
94905
94906 differ = (old->tile != real_packet->tile);
94907 if (differ) {
94908 BV_SET(fields, 1);
94909 }
94910
94911 differ = (old->size != real_packet->size);
94912 if (differ) {
94913 BV_SET(fields, 2);
94914 }
94915
94916 differ = (old->tag != real_packet->tag);
94917 if (differ) {
94918 BV_SET(fields, 3);
94919 }
94920#endif /* FREECIV_DELTA_PROTOCOL */
94921
94922#ifdef FREECIV_JSON_CONNECTION
94923 struct plocation field_addr;
94924 {
94925 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
94926 field_addr = *field_addr_tmp;
94927 FC_FREE(field_addr_tmp);
94928 }
94929#endif /* FREECIV_JSON_CONNECTION */
94930
94931#ifdef FREECIV_DELTA_PROTOCOL
94932#ifdef FREECIV_JSON_CONNECTION
94933 field_addr.name = "fields";
94934#endif /* FREECIV_JSON_CONNECTION */
94935 e = 0;
94936 e |= DIO_BV_PUT(&dout, &field_addr, fields);
94937 if (e) {
94938 log_packet_detailed("fields bitvector error detected");
94939 }
94940
94941 if (BV_ISSET(fields, 0)) {
94942 log_packet_detailed(" field 'owner' has changed");
94943
94944#ifdef FREECIV_JSON_CONNECTION
94945 field_addr.name = "owner";
94946#endif /* FREECIV_JSON_CONNECTION */
94947 e = 0;
94948
94949 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
94950
94951 if (e) {
94952 log_packet_detailed("'owner' field error detected");
94953 }
94954 }
94955
94956 if (BV_ISSET(fields, 1)) {
94957 log_packet_detailed(" field 'tile' has changed");
94958
94959#ifdef FREECIV_JSON_CONNECTION
94960 field_addr.name = "tile";
94961#endif /* FREECIV_JSON_CONNECTION */
94962 e = 0;
94963
94964 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
94965
94966 if (e) {
94967 log_packet_detailed("'tile' field error detected");
94968 }
94969 }
94970
94971 if (BV_ISSET(fields, 2)) {
94972 log_packet_detailed(" field 'size' has changed");
94973
94974#ifdef FREECIV_JSON_CONNECTION
94975 field_addr.name = "size";
94976#endif /* FREECIV_JSON_CONNECTION */
94977 e = 0;
94978
94979 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
94980
94981 if (e) {
94982 log_packet_detailed("'size' field error detected");
94983 }
94984 }
94985
94986 if (BV_ISSET(fields, 3)) {
94987 log_packet_detailed(" field 'tag' has changed");
94988
94989#ifdef FREECIV_JSON_CONNECTION
94990 field_addr.name = "tag";
94991#endif /* FREECIV_JSON_CONNECTION */
94992 e = 0;
94993
94994 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
94995
94996 if (e) {
94997 log_packet_detailed("'tag' field error detected");
94998 }
94999 }
95000
95001 *old = *real_packet;
95002
95003#else /* FREECIV_DELTA_PROTOCOL */
95004#ifdef FREECIV_JSON_CONNECTION
95005 field_addr.name = "owner";
95006#endif /* FREECIV_JSON_CONNECTION */
95007 e = 0;
95008
95009 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
95010
95011 if (e) {
95012 log_packet_detailed("'owner' field error detected");
95013 }
95014
95015#ifdef FREECIV_JSON_CONNECTION
95016 field_addr.name = "tile";
95017#endif /* FREECIV_JSON_CONNECTION */
95018 e = 0;
95019
95020 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
95021
95022 if (e) {
95023 log_packet_detailed("'tile' field error detected");
95024 }
95025
95026#ifdef FREECIV_JSON_CONNECTION
95027 field_addr.name = "size";
95028#endif /* FREECIV_JSON_CONNECTION */
95029 e = 0;
95030
95031 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
95032
95033 if (e) {
95034 log_packet_detailed("'size' field error detected");
95035 }
95036
95037#ifdef FREECIV_JSON_CONNECTION
95038 field_addr.name = "tag";
95039#endif /* FREECIV_JSON_CONNECTION */
95040 e = 0;
95041
95042 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
95043
95044 if (e) {
95045 log_packet_detailed("'tag' field error detected");
95046 }
95047#endif /* FREECIV_DELTA_PROTOCOL */
95048
95049 SEND_PACKET_END(PACKET_EDIT_CITY_CREATE);
95050}
95051
95052 int send_packet_edit_city_create(struct connection *pc, const struct packet_edit_city_create *packet)
95053{
95054 if (!pc->used) {
95055 log_error("WARNING: trying to send data to the closed connection %s",
95056 conn_description(pc));
95057 return -1;
95058 }
95059 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CITY_CREATE].packet != nullptr, -1,
95060 "Handler for PACKET_EDIT_CITY_CREATE not installed");
95061 return pc->phs.handlers->send[PACKET_EDIT_CITY_CREATE].packet(pc, packet);
95062}
95063
95064 int dsend_packet_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
95065{
95066 struct packet_edit_city_create packet, *real_packet = &packet;
95067
95068 real_packet->owner = owner;
95069 real_packet->tile = tile;
95070 real_packet->size = size;
95071 real_packet->tag = tag;
95072
95073 return send_packet_edit_city_create(pc, real_packet);
95074}
95075
95076 static inline void init_packet_edit_city_remove(struct packet_edit_city_remove *packet)
95077{
95078 memset(packet, 0, sizeof(*packet));
95079}
95080
95081#define free_packet_edit_city_remove(_packet) (void) 0
95082#define destroy_packet_edit_city_remove free
95083
95084#ifdef FREECIV_DELTA_PROTOCOL
95085#define hash_packet_edit_city_remove_100 hash_const
95086#define cmp_packet_edit_city_remove_100 cmp_const
95087 BV_DEFINE(packet_edit_city_remove_100_fields, 1);
95088#endif /* FREECIV_DELTA_PROTOCOL */
95089
95090 static struct packet_edit_city_remove *receive_packet_edit_city_remove_100(struct connection *pc)
95091{
95092#define FREE_PACKET_STRUCT(_packet) free_packet_edit_city_remove(_packet)
95093 RECEIVE_PACKET_START(packet_edit_city_remove, real_packet);
95094
95095#ifdef FREECIV_JSON_CONNECTION
95096 struct plocation field_addr;
95097 {
95098 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
95099 field_addr = *field_addr_tmp;
95100 FC_FREE(field_addr_tmp);
95101 }
95102#endif /* FREECIV_JSON_CONNECTION */
95103
95104 log_packet_detailed("packet_edit_city_remove_100: got info about ()");
95105
95106#ifdef FREECIV_DELTA_PROTOCOL
95107 packet_edit_city_remove_100_fields fields;
95108 struct packet_edit_city_remove *old;
95109 struct genhash **hash = pc->phs.received + PACKET_EDIT_CITY_REMOVE;
95110
95111 if (nullptr == *hash) {
95112 *hash = genhash_new_full(hash_packet_edit_city_remove_100, cmp_packet_edit_city_remove_100,
95113 nullptr, nullptr, nullptr, destroy_packet_edit_city_remove);
95114 }
95115
95116 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
95117 *real_packet = *old;
95118 } else {
95119 /* packet is already initialized empty */
95120 log_packet_detailed(" no old info");
95121 }
95122
95123#ifdef FREECIV_JSON_CONNECTION
95124 field_addr.name = "fields";
95125#endif /* FREECIV_JSON_CONNECTION */
95126 DIO_BV_GET(&din, &field_addr, fields);
95127
95128 if (BV_ISSET(fields, 0)) {
95129 log_packet_detailed(" got field 'id'");
95130
95131#ifdef FREECIV_JSON_CONNECTION
95132 field_addr.name = "id";
95133#endif /* FREECIV_JSON_CONNECTION */
95134
95135 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
95136 RECEIVE_PACKET_FIELD_ERROR(id);
95137 }
95138 }
95139
95140 if (nullptr == old) {
95141 old = fc_malloc(sizeof(*old));
95142 init_packet_edit_city_remove(old);
95143 *old = *real_packet;
95144 genhash_insert(*hash, old, old);
95145 } else {
95146 *old = *real_packet;
95147 }
95148
95149#else /* FREECIV_DELTA_PROTOCOL */
95150#ifdef FREECIV_JSON_CONNECTION
95151 field_addr.name = "id";
95152#endif /* FREECIV_JSON_CONNECTION */
95153
95154 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
95155 RECEIVE_PACKET_FIELD_ERROR(id);
95156 }
95157#endif /* FREECIV_DELTA_PROTOCOL */
95158
95159 RECEIVE_PACKET_END(real_packet);
95160#undef FREE_PACKET_STRUCT
95161}
95162
95163 static int send_packet_edit_city_remove_100(struct connection *pc, const struct packet_edit_city_remove *packet)
95164{
95165 const struct packet_edit_city_remove *real_packet = packet;
95166 int e;
95167 SEND_PACKET_START(PACKET_EDIT_CITY_REMOVE);
95168
95169 log_packet_detailed("packet_edit_city_remove_100: sending info about ()");
95170
95171#ifdef FREECIV_DELTA_PROTOCOL
95172 packet_edit_city_remove_100_fields fields;
95173 struct packet_edit_city_remove *old;
95174 bool differ;
95175 struct genhash **hash = pc->phs.sent + PACKET_EDIT_CITY_REMOVE;
95176
95177 if (nullptr == *hash) {
95178 *hash = genhash_new_full(hash_packet_edit_city_remove_100, cmp_packet_edit_city_remove_100,
95179 nullptr, nullptr, nullptr, destroy_packet_edit_city_remove);
95180 }
95181 BV_CLR_ALL(fields);
95182
95183 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
95184 old = fc_malloc(sizeof(*old));
95185 /* temporary bitcopy just to insert correctly */
95186 *old = *real_packet;
95187 genhash_insert(*hash, old, old);
95188 init_packet_edit_city_remove(old);
95189 }
95190
95191 differ = (old->id != real_packet->id);
95192 if (differ) {
95193 BV_SET(fields, 0);
95194 }
95195#endif /* FREECIV_DELTA_PROTOCOL */
95196
95197#ifdef FREECIV_JSON_CONNECTION
95198 struct plocation field_addr;
95199 {
95200 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
95201 field_addr = *field_addr_tmp;
95202 FC_FREE(field_addr_tmp);
95203 }
95204#endif /* FREECIV_JSON_CONNECTION */
95205
95206#ifdef FREECIV_DELTA_PROTOCOL
95207#ifdef FREECIV_JSON_CONNECTION
95208 field_addr.name = "fields";
95209#endif /* FREECIV_JSON_CONNECTION */
95210 e = 0;
95211 e |= DIO_BV_PUT(&dout, &field_addr, fields);
95212 if (e) {
95213 log_packet_detailed("fields bitvector error detected");
95214 }
95215
95216 if (BV_ISSET(fields, 0)) {
95217 log_packet_detailed(" field 'id' has changed");
95218
95219#ifdef FREECIV_JSON_CONNECTION
95220 field_addr.name = "id";
95221#endif /* FREECIV_JSON_CONNECTION */
95222 e = 0;
95223
95224 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
95225
95226 if (e) {
95227 log_packet_detailed("'id' field error detected");
95228 }
95229 }
95230
95231 *old = *real_packet;
95232
95233#else /* FREECIV_DELTA_PROTOCOL */
95234#ifdef FREECIV_JSON_CONNECTION
95235 field_addr.name = "id";
95236#endif /* FREECIV_JSON_CONNECTION */
95237 e = 0;
95238
95239 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
95240
95241 if (e) {
95242 log_packet_detailed("'id' field error detected");
95243 }
95244#endif /* FREECIV_DELTA_PROTOCOL */
95245
95246 SEND_PACKET_END(PACKET_EDIT_CITY_REMOVE);
95247}
95248
95249 int send_packet_edit_city_remove(struct connection *pc, const struct packet_edit_city_remove *packet)
95250{
95251 if (!pc->used) {
95252 log_error("WARNING: trying to send data to the closed connection %s",
95253 conn_description(pc));
95254 return -1;
95255 }
95256 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CITY_REMOVE].packet != nullptr, -1,
95257 "Handler for PACKET_EDIT_CITY_REMOVE not installed");
95258 return pc->phs.handlers->send[PACKET_EDIT_CITY_REMOVE].packet(pc, packet);
95259}
95260
95261 int dsend_packet_edit_city_remove(struct connection *pc, int id)
95262{
95263 struct packet_edit_city_remove packet, *real_packet = &packet;
95264
95265 real_packet->id = id;
95266
95267 return send_packet_edit_city_remove(pc, real_packet);
95268}
95269
95270 static inline void init_packet_edit_city(struct packet_edit_city *packet)
95271{
95272 memset(packet, 0, sizeof(*packet));
95273}
95274
95275#define free_packet_edit_city(_packet) (void) 0
95276#define destroy_packet_edit_city free
95277
95278#ifdef FREECIV_DELTA_PROTOCOL
95279static genhash_val_t hash_packet_edit_city_100(const void *vkey)
95280{
95281 const struct packet_edit_city *key = (const struct packet_edit_city *) vkey;
95282 genhash_val_t result = 0;
95283
95284 result += key->id;
95285
95286 result &= 0xFFFFFFFF;
95287 return result;
95288}
95289
95290static bool cmp_packet_edit_city_100(const void *vkey1, const void *vkey2)
95291{
95292 const struct packet_edit_city *old = (const struct packet_edit_city *) vkey1;
95293 const struct packet_edit_city *real_packet = (const struct packet_edit_city *) vkey2;
95294 bool differ;
95295
95296 differ = (old->id != real_packet->id);
95297
95298 return !differ;
95299}
95300 BV_DEFINE(packet_edit_city_100_fields, 28);
95301#endif /* FREECIV_DELTA_PROTOCOL */
95302
95303 static struct packet_edit_city *receive_packet_edit_city_100(struct connection *pc)
95304{
95305#define FREE_PACKET_STRUCT(_packet) free_packet_edit_city(_packet)
95306 RECEIVE_PACKET_START(packet_edit_city, real_packet);
95307
95308#ifdef FREECIV_JSON_CONNECTION
95309 struct plocation field_addr;
95310 {
95311 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
95312 field_addr = *field_addr_tmp;
95313 FC_FREE(field_addr_tmp);
95314 }
95315#endif /* FREECIV_JSON_CONNECTION */
95316
95317#ifdef FREECIV_JSON_CONNECTION
95318 field_addr.name = "id";
95319#endif /* FREECIV_JSON_CONNECTION */
95320
95321 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
95322 RECEIVE_PACKET_FIELD_ERROR(id);
95323 }
95324
95325 log_packet_detailed("packet_edit_city_100: got info about (%d)",
95326 real_packet->id);
95327
95328#ifdef FREECIV_DELTA_PROTOCOL
95329 packet_edit_city_100_fields fields;
95330 struct packet_edit_city *old;
95331 struct genhash **hash = pc->phs.received + PACKET_EDIT_CITY;
95332
95333 if (nullptr == *hash) {
95334 *hash = genhash_new_full(hash_packet_edit_city_100, cmp_packet_edit_city_100,
95335 nullptr, nullptr, nullptr, destroy_packet_edit_city);
95336 }
95337
95338 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
95339 *real_packet = *old;
95340 } else {
95341 /* packet is already initialized empty */
95342 log_packet_detailed(" no old info");
95343 }
95344
95345#ifdef FREECIV_JSON_CONNECTION
95346 field_addr.name = "fields";
95347#endif /* FREECIV_JSON_CONNECTION */
95348 DIO_BV_GET(&din, &field_addr, fields);
95349
95350 if (BV_ISSET(fields, 0)) {
95351 log_packet_detailed(" got field 'name'");
95352
95353#ifdef FREECIV_JSON_CONNECTION
95354 field_addr.name = "name";
95355#endif /* FREECIV_JSON_CONNECTION */
95356
95357 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
95358 RECEIVE_PACKET_FIELD_ERROR(name);
95359 }
95360 }
95361
95362 if (BV_ISSET(fields, 1)) {
95363 log_packet_detailed(" got field 'owner'");
95364
95365#ifdef FREECIV_JSON_CONNECTION
95366 field_addr.name = "owner";
95367#endif /* FREECIV_JSON_CONNECTION */
95368
95369 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
95370 RECEIVE_PACKET_FIELD_ERROR(owner);
95371 }
95372 }
95373
95374 if (BV_ISSET(fields, 2)) {
95375 log_packet_detailed(" got field 'original'");
95376
95377#ifdef FREECIV_JSON_CONNECTION
95378 field_addr.name = "original";
95379#endif /* FREECIV_JSON_CONNECTION */
95380
95381 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->original)) {
95382 RECEIVE_PACKET_FIELD_ERROR(original);
95383 }
95384 }
95385
95386 if (BV_ISSET(fields, 3)) {
95387 log_packet_detailed(" got field 'size'");
95388
95389#ifdef FREECIV_JSON_CONNECTION
95390 field_addr.name = "size";
95391#endif /* FREECIV_JSON_CONNECTION */
95392
95393 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
95394 RECEIVE_PACKET_FIELD_ERROR(size);
95395 }
95396 }
95397
95398 if (BV_ISSET(fields, 4)) {
95399 log_packet_detailed(" got field 'history'");
95400
95401#ifdef FREECIV_JSON_CONNECTION
95402 field_addr.name = "history";
95403#endif /* FREECIV_JSON_CONNECTION */
95404
95405 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->history)) {
95406 RECEIVE_PACKET_FIELD_ERROR(history);
95407 }
95408 }
95409
95410 if (BV_ISSET(fields, 5)) {
95411 log_packet_detailed(" got field 'ppl_happy'");
95412
95413#ifdef FREECIV_JSON_CONNECTION
95414 field_addr.name = "ppl_happy";
95415#endif /* FREECIV_JSON_CONNECTION */
95416
95417 {
95418 int i;
95419
95420
95421#ifdef FREECIV_JSON_CONNECTION
95422 /* Enter array. */
95423 field_addr.sub_location = plocation_elem_new(0);
95424#endif /* FREECIV_JSON_CONNECTION */
95425
95426 for (i = 0; i < 5; i++) {
95427#ifdef FREECIV_JSON_CONNECTION
95428 /* Next array element */
95429 field_addr.sub_location->number = i;
95430#endif /* FREECIV_JSON_CONNECTION */
95431
95432 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_happy[i])) {
95433 RECEIVE_PACKET_FIELD_ERROR(ppl_happy);
95434 }
95435 }
95436
95437#ifdef FREECIV_JSON_CONNECTION
95438 /* Exit array. */
95439 FC_FREE(field_addr.sub_location);
95440#endif /* FREECIV_JSON_CONNECTION */
95441 }
95442 }
95443
95444 if (BV_ISSET(fields, 6)) {
95445 log_packet_detailed(" got field 'ppl_content'");
95446
95447#ifdef FREECIV_JSON_CONNECTION
95448 field_addr.name = "ppl_content";
95449#endif /* FREECIV_JSON_CONNECTION */
95450
95451 {
95452 int i;
95453
95454
95455#ifdef FREECIV_JSON_CONNECTION
95456 /* Enter array. */
95457 field_addr.sub_location = plocation_elem_new(0);
95458#endif /* FREECIV_JSON_CONNECTION */
95459
95460 for (i = 0; i < 5; i++) {
95461#ifdef FREECIV_JSON_CONNECTION
95462 /* Next array element */
95463 field_addr.sub_location->number = i;
95464#endif /* FREECIV_JSON_CONNECTION */
95465
95466 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_content[i])) {
95467 RECEIVE_PACKET_FIELD_ERROR(ppl_content);
95468 }
95469 }
95470
95471#ifdef FREECIV_JSON_CONNECTION
95472 /* Exit array. */
95473 FC_FREE(field_addr.sub_location);
95474#endif /* FREECIV_JSON_CONNECTION */
95475 }
95476 }
95477
95478 if (BV_ISSET(fields, 7)) {
95479 log_packet_detailed(" got field 'ppl_unhappy'");
95480
95481#ifdef FREECIV_JSON_CONNECTION
95482 field_addr.name = "ppl_unhappy";
95483#endif /* FREECIV_JSON_CONNECTION */
95484
95485 {
95486 int i;
95487
95488
95489#ifdef FREECIV_JSON_CONNECTION
95490 /* Enter array. */
95491 field_addr.sub_location = plocation_elem_new(0);
95492#endif /* FREECIV_JSON_CONNECTION */
95493
95494 for (i = 0; i < 5; i++) {
95495#ifdef FREECIV_JSON_CONNECTION
95496 /* Next array element */
95497 field_addr.sub_location->number = i;
95498#endif /* FREECIV_JSON_CONNECTION */
95499
95500 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_unhappy[i])) {
95501 RECEIVE_PACKET_FIELD_ERROR(ppl_unhappy);
95502 }
95503 }
95504
95505#ifdef FREECIV_JSON_CONNECTION
95506 /* Exit array. */
95507 FC_FREE(field_addr.sub_location);
95508#endif /* FREECIV_JSON_CONNECTION */
95509 }
95510 }
95511
95512 if (BV_ISSET(fields, 8)) {
95513 log_packet_detailed(" got field 'ppl_angry'");
95514
95515#ifdef FREECIV_JSON_CONNECTION
95516 field_addr.name = "ppl_angry";
95517#endif /* FREECIV_JSON_CONNECTION */
95518
95519 {
95520 int i;
95521
95522
95523#ifdef FREECIV_JSON_CONNECTION
95524 /* Enter array. */
95525 field_addr.sub_location = plocation_elem_new(0);
95526#endif /* FREECIV_JSON_CONNECTION */
95527
95528 for (i = 0; i < 5; i++) {
95529#ifdef FREECIV_JSON_CONNECTION
95530 /* Next array element */
95531 field_addr.sub_location->number = i;
95532#endif /* FREECIV_JSON_CONNECTION */
95533
95534 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_angry[i])) {
95535 RECEIVE_PACKET_FIELD_ERROR(ppl_angry);
95536 }
95537 }
95538
95539#ifdef FREECIV_JSON_CONNECTION
95540 /* Exit array. */
95541 FC_FREE(field_addr.sub_location);
95542#endif /* FREECIV_JSON_CONNECTION */
95543 }
95544 }
95545
95546 if (BV_ISSET(fields, 9)) {
95547 log_packet_detailed(" got field 'specialists_size'");
95548
95549#ifdef FREECIV_JSON_CONNECTION
95550 field_addr.name = "specialists_size";
95551#endif /* FREECIV_JSON_CONNECTION */
95552
95553 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists_size)) {
95554 RECEIVE_PACKET_FIELD_ERROR(specialists_size);
95555 }
95556 }
95557
95558 if (BV_ISSET(fields, 10)) {
95559 log_packet_detailed(" got field 'specialists'");
95560
95561#ifdef FREECIV_JSON_CONNECTION
95562 field_addr.name = "specialists";
95563#endif /* FREECIV_JSON_CONNECTION */
95564
95565 {
95566 int i;
95567
95568 if (real_packet->specialists_size > SP_MAX) {
95569 RECEIVE_PACKET_FIELD_ERROR(specialists, ": array truncated");
95570 }
95571
95572#ifdef FREECIV_JSON_CONNECTION
95573 /* Enter array. */
95574 field_addr.sub_location = plocation_elem_new(0);
95575#endif /* FREECIV_JSON_CONNECTION */
95576
95577 for (i = 0; i < real_packet->specialists_size; i++) {
95578#ifdef FREECIV_JSON_CONNECTION
95579 /* Next array element */
95580 field_addr.sub_location->number = i;
95581#endif /* FREECIV_JSON_CONNECTION */
95582
95583 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists[i])) {
95584 RECEIVE_PACKET_FIELD_ERROR(specialists);
95585 }
95586 }
95587
95588#ifdef FREECIV_JSON_CONNECTION
95589 /* Exit array. */
95590 FC_FREE(field_addr.sub_location);
95591#endif /* FREECIV_JSON_CONNECTION */
95592 }
95593 }
95594
95595 if (BV_ISSET(fields, 11)) {
95596 log_packet_detailed(" got field 'food_stock'");
95597
95598#ifdef FREECIV_JSON_CONNECTION
95599 field_addr.name = "food_stock";
95600#endif /* FREECIV_JSON_CONNECTION */
95601
95602 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->food_stock)) {
95603 RECEIVE_PACKET_FIELD_ERROR(food_stock);
95604 }
95605 }
95606
95607 if (BV_ISSET(fields, 12)) {
95608 log_packet_detailed(" got field 'shield_stock'");
95609
95610#ifdef FREECIV_JSON_CONNECTION
95611 field_addr.name = "shield_stock";
95612#endif /* FREECIV_JSON_CONNECTION */
95613
95614 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->shield_stock)) {
95615 RECEIVE_PACKET_FIELD_ERROR(shield_stock);
95616 }
95617 }
95618
95619 real_packet->airlift = BV_ISSET(fields, 13);
95620
95621 real_packet->debug = BV_ISSET(fields, 14);
95622
95623 real_packet->did_buy = BV_ISSET(fields, 15);
95624
95625 real_packet->did_sell = BV_ISSET(fields, 16);
95626
95627 real_packet->was_happy = BV_ISSET(fields, 17);
95628
95629 real_packet->had_famine = BV_ISSET(fields, 18);
95630
95631 if (BV_ISSET(fields, 19)) {
95632 log_packet_detailed(" got field 'anarchy'");
95633
95634#ifdef FREECIV_JSON_CONNECTION
95635 field_addr.name = "anarchy";
95636#endif /* FREECIV_JSON_CONNECTION */
95637
95638 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->anarchy)) {
95639 RECEIVE_PACKET_FIELD_ERROR(anarchy);
95640 }
95641 }
95642
95643 if (BV_ISSET(fields, 20)) {
95644 log_packet_detailed(" got field 'rapture'");
95645
95646#ifdef FREECIV_JSON_CONNECTION
95647 field_addr.name = "rapture";
95648#endif /* FREECIV_JSON_CONNECTION */
95649
95650 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->rapture)) {
95651 RECEIVE_PACKET_FIELD_ERROR(rapture);
95652 }
95653 }
95654
95655 if (BV_ISSET(fields, 21)) {
95656 log_packet_detailed(" got field 'steal'");
95657
95658#ifdef FREECIV_JSON_CONNECTION
95659 field_addr.name = "steal";
95660#endif /* FREECIV_JSON_CONNECTION */
95661
95662 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->steal)) {
95663 RECEIVE_PACKET_FIELD_ERROR(steal);
95664 }
95665 }
95666
95667 if (BV_ISSET(fields, 22)) {
95668 log_packet_detailed(" got field 'turn_founded'");
95669
95670#ifdef FREECIV_JSON_CONNECTION
95671 field_addr.name = "turn_founded";
95672#endif /* FREECIV_JSON_CONNECTION */
95673
95674 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_founded)) {
95675 RECEIVE_PACKET_FIELD_ERROR(turn_founded);
95676 }
95677 }
95678
95679 if (BV_ISSET(fields, 23)) {
95680 log_packet_detailed(" got field 'turn_last_built'");
95681
95682#ifdef FREECIV_JSON_CONNECTION
95683 field_addr.name = "turn_last_built";
95684#endif /* FREECIV_JSON_CONNECTION */
95685
95686 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_last_built)) {
95687 RECEIVE_PACKET_FIELD_ERROR(turn_last_built);
95688 }
95689 }
95690
95691 if (BV_ISSET(fields, 24)) {
95692 log_packet_detailed(" got field 'built'");
95693
95694#ifdef FREECIV_JSON_CONNECTION
95695 field_addr.name = "built";
95696#endif /* FREECIV_JSON_CONNECTION */
95697
95698 FC_STATIC_ASSERT(B_LAST <= MAX_UINT16, packet_array_too_long_built);
95699#ifdef FREECIV_JSON_CONNECTION
95700 /* Enter array (start at initial element). */
95701 field_addr.sub_location = plocation_elem_new(0);
95702 /* Enter diff array element (start at the index address). */
95703 field_addr.sub_location->sub_location = plocation_field_new("index");
95704#endif /* FREECIV_JSON_CONNECTION */
95705
95706 while (TRUE) {
95707 int i;
95708
95709 /* Read next index */
95710#if B_LAST <= MAX_UINT8
95711 if (!DIO_GET(uint8, &din, &field_addr, &i)) {
95712#else
95713 if (!DIO_GET(uint16, &din, &field_addr, &i)) {
95714#endif
95715 RECEIVE_PACKET_FIELD_ERROR(built);
95716 }
95717
95718 if (i == B_LAST) {
95719 break;
95720 }
95721 if (i > B_LAST) {
95722 RECEIVE_PACKET_FIELD_ERROR(built,
95723 ": unexpected index %d "
95724 "> length %d in array diff",
95725 i,
95726 B_LAST);
95727 }
95728
95729#ifdef FREECIV_JSON_CONNECTION
95730 /* Content address. */
95731 field_addr.sub_location->sub_location->name = "data";
95732#endif /* FREECIV_JSON_CONNECTION */
95733
95734 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->built[i])) {
95735 RECEIVE_PACKET_FIELD_ERROR(built);
95736 }
95737
95738#ifdef FREECIV_JSON_CONNECTION
95739 /* Move to the next diff array element. */
95740 field_addr.sub_location->number++;
95741 /* Back to the index address. */
95742 field_addr.sub_location->sub_location->name = "index";
95743#endif /* FREECIV_JSON_CONNECTION */
95744 }
95745
95746#ifdef FREECIV_JSON_CONNECTION
95747 /* Exit diff array element. */
95748 FC_FREE(field_addr.sub_location->sub_location);
95749 /* Exit array. */
95750 FC_FREE(field_addr.sub_location);
95751#endif /* FREECIV_JSON_CONNECTION */
95752 }
95753
95754 if (BV_ISSET(fields, 25)) {
95755 log_packet_detailed(" got field 'production_kind'");
95756
95757#ifdef FREECIV_JSON_CONNECTION
95758 field_addr.name = "production_kind";
95759#endif /* FREECIV_JSON_CONNECTION */
95760
95761 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_kind)) {
95762 RECEIVE_PACKET_FIELD_ERROR(production_kind);
95763 }
95764 }
95765
95766 if (BV_ISSET(fields, 26)) {
95767 log_packet_detailed(" got field 'production_value'");
95768
95769#ifdef FREECIV_JSON_CONNECTION
95770 field_addr.name = "production_value";
95771#endif /* FREECIV_JSON_CONNECTION */
95772
95773 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_value)) {
95774 RECEIVE_PACKET_FIELD_ERROR(production_value);
95775 }
95776 }
95777
95778 if (BV_ISSET(fields, 27)) {
95779 log_packet_detailed(" got field 'city_options'");
95780
95781#ifdef FREECIV_JSON_CONNECTION
95782 field_addr.name = "city_options";
95783#endif /* FREECIV_JSON_CONNECTION */
95784
95785 if (!DIO_BV_GET(&din, &field_addr, real_packet->city_options)) {
95786 RECEIVE_PACKET_FIELD_ERROR(city_options);
95787 }
95788 }
95789
95790 if (nullptr == old) {
95791 old = fc_malloc(sizeof(*old));
95792 init_packet_edit_city(old);
95793 *old = *real_packet;
95794 genhash_insert(*hash, old, old);
95795 } else {
95796 *old = *real_packet;
95797 }
95798
95799#else /* FREECIV_DELTA_PROTOCOL */
95800#ifdef FREECIV_JSON_CONNECTION
95801 field_addr.name = "name";
95802#endif /* FREECIV_JSON_CONNECTION */
95803
95804 if (!DIO_GET(estring, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
95805 RECEIVE_PACKET_FIELD_ERROR(name);
95806 }
95807
95808#ifdef FREECIV_JSON_CONNECTION
95809 field_addr.name = "owner";
95810#endif /* FREECIV_JSON_CONNECTION */
95811
95812 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->owner)) {
95813 RECEIVE_PACKET_FIELD_ERROR(owner);
95814 }
95815
95816#ifdef FREECIV_JSON_CONNECTION
95817 field_addr.name = "original";
95818#endif /* FREECIV_JSON_CONNECTION */
95819
95820 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->original)) {
95821 RECEIVE_PACKET_FIELD_ERROR(original);
95822 }
95823
95824#ifdef FREECIV_JSON_CONNECTION
95825 field_addr.name = "size";
95826#endif /* FREECIV_JSON_CONNECTION */
95827
95828 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
95829 RECEIVE_PACKET_FIELD_ERROR(size);
95830 }
95831
95832#ifdef FREECIV_JSON_CONNECTION
95833 field_addr.name = "history";
95834#endif /* FREECIV_JSON_CONNECTION */
95835
95836 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->history)) {
95837 RECEIVE_PACKET_FIELD_ERROR(history);
95838 }
95839
95840#ifdef FREECIV_JSON_CONNECTION
95841 field_addr.name = "ppl_happy";
95842#endif /* FREECIV_JSON_CONNECTION */
95843
95844 {
95845 int i;
95846
95847
95848#ifdef FREECIV_JSON_CONNECTION
95849 /* Enter array. */
95850 field_addr.sub_location = plocation_elem_new(0);
95851#endif /* FREECIV_JSON_CONNECTION */
95852
95853 for (i = 0; i < 5; i++) {
95854#ifdef FREECIV_JSON_CONNECTION
95855 /* Next array element */
95856 field_addr.sub_location->number = i;
95857#endif /* FREECIV_JSON_CONNECTION */
95858
95859 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_happy[i])) {
95860 RECEIVE_PACKET_FIELD_ERROR(ppl_happy);
95861 }
95862 }
95863
95864#ifdef FREECIV_JSON_CONNECTION
95865 /* Exit array. */
95866 FC_FREE(field_addr.sub_location);
95867#endif /* FREECIV_JSON_CONNECTION */
95868 }
95869
95870#ifdef FREECIV_JSON_CONNECTION
95871 field_addr.name = "ppl_content";
95872#endif /* FREECIV_JSON_CONNECTION */
95873
95874 {
95875 int i;
95876
95877
95878#ifdef FREECIV_JSON_CONNECTION
95879 /* Enter array. */
95880 field_addr.sub_location = plocation_elem_new(0);
95881#endif /* FREECIV_JSON_CONNECTION */
95882
95883 for (i = 0; i < 5; i++) {
95884#ifdef FREECIV_JSON_CONNECTION
95885 /* Next array element */
95886 field_addr.sub_location->number = i;
95887#endif /* FREECIV_JSON_CONNECTION */
95888
95889 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_content[i])) {
95890 RECEIVE_PACKET_FIELD_ERROR(ppl_content);
95891 }
95892 }
95893
95894#ifdef FREECIV_JSON_CONNECTION
95895 /* Exit array. */
95896 FC_FREE(field_addr.sub_location);
95897#endif /* FREECIV_JSON_CONNECTION */
95898 }
95899
95900#ifdef FREECIV_JSON_CONNECTION
95901 field_addr.name = "ppl_unhappy";
95902#endif /* FREECIV_JSON_CONNECTION */
95903
95904 {
95905 int i;
95906
95907
95908#ifdef FREECIV_JSON_CONNECTION
95909 /* Enter array. */
95910 field_addr.sub_location = plocation_elem_new(0);
95911#endif /* FREECIV_JSON_CONNECTION */
95912
95913 for (i = 0; i < 5; i++) {
95914#ifdef FREECIV_JSON_CONNECTION
95915 /* Next array element */
95916 field_addr.sub_location->number = i;
95917#endif /* FREECIV_JSON_CONNECTION */
95918
95919 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_unhappy[i])) {
95920 RECEIVE_PACKET_FIELD_ERROR(ppl_unhappy);
95921 }
95922 }
95923
95924#ifdef FREECIV_JSON_CONNECTION
95925 /* Exit array. */
95926 FC_FREE(field_addr.sub_location);
95927#endif /* FREECIV_JSON_CONNECTION */
95928 }
95929
95930#ifdef FREECIV_JSON_CONNECTION
95931 field_addr.name = "ppl_angry";
95932#endif /* FREECIV_JSON_CONNECTION */
95933
95934 {
95935 int i;
95936
95937
95938#ifdef FREECIV_JSON_CONNECTION
95939 /* Enter array. */
95940 field_addr.sub_location = plocation_elem_new(0);
95941#endif /* FREECIV_JSON_CONNECTION */
95942
95943 for (i = 0; i < 5; i++) {
95944#ifdef FREECIV_JSON_CONNECTION
95945 /* Next array element */
95946 field_addr.sub_location->number = i;
95947#endif /* FREECIV_JSON_CONNECTION */
95948
95949 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->ppl_angry[i])) {
95950 RECEIVE_PACKET_FIELD_ERROR(ppl_angry);
95951 }
95952 }
95953
95954#ifdef FREECIV_JSON_CONNECTION
95955 /* Exit array. */
95956 FC_FREE(field_addr.sub_location);
95957#endif /* FREECIV_JSON_CONNECTION */
95958 }
95959
95960#ifdef FREECIV_JSON_CONNECTION
95961 field_addr.name = "specialists_size";
95962#endif /* FREECIV_JSON_CONNECTION */
95963
95964 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists_size)) {
95965 RECEIVE_PACKET_FIELD_ERROR(specialists_size);
95966 }
95967
95968#ifdef FREECIV_JSON_CONNECTION
95969 field_addr.name = "specialists";
95970#endif /* FREECIV_JSON_CONNECTION */
95971
95972 {
95973 int i;
95974
95975 if (real_packet->specialists_size > SP_MAX) {
95976 RECEIVE_PACKET_FIELD_ERROR(specialists, ": array truncated");
95977 }
95978
95979#ifdef FREECIV_JSON_CONNECTION
95980 /* Enter array. */
95981 field_addr.sub_location = plocation_elem_new(0);
95982#endif /* FREECIV_JSON_CONNECTION */
95983
95984 for (i = 0; i < real_packet->specialists_size; i++) {
95985#ifdef FREECIV_JSON_CONNECTION
95986 /* Next array element */
95987 field_addr.sub_location->number = i;
95988#endif /* FREECIV_JSON_CONNECTION */
95989
95990 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->specialists[i])) {
95991 RECEIVE_PACKET_FIELD_ERROR(specialists);
95992 }
95993 }
95994
95995#ifdef FREECIV_JSON_CONNECTION
95996 /* Exit array. */
95997 FC_FREE(field_addr.sub_location);
95998#endif /* FREECIV_JSON_CONNECTION */
95999 }
96000
96001#ifdef FREECIV_JSON_CONNECTION
96002 field_addr.name = "food_stock";
96003#endif /* FREECIV_JSON_CONNECTION */
96004
96005 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->food_stock)) {
96006 RECEIVE_PACKET_FIELD_ERROR(food_stock);
96007 }
96008
96009#ifdef FREECIV_JSON_CONNECTION
96010 field_addr.name = "shield_stock";
96011#endif /* FREECIV_JSON_CONNECTION */
96012
96013 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->shield_stock)) {
96014 RECEIVE_PACKET_FIELD_ERROR(shield_stock);
96015 }
96016
96017#ifdef FREECIV_JSON_CONNECTION
96018 field_addr.name = "airlift";
96019#endif /* FREECIV_JSON_CONNECTION */
96020
96021 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->airlift)) {
96022 RECEIVE_PACKET_FIELD_ERROR(airlift);
96023 }
96024
96025#ifdef FREECIV_JSON_CONNECTION
96026 field_addr.name = "debug";
96027#endif /* FREECIV_JSON_CONNECTION */
96028
96029 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->debug)) {
96030 RECEIVE_PACKET_FIELD_ERROR(debug);
96031 }
96032
96033#ifdef FREECIV_JSON_CONNECTION
96034 field_addr.name = "did_buy";
96035#endif /* FREECIV_JSON_CONNECTION */
96036
96037 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->did_buy)) {
96038 RECEIVE_PACKET_FIELD_ERROR(did_buy);
96039 }
96040
96041#ifdef FREECIV_JSON_CONNECTION
96042 field_addr.name = "did_sell";
96043#endif /* FREECIV_JSON_CONNECTION */
96044
96045 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->did_sell)) {
96046 RECEIVE_PACKET_FIELD_ERROR(did_sell);
96047 }
96048
96049#ifdef FREECIV_JSON_CONNECTION
96050 field_addr.name = "was_happy";
96051#endif /* FREECIV_JSON_CONNECTION */
96052
96053 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->was_happy)) {
96054 RECEIVE_PACKET_FIELD_ERROR(was_happy);
96055 }
96056
96057#ifdef FREECIV_JSON_CONNECTION
96058 field_addr.name = "had_famine";
96059#endif /* FREECIV_JSON_CONNECTION */
96060
96061 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->had_famine)) {
96062 RECEIVE_PACKET_FIELD_ERROR(had_famine);
96063 }
96064
96065#ifdef FREECIV_JSON_CONNECTION
96066 field_addr.name = "anarchy";
96067#endif /* FREECIV_JSON_CONNECTION */
96068
96069 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->anarchy)) {
96070 RECEIVE_PACKET_FIELD_ERROR(anarchy);
96071 }
96072
96073#ifdef FREECIV_JSON_CONNECTION
96074 field_addr.name = "rapture";
96075#endif /* FREECIV_JSON_CONNECTION */
96076
96077 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->rapture)) {
96078 RECEIVE_PACKET_FIELD_ERROR(rapture);
96079 }
96080
96081#ifdef FREECIV_JSON_CONNECTION
96082 field_addr.name = "steal";
96083#endif /* FREECIV_JSON_CONNECTION */
96084
96085 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->steal)) {
96086 RECEIVE_PACKET_FIELD_ERROR(steal);
96087 }
96088
96089#ifdef FREECIV_JSON_CONNECTION
96090 field_addr.name = "turn_founded";
96091#endif /* FREECIV_JSON_CONNECTION */
96092
96093 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_founded)) {
96094 RECEIVE_PACKET_FIELD_ERROR(turn_founded);
96095 }
96096
96097#ifdef FREECIV_JSON_CONNECTION
96098 field_addr.name = "turn_last_built";
96099#endif /* FREECIV_JSON_CONNECTION */
96100
96101 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->turn_last_built)) {
96102 RECEIVE_PACKET_FIELD_ERROR(turn_last_built);
96103 }
96104
96105#ifdef FREECIV_JSON_CONNECTION
96106 field_addr.name = "built";
96107#endif /* FREECIV_JSON_CONNECTION */
96108
96109 {
96110 int i;
96111
96112
96113#ifdef FREECIV_JSON_CONNECTION
96114 /* Enter array. */
96115 field_addr.sub_location = plocation_elem_new(0);
96116#endif /* FREECIV_JSON_CONNECTION */
96117
96118 for (i = 0; i < B_LAST; i++) {
96119#ifdef FREECIV_JSON_CONNECTION
96120 /* Next array element */
96121 field_addr.sub_location->number = i;
96122#endif /* FREECIV_JSON_CONNECTION */
96123
96124 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->built[i])) {
96125 RECEIVE_PACKET_FIELD_ERROR(built);
96126 }
96127 }
96128
96129#ifdef FREECIV_JSON_CONNECTION
96130 /* Exit array. */
96131 FC_FREE(field_addr.sub_location);
96132#endif /* FREECIV_JSON_CONNECTION */
96133 }
96134
96135#ifdef FREECIV_JSON_CONNECTION
96136 field_addr.name = "production_kind";
96137#endif /* FREECIV_JSON_CONNECTION */
96138
96139 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_kind)) {
96140 RECEIVE_PACKET_FIELD_ERROR(production_kind);
96141 }
96142
96143#ifdef FREECIV_JSON_CONNECTION
96144 field_addr.name = "production_value";
96145#endif /* FREECIV_JSON_CONNECTION */
96146
96147 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->production_value)) {
96148 RECEIVE_PACKET_FIELD_ERROR(production_value);
96149 }
96150
96151#ifdef FREECIV_JSON_CONNECTION
96152 field_addr.name = "city_options";
96153#endif /* FREECIV_JSON_CONNECTION */
96154
96155 if (!DIO_BV_GET(&din, &field_addr, real_packet->city_options)) {
96156 RECEIVE_PACKET_FIELD_ERROR(city_options);
96157 }
96158#endif /* FREECIV_DELTA_PROTOCOL */
96159
96160 RECEIVE_PACKET_END(real_packet);
96161#undef FREE_PACKET_STRUCT
96162}
96163
96164 static int send_packet_edit_city_100(struct connection *pc, const struct packet_edit_city *packet)
96165{
96166 const struct packet_edit_city *real_packet = packet;
96167 int e;
96168 SEND_PACKET_START(PACKET_EDIT_CITY);
96169
96170 log_packet_detailed("packet_edit_city_100: sending info about (%d)",
96171 real_packet->id);
96172
96173#ifdef FREECIV_DELTA_PROTOCOL
96174 packet_edit_city_100_fields fields;
96175 struct packet_edit_city *old;
96176 bool differ;
96177 struct genhash **hash = pc->phs.sent + PACKET_EDIT_CITY;
96178
96179 if (nullptr == *hash) {
96180 *hash = genhash_new_full(hash_packet_edit_city_100, cmp_packet_edit_city_100,
96181 nullptr, nullptr, nullptr, destroy_packet_edit_city);
96182 }
96183 BV_CLR_ALL(fields);
96184
96185 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
96186 old = fc_malloc(sizeof(*old));
96187 /* temporary bitcopy just to insert correctly */
96188 *old = *real_packet;
96189 genhash_insert(*hash, old, old);
96190 init_packet_edit_city(old);
96191 }
96192
96193 differ = (strcmp(old->name, real_packet->name) != 0);
96194 if (differ) {
96195 BV_SET(fields, 0);
96196 }
96197
96198 differ = (old->owner != real_packet->owner);
96199 if (differ) {
96200 BV_SET(fields, 1);
96201 }
96202
96203 differ = (old->original != real_packet->original);
96204 if (differ) {
96205 BV_SET(fields, 2);
96206 }
96207
96208 differ = (old->size != real_packet->size);
96209 if (differ) {
96210 BV_SET(fields, 3);
96211 }
96212
96213 differ = (old->history != real_packet->history);
96214 if (differ) {
96215 BV_SET(fields, 4);
96216 }
96217
96218 differ = FALSE;
96219 {
96220 int i;
96221
96222 for (i = 0; i < 5; i++) {
96223 differ = (old->ppl_happy[i] != real_packet->ppl_happy[i]);
96224 if (differ) {
96225 break;
96226 }
96227 }
96228 }
96229 if (differ) {
96230 BV_SET(fields, 5);
96231 }
96232
96233 differ = FALSE;
96234 {
96235 int i;
96236
96237 for (i = 0; i < 5; i++) {
96238 differ = (old->ppl_content[i] != real_packet->ppl_content[i]);
96239 if (differ) {
96240 break;
96241 }
96242 }
96243 }
96244 if (differ) {
96245 BV_SET(fields, 6);
96246 }
96247
96248 differ = FALSE;
96249 {
96250 int i;
96251
96252 for (i = 0; i < 5; i++) {
96253 differ = (old->ppl_unhappy[i] != real_packet->ppl_unhappy[i]);
96254 if (differ) {
96255 break;
96256 }
96257 }
96258 }
96259 if (differ) {
96260 BV_SET(fields, 7);
96261 }
96262
96263 differ = FALSE;
96264 {
96265 int i;
96266
96267 for (i = 0; i < 5; i++) {
96268 differ = (old->ppl_angry[i] != real_packet->ppl_angry[i]);
96269 if (differ) {
96270 break;
96271 }
96272 }
96273 }
96274 if (differ) {
96275 BV_SET(fields, 8);
96276 }
96277
96278 differ = (old->specialists_size != real_packet->specialists_size);
96279 if (differ) {
96280 BV_SET(fields, 9);
96281 }
96282
96283 differ = (old->specialists_size != real_packet->specialists_size);
96284 if (!differ) {
96285 int i;
96286
96287 for (i = 0; i < old->specialists_size; i++) {
96288 differ = (old->specialists[i] != real_packet->specialists[i]);
96289 if (differ) {
96290 break;
96291 }
96292 }
96293 }
96294 if (differ) {
96295 BV_SET(fields, 10);
96296 }
96297
96298 differ = (old->food_stock != real_packet->food_stock);
96299 if (differ) {
96300 BV_SET(fields, 11);
96301 }
96302
96303 differ = (old->shield_stock != real_packet->shield_stock);
96304 if (differ) {
96305 BV_SET(fields, 12);
96306 }
96307
96308 /* folded into head */
96309 if (real_packet->airlift) {
96310 BV_SET(fields, 13);
96311 }
96312
96313 /* folded into head */
96314 if (real_packet->debug) {
96315 BV_SET(fields, 14);
96316 }
96317
96318 /* folded into head */
96319 if (real_packet->did_buy) {
96320 BV_SET(fields, 15);
96321 }
96322
96323 /* folded into head */
96324 if (real_packet->did_sell) {
96325 BV_SET(fields, 16);
96326 }
96327
96328 /* folded into head */
96329 if (real_packet->was_happy) {
96330 BV_SET(fields, 17);
96331 }
96332
96333 /* folded into head */
96334 if (real_packet->had_famine) {
96335 BV_SET(fields, 18);
96336 }
96337
96338 differ = (old->anarchy != real_packet->anarchy);
96339 if (differ) {
96340 BV_SET(fields, 19);
96341 }
96342
96343 differ = (old->rapture != real_packet->rapture);
96344 if (differ) {
96345 BV_SET(fields, 20);
96346 }
96347
96348 differ = (old->steal != real_packet->steal);
96349 if (differ) {
96350 BV_SET(fields, 21);
96351 }
96352
96353 differ = (old->turn_founded != real_packet->turn_founded);
96354 if (differ) {
96355 BV_SET(fields, 22);
96356 }
96357
96358 differ = (old->turn_last_built != real_packet->turn_last_built);
96359 if (differ) {
96360 BV_SET(fields, 23);
96361 }
96362
96363 differ = FALSE;
96364 {
96365 int i;
96366
96367 for (i = 0; i < B_LAST; i++) {
96368 differ = (old->built[i] != real_packet->built[i]);
96369 if (differ) {
96370 break;
96371 }
96372 }
96373 }
96374 if (differ) {
96375 BV_SET(fields, 24);
96376 }
96377
96378 differ = (old->production_kind != real_packet->production_kind);
96379 if (differ) {
96380 BV_SET(fields, 25);
96381 }
96382
96383 differ = (old->production_value != real_packet->production_value);
96384 if (differ) {
96385 BV_SET(fields, 26);
96386 }
96387
96388 differ = !BV_ARE_EQUAL(old->city_options, real_packet->city_options);
96389 if (differ) {
96390 BV_SET(fields, 27);
96391 }
96392#endif /* FREECIV_DELTA_PROTOCOL */
96393
96394#ifdef FREECIV_JSON_CONNECTION
96395 struct plocation field_addr;
96396 {
96397 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
96398 field_addr = *field_addr_tmp;
96399 FC_FREE(field_addr_tmp);
96400 }
96401#endif /* FREECIV_JSON_CONNECTION */
96402
96403#ifdef FREECIV_JSON_CONNECTION
96404 field_addr.name = "id";
96405#endif /* FREECIV_JSON_CONNECTION */
96406 e = 0;
96407
96408 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
96409
96410 if (e) {
96411 log_packet_detailed("'id' field error detected");
96412 }
96413
96414#ifdef FREECIV_DELTA_PROTOCOL
96415#ifdef FREECIV_JSON_CONNECTION
96416 field_addr.name = "fields";
96417#endif /* FREECIV_JSON_CONNECTION */
96418 e = 0;
96419 e |= DIO_BV_PUT(&dout, &field_addr, fields);
96420 if (e) {
96421 log_packet_detailed("fields bitvector error detected");
96422 }
96423
96424 if (BV_ISSET(fields, 0)) {
96425 log_packet_detailed(" field 'name' has changed");
96426
96427#ifdef FREECIV_JSON_CONNECTION
96428 field_addr.name = "name";
96429#endif /* FREECIV_JSON_CONNECTION */
96430 e = 0;
96431
96432 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
96433
96434 if (e) {
96435 log_packet_detailed("'name' field error detected");
96436 }
96437 }
96438
96439 if (BV_ISSET(fields, 1)) {
96440 log_packet_detailed(" field 'owner' has changed");
96441
96442#ifdef FREECIV_JSON_CONNECTION
96443 field_addr.name = "owner";
96444#endif /* FREECIV_JSON_CONNECTION */
96445 e = 0;
96446
96447 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
96448
96449 if (e) {
96450 log_packet_detailed("'owner' field error detected");
96451 }
96452 }
96453
96454 if (BV_ISSET(fields, 2)) {
96455 log_packet_detailed(" field 'original' has changed");
96456
96457#ifdef FREECIV_JSON_CONNECTION
96458 field_addr.name = "original";
96459#endif /* FREECIV_JSON_CONNECTION */
96460 e = 0;
96461
96462 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->original);
96463
96464 if (e) {
96465 log_packet_detailed("'original' field error detected");
96466 }
96467 }
96468
96469 if (BV_ISSET(fields, 3)) {
96470 log_packet_detailed(" field 'size' has changed");
96471
96472#ifdef FREECIV_JSON_CONNECTION
96473 field_addr.name = "size";
96474#endif /* FREECIV_JSON_CONNECTION */
96475 e = 0;
96476
96477 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
96478
96479 if (e) {
96480 log_packet_detailed("'size' field error detected");
96481 }
96482 }
96483
96484 if (BV_ISSET(fields, 4)) {
96485 log_packet_detailed(" field 'history' has changed");
96486
96487#ifdef FREECIV_JSON_CONNECTION
96488 field_addr.name = "history";
96489#endif /* FREECIV_JSON_CONNECTION */
96490 e = 0;
96491
96492 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->history);
96493
96494 if (e) {
96495 log_packet_detailed("'history' field error detected");
96496 }
96497 }
96498
96499 if (BV_ISSET(fields, 5)) {
96500 log_packet_detailed(" field 'ppl_happy' has changed");
96501
96502#ifdef FREECIV_JSON_CONNECTION
96503 field_addr.name = "ppl_happy";
96504#endif /* FREECIV_JSON_CONNECTION */
96505 e = 0;
96506
96507 {
96508 int i;
96509
96510#ifdef FREECIV_JSON_CONNECTION
96511 /* Create the array. */
96512 e |= DIO_PUT(farray, &dout, &field_addr, 5);
96513
96514 /* Enter array. */
96515 field_addr.sub_location = plocation_elem_new(0);
96516#endif /* FREECIV_JSON_CONNECTION */
96517
96518 for (i = 0; i < 5; i++) {
96519#ifdef FREECIV_JSON_CONNECTION
96520 /* Next array element. */
96521 field_addr.sub_location->number = i;
96522#endif /* FREECIV_JSON_CONNECTION */
96523
96524 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_happy[i]);
96525 }
96526
96527#ifdef FREECIV_JSON_CONNECTION
96528 /* Exit array. */
96529 FC_FREE(field_addr.sub_location);
96530#endif /* FREECIV_JSON_CONNECTION */
96531 }
96532
96533 if (e) {
96534 log_packet_detailed("'ppl_happy' field error detected");
96535 }
96536 }
96537
96538 if (BV_ISSET(fields, 6)) {
96539 log_packet_detailed(" field 'ppl_content' has changed");
96540
96541#ifdef FREECIV_JSON_CONNECTION
96542 field_addr.name = "ppl_content";
96543#endif /* FREECIV_JSON_CONNECTION */
96544 e = 0;
96545
96546 {
96547 int i;
96548
96549#ifdef FREECIV_JSON_CONNECTION
96550 /* Create the array. */
96551 e |= DIO_PUT(farray, &dout, &field_addr, 5);
96552
96553 /* Enter array. */
96554 field_addr.sub_location = plocation_elem_new(0);
96555#endif /* FREECIV_JSON_CONNECTION */
96556
96557 for (i = 0; i < 5; i++) {
96558#ifdef FREECIV_JSON_CONNECTION
96559 /* Next array element. */
96560 field_addr.sub_location->number = i;
96561#endif /* FREECIV_JSON_CONNECTION */
96562
96563 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_content[i]);
96564 }
96565
96566#ifdef FREECIV_JSON_CONNECTION
96567 /* Exit array. */
96568 FC_FREE(field_addr.sub_location);
96569#endif /* FREECIV_JSON_CONNECTION */
96570 }
96571
96572 if (e) {
96573 log_packet_detailed("'ppl_content' field error detected");
96574 }
96575 }
96576
96577 if (BV_ISSET(fields, 7)) {
96578 log_packet_detailed(" field 'ppl_unhappy' has changed");
96579
96580#ifdef FREECIV_JSON_CONNECTION
96581 field_addr.name = "ppl_unhappy";
96582#endif /* FREECIV_JSON_CONNECTION */
96583 e = 0;
96584
96585 {
96586 int i;
96587
96588#ifdef FREECIV_JSON_CONNECTION
96589 /* Create the array. */
96590 e |= DIO_PUT(farray, &dout, &field_addr, 5);
96591
96592 /* Enter array. */
96593 field_addr.sub_location = plocation_elem_new(0);
96594#endif /* FREECIV_JSON_CONNECTION */
96595
96596 for (i = 0; i < 5; i++) {
96597#ifdef FREECIV_JSON_CONNECTION
96598 /* Next array element. */
96599 field_addr.sub_location->number = i;
96600#endif /* FREECIV_JSON_CONNECTION */
96601
96602 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_unhappy[i]);
96603 }
96604
96605#ifdef FREECIV_JSON_CONNECTION
96606 /* Exit array. */
96607 FC_FREE(field_addr.sub_location);
96608#endif /* FREECIV_JSON_CONNECTION */
96609 }
96610
96611 if (e) {
96612 log_packet_detailed("'ppl_unhappy' field error detected");
96613 }
96614 }
96615
96616 if (BV_ISSET(fields, 8)) {
96617 log_packet_detailed(" field 'ppl_angry' has changed");
96618
96619#ifdef FREECIV_JSON_CONNECTION
96620 field_addr.name = "ppl_angry";
96621#endif /* FREECIV_JSON_CONNECTION */
96622 e = 0;
96623
96624 {
96625 int i;
96626
96627#ifdef FREECIV_JSON_CONNECTION
96628 /* Create the array. */
96629 e |= DIO_PUT(farray, &dout, &field_addr, 5);
96630
96631 /* Enter array. */
96632 field_addr.sub_location = plocation_elem_new(0);
96633#endif /* FREECIV_JSON_CONNECTION */
96634
96635 for (i = 0; i < 5; i++) {
96636#ifdef FREECIV_JSON_CONNECTION
96637 /* Next array element. */
96638 field_addr.sub_location->number = i;
96639#endif /* FREECIV_JSON_CONNECTION */
96640
96641 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_angry[i]);
96642 }
96643
96644#ifdef FREECIV_JSON_CONNECTION
96645 /* Exit array. */
96646 FC_FREE(field_addr.sub_location);
96647#endif /* FREECIV_JSON_CONNECTION */
96648 }
96649
96650 if (e) {
96651 log_packet_detailed("'ppl_angry' field error detected");
96652 }
96653 }
96654
96655 if (BV_ISSET(fields, 9)) {
96656 log_packet_detailed(" field 'specialists_size' has changed");
96657
96658#ifdef FREECIV_JSON_CONNECTION
96659 field_addr.name = "specialists_size";
96660#endif /* FREECIV_JSON_CONNECTION */
96661 e = 0;
96662
96663 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists_size);
96664
96665 if (e) {
96666 log_packet_detailed("'specialists_size' field error detected");
96667 }
96668 }
96669
96670 if (BV_ISSET(fields, 10)) {
96671 log_packet_detailed(" field 'specialists' has changed");
96672
96673#ifdef FREECIV_JSON_CONNECTION
96674 field_addr.name = "specialists";
96675#endif /* FREECIV_JSON_CONNECTION */
96676 e = 0;
96677
96678 {
96679 int i;
96680
96681#ifdef FREECIV_JSON_CONNECTION
96682 /* Create the array. */
96683 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->specialists_size);
96684
96685 /* Enter array. */
96686 field_addr.sub_location = plocation_elem_new(0);
96687#endif /* FREECIV_JSON_CONNECTION */
96688
96689 for (i = 0; i < real_packet->specialists_size; i++) {
96690#ifdef FREECIV_JSON_CONNECTION
96691 /* Next array element. */
96692 field_addr.sub_location->number = i;
96693#endif /* FREECIV_JSON_CONNECTION */
96694
96695 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists[i]);
96696 }
96697
96698#ifdef FREECIV_JSON_CONNECTION
96699 /* Exit array. */
96700 FC_FREE(field_addr.sub_location);
96701#endif /* FREECIV_JSON_CONNECTION */
96702 }
96703
96704 if (e) {
96705 log_packet_detailed("'specialists' field error detected");
96706 }
96707 }
96708
96709 if (BV_ISSET(fields, 11)) {
96710 log_packet_detailed(" field 'food_stock' has changed");
96711
96712#ifdef FREECIV_JSON_CONNECTION
96713 field_addr.name = "food_stock";
96714#endif /* FREECIV_JSON_CONNECTION */
96715 e = 0;
96716
96717 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->food_stock);
96718
96719 if (e) {
96720 log_packet_detailed("'food_stock' field error detected");
96721 }
96722 }
96723
96724 if (BV_ISSET(fields, 12)) {
96725 log_packet_detailed(" field 'shield_stock' has changed");
96726
96727#ifdef FREECIV_JSON_CONNECTION
96728 field_addr.name = "shield_stock";
96729#endif /* FREECIV_JSON_CONNECTION */
96730 e = 0;
96731
96732 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->shield_stock);
96733
96734 if (e) {
96735 log_packet_detailed("'shield_stock' field error detected");
96736 }
96737 }
96738
96739 /* field 13 is folded into the header */
96740
96741 /* field 14 is folded into the header */
96742
96743 /* field 15 is folded into the header */
96744
96745 /* field 16 is folded into the header */
96746
96747 /* field 17 is folded into the header */
96748
96749 /* field 18 is folded into the header */
96750
96751 if (BV_ISSET(fields, 19)) {
96752 log_packet_detailed(" field 'anarchy' has changed");
96753
96754#ifdef FREECIV_JSON_CONNECTION
96755 field_addr.name = "anarchy";
96756#endif /* FREECIV_JSON_CONNECTION */
96757 e = 0;
96758
96759 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->anarchy);
96760
96761 if (e) {
96762 log_packet_detailed("'anarchy' field error detected");
96763 }
96764 }
96765
96766 if (BV_ISSET(fields, 20)) {
96767 log_packet_detailed(" field 'rapture' has changed");
96768
96769#ifdef FREECIV_JSON_CONNECTION
96770 field_addr.name = "rapture";
96771#endif /* FREECIV_JSON_CONNECTION */
96772 e = 0;
96773
96774 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->rapture);
96775
96776 if (e) {
96777 log_packet_detailed("'rapture' field error detected");
96778 }
96779 }
96780
96781 if (BV_ISSET(fields, 21)) {
96782 log_packet_detailed(" field 'steal' has changed");
96783
96784#ifdef FREECIV_JSON_CONNECTION
96785 field_addr.name = "steal";
96786#endif /* FREECIV_JSON_CONNECTION */
96787 e = 0;
96788
96789 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->steal);
96790
96791 if (e) {
96792 log_packet_detailed("'steal' field error detected");
96793 }
96794 }
96795
96796 if (BV_ISSET(fields, 22)) {
96797 log_packet_detailed(" field 'turn_founded' has changed");
96798
96799#ifdef FREECIV_JSON_CONNECTION
96800 field_addr.name = "turn_founded";
96801#endif /* FREECIV_JSON_CONNECTION */
96802 e = 0;
96803
96804 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_founded);
96805
96806 if (e) {
96807 log_packet_detailed("'turn_founded' field error detected");
96808 }
96809 }
96810
96811 if (BV_ISSET(fields, 23)) {
96812 log_packet_detailed(" field 'turn_last_built' has changed");
96813
96814#ifdef FREECIV_JSON_CONNECTION
96815 field_addr.name = "turn_last_built";
96816#endif /* FREECIV_JSON_CONNECTION */
96817 e = 0;
96818
96819 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_last_built);
96820
96821 if (e) {
96822 log_packet_detailed("'turn_last_built' field error detected");
96823 }
96824 }
96825
96826 if (BV_ISSET(fields, 24)) {
96827 log_packet_detailed(" field 'built' has changed");
96828
96829#ifdef FREECIV_JSON_CONNECTION
96830 field_addr.name = "built";
96831#endif /* FREECIV_JSON_CONNECTION */
96832 e = 0;
96833
96834 {
96835 int i;
96836
96837 FC_STATIC_ASSERT(B_LAST <= MAX_UINT16, packet_array_too_long_built);
96838
96839#ifdef FREECIV_JSON_CONNECTION
96840 size_t count_i = 0;
96841
96842 /* Create the array. */
96843 e |= DIO_PUT(farray, &dout, &field_addr, 0);
96844
96845 /* Enter array. */
96846 field_addr.sub_location = plocation_elem_new(0);
96847#endif /* FREECIV_JSON_CONNECTION */
96848
96849 for (i = 0; i < B_LAST; i++) {
96850 differ = (old->built[i] != real_packet->built[i]);
96851
96852 if (!differ) {
96853 continue;
96854 }
96855
96856#ifdef FREECIV_JSON_CONNECTION
96857 /* Append next diff array element. */
96858 field_addr.sub_location->number = -1;
96859
96860 /* Create the diff array element. */
96861 e |= DIO_PUT(object, &dout, &field_addr);
96862
96863 /* Enter diff array element (start at the index address). */
96864 field_addr.sub_location->number = count_i++;
96865 field_addr.sub_location->sub_location = plocation_field_new("index");
96866#endif /* FREECIV_JSON_CONNECTION */
96867
96868 /* Write the index */
96869#if B_LAST <= MAX_UINT8
96870 e |= DIO_PUT(uint8, &dout, &field_addr, i);
96871#else
96872 e |= DIO_PUT(uint16, &dout, &field_addr, i);
96873#endif
96874
96875#ifdef FREECIV_JSON_CONNECTION
96876 /* Content address. */
96877 field_addr.sub_location->sub_location->name = "data";
96878#endif /* FREECIV_JSON_CONNECTION */
96879
96880 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->built[i]);
96881
96882#ifdef FREECIV_JSON_CONNECTION
96883 /* Exit diff array element. */
96884 FC_FREE(field_addr.sub_location->sub_location);
96885#endif /* FREECIV_JSON_CONNECTION */
96886 }
96887
96888#ifdef FREECIV_JSON_CONNECTION
96889 /* Append diff array element. */
96890 field_addr.sub_location->number = -1;
96891
96892 /* Create the terminating diff array element. */
96893 e |= DIO_PUT(object, &dout, &field_addr);
96894
96895 /* Enter diff array element (start at the index address). */
96896 field_addr.sub_location->number = count_i;
96897 field_addr.sub_location->sub_location = plocation_field_new("index");
96898#endif /* FREECIV_JSON_CONNECTION */
96899
96900 /* Write the sentinel value */
96901#if B_LAST <= MAX_UINT8
96902 e |= DIO_PUT(uint8, &dout, &field_addr, B_LAST);
96903#else
96904 e |= DIO_PUT(uint16, &dout, &field_addr, B_LAST);
96905#endif
96906
96907#ifdef FREECIV_JSON_CONNECTION
96908 /* Exit diff array element. */
96909 FC_FREE(field_addr.sub_location->sub_location);
96910 /* Exit array. */
96911 FC_FREE(field_addr.sub_location);
96912#endif /* FREECIV_JSON_CONNECTION */
96913 }
96914
96915 if (e) {
96916 log_packet_detailed("'built' field error detected");
96917 }
96918 }
96919
96920 if (BV_ISSET(fields, 25)) {
96921 log_packet_detailed(" field 'production_kind' has changed");
96922
96923#ifdef FREECIV_JSON_CONNECTION
96924 field_addr.name = "production_kind";
96925#endif /* FREECIV_JSON_CONNECTION */
96926 e = 0;
96927
96928 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_kind);
96929
96930 if (e) {
96931 log_packet_detailed("'production_kind' field error detected");
96932 }
96933 }
96934
96935 if (BV_ISSET(fields, 26)) {
96936 log_packet_detailed(" field 'production_value' has changed");
96937
96938#ifdef FREECIV_JSON_CONNECTION
96939 field_addr.name = "production_value";
96940#endif /* FREECIV_JSON_CONNECTION */
96941 e = 0;
96942
96943 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_value);
96944
96945 if (e) {
96946 log_packet_detailed("'production_value' field error detected");
96947 }
96948 }
96949
96950 if (BV_ISSET(fields, 27)) {
96951 log_packet_detailed(" field 'city_options' has changed");
96952
96953#ifdef FREECIV_JSON_CONNECTION
96954 field_addr.name = "city_options";
96955#endif /* FREECIV_JSON_CONNECTION */
96956 e = 0;
96957
96958 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->city_options);
96959
96960 if (e) {
96961 log_packet_detailed("'city_options' field error detected");
96962 }
96963 }
96964
96965 *old = *real_packet;
96966
96967#else /* FREECIV_DELTA_PROTOCOL */
96968#ifdef FREECIV_JSON_CONNECTION
96969 field_addr.name = "name";
96970#endif /* FREECIV_JSON_CONNECTION */
96971 e = 0;
96972
96973 e |= DIO_PUT(estring, &dout, &field_addr, real_packet->name);
96974
96975 if (e) {
96976 log_packet_detailed("'name' field error detected");
96977 }
96978
96979#ifdef FREECIV_JSON_CONNECTION
96980 field_addr.name = "owner";
96981#endif /* FREECIV_JSON_CONNECTION */
96982 e = 0;
96983
96984 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->owner);
96985
96986 if (e) {
96987 log_packet_detailed("'owner' field error detected");
96988 }
96989
96990#ifdef FREECIV_JSON_CONNECTION
96991 field_addr.name = "original";
96992#endif /* FREECIV_JSON_CONNECTION */
96993 e = 0;
96994
96995 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->original);
96996
96997 if (e) {
96998 log_packet_detailed("'original' field error detected");
96999 }
97000
97001#ifdef FREECIV_JSON_CONNECTION
97002 field_addr.name = "size";
97003#endif /* FREECIV_JSON_CONNECTION */
97004 e = 0;
97005
97006 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
97007
97008 if (e) {
97009 log_packet_detailed("'size' field error detected");
97010 }
97011
97012#ifdef FREECIV_JSON_CONNECTION
97013 field_addr.name = "history";
97014#endif /* FREECIV_JSON_CONNECTION */
97015 e = 0;
97016
97017 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->history);
97018
97019 if (e) {
97020 log_packet_detailed("'history' field error detected");
97021 }
97022
97023#ifdef FREECIV_JSON_CONNECTION
97024 field_addr.name = "ppl_happy";
97025#endif /* FREECIV_JSON_CONNECTION */
97026 e = 0;
97027
97028 {
97029 int i;
97030
97031#ifdef FREECIV_JSON_CONNECTION
97032 /* Create the array. */
97033 e |= DIO_PUT(farray, &dout, &field_addr, 5);
97034
97035 /* Enter array. */
97036 field_addr.sub_location = plocation_elem_new(0);
97037#endif /* FREECIV_JSON_CONNECTION */
97038
97039 for (i = 0; i < 5; i++) {
97040#ifdef FREECIV_JSON_CONNECTION
97041 /* Next array element. */
97042 field_addr.sub_location->number = i;
97043#endif /* FREECIV_JSON_CONNECTION */
97044
97045 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_happy[i]);
97046 }
97047
97048#ifdef FREECIV_JSON_CONNECTION
97049 /* Exit array. */
97050 FC_FREE(field_addr.sub_location);
97051#endif /* FREECIV_JSON_CONNECTION */
97052 }
97053
97054 if (e) {
97055 log_packet_detailed("'ppl_happy' field error detected");
97056 }
97057
97058#ifdef FREECIV_JSON_CONNECTION
97059 field_addr.name = "ppl_content";
97060#endif /* FREECIV_JSON_CONNECTION */
97061 e = 0;
97062
97063 {
97064 int i;
97065
97066#ifdef FREECIV_JSON_CONNECTION
97067 /* Create the array. */
97068 e |= DIO_PUT(farray, &dout, &field_addr, 5);
97069
97070 /* Enter array. */
97071 field_addr.sub_location = plocation_elem_new(0);
97072#endif /* FREECIV_JSON_CONNECTION */
97073
97074 for (i = 0; i < 5; i++) {
97075#ifdef FREECIV_JSON_CONNECTION
97076 /* Next array element. */
97077 field_addr.sub_location->number = i;
97078#endif /* FREECIV_JSON_CONNECTION */
97079
97080 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_content[i]);
97081 }
97082
97083#ifdef FREECIV_JSON_CONNECTION
97084 /* Exit array. */
97085 FC_FREE(field_addr.sub_location);
97086#endif /* FREECIV_JSON_CONNECTION */
97087 }
97088
97089 if (e) {
97090 log_packet_detailed("'ppl_content' field error detected");
97091 }
97092
97093#ifdef FREECIV_JSON_CONNECTION
97094 field_addr.name = "ppl_unhappy";
97095#endif /* FREECIV_JSON_CONNECTION */
97096 e = 0;
97097
97098 {
97099 int i;
97100
97101#ifdef FREECIV_JSON_CONNECTION
97102 /* Create the array. */
97103 e |= DIO_PUT(farray, &dout, &field_addr, 5);
97104
97105 /* Enter array. */
97106 field_addr.sub_location = plocation_elem_new(0);
97107#endif /* FREECIV_JSON_CONNECTION */
97108
97109 for (i = 0; i < 5; i++) {
97110#ifdef FREECIV_JSON_CONNECTION
97111 /* Next array element. */
97112 field_addr.sub_location->number = i;
97113#endif /* FREECIV_JSON_CONNECTION */
97114
97115 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_unhappy[i]);
97116 }
97117
97118#ifdef FREECIV_JSON_CONNECTION
97119 /* Exit array. */
97120 FC_FREE(field_addr.sub_location);
97121#endif /* FREECIV_JSON_CONNECTION */
97122 }
97123
97124 if (e) {
97125 log_packet_detailed("'ppl_unhappy' field error detected");
97126 }
97127
97128#ifdef FREECIV_JSON_CONNECTION
97129 field_addr.name = "ppl_angry";
97130#endif /* FREECIV_JSON_CONNECTION */
97131 e = 0;
97132
97133 {
97134 int i;
97135
97136#ifdef FREECIV_JSON_CONNECTION
97137 /* Create the array. */
97138 e |= DIO_PUT(farray, &dout, &field_addr, 5);
97139
97140 /* Enter array. */
97141 field_addr.sub_location = plocation_elem_new(0);
97142#endif /* FREECIV_JSON_CONNECTION */
97143
97144 for (i = 0; i < 5; i++) {
97145#ifdef FREECIV_JSON_CONNECTION
97146 /* Next array element. */
97147 field_addr.sub_location->number = i;
97148#endif /* FREECIV_JSON_CONNECTION */
97149
97150 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->ppl_angry[i]);
97151 }
97152
97153#ifdef FREECIV_JSON_CONNECTION
97154 /* Exit array. */
97155 FC_FREE(field_addr.sub_location);
97156#endif /* FREECIV_JSON_CONNECTION */
97157 }
97158
97159 if (e) {
97160 log_packet_detailed("'ppl_angry' field error detected");
97161 }
97162
97163#ifdef FREECIV_JSON_CONNECTION
97164 field_addr.name = "specialists_size";
97165#endif /* FREECIV_JSON_CONNECTION */
97166 e = 0;
97167
97168 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists_size);
97169
97170 if (e) {
97171 log_packet_detailed("'specialists_size' field error detected");
97172 }
97173
97174#ifdef FREECIV_JSON_CONNECTION
97175 field_addr.name = "specialists";
97176#endif /* FREECIV_JSON_CONNECTION */
97177 e = 0;
97178
97179 {
97180 int i;
97181
97182#ifdef FREECIV_JSON_CONNECTION
97183 /* Create the array. */
97184 e |= DIO_PUT(farray, &dout, &field_addr, real_packet->specialists_size);
97185
97186 /* Enter array. */
97187 field_addr.sub_location = plocation_elem_new(0);
97188#endif /* FREECIV_JSON_CONNECTION */
97189
97190 for (i = 0; i < real_packet->specialists_size; i++) {
97191#ifdef FREECIV_JSON_CONNECTION
97192 /* Next array element. */
97193 field_addr.sub_location->number = i;
97194#endif /* FREECIV_JSON_CONNECTION */
97195
97196 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->specialists[i]);
97197 }
97198
97199#ifdef FREECIV_JSON_CONNECTION
97200 /* Exit array. */
97201 FC_FREE(field_addr.sub_location);
97202#endif /* FREECIV_JSON_CONNECTION */
97203 }
97204
97205 if (e) {
97206 log_packet_detailed("'specialists' field error detected");
97207 }
97208
97209#ifdef FREECIV_JSON_CONNECTION
97210 field_addr.name = "food_stock";
97211#endif /* FREECIV_JSON_CONNECTION */
97212 e = 0;
97213
97214 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->food_stock);
97215
97216 if (e) {
97217 log_packet_detailed("'food_stock' field error detected");
97218 }
97219
97220#ifdef FREECIV_JSON_CONNECTION
97221 field_addr.name = "shield_stock";
97222#endif /* FREECIV_JSON_CONNECTION */
97223 e = 0;
97224
97225 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->shield_stock);
97226
97227 if (e) {
97228 log_packet_detailed("'shield_stock' field error detected");
97229 }
97230
97231#ifdef FREECIV_JSON_CONNECTION
97232 field_addr.name = "airlift";
97233#endif /* FREECIV_JSON_CONNECTION */
97234 e = 0;
97235
97236 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->airlift);
97237
97238 if (e) {
97239 log_packet_detailed("'airlift' field error detected");
97240 }
97241
97242#ifdef FREECIV_JSON_CONNECTION
97243 field_addr.name = "debug";
97244#endif /* FREECIV_JSON_CONNECTION */
97245 e = 0;
97246
97247 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->debug);
97248
97249 if (e) {
97250 log_packet_detailed("'debug' field error detected");
97251 }
97252
97253#ifdef FREECIV_JSON_CONNECTION
97254 field_addr.name = "did_buy";
97255#endif /* FREECIV_JSON_CONNECTION */
97256 e = 0;
97257
97258 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->did_buy);
97259
97260 if (e) {
97261 log_packet_detailed("'did_buy' field error detected");
97262 }
97263
97264#ifdef FREECIV_JSON_CONNECTION
97265 field_addr.name = "did_sell";
97266#endif /* FREECIV_JSON_CONNECTION */
97267 e = 0;
97268
97269 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->did_sell);
97270
97271 if (e) {
97272 log_packet_detailed("'did_sell' field error detected");
97273 }
97274
97275#ifdef FREECIV_JSON_CONNECTION
97276 field_addr.name = "was_happy";
97277#endif /* FREECIV_JSON_CONNECTION */
97278 e = 0;
97279
97280 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->was_happy);
97281
97282 if (e) {
97283 log_packet_detailed("'was_happy' field error detected");
97284 }
97285
97286#ifdef FREECIV_JSON_CONNECTION
97287 field_addr.name = "had_famine";
97288#endif /* FREECIV_JSON_CONNECTION */
97289 e = 0;
97290
97291 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->had_famine);
97292
97293 if (e) {
97294 log_packet_detailed("'had_famine' field error detected");
97295 }
97296
97297#ifdef FREECIV_JSON_CONNECTION
97298 field_addr.name = "anarchy";
97299#endif /* FREECIV_JSON_CONNECTION */
97300 e = 0;
97301
97302 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->anarchy);
97303
97304 if (e) {
97305 log_packet_detailed("'anarchy' field error detected");
97306 }
97307
97308#ifdef FREECIV_JSON_CONNECTION
97309 field_addr.name = "rapture";
97310#endif /* FREECIV_JSON_CONNECTION */
97311 e = 0;
97312
97313 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->rapture);
97314
97315 if (e) {
97316 log_packet_detailed("'rapture' field error detected");
97317 }
97318
97319#ifdef FREECIV_JSON_CONNECTION
97320 field_addr.name = "steal";
97321#endif /* FREECIV_JSON_CONNECTION */
97322 e = 0;
97323
97324 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->steal);
97325
97326 if (e) {
97327 log_packet_detailed("'steal' field error detected");
97328 }
97329
97330#ifdef FREECIV_JSON_CONNECTION
97331 field_addr.name = "turn_founded";
97332#endif /* FREECIV_JSON_CONNECTION */
97333 e = 0;
97334
97335 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_founded);
97336
97337 if (e) {
97338 log_packet_detailed("'turn_founded' field error detected");
97339 }
97340
97341#ifdef FREECIV_JSON_CONNECTION
97342 field_addr.name = "turn_last_built";
97343#endif /* FREECIV_JSON_CONNECTION */
97344 e = 0;
97345
97346 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->turn_last_built);
97347
97348 if (e) {
97349 log_packet_detailed("'turn_last_built' field error detected");
97350 }
97351
97352#ifdef FREECIV_JSON_CONNECTION
97353 field_addr.name = "built";
97354#endif /* FREECIV_JSON_CONNECTION */
97355 e = 0;
97356
97357 {
97358 int i;
97359
97360#ifdef FREECIV_JSON_CONNECTION
97361 /* Create the array. */
97362 e |= DIO_PUT(farray, &dout, &field_addr, B_LAST);
97363
97364 /* Enter array. */
97365 field_addr.sub_location = plocation_elem_new(0);
97366#endif /* FREECIV_JSON_CONNECTION */
97367
97368 for (i = 0; i < B_LAST; i++) {
97369#ifdef FREECIV_JSON_CONNECTION
97370 /* Next array element. */
97371 field_addr.sub_location->number = i;
97372#endif /* FREECIV_JSON_CONNECTION */
97373
97374 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->built[i]);
97375 }
97376
97377#ifdef FREECIV_JSON_CONNECTION
97378 /* Exit array. */
97379 FC_FREE(field_addr.sub_location);
97380#endif /* FREECIV_JSON_CONNECTION */
97381 }
97382
97383 if (e) {
97384 log_packet_detailed("'built' field error detected");
97385 }
97386
97387#ifdef FREECIV_JSON_CONNECTION
97388 field_addr.name = "production_kind";
97389#endif /* FREECIV_JSON_CONNECTION */
97390 e = 0;
97391
97392 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_kind);
97393
97394 if (e) {
97395 log_packet_detailed("'production_kind' field error detected");
97396 }
97397
97398#ifdef FREECIV_JSON_CONNECTION
97399 field_addr.name = "production_value";
97400#endif /* FREECIV_JSON_CONNECTION */
97401 e = 0;
97402
97403 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->production_value);
97404
97405 if (e) {
97406 log_packet_detailed("'production_value' field error detected");
97407 }
97408
97409#ifdef FREECIV_JSON_CONNECTION
97410 field_addr.name = "city_options";
97411#endif /* FREECIV_JSON_CONNECTION */
97412 e = 0;
97413
97414 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->city_options);
97415
97416 if (e) {
97417 log_packet_detailed("'city_options' field error detected");
97418 }
97419#endif /* FREECIV_DELTA_PROTOCOL */
97420
97421 SEND_PACKET_END(PACKET_EDIT_CITY);
97422}
97423
97424 int send_packet_edit_city(struct connection *pc, const struct packet_edit_city *packet)
97425{
97426 if (!pc->used) {
97427 log_error("WARNING: trying to send data to the closed connection %s",
97428 conn_description(pc));
97429 return -1;
97430 }
97431 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_CITY].packet != nullptr, -1,
97432 "Handler for PACKET_EDIT_CITY not installed");
97433 return pc->phs.handlers->send[PACKET_EDIT_CITY].packet(pc, packet);
97434}
97435
97436 static inline void init_packet_edit_player_create(struct packet_edit_player_create *packet)
97437{
97438 memset(packet, 0, sizeof(*packet));
97439}
97440
97441#define free_packet_edit_player_create(_packet) (void) 0
97442#define destroy_packet_edit_player_create free
97443
97444#ifdef FREECIV_DELTA_PROTOCOL
97445#define hash_packet_edit_player_create_100 hash_const
97446#define cmp_packet_edit_player_create_100 cmp_const
97447 BV_DEFINE(packet_edit_player_create_100_fields, 1);
97448#endif /* FREECIV_DELTA_PROTOCOL */
97449
97450 static struct packet_edit_player_create *receive_packet_edit_player_create_100(struct connection *pc)
97451{
97452#define FREE_PACKET_STRUCT(_packet) free_packet_edit_player_create(_packet)
97453 RECEIVE_PACKET_START(packet_edit_player_create, real_packet);
97454
97455#ifdef FREECIV_JSON_CONNECTION
97456 struct plocation field_addr;
97457 {
97458 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
97459 field_addr = *field_addr_tmp;
97460 FC_FREE(field_addr_tmp);
97461 }
97462#endif /* FREECIV_JSON_CONNECTION */
97463
97464 log_packet_detailed("packet_edit_player_create_100: got info about ()");
97465
97466#ifdef FREECIV_DELTA_PROTOCOL
97467 packet_edit_player_create_100_fields fields;
97468 struct packet_edit_player_create *old;
97469 struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER_CREATE;
97470
97471 if (nullptr == *hash) {
97472 *hash = genhash_new_full(hash_packet_edit_player_create_100, cmp_packet_edit_player_create_100,
97473 nullptr, nullptr, nullptr, destroy_packet_edit_player_create);
97474 }
97475
97476 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
97477 *real_packet = *old;
97478 } else {
97479 /* packet is already initialized empty */
97480 log_packet_detailed(" no old info");
97481 }
97482
97483#ifdef FREECIV_JSON_CONNECTION
97484 field_addr.name = "fields";
97485#endif /* FREECIV_JSON_CONNECTION */
97486 DIO_BV_GET(&din, &field_addr, fields);
97487
97488 if (BV_ISSET(fields, 0)) {
97489 log_packet_detailed(" got field 'tag'");
97490
97491#ifdef FREECIV_JSON_CONNECTION
97492 field_addr.name = "tag";
97493#endif /* FREECIV_JSON_CONNECTION */
97494
97495 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
97496 RECEIVE_PACKET_FIELD_ERROR(tag);
97497 }
97498 }
97499
97500 if (nullptr == old) {
97501 old = fc_malloc(sizeof(*old));
97502 init_packet_edit_player_create(old);
97503 *old = *real_packet;
97504 genhash_insert(*hash, old, old);
97505 } else {
97506 *old = *real_packet;
97507 }
97508
97509#else /* FREECIV_DELTA_PROTOCOL */
97510#ifdef FREECIV_JSON_CONNECTION
97511 field_addr.name = "tag";
97512#endif /* FREECIV_JSON_CONNECTION */
97513
97514 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
97515 RECEIVE_PACKET_FIELD_ERROR(tag);
97516 }
97517#endif /* FREECIV_DELTA_PROTOCOL */
97518
97519 RECEIVE_PACKET_END(real_packet);
97520#undef FREE_PACKET_STRUCT
97521}
97522
97523 static int send_packet_edit_player_create_100(struct connection *pc, const struct packet_edit_player_create *packet)
97524{
97525 const struct packet_edit_player_create *real_packet = packet;
97526 int e;
97527 SEND_PACKET_START(PACKET_EDIT_PLAYER_CREATE);
97528
97529 log_packet_detailed("packet_edit_player_create_100: sending info about ()");
97530
97531#ifdef FREECIV_DELTA_PROTOCOL
97532 packet_edit_player_create_100_fields fields;
97533 struct packet_edit_player_create *old;
97534 bool differ;
97535 struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER_CREATE;
97536
97537 if (nullptr == *hash) {
97538 *hash = genhash_new_full(hash_packet_edit_player_create_100, cmp_packet_edit_player_create_100,
97539 nullptr, nullptr, nullptr, destroy_packet_edit_player_create);
97540 }
97541 BV_CLR_ALL(fields);
97542
97543 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
97544 old = fc_malloc(sizeof(*old));
97545 /* temporary bitcopy just to insert correctly */
97546 *old = *real_packet;
97547 genhash_insert(*hash, old, old);
97548 init_packet_edit_player_create(old);
97549 }
97550
97551 differ = (old->tag != real_packet->tag);
97552 if (differ) {
97553 BV_SET(fields, 0);
97554 }
97555#endif /* FREECIV_DELTA_PROTOCOL */
97556
97557#ifdef FREECIV_JSON_CONNECTION
97558 struct plocation field_addr;
97559 {
97560 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
97561 field_addr = *field_addr_tmp;
97562 FC_FREE(field_addr_tmp);
97563 }
97564#endif /* FREECIV_JSON_CONNECTION */
97565
97566#ifdef FREECIV_DELTA_PROTOCOL
97567#ifdef FREECIV_JSON_CONNECTION
97568 field_addr.name = "fields";
97569#endif /* FREECIV_JSON_CONNECTION */
97570 e = 0;
97571 e |= DIO_BV_PUT(&dout, &field_addr, fields);
97572 if (e) {
97573 log_packet_detailed("fields bitvector error detected");
97574 }
97575
97576 if (BV_ISSET(fields, 0)) {
97577 log_packet_detailed(" field 'tag' has changed");
97578
97579#ifdef FREECIV_JSON_CONNECTION
97580 field_addr.name = "tag";
97581#endif /* FREECIV_JSON_CONNECTION */
97582 e = 0;
97583
97584 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
97585
97586 if (e) {
97587 log_packet_detailed("'tag' field error detected");
97588 }
97589 }
97590
97591 *old = *real_packet;
97592
97593#else /* FREECIV_DELTA_PROTOCOL */
97594#ifdef FREECIV_JSON_CONNECTION
97595 field_addr.name = "tag";
97596#endif /* FREECIV_JSON_CONNECTION */
97597 e = 0;
97598
97599 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
97600
97601 if (e) {
97602 log_packet_detailed("'tag' field error detected");
97603 }
97604#endif /* FREECIV_DELTA_PROTOCOL */
97605
97606 SEND_PACKET_END(PACKET_EDIT_PLAYER_CREATE);
97607}
97608
97609 int send_packet_edit_player_create(struct connection *pc, const struct packet_edit_player_create *packet)
97610{
97611 if (!pc->used) {
97612 log_error("WARNING: trying to send data to the closed connection %s",
97613 conn_description(pc));
97614 return -1;
97615 }
97616 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER_CREATE].packet != nullptr, -1,
97617 "Handler for PACKET_EDIT_PLAYER_CREATE not installed");
97618 return pc->phs.handlers->send[PACKET_EDIT_PLAYER_CREATE].packet(pc, packet);
97619}
97620
97621 int dsend_packet_edit_player_create(struct connection *pc, int tag)
97622{
97623 struct packet_edit_player_create packet, *real_packet = &packet;
97624
97625 real_packet->tag = tag;
97626
97627 return send_packet_edit_player_create(pc, real_packet);
97628}
97629
97630 static inline void init_packet_edit_player_remove(struct packet_edit_player_remove *packet)
97631{
97632 memset(packet, 0, sizeof(*packet));
97633}
97634
97635#define free_packet_edit_player_remove(_packet) (void) 0
97636#define destroy_packet_edit_player_remove free
97637
97638#ifdef FREECIV_DELTA_PROTOCOL
97639#define hash_packet_edit_player_remove_100 hash_const
97640#define cmp_packet_edit_player_remove_100 cmp_const
97641 BV_DEFINE(packet_edit_player_remove_100_fields, 1);
97642#endif /* FREECIV_DELTA_PROTOCOL */
97643
97644 static struct packet_edit_player_remove *receive_packet_edit_player_remove_100(struct connection *pc)
97645{
97646#define FREE_PACKET_STRUCT(_packet) free_packet_edit_player_remove(_packet)
97647 RECEIVE_PACKET_START(packet_edit_player_remove, real_packet);
97648
97649#ifdef FREECIV_JSON_CONNECTION
97650 struct plocation field_addr;
97651 {
97652 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
97653 field_addr = *field_addr_tmp;
97654 FC_FREE(field_addr_tmp);
97655 }
97656#endif /* FREECIV_JSON_CONNECTION */
97657
97658 log_packet_detailed("packet_edit_player_remove_100: got info about ()");
97659
97660#ifdef FREECIV_DELTA_PROTOCOL
97661 packet_edit_player_remove_100_fields fields;
97662 struct packet_edit_player_remove *old;
97663 struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER_REMOVE;
97664
97665 if (nullptr == *hash) {
97666 *hash = genhash_new_full(hash_packet_edit_player_remove_100, cmp_packet_edit_player_remove_100,
97667 nullptr, nullptr, nullptr, destroy_packet_edit_player_remove);
97668 }
97669
97670 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
97671 *real_packet = *old;
97672 } else {
97673 /* packet is already initialized empty */
97674 log_packet_detailed(" no old info");
97675 }
97676
97677#ifdef FREECIV_JSON_CONNECTION
97678 field_addr.name = "fields";
97679#endif /* FREECIV_JSON_CONNECTION */
97680 DIO_BV_GET(&din, &field_addr, fields);
97681
97682 if (BV_ISSET(fields, 0)) {
97683 log_packet_detailed(" got field 'id'");
97684
97685#ifdef FREECIV_JSON_CONNECTION
97686 field_addr.name = "id";
97687#endif /* FREECIV_JSON_CONNECTION */
97688
97689 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->id)) {
97690 RECEIVE_PACKET_FIELD_ERROR(id);
97691 }
97692 }
97693
97694 if (nullptr == old) {
97695 old = fc_malloc(sizeof(*old));
97696 init_packet_edit_player_remove(old);
97697 *old = *real_packet;
97698 genhash_insert(*hash, old, old);
97699 } else {
97700 *old = *real_packet;
97701 }
97702
97703#else /* FREECIV_DELTA_PROTOCOL */
97704#ifdef FREECIV_JSON_CONNECTION
97705 field_addr.name = "id";
97706#endif /* FREECIV_JSON_CONNECTION */
97707
97708 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->id)) {
97709 RECEIVE_PACKET_FIELD_ERROR(id);
97710 }
97711#endif /* FREECIV_DELTA_PROTOCOL */
97712
97713 RECEIVE_PACKET_END(real_packet);
97714#undef FREE_PACKET_STRUCT
97715}
97716
97717 static int send_packet_edit_player_remove_100(struct connection *pc, const struct packet_edit_player_remove *packet)
97718{
97719 const struct packet_edit_player_remove *real_packet = packet;
97720 int e;
97721 SEND_PACKET_START(PACKET_EDIT_PLAYER_REMOVE);
97722
97723 log_packet_detailed("packet_edit_player_remove_100: sending info about ()");
97724
97725#ifdef FREECIV_DELTA_PROTOCOL
97726 packet_edit_player_remove_100_fields fields;
97727 struct packet_edit_player_remove *old;
97728 bool differ;
97729 struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER_REMOVE;
97730
97731 if (nullptr == *hash) {
97732 *hash = genhash_new_full(hash_packet_edit_player_remove_100, cmp_packet_edit_player_remove_100,
97733 nullptr, nullptr, nullptr, destroy_packet_edit_player_remove);
97734 }
97735 BV_CLR_ALL(fields);
97736
97737 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
97738 old = fc_malloc(sizeof(*old));
97739 /* temporary bitcopy just to insert correctly */
97740 *old = *real_packet;
97741 genhash_insert(*hash, old, old);
97742 init_packet_edit_player_remove(old);
97743 }
97744
97745 differ = (old->id != real_packet->id);
97746 if (differ) {
97747 BV_SET(fields, 0);
97748 }
97749#endif /* FREECIV_DELTA_PROTOCOL */
97750
97751#ifdef FREECIV_JSON_CONNECTION
97752 struct plocation field_addr;
97753 {
97754 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
97755 field_addr = *field_addr_tmp;
97756 FC_FREE(field_addr_tmp);
97757 }
97758#endif /* FREECIV_JSON_CONNECTION */
97759
97760#ifdef FREECIV_DELTA_PROTOCOL
97761#ifdef FREECIV_JSON_CONNECTION
97762 field_addr.name = "fields";
97763#endif /* FREECIV_JSON_CONNECTION */
97764 e = 0;
97765 e |= DIO_BV_PUT(&dout, &field_addr, fields);
97766 if (e) {
97767 log_packet_detailed("fields bitvector error detected");
97768 }
97769
97770 if (BV_ISSET(fields, 0)) {
97771 log_packet_detailed(" field 'id' has changed");
97772
97773#ifdef FREECIV_JSON_CONNECTION
97774 field_addr.name = "id";
97775#endif /* FREECIV_JSON_CONNECTION */
97776 e = 0;
97777
97778 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->id);
97779
97780 if (e) {
97781 log_packet_detailed("'id' field error detected");
97782 }
97783 }
97784
97785 *old = *real_packet;
97786
97787#else /* FREECIV_DELTA_PROTOCOL */
97788#ifdef FREECIV_JSON_CONNECTION
97789 field_addr.name = "id";
97790#endif /* FREECIV_JSON_CONNECTION */
97791 e = 0;
97792
97793 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->id);
97794
97795 if (e) {
97796 log_packet_detailed("'id' field error detected");
97797 }
97798#endif /* FREECIV_DELTA_PROTOCOL */
97799
97800 SEND_PACKET_END(PACKET_EDIT_PLAYER_REMOVE);
97801}
97802
97803 int send_packet_edit_player_remove(struct connection *pc, const struct packet_edit_player_remove *packet)
97804{
97805 if (!pc->used) {
97806 log_error("WARNING: trying to send data to the closed connection %s",
97807 conn_description(pc));
97808 return -1;
97809 }
97810 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER_REMOVE].packet != nullptr, -1,
97811 "Handler for PACKET_EDIT_PLAYER_REMOVE not installed");
97812 return pc->phs.handlers->send[PACKET_EDIT_PLAYER_REMOVE].packet(pc, packet);
97813}
97814
97815 int dsend_packet_edit_player_remove(struct connection *pc, int id)
97816{
97817 struct packet_edit_player_remove packet, *real_packet = &packet;
97818
97819 real_packet->id = id;
97820
97821 return send_packet_edit_player_remove(pc, real_packet);
97822}
97823
97824 static inline void init_packet_edit_player(struct packet_edit_player *packet)
97825{
97826 memset(packet, 0, sizeof(*packet));
97827}
97828
97829#define free_packet_edit_player(_packet) (void) 0
97830#define destroy_packet_edit_player free
97831
97832#ifdef FREECIV_DELTA_PROTOCOL
97833static genhash_val_t hash_packet_edit_player_100(const void *vkey)
97834{
97835 const struct packet_edit_player *key = (const struct packet_edit_player *) vkey;
97836 genhash_val_t result = 0;
97837
97838 result += key->id;
97839
97840 result &= 0xFFFFFFFF;
97841 return result;
97842}
97843
97844static bool cmp_packet_edit_player_100(const void *vkey1, const void *vkey2)
97845{
97846 const struct packet_edit_player *old = (const struct packet_edit_player *) vkey1;
97847 const struct packet_edit_player *real_packet = (const struct packet_edit_player *) vkey2;
97848 bool differ;
97849
97850 differ = (old->id != real_packet->id);
97851
97852 return !differ;
97853}
97854 BV_DEFINE(packet_edit_player_100_fields, 25);
97855#endif /* FREECIV_DELTA_PROTOCOL */
97856
97857 static struct packet_edit_player *receive_packet_edit_player_100(struct connection *pc)
97858{
97859#define FREE_PACKET_STRUCT(_packet) free_packet_edit_player(_packet)
97860 RECEIVE_PACKET_START(packet_edit_player, real_packet);
97861
97862#ifdef FREECIV_JSON_CONNECTION
97863 struct plocation field_addr;
97864 {
97865 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
97866 field_addr = *field_addr_tmp;
97867 FC_FREE(field_addr_tmp);
97868 }
97869#endif /* FREECIV_JSON_CONNECTION */
97870
97871#ifdef FREECIV_JSON_CONNECTION
97872 field_addr.name = "id";
97873#endif /* FREECIV_JSON_CONNECTION */
97874
97875 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->id)) {
97876 RECEIVE_PACKET_FIELD_ERROR(id);
97877 }
97878
97879 log_packet_detailed("packet_edit_player_100: got info about (%d)",
97880 real_packet->id);
97881
97882#ifdef FREECIV_DELTA_PROTOCOL
97883 packet_edit_player_100_fields fields;
97884 struct packet_edit_player *old;
97885 struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER;
97886
97887 if (nullptr == *hash) {
97888 *hash = genhash_new_full(hash_packet_edit_player_100, cmp_packet_edit_player_100,
97889 nullptr, nullptr, nullptr, destroy_packet_edit_player);
97890 }
97891
97892 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
97893 *real_packet = *old;
97894 } else {
97895 /* packet is already initialized empty */
97896 log_packet_detailed(" no old info");
97897 }
97898
97899#ifdef FREECIV_JSON_CONNECTION
97900 field_addr.name = "fields";
97901#endif /* FREECIV_JSON_CONNECTION */
97902 DIO_BV_GET(&din, &field_addr, fields);
97903
97904 if (BV_ISSET(fields, 0)) {
97905 log_packet_detailed(" got field 'name'");
97906
97907#ifdef FREECIV_JSON_CONNECTION
97908 field_addr.name = "name";
97909#endif /* FREECIV_JSON_CONNECTION */
97910
97911 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
97912 RECEIVE_PACKET_FIELD_ERROR(name);
97913 }
97914 }
97915
97916 if (BV_ISSET(fields, 1)) {
97917 log_packet_detailed(" got field 'username'");
97918
97919#ifdef FREECIV_JSON_CONNECTION
97920 field_addr.name = "username";
97921#endif /* FREECIV_JSON_CONNECTION */
97922
97923 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
97924 RECEIVE_PACKET_FIELD_ERROR(username);
97925 }
97926 }
97927
97928 if (BV_ISSET(fields, 2)) {
97929 log_packet_detailed(" got field 'ranked_username'");
97930
97931#ifdef FREECIV_JSON_CONNECTION
97932 field_addr.name = "ranked_username";
97933#endif /* FREECIV_JSON_CONNECTION */
97934
97935 if (!DIO_GET(string, &din, &field_addr, real_packet->ranked_username, sizeof(real_packet->ranked_username))) {
97936 RECEIVE_PACKET_FIELD_ERROR(ranked_username);
97937 }
97938 }
97939
97940 if (BV_ISSET(fields, 3)) {
97941 log_packet_detailed(" got field 'user_turns'");
97942
97943#ifdef FREECIV_JSON_CONNECTION
97944 field_addr.name = "user_turns";
97945#endif /* FREECIV_JSON_CONNECTION */
97946
97947 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->user_turns)) {
97948 RECEIVE_PACKET_FIELD_ERROR(user_turns);
97949 }
97950 }
97951
97952 real_packet->is_male = BV_ISSET(fields, 4);
97953
97954 if (BV_ISSET(fields, 5)) {
97955 log_packet_detailed(" got field 'government'");
97956
97957#ifdef FREECIV_JSON_CONNECTION
97958 field_addr.name = "government";
97959#endif /* FREECIV_JSON_CONNECTION */
97960
97961 {
97962 int readin;
97963
97964 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
97965 RECEIVE_PACKET_FIELD_ERROR(government);
97966 }
97967 real_packet->government = readin;
97968 }
97969 }
97970
97971 if (BV_ISSET(fields, 6)) {
97972 log_packet_detailed(" got field 'target_government'");
97973
97974#ifdef FREECIV_JSON_CONNECTION
97975 field_addr.name = "target_government";
97976#endif /* FREECIV_JSON_CONNECTION */
97977
97978 {
97979 int readin;
97980
97981 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
97982 RECEIVE_PACKET_FIELD_ERROR(target_government);
97983 }
97984 real_packet->target_government = readin;
97985 }
97986 }
97987
97988 if (BV_ISSET(fields, 7)) {
97989 log_packet_detailed(" got field 'nation'");
97990
97991#ifdef FREECIV_JSON_CONNECTION
97992 field_addr.name = "nation";
97993#endif /* FREECIV_JSON_CONNECTION */
97994
97995 {
97996 int readin;
97997
97998 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
97999 RECEIVE_PACKET_FIELD_ERROR(nation);
98000 }
98001 real_packet->nation = readin;
98002 }
98003 }
98004
98005 if (BV_ISSET(fields, 8)) {
98006 log_packet_detailed(" got field 'team'");
98007
98008#ifdef FREECIV_JSON_CONNECTION
98009 field_addr.name = "team";
98010#endif /* FREECIV_JSON_CONNECTION */
98011
98012 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->team)) {
98013 RECEIVE_PACKET_FIELD_ERROR(team);
98014 }
98015 }
98016
98017 real_packet->phase_done = BV_ISSET(fields, 9);
98018
98019 if (BV_ISSET(fields, 10)) {
98020 log_packet_detailed(" got field 'nturns_idle'");
98021
98022#ifdef FREECIV_JSON_CONNECTION
98023 field_addr.name = "nturns_idle";
98024#endif /* FREECIV_JSON_CONNECTION */
98025
98026 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nturns_idle)) {
98027 RECEIVE_PACKET_FIELD_ERROR(nturns_idle);
98028 }
98029 }
98030
98031 real_packet->is_alive = BV_ISSET(fields, 11);
98032
98033 if (BV_ISSET(fields, 12)) {
98034 log_packet_detailed(" got field 'revolution_finishes'");
98035
98036#ifdef FREECIV_JSON_CONNECTION
98037 field_addr.name = "revolution_finishes";
98038#endif /* FREECIV_JSON_CONNECTION */
98039
98040 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->revolution_finishes)) {
98041 RECEIVE_PACKET_FIELD_ERROR(revolution_finishes);
98042 }
98043 }
98044
98045 if (BV_ISSET(fields, 13)) {
98046 log_packet_detailed(" got field 'autoselect_weight'");
98047
98048#ifdef FREECIV_JSON_CONNECTION
98049 field_addr.name = "autoselect_weight";
98050#endif /* FREECIV_JSON_CONNECTION */
98051
98052 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->autoselect_weight)) {
98053 RECEIVE_PACKET_FIELD_ERROR(autoselect_weight);
98054 }
98055 }
98056
98057 if (BV_ISSET(fields, 14)) {
98058 log_packet_detailed(" got field 'embassy'");
98059
98060#ifdef FREECIV_JSON_CONNECTION
98061 field_addr.name = "embassy";
98062#endif /* FREECIV_JSON_CONNECTION */
98063
98064 if (!DIO_BV_GET(&din, &field_addr, real_packet->embassy)) {
98065 RECEIVE_PACKET_FIELD_ERROR(embassy);
98066 }
98067 }
98068
98069 if (BV_ISSET(fields, 15)) {
98070 log_packet_detailed(" got field 'gold'");
98071
98072#ifdef FREECIV_JSON_CONNECTION
98073 field_addr.name = "gold";
98074#endif /* FREECIV_JSON_CONNECTION */
98075
98076 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->gold)) {
98077 RECEIVE_PACKET_FIELD_ERROR(gold);
98078 }
98079 }
98080
98081 if (BV_ISSET(fields, 16)) {
98082 log_packet_detailed(" got field 'tax'");
98083
98084#ifdef FREECIV_JSON_CONNECTION
98085 field_addr.name = "tax";
98086#endif /* FREECIV_JSON_CONNECTION */
98087
98088 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tax)) {
98089 RECEIVE_PACKET_FIELD_ERROR(tax);
98090 }
98091 }
98092
98093 if (BV_ISSET(fields, 17)) {
98094 log_packet_detailed(" got field 'science'");
98095
98096#ifdef FREECIV_JSON_CONNECTION
98097 field_addr.name = "science";
98098#endif /* FREECIV_JSON_CONNECTION */
98099
98100 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->science)) {
98101 RECEIVE_PACKET_FIELD_ERROR(science);
98102 }
98103 }
98104
98105 if (BV_ISSET(fields, 18)) {
98106 log_packet_detailed(" got field 'luxury'");
98107
98108#ifdef FREECIV_JSON_CONNECTION
98109 field_addr.name = "luxury";
98110#endif /* FREECIV_JSON_CONNECTION */
98111
98112 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->luxury)) {
98113 RECEIVE_PACKET_FIELD_ERROR(luxury);
98114 }
98115 }
98116
98117 if (BV_ISSET(fields, 19)) {
98118 log_packet_detailed(" got field 'future_tech'");
98119
98120#ifdef FREECIV_JSON_CONNECTION
98121 field_addr.name = "future_tech";
98122#endif /* FREECIV_JSON_CONNECTION */
98123
98124 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->future_tech)) {
98125 RECEIVE_PACKET_FIELD_ERROR(future_tech);
98126 }
98127 }
98128
98129 if (BV_ISSET(fields, 20)) {
98130 log_packet_detailed(" got field 'researching'");
98131
98132#ifdef FREECIV_JSON_CONNECTION
98133 field_addr.name = "researching";
98134#endif /* FREECIV_JSON_CONNECTION */
98135
98136 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->researching)) {
98137 RECEIVE_PACKET_FIELD_ERROR(researching);
98138 }
98139 }
98140
98141 if (BV_ISSET(fields, 21)) {
98142 log_packet_detailed(" got field 'bulbs_researched'");
98143
98144#ifdef FREECIV_JSON_CONNECTION
98145 field_addr.name = "bulbs_researched";
98146#endif /* FREECIV_JSON_CONNECTION */
98147
98148 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->bulbs_researched)) {
98149 RECEIVE_PACKET_FIELD_ERROR(bulbs_researched);
98150 }
98151 }
98152
98153 if (BV_ISSET(fields, 22)) {
98154 log_packet_detailed(" got field 'inventions'");
98155
98156#ifdef FREECIV_JSON_CONNECTION
98157 field_addr.name = "inventions";
98158#endif /* FREECIV_JSON_CONNECTION */
98159
98160 FC_STATIC_ASSERT(A_LAST + 1 <= MAX_UINT16, packet_array_too_long_inventions);
98161#ifdef FREECIV_JSON_CONNECTION
98162 /* Enter array (start at initial element). */
98163 field_addr.sub_location = plocation_elem_new(0);
98164 /* Enter diff array element (start at the index address). */
98165 field_addr.sub_location->sub_location = plocation_field_new("index");
98166#endif /* FREECIV_JSON_CONNECTION */
98167
98168 while (TRUE) {
98169 int i;
98170
98171 /* Read next index */
98172#if A_LAST + 1 <= MAX_UINT8
98173 if (!DIO_GET(uint8, &din, &field_addr, &i)) {
98174#else
98175 if (!DIO_GET(uint16, &din, &field_addr, &i)) {
98176#endif
98177 RECEIVE_PACKET_FIELD_ERROR(inventions);
98178 }
98179
98180 if (i == A_LAST + 1) {
98181 break;
98182 }
98183 if (i > A_LAST + 1) {
98184 RECEIVE_PACKET_FIELD_ERROR(inventions,
98185 ": unexpected index %d "
98186 "> length %d in array diff",
98187 i,
98188 A_LAST + 1);
98189 }
98190
98191#ifdef FREECIV_JSON_CONNECTION
98192 /* Content address. */
98193 field_addr.sub_location->sub_location->name = "data";
98194#endif /* FREECIV_JSON_CONNECTION */
98195
98196 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->inventions[i])) {
98197 RECEIVE_PACKET_FIELD_ERROR(inventions);
98198 }
98199
98200#ifdef FREECIV_JSON_CONNECTION
98201 /* Move to the next diff array element. */
98202 field_addr.sub_location->number++;
98203 /* Back to the index address. */
98204 field_addr.sub_location->sub_location->name = "index";
98205#endif /* FREECIV_JSON_CONNECTION */
98206 }
98207
98208#ifdef FREECIV_JSON_CONNECTION
98209 /* Exit diff array element. */
98210 FC_FREE(field_addr.sub_location->sub_location);
98211 /* Exit array. */
98212 FC_FREE(field_addr.sub_location);
98213#endif /* FREECIV_JSON_CONNECTION */
98214 }
98215
98216 real_packet->ai = BV_ISSET(fields, 23);
98217
98218 real_packet->scenario_reserved = BV_ISSET(fields, 24);
98219
98220 if (nullptr == old) {
98221 old = fc_malloc(sizeof(*old));
98222 init_packet_edit_player(old);
98223 *old = *real_packet;
98224 genhash_insert(*hash, old, old);
98225 } else {
98226 *old = *real_packet;
98227 }
98228
98229#else /* FREECIV_DELTA_PROTOCOL */
98230#ifdef FREECIV_JSON_CONNECTION
98231 field_addr.name = "name";
98232#endif /* FREECIV_JSON_CONNECTION */
98233
98234 if (!DIO_GET(string, &din, &field_addr, real_packet->name, sizeof(real_packet->name))) {
98235 RECEIVE_PACKET_FIELD_ERROR(name);
98236 }
98237
98238#ifdef FREECIV_JSON_CONNECTION
98239 field_addr.name = "username";
98240#endif /* FREECIV_JSON_CONNECTION */
98241
98242 if (!DIO_GET(string, &din, &field_addr, real_packet->username, sizeof(real_packet->username))) {
98243 RECEIVE_PACKET_FIELD_ERROR(username);
98244 }
98245
98246#ifdef FREECIV_JSON_CONNECTION
98247 field_addr.name = "ranked_username";
98248#endif /* FREECIV_JSON_CONNECTION */
98249
98250 if (!DIO_GET(string, &din, &field_addr, real_packet->ranked_username, sizeof(real_packet->ranked_username))) {
98251 RECEIVE_PACKET_FIELD_ERROR(ranked_username);
98252 }
98253
98254#ifdef FREECIV_JSON_CONNECTION
98255 field_addr.name = "user_turns";
98256#endif /* FREECIV_JSON_CONNECTION */
98257
98258 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->user_turns)) {
98259 RECEIVE_PACKET_FIELD_ERROR(user_turns);
98260 }
98261
98262#ifdef FREECIV_JSON_CONNECTION
98263 field_addr.name = "is_male";
98264#endif /* FREECIV_JSON_CONNECTION */
98265
98266 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_male)) {
98267 RECEIVE_PACKET_FIELD_ERROR(is_male);
98268 }
98269
98270#ifdef FREECIV_JSON_CONNECTION
98271 field_addr.name = "government";
98272#endif /* FREECIV_JSON_CONNECTION */
98273
98274 {
98275 int readin;
98276
98277 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
98278 RECEIVE_PACKET_FIELD_ERROR(government);
98279 }
98280 real_packet->government = readin;
98281 }
98282
98283#ifdef FREECIV_JSON_CONNECTION
98284 field_addr.name = "target_government";
98285#endif /* FREECIV_JSON_CONNECTION */
98286
98287 {
98288 int readin;
98289
98290 if (!DIO_GET(sint8, &din, &field_addr, &readin)) {
98291 RECEIVE_PACKET_FIELD_ERROR(target_government);
98292 }
98293 real_packet->target_government = readin;
98294 }
98295
98296#ifdef FREECIV_JSON_CONNECTION
98297 field_addr.name = "nation";
98298#endif /* FREECIV_JSON_CONNECTION */
98299
98300 {
98301 int readin;
98302
98303 if (!DIO_GET(sint16, &din, &field_addr, &readin)) {
98304 RECEIVE_PACKET_FIELD_ERROR(nation);
98305 }
98306 real_packet->nation = readin;
98307 }
98308
98309#ifdef FREECIV_JSON_CONNECTION
98310 field_addr.name = "team";
98311#endif /* FREECIV_JSON_CONNECTION */
98312
98313 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->team)) {
98314 RECEIVE_PACKET_FIELD_ERROR(team);
98315 }
98316
98317#ifdef FREECIV_JSON_CONNECTION
98318 field_addr.name = "phase_done";
98319#endif /* FREECIV_JSON_CONNECTION */
98320
98321 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->phase_done)) {
98322 RECEIVE_PACKET_FIELD_ERROR(phase_done);
98323 }
98324
98325#ifdef FREECIV_JSON_CONNECTION
98326 field_addr.name = "nturns_idle";
98327#endif /* FREECIV_JSON_CONNECTION */
98328
98329 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->nturns_idle)) {
98330 RECEIVE_PACKET_FIELD_ERROR(nturns_idle);
98331 }
98332
98333#ifdef FREECIV_JSON_CONNECTION
98334 field_addr.name = "is_alive";
98335#endif /* FREECIV_JSON_CONNECTION */
98336
98337 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->is_alive)) {
98338 RECEIVE_PACKET_FIELD_ERROR(is_alive);
98339 }
98340
98341#ifdef FREECIV_JSON_CONNECTION
98342 field_addr.name = "revolution_finishes";
98343#endif /* FREECIV_JSON_CONNECTION */
98344
98345 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->revolution_finishes)) {
98346 RECEIVE_PACKET_FIELD_ERROR(revolution_finishes);
98347 }
98348
98349#ifdef FREECIV_JSON_CONNECTION
98350 field_addr.name = "autoselect_weight";
98351#endif /* FREECIV_JSON_CONNECTION */
98352
98353 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->autoselect_weight)) {
98354 RECEIVE_PACKET_FIELD_ERROR(autoselect_weight);
98355 }
98356
98357#ifdef FREECIV_JSON_CONNECTION
98358 field_addr.name = "embassy";
98359#endif /* FREECIV_JSON_CONNECTION */
98360
98361 if (!DIO_BV_GET(&din, &field_addr, real_packet->embassy)) {
98362 RECEIVE_PACKET_FIELD_ERROR(embassy);
98363 }
98364
98365#ifdef FREECIV_JSON_CONNECTION
98366 field_addr.name = "gold";
98367#endif /* FREECIV_JSON_CONNECTION */
98368
98369 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->gold)) {
98370 RECEIVE_PACKET_FIELD_ERROR(gold);
98371 }
98372
98373#ifdef FREECIV_JSON_CONNECTION
98374 field_addr.name = "tax";
98375#endif /* FREECIV_JSON_CONNECTION */
98376
98377 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->tax)) {
98378 RECEIVE_PACKET_FIELD_ERROR(tax);
98379 }
98380
98381#ifdef FREECIV_JSON_CONNECTION
98382 field_addr.name = "science";
98383#endif /* FREECIV_JSON_CONNECTION */
98384
98385 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->science)) {
98386 RECEIVE_PACKET_FIELD_ERROR(science);
98387 }
98388
98389#ifdef FREECIV_JSON_CONNECTION
98390 field_addr.name = "luxury";
98391#endif /* FREECIV_JSON_CONNECTION */
98392
98393 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->luxury)) {
98394 RECEIVE_PACKET_FIELD_ERROR(luxury);
98395 }
98396
98397#ifdef FREECIV_JSON_CONNECTION
98398 field_addr.name = "future_tech";
98399#endif /* FREECIV_JSON_CONNECTION */
98400
98401 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->future_tech)) {
98402 RECEIVE_PACKET_FIELD_ERROR(future_tech);
98403 }
98404
98405#ifdef FREECIV_JSON_CONNECTION
98406 field_addr.name = "researching";
98407#endif /* FREECIV_JSON_CONNECTION */
98408
98409 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->researching)) {
98410 RECEIVE_PACKET_FIELD_ERROR(researching);
98411 }
98412
98413#ifdef FREECIV_JSON_CONNECTION
98414 field_addr.name = "bulbs_researched";
98415#endif /* FREECIV_JSON_CONNECTION */
98416
98417 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->bulbs_researched)) {
98418 RECEIVE_PACKET_FIELD_ERROR(bulbs_researched);
98419 }
98420
98421#ifdef FREECIV_JSON_CONNECTION
98422 field_addr.name = "inventions";
98423#endif /* FREECIV_JSON_CONNECTION */
98424
98425 {
98426 int i;
98427
98428
98429#ifdef FREECIV_JSON_CONNECTION
98430 /* Enter array. */
98431 field_addr.sub_location = plocation_elem_new(0);
98432#endif /* FREECIV_JSON_CONNECTION */
98433
98434 for (i = 0; i < A_LAST + 1; i++) {
98435#ifdef FREECIV_JSON_CONNECTION
98436 /* Next array element */
98437 field_addr.sub_location->number = i;
98438#endif /* FREECIV_JSON_CONNECTION */
98439
98440 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->inventions[i])) {
98441 RECEIVE_PACKET_FIELD_ERROR(inventions);
98442 }
98443 }
98444
98445#ifdef FREECIV_JSON_CONNECTION
98446 /* Exit array. */
98447 FC_FREE(field_addr.sub_location);
98448#endif /* FREECIV_JSON_CONNECTION */
98449 }
98450
98451#ifdef FREECIV_JSON_CONNECTION
98452 field_addr.name = "ai";
98453#endif /* FREECIV_JSON_CONNECTION */
98454
98455 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->ai)) {
98456 RECEIVE_PACKET_FIELD_ERROR(ai);
98457 }
98458
98459#ifdef FREECIV_JSON_CONNECTION
98460 field_addr.name = "scenario_reserved";
98461#endif /* FREECIV_JSON_CONNECTION */
98462
98463 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->scenario_reserved)) {
98464 RECEIVE_PACKET_FIELD_ERROR(scenario_reserved);
98465 }
98466#endif /* FREECIV_DELTA_PROTOCOL */
98467
98468 RECEIVE_PACKET_END(real_packet);
98469#undef FREE_PACKET_STRUCT
98470}
98471
98472 static int send_packet_edit_player_100(struct connection *pc, const struct packet_edit_player *packet)
98473{
98474 const struct packet_edit_player *real_packet = packet;
98475 int e;
98476 SEND_PACKET_START(PACKET_EDIT_PLAYER);
98477
98478 log_packet_detailed("packet_edit_player_100: sending info about (%d)",
98479 real_packet->id);
98480
98481#ifdef FREECIV_DELTA_PROTOCOL
98482 packet_edit_player_100_fields fields;
98483 struct packet_edit_player *old;
98484 bool differ;
98485 struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER;
98486
98487 if (nullptr == *hash) {
98488 *hash = genhash_new_full(hash_packet_edit_player_100, cmp_packet_edit_player_100,
98489 nullptr, nullptr, nullptr, destroy_packet_edit_player);
98490 }
98491 BV_CLR_ALL(fields);
98492
98493 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
98494 old = fc_malloc(sizeof(*old));
98495 /* temporary bitcopy just to insert correctly */
98496 *old = *real_packet;
98497 genhash_insert(*hash, old, old);
98498 init_packet_edit_player(old);
98499 }
98500
98501 differ = (strcmp(old->name, real_packet->name) != 0);
98502 if (differ) {
98503 BV_SET(fields, 0);
98504 }
98505
98506 differ = (strcmp(old->username, real_packet->username) != 0);
98507 if (differ) {
98508 BV_SET(fields, 1);
98509 }
98510
98511 differ = (strcmp(old->ranked_username, real_packet->ranked_username) != 0);
98512 if (differ) {
98513 BV_SET(fields, 2);
98514 }
98515
98516 differ = (old->user_turns != real_packet->user_turns);
98517 if (differ) {
98518 BV_SET(fields, 3);
98519 }
98520
98521 /* folded into head */
98522 if (real_packet->is_male) {
98523 BV_SET(fields, 4);
98524 }
98525
98526 differ = (old->government != real_packet->government);
98527 if (differ) {
98528 BV_SET(fields, 5);
98529 }
98530
98531 differ = (old->target_government != real_packet->target_government);
98532 if (differ) {
98533 BV_SET(fields, 6);
98534 }
98535
98536 differ = (old->nation != real_packet->nation);
98537 if (differ) {
98538 BV_SET(fields, 7);
98539 }
98540
98541 differ = (old->team != real_packet->team);
98542 if (differ) {
98543 BV_SET(fields, 8);
98544 }
98545
98546 /* folded into head */
98547 if (real_packet->phase_done) {
98548 BV_SET(fields, 9);
98549 }
98550
98551 differ = (old->nturns_idle != real_packet->nturns_idle);
98552 if (differ) {
98553 BV_SET(fields, 10);
98554 }
98555
98556 /* folded into head */
98557 if (real_packet->is_alive) {
98558 BV_SET(fields, 11);
98559 }
98560
98561 differ = (old->revolution_finishes != real_packet->revolution_finishes);
98562 if (differ) {
98563 BV_SET(fields, 12);
98564 }
98565
98566 differ = (old->autoselect_weight != real_packet->autoselect_weight);
98567 if (differ) {
98568 BV_SET(fields, 13);
98569 }
98570
98571 differ = !BV_ARE_EQUAL(old->embassy, real_packet->embassy);
98572 if (differ) {
98573 BV_SET(fields, 14);
98574 }
98575
98576 differ = (old->gold != real_packet->gold);
98577 if (differ) {
98578 BV_SET(fields, 15);
98579 }
98580
98581 differ = (old->tax != real_packet->tax);
98582 if (differ) {
98583 BV_SET(fields, 16);
98584 }
98585
98586 differ = (old->science != real_packet->science);
98587 if (differ) {
98588 BV_SET(fields, 17);
98589 }
98590
98591 differ = (old->luxury != real_packet->luxury);
98592 if (differ) {
98593 BV_SET(fields, 18);
98594 }
98595
98596 differ = (old->future_tech != real_packet->future_tech);
98597 if (differ) {
98598 BV_SET(fields, 19);
98599 }
98600
98601 differ = (old->researching != real_packet->researching);
98602 if (differ) {
98603 BV_SET(fields, 20);
98604 }
98605
98606 differ = (old->bulbs_researched != real_packet->bulbs_researched);
98607 if (differ) {
98608 BV_SET(fields, 21);
98609 }
98610
98611 differ = FALSE;
98612 {
98613 int i;
98614
98615 for (i = 0; i < A_LAST + 1; i++) {
98616 differ = (old->inventions[i] != real_packet->inventions[i]);
98617 if (differ) {
98618 break;
98619 }
98620 }
98621 }
98622 if (differ) {
98623 BV_SET(fields, 22);
98624 }
98625
98626 /* folded into head */
98627 if (real_packet->ai) {
98628 BV_SET(fields, 23);
98629 }
98630
98631 /* folded into head */
98632 if (real_packet->scenario_reserved) {
98633 BV_SET(fields, 24);
98634 }
98635#endif /* FREECIV_DELTA_PROTOCOL */
98636
98637#ifdef FREECIV_JSON_CONNECTION
98638 struct plocation field_addr;
98639 {
98640 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
98641 field_addr = *field_addr_tmp;
98642 FC_FREE(field_addr_tmp);
98643 }
98644#endif /* FREECIV_JSON_CONNECTION */
98645
98646#ifdef FREECIV_JSON_CONNECTION
98647 field_addr.name = "id";
98648#endif /* FREECIV_JSON_CONNECTION */
98649 e = 0;
98650
98651 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->id);
98652
98653 if (e) {
98654 log_packet_detailed("'id' field error detected");
98655 }
98656
98657#ifdef FREECIV_DELTA_PROTOCOL
98658#ifdef FREECIV_JSON_CONNECTION
98659 field_addr.name = "fields";
98660#endif /* FREECIV_JSON_CONNECTION */
98661 e = 0;
98662 e |= DIO_BV_PUT(&dout, &field_addr, fields);
98663 if (e) {
98664 log_packet_detailed("fields bitvector error detected");
98665 }
98666
98667 if (BV_ISSET(fields, 0)) {
98668 log_packet_detailed(" field 'name' has changed");
98669
98670#ifdef FREECIV_JSON_CONNECTION
98671 field_addr.name = "name";
98672#endif /* FREECIV_JSON_CONNECTION */
98673 e = 0;
98674
98675 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
98676
98677 if (e) {
98678 log_packet_detailed("'name' field error detected");
98679 }
98680 }
98681
98682 if (BV_ISSET(fields, 1)) {
98683 log_packet_detailed(" field 'username' has changed");
98684
98685#ifdef FREECIV_JSON_CONNECTION
98686 field_addr.name = "username";
98687#endif /* FREECIV_JSON_CONNECTION */
98688 e = 0;
98689
98690 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
98691
98692 if (e) {
98693 log_packet_detailed("'username' field error detected");
98694 }
98695 }
98696
98697 if (BV_ISSET(fields, 2)) {
98698 log_packet_detailed(" field 'ranked_username' has changed");
98699
98700#ifdef FREECIV_JSON_CONNECTION
98701 field_addr.name = "ranked_username";
98702#endif /* FREECIV_JSON_CONNECTION */
98703 e = 0;
98704
98705 e |= DIO_PUT(string, &dout, &field_addr, real_packet->ranked_username);
98706
98707 if (e) {
98708 log_packet_detailed("'ranked_username' field error detected");
98709 }
98710 }
98711
98712 if (BV_ISSET(fields, 3)) {
98713 log_packet_detailed(" field 'user_turns' has changed");
98714
98715#ifdef FREECIV_JSON_CONNECTION
98716 field_addr.name = "user_turns";
98717#endif /* FREECIV_JSON_CONNECTION */
98718 e = 0;
98719
98720 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->user_turns);
98721
98722 if (e) {
98723 log_packet_detailed("'user_turns' field error detected");
98724 }
98725 }
98726
98727 /* field 4 is folded into the header */
98728
98729 if (BV_ISSET(fields, 5)) {
98730 log_packet_detailed(" field 'government' has changed");
98731
98732#ifdef FREECIV_JSON_CONNECTION
98733 field_addr.name = "government";
98734#endif /* FREECIV_JSON_CONNECTION */
98735 e = 0;
98736
98737 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government);
98738
98739 if (e) {
98740 log_packet_detailed("'government' field error detected");
98741 }
98742 }
98743
98744 if (BV_ISSET(fields, 6)) {
98745 log_packet_detailed(" field 'target_government' has changed");
98746
98747#ifdef FREECIV_JSON_CONNECTION
98748 field_addr.name = "target_government";
98749#endif /* FREECIV_JSON_CONNECTION */
98750 e = 0;
98751
98752 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_government);
98753
98754 if (e) {
98755 log_packet_detailed("'target_government' field error detected");
98756 }
98757 }
98758
98759 if (BV_ISSET(fields, 7)) {
98760 log_packet_detailed(" field 'nation' has changed");
98761
98762#ifdef FREECIV_JSON_CONNECTION
98763 field_addr.name = "nation";
98764#endif /* FREECIV_JSON_CONNECTION */
98765 e = 0;
98766
98767 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation);
98768
98769 if (e) {
98770 log_packet_detailed("'nation' field error detected");
98771 }
98772 }
98773
98774 if (BV_ISSET(fields, 8)) {
98775 log_packet_detailed(" field 'team' has changed");
98776
98777#ifdef FREECIV_JSON_CONNECTION
98778 field_addr.name = "team";
98779#endif /* FREECIV_JSON_CONNECTION */
98780 e = 0;
98781
98782 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->team);
98783
98784 if (e) {
98785 log_packet_detailed("'team' field error detected");
98786 }
98787 }
98788
98789 /* field 9 is folded into the header */
98790
98791 if (BV_ISSET(fields, 10)) {
98792 log_packet_detailed(" field 'nturns_idle' has changed");
98793
98794#ifdef FREECIV_JSON_CONNECTION
98795 field_addr.name = "nturns_idle";
98796#endif /* FREECIV_JSON_CONNECTION */
98797 e = 0;
98798
98799 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nturns_idle);
98800
98801 if (e) {
98802 log_packet_detailed("'nturns_idle' field error detected");
98803 }
98804 }
98805
98806 /* field 11 is folded into the header */
98807
98808 if (BV_ISSET(fields, 12)) {
98809 log_packet_detailed(" field 'revolution_finishes' has changed");
98810
98811#ifdef FREECIV_JSON_CONNECTION
98812 field_addr.name = "revolution_finishes";
98813#endif /* FREECIV_JSON_CONNECTION */
98814 e = 0;
98815
98816 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->revolution_finishes);
98817
98818 if (e) {
98819 log_packet_detailed("'revolution_finishes' field error detected");
98820 }
98821 }
98822
98823 if (BV_ISSET(fields, 13)) {
98824 log_packet_detailed(" field 'autoselect_weight' has changed");
98825
98826#ifdef FREECIV_JSON_CONNECTION
98827 field_addr.name = "autoselect_weight";
98828#endif /* FREECIV_JSON_CONNECTION */
98829 e = 0;
98830
98831 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->autoselect_weight);
98832
98833 if (e) {
98834 log_packet_detailed("'autoselect_weight' field error detected");
98835 }
98836 }
98837
98838 if (BV_ISSET(fields, 14)) {
98839 log_packet_detailed(" field 'embassy' has changed");
98840
98841#ifdef FREECIV_JSON_CONNECTION
98842 field_addr.name = "embassy";
98843#endif /* FREECIV_JSON_CONNECTION */
98844 e = 0;
98845
98846 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->embassy);
98847
98848 if (e) {
98849 log_packet_detailed("'embassy' field error detected");
98850 }
98851 }
98852
98853 if (BV_ISSET(fields, 15)) {
98854 log_packet_detailed(" field 'gold' has changed");
98855
98856#ifdef FREECIV_JSON_CONNECTION
98857 field_addr.name = "gold";
98858#endif /* FREECIV_JSON_CONNECTION */
98859 e = 0;
98860
98861 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->gold);
98862
98863 if (e) {
98864 log_packet_detailed("'gold' field error detected");
98865 }
98866 }
98867
98868 if (BV_ISSET(fields, 16)) {
98869 log_packet_detailed(" field 'tax' has changed");
98870
98871#ifdef FREECIV_JSON_CONNECTION
98872 field_addr.name = "tax";
98873#endif /* FREECIV_JSON_CONNECTION */
98874 e = 0;
98875
98876 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tax);
98877
98878 if (e) {
98879 log_packet_detailed("'tax' field error detected");
98880 }
98881 }
98882
98883 if (BV_ISSET(fields, 17)) {
98884 log_packet_detailed(" field 'science' has changed");
98885
98886#ifdef FREECIV_JSON_CONNECTION
98887 field_addr.name = "science";
98888#endif /* FREECIV_JSON_CONNECTION */
98889 e = 0;
98890
98891 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->science);
98892
98893 if (e) {
98894 log_packet_detailed("'science' field error detected");
98895 }
98896 }
98897
98898 if (BV_ISSET(fields, 18)) {
98899 log_packet_detailed(" field 'luxury' has changed");
98900
98901#ifdef FREECIV_JSON_CONNECTION
98902 field_addr.name = "luxury";
98903#endif /* FREECIV_JSON_CONNECTION */
98904 e = 0;
98905
98906 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->luxury);
98907
98908 if (e) {
98909 log_packet_detailed("'luxury' field error detected");
98910 }
98911 }
98912
98913 if (BV_ISSET(fields, 19)) {
98914 log_packet_detailed(" field 'future_tech' has changed");
98915
98916#ifdef FREECIV_JSON_CONNECTION
98917 field_addr.name = "future_tech";
98918#endif /* FREECIV_JSON_CONNECTION */
98919 e = 0;
98920
98921 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->future_tech);
98922
98923 if (e) {
98924 log_packet_detailed("'future_tech' field error detected");
98925 }
98926 }
98927
98928 if (BV_ISSET(fields, 20)) {
98929 log_packet_detailed(" field 'researching' has changed");
98930
98931#ifdef FREECIV_JSON_CONNECTION
98932 field_addr.name = "researching";
98933#endif /* FREECIV_JSON_CONNECTION */
98934 e = 0;
98935
98936 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->researching);
98937
98938 if (e) {
98939 log_packet_detailed("'researching' field error detected");
98940 }
98941 }
98942
98943 if (BV_ISSET(fields, 21)) {
98944 log_packet_detailed(" field 'bulbs_researched' has changed");
98945
98946#ifdef FREECIV_JSON_CONNECTION
98947 field_addr.name = "bulbs_researched";
98948#endif /* FREECIV_JSON_CONNECTION */
98949 e = 0;
98950
98951 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->bulbs_researched);
98952
98953 if (e) {
98954 log_packet_detailed("'bulbs_researched' field error detected");
98955 }
98956 }
98957
98958 if (BV_ISSET(fields, 22)) {
98959 log_packet_detailed(" field 'inventions' has changed");
98960
98961#ifdef FREECIV_JSON_CONNECTION
98962 field_addr.name = "inventions";
98963#endif /* FREECIV_JSON_CONNECTION */
98964 e = 0;
98965
98966 {
98967 int i;
98968
98969 FC_STATIC_ASSERT(A_LAST + 1 <= MAX_UINT16, packet_array_too_long_inventions);
98970
98971#ifdef FREECIV_JSON_CONNECTION
98972 size_t count_i = 0;
98973
98974 /* Create the array. */
98975 e |= DIO_PUT(farray, &dout, &field_addr, 0);
98976
98977 /* Enter array. */
98978 field_addr.sub_location = plocation_elem_new(0);
98979#endif /* FREECIV_JSON_CONNECTION */
98980
98981 for (i = 0; i < A_LAST + 1; i++) {
98982 differ = (old->inventions[i] != real_packet->inventions[i]);
98983
98984 if (!differ) {
98985 continue;
98986 }
98987
98988#ifdef FREECIV_JSON_CONNECTION
98989 /* Append next diff array element. */
98990 field_addr.sub_location->number = -1;
98991
98992 /* Create the diff array element. */
98993 e |= DIO_PUT(object, &dout, &field_addr);
98994
98995 /* Enter diff array element (start at the index address). */
98996 field_addr.sub_location->number = count_i++;
98997 field_addr.sub_location->sub_location = plocation_field_new("index");
98998#endif /* FREECIV_JSON_CONNECTION */
98999
99000 /* Write the index */
99001#if A_LAST + 1 <= MAX_UINT8
99002 e |= DIO_PUT(uint8, &dout, &field_addr, i);
99003#else
99004 e |= DIO_PUT(uint16, &dout, &field_addr, i);
99005#endif
99006
99007#ifdef FREECIV_JSON_CONNECTION
99008 /* Content address. */
99009 field_addr.sub_location->sub_location->name = "data";
99010#endif /* FREECIV_JSON_CONNECTION */
99011
99012 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->inventions[i]);
99013
99014#ifdef FREECIV_JSON_CONNECTION
99015 /* Exit diff array element. */
99016 FC_FREE(field_addr.sub_location->sub_location);
99017#endif /* FREECIV_JSON_CONNECTION */
99018 }
99019
99020#ifdef FREECIV_JSON_CONNECTION
99021 /* Append diff array element. */
99022 field_addr.sub_location->number = -1;
99023
99024 /* Create the terminating diff array element. */
99025 e |= DIO_PUT(object, &dout, &field_addr);
99026
99027 /* Enter diff array element (start at the index address). */
99028 field_addr.sub_location->number = count_i;
99029 field_addr.sub_location->sub_location = plocation_field_new("index");
99030#endif /* FREECIV_JSON_CONNECTION */
99031
99032 /* Write the sentinel value */
99033#if A_LAST + 1 <= MAX_UINT8
99034 e |= DIO_PUT(uint8, &dout, &field_addr, A_LAST + 1);
99035#else
99036 e |= DIO_PUT(uint16, &dout, &field_addr, A_LAST + 1);
99037#endif
99038
99039#ifdef FREECIV_JSON_CONNECTION
99040 /* Exit diff array element. */
99041 FC_FREE(field_addr.sub_location->sub_location);
99042 /* Exit array. */
99043 FC_FREE(field_addr.sub_location);
99044#endif /* FREECIV_JSON_CONNECTION */
99045 }
99046
99047 if (e) {
99048 log_packet_detailed("'inventions' field error detected");
99049 }
99050 }
99051
99052 /* field 23 is folded into the header */
99053
99054 /* field 24 is folded into the header */
99055
99056 *old = *real_packet;
99057
99058#else /* FREECIV_DELTA_PROTOCOL */
99059#ifdef FREECIV_JSON_CONNECTION
99060 field_addr.name = "name";
99061#endif /* FREECIV_JSON_CONNECTION */
99062 e = 0;
99063
99064 e |= DIO_PUT(string, &dout, &field_addr, real_packet->name);
99065
99066 if (e) {
99067 log_packet_detailed("'name' field error detected");
99068 }
99069
99070#ifdef FREECIV_JSON_CONNECTION
99071 field_addr.name = "username";
99072#endif /* FREECIV_JSON_CONNECTION */
99073 e = 0;
99074
99075 e |= DIO_PUT(string, &dout, &field_addr, real_packet->username);
99076
99077 if (e) {
99078 log_packet_detailed("'username' field error detected");
99079 }
99080
99081#ifdef FREECIV_JSON_CONNECTION
99082 field_addr.name = "ranked_username";
99083#endif /* FREECIV_JSON_CONNECTION */
99084 e = 0;
99085
99086 e |= DIO_PUT(string, &dout, &field_addr, real_packet->ranked_username);
99087
99088 if (e) {
99089 log_packet_detailed("'ranked_username' field error detected");
99090 }
99091
99092#ifdef FREECIV_JSON_CONNECTION
99093 field_addr.name = "user_turns";
99094#endif /* FREECIV_JSON_CONNECTION */
99095 e = 0;
99096
99097 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->user_turns);
99098
99099 if (e) {
99100 log_packet_detailed("'user_turns' field error detected");
99101 }
99102
99103#ifdef FREECIV_JSON_CONNECTION
99104 field_addr.name = "is_male";
99105#endif /* FREECIV_JSON_CONNECTION */
99106 e = 0;
99107
99108 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_male);
99109
99110 if (e) {
99111 log_packet_detailed("'is_male' field error detected");
99112 }
99113
99114#ifdef FREECIV_JSON_CONNECTION
99115 field_addr.name = "government";
99116#endif /* FREECIV_JSON_CONNECTION */
99117 e = 0;
99118
99119 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->government);
99120
99121 if (e) {
99122 log_packet_detailed("'government' field error detected");
99123 }
99124
99125#ifdef FREECIV_JSON_CONNECTION
99126 field_addr.name = "target_government";
99127#endif /* FREECIV_JSON_CONNECTION */
99128 e = 0;
99129
99130 e |= DIO_PUT(sint8, &dout, &field_addr, real_packet->target_government);
99131
99132 if (e) {
99133 log_packet_detailed("'target_government' field error detected");
99134 }
99135
99136#ifdef FREECIV_JSON_CONNECTION
99137 field_addr.name = "nation";
99138#endif /* FREECIV_JSON_CONNECTION */
99139 e = 0;
99140
99141 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nation);
99142
99143 if (e) {
99144 log_packet_detailed("'nation' field error detected");
99145 }
99146
99147#ifdef FREECIV_JSON_CONNECTION
99148 field_addr.name = "team";
99149#endif /* FREECIV_JSON_CONNECTION */
99150 e = 0;
99151
99152 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->team);
99153
99154 if (e) {
99155 log_packet_detailed("'team' field error detected");
99156 }
99157
99158#ifdef FREECIV_JSON_CONNECTION
99159 field_addr.name = "phase_done";
99160#endif /* FREECIV_JSON_CONNECTION */
99161 e = 0;
99162
99163 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->phase_done);
99164
99165 if (e) {
99166 log_packet_detailed("'phase_done' field error detected");
99167 }
99168
99169#ifdef FREECIV_JSON_CONNECTION
99170 field_addr.name = "nturns_idle";
99171#endif /* FREECIV_JSON_CONNECTION */
99172 e = 0;
99173
99174 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->nturns_idle);
99175
99176 if (e) {
99177 log_packet_detailed("'nturns_idle' field error detected");
99178 }
99179
99180#ifdef FREECIV_JSON_CONNECTION
99181 field_addr.name = "is_alive";
99182#endif /* FREECIV_JSON_CONNECTION */
99183 e = 0;
99184
99185 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->is_alive);
99186
99187 if (e) {
99188 log_packet_detailed("'is_alive' field error detected");
99189 }
99190
99191#ifdef FREECIV_JSON_CONNECTION
99192 field_addr.name = "revolution_finishes";
99193#endif /* FREECIV_JSON_CONNECTION */
99194 e = 0;
99195
99196 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->revolution_finishes);
99197
99198 if (e) {
99199 log_packet_detailed("'revolution_finishes' field error detected");
99200 }
99201
99202#ifdef FREECIV_JSON_CONNECTION
99203 field_addr.name = "autoselect_weight";
99204#endif /* FREECIV_JSON_CONNECTION */
99205 e = 0;
99206
99207 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->autoselect_weight);
99208
99209 if (e) {
99210 log_packet_detailed("'autoselect_weight' field error detected");
99211 }
99212
99213#ifdef FREECIV_JSON_CONNECTION
99214 field_addr.name = "embassy";
99215#endif /* FREECIV_JSON_CONNECTION */
99216 e = 0;
99217
99218 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->embassy);
99219
99220 if (e) {
99221 log_packet_detailed("'embassy' field error detected");
99222 }
99223
99224#ifdef FREECIV_JSON_CONNECTION
99225 field_addr.name = "gold";
99226#endif /* FREECIV_JSON_CONNECTION */
99227 e = 0;
99228
99229 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->gold);
99230
99231 if (e) {
99232 log_packet_detailed("'gold' field error detected");
99233 }
99234
99235#ifdef FREECIV_JSON_CONNECTION
99236 field_addr.name = "tax";
99237#endif /* FREECIV_JSON_CONNECTION */
99238 e = 0;
99239
99240 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->tax);
99241
99242 if (e) {
99243 log_packet_detailed("'tax' field error detected");
99244 }
99245
99246#ifdef FREECIV_JSON_CONNECTION
99247 field_addr.name = "science";
99248#endif /* FREECIV_JSON_CONNECTION */
99249 e = 0;
99250
99251 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->science);
99252
99253 if (e) {
99254 log_packet_detailed("'science' field error detected");
99255 }
99256
99257#ifdef FREECIV_JSON_CONNECTION
99258 field_addr.name = "luxury";
99259#endif /* FREECIV_JSON_CONNECTION */
99260 e = 0;
99261
99262 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->luxury);
99263
99264 if (e) {
99265 log_packet_detailed("'luxury' field error detected");
99266 }
99267
99268#ifdef FREECIV_JSON_CONNECTION
99269 field_addr.name = "future_tech";
99270#endif /* FREECIV_JSON_CONNECTION */
99271 e = 0;
99272
99273 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->future_tech);
99274
99275 if (e) {
99276 log_packet_detailed("'future_tech' field error detected");
99277 }
99278
99279#ifdef FREECIV_JSON_CONNECTION
99280 field_addr.name = "researching";
99281#endif /* FREECIV_JSON_CONNECTION */
99282 e = 0;
99283
99284 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->researching);
99285
99286 if (e) {
99287 log_packet_detailed("'researching' field error detected");
99288 }
99289
99290#ifdef FREECIV_JSON_CONNECTION
99291 field_addr.name = "bulbs_researched";
99292#endif /* FREECIV_JSON_CONNECTION */
99293 e = 0;
99294
99295 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->bulbs_researched);
99296
99297 if (e) {
99298 log_packet_detailed("'bulbs_researched' field error detected");
99299 }
99300
99301#ifdef FREECIV_JSON_CONNECTION
99302 field_addr.name = "inventions";
99303#endif /* FREECIV_JSON_CONNECTION */
99304 e = 0;
99305
99306 {
99307 int i;
99308
99309#ifdef FREECIV_JSON_CONNECTION
99310 /* Create the array. */
99311 e |= DIO_PUT(farray, &dout, &field_addr, A_LAST + 1);
99312
99313 /* Enter array. */
99314 field_addr.sub_location = plocation_elem_new(0);
99315#endif /* FREECIV_JSON_CONNECTION */
99316
99317 for (i = 0; i < A_LAST + 1; i++) {
99318#ifdef FREECIV_JSON_CONNECTION
99319 /* Next array element. */
99320 field_addr.sub_location->number = i;
99321#endif /* FREECIV_JSON_CONNECTION */
99322
99323 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->inventions[i]);
99324 }
99325
99326#ifdef FREECIV_JSON_CONNECTION
99327 /* Exit array. */
99328 FC_FREE(field_addr.sub_location);
99329#endif /* FREECIV_JSON_CONNECTION */
99330 }
99331
99332 if (e) {
99333 log_packet_detailed("'inventions' field error detected");
99334 }
99335
99336#ifdef FREECIV_JSON_CONNECTION
99337 field_addr.name = "ai";
99338#endif /* FREECIV_JSON_CONNECTION */
99339 e = 0;
99340
99341 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->ai);
99342
99343 if (e) {
99344 log_packet_detailed("'ai' field error detected");
99345 }
99346
99347#ifdef FREECIV_JSON_CONNECTION
99348 field_addr.name = "scenario_reserved";
99349#endif /* FREECIV_JSON_CONNECTION */
99350 e = 0;
99351
99352 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->scenario_reserved);
99353
99354 if (e) {
99355 log_packet_detailed("'scenario_reserved' field error detected");
99356 }
99357#endif /* FREECIV_DELTA_PROTOCOL */
99358
99359 SEND_PACKET_END(PACKET_EDIT_PLAYER);
99360}
99361
99362 int send_packet_edit_player(struct connection *pc, const struct packet_edit_player *packet)
99363{
99364 if (!pc->used) {
99365 log_error("WARNING: trying to send data to the closed connection %s",
99366 conn_description(pc));
99367 return -1;
99368 }
99369 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER].packet != nullptr, -1,
99370 "Handler for PACKET_EDIT_PLAYER not installed");
99371 return pc->phs.handlers->send[PACKET_EDIT_PLAYER].packet(pc, packet);
99372}
99373
99374 void lsend_packet_edit_player(struct conn_list *dest, const struct packet_edit_player *packet)
99375{
99376 conn_list_iterate(dest, pconn) {
99377 send_packet_edit_player(pconn, packet);
99378 } conn_list_iterate_end;
99379}
99380
99381 static inline void init_packet_edit_player_vision(struct packet_edit_player_vision *packet)
99382{
99383 memset(packet, 0, sizeof(*packet));
99384}
99385
99386#define free_packet_edit_player_vision(_packet) (void) 0
99387#define destroy_packet_edit_player_vision free
99388
99389#ifdef FREECIV_DELTA_PROTOCOL
99390#define hash_packet_edit_player_vision_100 hash_const
99391#define cmp_packet_edit_player_vision_100 cmp_const
99392 BV_DEFINE(packet_edit_player_vision_100_fields, 4);
99393#endif /* FREECIV_DELTA_PROTOCOL */
99394
99395 static struct packet_edit_player_vision *receive_packet_edit_player_vision_100(struct connection *pc)
99396{
99397#define FREE_PACKET_STRUCT(_packet) free_packet_edit_player_vision(_packet)
99398 RECEIVE_PACKET_START(packet_edit_player_vision, real_packet);
99399
99400#ifdef FREECIV_JSON_CONNECTION
99401 struct plocation field_addr;
99402 {
99403 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
99404 field_addr = *field_addr_tmp;
99405 FC_FREE(field_addr_tmp);
99406 }
99407#endif /* FREECIV_JSON_CONNECTION */
99408
99409 log_packet_detailed("packet_edit_player_vision_100: got info about ()");
99410
99411#ifdef FREECIV_DELTA_PROTOCOL
99412 packet_edit_player_vision_100_fields fields;
99413 struct packet_edit_player_vision *old;
99414 struct genhash **hash = pc->phs.received + PACKET_EDIT_PLAYER_VISION;
99415
99416 if (nullptr == *hash) {
99417 *hash = genhash_new_full(hash_packet_edit_player_vision_100, cmp_packet_edit_player_vision_100,
99418 nullptr, nullptr, nullptr, destroy_packet_edit_player_vision);
99419 }
99420
99421 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
99422 *real_packet = *old;
99423 } else {
99424 /* packet is already initialized empty */
99425 log_packet_detailed(" no old info");
99426 }
99427
99428#ifdef FREECIV_JSON_CONNECTION
99429 field_addr.name = "fields";
99430#endif /* FREECIV_JSON_CONNECTION */
99431 DIO_BV_GET(&din, &field_addr, fields);
99432
99433 if (BV_ISSET(fields, 0)) {
99434 log_packet_detailed(" got field 'player'");
99435
99436#ifdef FREECIV_JSON_CONNECTION
99437 field_addr.name = "player";
99438#endif /* FREECIV_JSON_CONNECTION */
99439
99440 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player)) {
99441 RECEIVE_PACKET_FIELD_ERROR(player);
99442 }
99443 }
99444
99445 if (BV_ISSET(fields, 1)) {
99446 log_packet_detailed(" got field 'tile'");
99447
99448#ifdef FREECIV_JSON_CONNECTION
99449 field_addr.name = "tile";
99450#endif /* FREECIV_JSON_CONNECTION */
99451
99452 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
99453 RECEIVE_PACKET_FIELD_ERROR(tile);
99454 }
99455 }
99456
99457 real_packet->known = BV_ISSET(fields, 2);
99458
99459 if (BV_ISSET(fields, 3)) {
99460 log_packet_detailed(" got field 'size'");
99461
99462#ifdef FREECIV_JSON_CONNECTION
99463 field_addr.name = "size";
99464#endif /* FREECIV_JSON_CONNECTION */
99465
99466 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
99467 RECEIVE_PACKET_FIELD_ERROR(size);
99468 }
99469 }
99470
99471 if (nullptr == old) {
99472 old = fc_malloc(sizeof(*old));
99473 init_packet_edit_player_vision(old);
99474 *old = *real_packet;
99475 genhash_insert(*hash, old, old);
99476 } else {
99477 *old = *real_packet;
99478 }
99479
99480#else /* FREECIV_DELTA_PROTOCOL */
99481#ifdef FREECIV_JSON_CONNECTION
99482 field_addr.name = "player";
99483#endif /* FREECIV_JSON_CONNECTION */
99484
99485 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->player)) {
99486 RECEIVE_PACKET_FIELD_ERROR(player);
99487 }
99488
99489#ifdef FREECIV_JSON_CONNECTION
99490 field_addr.name = "tile";
99491#endif /* FREECIV_JSON_CONNECTION */
99492
99493 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tile)) {
99494 RECEIVE_PACKET_FIELD_ERROR(tile);
99495 }
99496
99497#ifdef FREECIV_JSON_CONNECTION
99498 field_addr.name = "known";
99499#endif /* FREECIV_JSON_CONNECTION */
99500
99501 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->known)) {
99502 RECEIVE_PACKET_FIELD_ERROR(known);
99503 }
99504
99505#ifdef FREECIV_JSON_CONNECTION
99506 field_addr.name = "size";
99507#endif /* FREECIV_JSON_CONNECTION */
99508
99509 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->size)) {
99510 RECEIVE_PACKET_FIELD_ERROR(size);
99511 }
99512#endif /* FREECIV_DELTA_PROTOCOL */
99513
99514 RECEIVE_PACKET_END(real_packet);
99515#undef FREE_PACKET_STRUCT
99516}
99517
99518 static int send_packet_edit_player_vision_100(struct connection *pc, const struct packet_edit_player_vision *packet)
99519{
99520 const struct packet_edit_player_vision *real_packet = packet;
99521 int e;
99522 SEND_PACKET_START(PACKET_EDIT_PLAYER_VISION);
99523
99524 log_packet_detailed("packet_edit_player_vision_100: sending info about ()");
99525
99526#ifdef FREECIV_DELTA_PROTOCOL
99527 packet_edit_player_vision_100_fields fields;
99528 struct packet_edit_player_vision *old;
99529 bool differ;
99530 struct genhash **hash = pc->phs.sent + PACKET_EDIT_PLAYER_VISION;
99531
99532 if (nullptr == *hash) {
99533 *hash = genhash_new_full(hash_packet_edit_player_vision_100, cmp_packet_edit_player_vision_100,
99534 nullptr, nullptr, nullptr, destroy_packet_edit_player_vision);
99535 }
99536 BV_CLR_ALL(fields);
99537
99538 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
99539 old = fc_malloc(sizeof(*old));
99540 /* temporary bitcopy just to insert correctly */
99541 *old = *real_packet;
99542 genhash_insert(*hash, old, old);
99543 init_packet_edit_player_vision(old);
99544 }
99545
99546 differ = (old->player != real_packet->player);
99547 if (differ) {
99548 BV_SET(fields, 0);
99549 }
99550
99551 differ = (old->tile != real_packet->tile);
99552 if (differ) {
99553 BV_SET(fields, 1);
99554 }
99555
99556 /* folded into head */
99557 if (real_packet->known) {
99558 BV_SET(fields, 2);
99559 }
99560
99561 differ = (old->size != real_packet->size);
99562 if (differ) {
99563 BV_SET(fields, 3);
99564 }
99565#endif /* FREECIV_DELTA_PROTOCOL */
99566
99567#ifdef FREECIV_JSON_CONNECTION
99568 struct plocation field_addr;
99569 {
99570 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
99571 field_addr = *field_addr_tmp;
99572 FC_FREE(field_addr_tmp);
99573 }
99574#endif /* FREECIV_JSON_CONNECTION */
99575
99576#ifdef FREECIV_DELTA_PROTOCOL
99577#ifdef FREECIV_JSON_CONNECTION
99578 field_addr.name = "fields";
99579#endif /* FREECIV_JSON_CONNECTION */
99580 e = 0;
99581 e |= DIO_BV_PUT(&dout, &field_addr, fields);
99582 if (e) {
99583 log_packet_detailed("fields bitvector error detected");
99584 }
99585
99586 if (BV_ISSET(fields, 0)) {
99587 log_packet_detailed(" field 'player' has changed");
99588
99589#ifdef FREECIV_JSON_CONNECTION
99590 field_addr.name = "player";
99591#endif /* FREECIV_JSON_CONNECTION */
99592 e = 0;
99593
99594 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player);
99595
99596 if (e) {
99597 log_packet_detailed("'player' field error detected");
99598 }
99599 }
99600
99601 if (BV_ISSET(fields, 1)) {
99602 log_packet_detailed(" field 'tile' has changed");
99603
99604#ifdef FREECIV_JSON_CONNECTION
99605 field_addr.name = "tile";
99606#endif /* FREECIV_JSON_CONNECTION */
99607 e = 0;
99608
99609 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
99610
99611 if (e) {
99612 log_packet_detailed("'tile' field error detected");
99613 }
99614 }
99615
99616 /* field 2 is folded into the header */
99617
99618 if (BV_ISSET(fields, 3)) {
99619 log_packet_detailed(" field 'size' has changed");
99620
99621#ifdef FREECIV_JSON_CONNECTION
99622 field_addr.name = "size";
99623#endif /* FREECIV_JSON_CONNECTION */
99624 e = 0;
99625
99626 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
99627
99628 if (e) {
99629 log_packet_detailed("'size' field error detected");
99630 }
99631 }
99632
99633 *old = *real_packet;
99634
99635#else /* FREECIV_DELTA_PROTOCOL */
99636#ifdef FREECIV_JSON_CONNECTION
99637 field_addr.name = "player";
99638#endif /* FREECIV_JSON_CONNECTION */
99639 e = 0;
99640
99641 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->player);
99642
99643 if (e) {
99644 log_packet_detailed("'player' field error detected");
99645 }
99646
99647#ifdef FREECIV_JSON_CONNECTION
99648 field_addr.name = "tile";
99649#endif /* FREECIV_JSON_CONNECTION */
99650 e = 0;
99651
99652 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tile);
99653
99654 if (e) {
99655 log_packet_detailed("'tile' field error detected");
99656 }
99657
99658#ifdef FREECIV_JSON_CONNECTION
99659 field_addr.name = "known";
99660#endif /* FREECIV_JSON_CONNECTION */
99661 e = 0;
99662
99663 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->known);
99664
99665 if (e) {
99666 log_packet_detailed("'known' field error detected");
99667 }
99668
99669#ifdef FREECIV_JSON_CONNECTION
99670 field_addr.name = "size";
99671#endif /* FREECIV_JSON_CONNECTION */
99672 e = 0;
99673
99674 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->size);
99675
99676 if (e) {
99677 log_packet_detailed("'size' field error detected");
99678 }
99679#endif /* FREECIV_DELTA_PROTOCOL */
99680
99681 SEND_PACKET_END(PACKET_EDIT_PLAYER_VISION);
99682}
99683
99684 int send_packet_edit_player_vision(struct connection *pc, const struct packet_edit_player_vision *packet)
99685{
99686 if (!pc->used) {
99687 log_error("WARNING: trying to send data to the closed connection %s",
99688 conn_description(pc));
99689 return -1;
99690 }
99691 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_PLAYER_VISION].packet != nullptr, -1,
99692 "Handler for PACKET_EDIT_PLAYER_VISION not installed");
99693 return pc->phs.handlers->send[PACKET_EDIT_PLAYER_VISION].packet(pc, packet);
99694}
99695
99696 int dsend_packet_edit_player_vision(struct connection *pc, int player, int tile, bool known, int size)
99697{
99698 struct packet_edit_player_vision packet, *real_packet = &packet;
99699
99700 real_packet->player = player;
99701 real_packet->tile = tile;
99702 real_packet->known = known;
99703 real_packet->size = size;
99704
99705 return send_packet_edit_player_vision(pc, real_packet);
99706}
99707
99708 static inline void init_packet_edit_game(struct packet_edit_game *packet)
99709{
99710 memset(packet, 0, sizeof(*packet));
99711}
99712
99713#define free_packet_edit_game(_packet) (void) 0
99714#define destroy_packet_edit_game free
99715
99716#ifdef FREECIV_DELTA_PROTOCOL
99717#define hash_packet_edit_game_100 hash_const
99718#define cmp_packet_edit_game_100 cmp_const
99719 BV_DEFINE(packet_edit_game_100_fields, 9);
99720#endif /* FREECIV_DELTA_PROTOCOL */
99721
99722 static struct packet_edit_game *receive_packet_edit_game_100(struct connection *pc)
99723{
99724#define FREE_PACKET_STRUCT(_packet) free_packet_edit_game(_packet)
99725 RECEIVE_PACKET_START(packet_edit_game, real_packet);
99726
99727#ifdef FREECIV_JSON_CONNECTION
99728 struct plocation field_addr;
99729 {
99730 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
99731 field_addr = *field_addr_tmp;
99732 FC_FREE(field_addr_tmp);
99733 }
99734#endif /* FREECIV_JSON_CONNECTION */
99735
99736 log_packet_detailed("packet_edit_game_100: got info about ()");
99737
99738#ifdef FREECIV_DELTA_PROTOCOL
99739 packet_edit_game_100_fields fields;
99740 struct packet_edit_game *old;
99741 struct genhash **hash = pc->phs.received + PACKET_EDIT_GAME;
99742
99743 if (nullptr == *hash) {
99744 *hash = genhash_new_full(hash_packet_edit_game_100, cmp_packet_edit_game_100,
99745 nullptr, nullptr, nullptr, destroy_packet_edit_game);
99746 }
99747
99748 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
99749 *real_packet = *old;
99750 } else {
99751 /* packet is already initialized empty */
99752 log_packet_detailed(" no old info");
99753 }
99754
99755#ifdef FREECIV_JSON_CONNECTION
99756 field_addr.name = "fields";
99757#endif /* FREECIV_JSON_CONNECTION */
99758 DIO_BV_GET(&din, &field_addr, fields);
99759
99760 real_packet->scenario = BV_ISSET(fields, 0);
99761
99762 if (BV_ISSET(fields, 1)) {
99763 log_packet_detailed(" got field 'scenario_name'");
99764
99765#ifdef FREECIV_JSON_CONNECTION
99766 field_addr.name = "scenario_name";
99767#endif /* FREECIV_JSON_CONNECTION */
99768
99769 if (!DIO_GET(string, &din, &field_addr, real_packet->scenario_name, sizeof(real_packet->scenario_name))) {
99770 RECEIVE_PACKET_FIELD_ERROR(scenario_name);
99771 }
99772 }
99773
99774 if (BV_ISSET(fields, 2)) {
99775 log_packet_detailed(" got field 'scenario_authors'");
99776
99777#ifdef FREECIV_JSON_CONNECTION
99778 field_addr.name = "scenario_authors";
99779#endif /* FREECIV_JSON_CONNECTION */
99780
99781 if (!DIO_GET(string, &din, &field_addr, real_packet->scenario_authors, sizeof(real_packet->scenario_authors))) {
99782 RECEIVE_PACKET_FIELD_ERROR(scenario_authors);
99783 }
99784 }
99785
99786 real_packet->scenario_random = BV_ISSET(fields, 3);
99787
99788 real_packet->scenario_players = BV_ISSET(fields, 4);
99789
99790 real_packet->startpos_nations = BV_ISSET(fields, 5);
99791
99792 real_packet->prevent_new_cities = BV_ISSET(fields, 6);
99793
99794 real_packet->lake_flooding = BV_ISSET(fields, 7);
99795
99796 real_packet->ruleset_locked = BV_ISSET(fields, 8);
99797
99798 if (nullptr == old) {
99799 old = fc_malloc(sizeof(*old));
99800 init_packet_edit_game(old);
99801 *old = *real_packet;
99802 genhash_insert(*hash, old, old);
99803 } else {
99804 *old = *real_packet;
99805 }
99806
99807#else /* FREECIV_DELTA_PROTOCOL */
99808#ifdef FREECIV_JSON_CONNECTION
99809 field_addr.name = "scenario";
99810#endif /* FREECIV_JSON_CONNECTION */
99811
99812 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->scenario)) {
99813 RECEIVE_PACKET_FIELD_ERROR(scenario);
99814 }
99815
99816#ifdef FREECIV_JSON_CONNECTION
99817 field_addr.name = "scenario_name";
99818#endif /* FREECIV_JSON_CONNECTION */
99819
99820 if (!DIO_GET(string, &din, &field_addr, real_packet->scenario_name, sizeof(real_packet->scenario_name))) {
99821 RECEIVE_PACKET_FIELD_ERROR(scenario_name);
99822 }
99823
99824#ifdef FREECIV_JSON_CONNECTION
99825 field_addr.name = "scenario_authors";
99826#endif /* FREECIV_JSON_CONNECTION */
99827
99828 if (!DIO_GET(string, &din, &field_addr, real_packet->scenario_authors, sizeof(real_packet->scenario_authors))) {
99829 RECEIVE_PACKET_FIELD_ERROR(scenario_authors);
99830 }
99831
99832#ifdef FREECIV_JSON_CONNECTION
99833 field_addr.name = "scenario_random";
99834#endif /* FREECIV_JSON_CONNECTION */
99835
99836 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->scenario_random)) {
99837 RECEIVE_PACKET_FIELD_ERROR(scenario_random);
99838 }
99839
99840#ifdef FREECIV_JSON_CONNECTION
99841 field_addr.name = "scenario_players";
99842#endif /* FREECIV_JSON_CONNECTION */
99843
99844 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->scenario_players)) {
99845 RECEIVE_PACKET_FIELD_ERROR(scenario_players);
99846 }
99847
99848#ifdef FREECIV_JSON_CONNECTION
99849 field_addr.name = "startpos_nations";
99850#endif /* FREECIV_JSON_CONNECTION */
99851
99852 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->startpos_nations)) {
99853 RECEIVE_PACKET_FIELD_ERROR(startpos_nations);
99854 }
99855
99856#ifdef FREECIV_JSON_CONNECTION
99857 field_addr.name = "prevent_new_cities";
99858#endif /* FREECIV_JSON_CONNECTION */
99859
99860 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->prevent_new_cities)) {
99861 RECEIVE_PACKET_FIELD_ERROR(prevent_new_cities);
99862 }
99863
99864#ifdef FREECIV_JSON_CONNECTION
99865 field_addr.name = "lake_flooding";
99866#endif /* FREECIV_JSON_CONNECTION */
99867
99868 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->lake_flooding)) {
99869 RECEIVE_PACKET_FIELD_ERROR(lake_flooding);
99870 }
99871
99872#ifdef FREECIV_JSON_CONNECTION
99873 field_addr.name = "ruleset_locked";
99874#endif /* FREECIV_JSON_CONNECTION */
99875
99876 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->ruleset_locked)) {
99877 RECEIVE_PACKET_FIELD_ERROR(ruleset_locked);
99878 }
99879#endif /* FREECIV_DELTA_PROTOCOL */
99880
99881 RECEIVE_PACKET_END(real_packet);
99882#undef FREE_PACKET_STRUCT
99883}
99884
99885 static int send_packet_edit_game_100(struct connection *pc, const struct packet_edit_game *packet)
99886{
99887 const struct packet_edit_game *real_packet = packet;
99888 int e;
99889 SEND_PACKET_START(PACKET_EDIT_GAME);
99890
99891 log_packet_detailed("packet_edit_game_100: sending info about ()");
99892
99893#ifdef FREECIV_DELTA_PROTOCOL
99894 packet_edit_game_100_fields fields;
99895 struct packet_edit_game *old;
99896 bool differ;
99897 struct genhash **hash = pc->phs.sent + PACKET_EDIT_GAME;
99898
99899 if (nullptr == *hash) {
99900 *hash = genhash_new_full(hash_packet_edit_game_100, cmp_packet_edit_game_100,
99901 nullptr, nullptr, nullptr, destroy_packet_edit_game);
99902 }
99903 BV_CLR_ALL(fields);
99904
99905 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
99906 old = fc_malloc(sizeof(*old));
99907 /* temporary bitcopy just to insert correctly */
99908 *old = *real_packet;
99909 genhash_insert(*hash, old, old);
99910 init_packet_edit_game(old);
99911 }
99912
99913 /* folded into head */
99914 if (real_packet->scenario) {
99915 BV_SET(fields, 0);
99916 }
99917
99918 differ = (strcmp(old->scenario_name, real_packet->scenario_name) != 0);
99919 if (differ) {
99920 BV_SET(fields, 1);
99921 }
99922
99923 differ = (strcmp(old->scenario_authors, real_packet->scenario_authors) != 0);
99924 if (differ) {
99925 BV_SET(fields, 2);
99926 }
99927
99928 /* folded into head */
99929 if (real_packet->scenario_random) {
99930 BV_SET(fields, 3);
99931 }
99932
99933 /* folded into head */
99934 if (real_packet->scenario_players) {
99935 BV_SET(fields, 4);
99936 }
99937
99938 /* folded into head */
99939 if (real_packet->startpos_nations) {
99940 BV_SET(fields, 5);
99941 }
99942
99943 /* folded into head */
99944 if (real_packet->prevent_new_cities) {
99945 BV_SET(fields, 6);
99946 }
99947
99948 /* folded into head */
99949 if (real_packet->lake_flooding) {
99950 BV_SET(fields, 7);
99951 }
99952
99953 /* folded into head */
99954 if (real_packet->ruleset_locked) {
99955 BV_SET(fields, 8);
99956 }
99957#endif /* FREECIV_DELTA_PROTOCOL */
99958
99959#ifdef FREECIV_JSON_CONNECTION
99960 struct plocation field_addr;
99961 {
99962 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
99963 field_addr = *field_addr_tmp;
99964 FC_FREE(field_addr_tmp);
99965 }
99966#endif /* FREECIV_JSON_CONNECTION */
99967
99968#ifdef FREECIV_DELTA_PROTOCOL
99969#ifdef FREECIV_JSON_CONNECTION
99970 field_addr.name = "fields";
99971#endif /* FREECIV_JSON_CONNECTION */
99972 e = 0;
99973 e |= DIO_BV_PUT(&dout, &field_addr, fields);
99974 if (e) {
99975 log_packet_detailed("fields bitvector error detected");
99976 }
99977
99978 /* field 0 is folded into the header */
99979
99980 if (BV_ISSET(fields, 1)) {
99981 log_packet_detailed(" field 'scenario_name' has changed");
99982
99983#ifdef FREECIV_JSON_CONNECTION
99984 field_addr.name = "scenario_name";
99985#endif /* FREECIV_JSON_CONNECTION */
99986 e = 0;
99987
99988 e |= DIO_PUT(string, &dout, &field_addr, real_packet->scenario_name);
99989
99990 if (e) {
99991 log_packet_detailed("'scenario_name' field error detected");
99992 }
99993 }
99994
99995 if (BV_ISSET(fields, 2)) {
99996 log_packet_detailed(" field 'scenario_authors' has changed");
99997
99998#ifdef FREECIV_JSON_CONNECTION
99999 field_addr.name = "scenario_authors";
100000#endif /* FREECIV_JSON_CONNECTION */
100001 e = 0;
100002
100003 e |= DIO_PUT(string, &dout, &field_addr, real_packet->scenario_authors);
100004
100005 if (e) {
100006 log_packet_detailed("'scenario_authors' field error detected");
100007 }
100008 }
100009
100010 /* field 3 is folded into the header */
100011
100012 /* field 4 is folded into the header */
100013
100014 /* field 5 is folded into the header */
100015
100016 /* field 6 is folded into the header */
100017
100018 /* field 7 is folded into the header */
100019
100020 /* field 8 is folded into the header */
100021
100022 *old = *real_packet;
100023
100024#else /* FREECIV_DELTA_PROTOCOL */
100025#ifdef FREECIV_JSON_CONNECTION
100026 field_addr.name = "scenario";
100027#endif /* FREECIV_JSON_CONNECTION */
100028 e = 0;
100029
100030 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->scenario);
100031
100032 if (e) {
100033 log_packet_detailed("'scenario' field error detected");
100034 }
100035
100036#ifdef FREECIV_JSON_CONNECTION
100037 field_addr.name = "scenario_name";
100038#endif /* FREECIV_JSON_CONNECTION */
100039 e = 0;
100040
100041 e |= DIO_PUT(string, &dout, &field_addr, real_packet->scenario_name);
100042
100043 if (e) {
100044 log_packet_detailed("'scenario_name' field error detected");
100045 }
100046
100047#ifdef FREECIV_JSON_CONNECTION
100048 field_addr.name = "scenario_authors";
100049#endif /* FREECIV_JSON_CONNECTION */
100050 e = 0;
100051
100052 e |= DIO_PUT(string, &dout, &field_addr, real_packet->scenario_authors);
100053
100054 if (e) {
100055 log_packet_detailed("'scenario_authors' field error detected");
100056 }
100057
100058#ifdef FREECIV_JSON_CONNECTION
100059 field_addr.name = "scenario_random";
100060#endif /* FREECIV_JSON_CONNECTION */
100061 e = 0;
100062
100063 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->scenario_random);
100064
100065 if (e) {
100066 log_packet_detailed("'scenario_random' field error detected");
100067 }
100068
100069#ifdef FREECIV_JSON_CONNECTION
100070 field_addr.name = "scenario_players";
100071#endif /* FREECIV_JSON_CONNECTION */
100072 e = 0;
100073
100074 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->scenario_players);
100075
100076 if (e) {
100077 log_packet_detailed("'scenario_players' field error detected");
100078 }
100079
100080#ifdef FREECIV_JSON_CONNECTION
100081 field_addr.name = "startpos_nations";
100082#endif /* FREECIV_JSON_CONNECTION */
100083 e = 0;
100084
100085 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->startpos_nations);
100086
100087 if (e) {
100088 log_packet_detailed("'startpos_nations' field error detected");
100089 }
100090
100091#ifdef FREECIV_JSON_CONNECTION
100092 field_addr.name = "prevent_new_cities";
100093#endif /* FREECIV_JSON_CONNECTION */
100094 e = 0;
100095
100096 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->prevent_new_cities);
100097
100098 if (e) {
100099 log_packet_detailed("'prevent_new_cities' field error detected");
100100 }
100101
100102#ifdef FREECIV_JSON_CONNECTION
100103 field_addr.name = "lake_flooding";
100104#endif /* FREECIV_JSON_CONNECTION */
100105 e = 0;
100106
100107 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->lake_flooding);
100108
100109 if (e) {
100110 log_packet_detailed("'lake_flooding' field error detected");
100111 }
100112
100113#ifdef FREECIV_JSON_CONNECTION
100114 field_addr.name = "ruleset_locked";
100115#endif /* FREECIV_JSON_CONNECTION */
100116 e = 0;
100117
100118 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->ruleset_locked);
100119
100120 if (e) {
100121 log_packet_detailed("'ruleset_locked' field error detected");
100122 }
100123#endif /* FREECIV_DELTA_PROTOCOL */
100124
100125 SEND_PACKET_END(PACKET_EDIT_GAME);
100126}
100127
100128 int send_packet_edit_game(struct connection *pc, const struct packet_edit_game *packet)
100129{
100130 if (!pc->used) {
100131 log_error("WARNING: trying to send data to the closed connection %s",
100132 conn_description(pc));
100133 return -1;
100134 }
100135 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_GAME].packet != nullptr, -1,
100136 "Handler for PACKET_EDIT_GAME not installed");
100137 return pc->phs.handlers->send[PACKET_EDIT_GAME].packet(pc, packet);
100138}
100139
100140 static inline void init_packet_edit_scenario_desc(struct packet_edit_scenario_desc *packet)
100141{
100142 memset(packet, 0, sizeof(*packet));
100143}
100144
100145#define free_packet_edit_scenario_desc(_packet) (void) 0
100146#define destroy_packet_edit_scenario_desc free
100147
100148#ifdef FREECIV_DELTA_PROTOCOL
100149#define hash_packet_edit_scenario_desc_100 hash_const
100150#define cmp_packet_edit_scenario_desc_100 cmp_const
100151 BV_DEFINE(packet_edit_scenario_desc_100_fields, 1);
100152#endif /* FREECIV_DELTA_PROTOCOL */
100153
100154 static struct packet_edit_scenario_desc *receive_packet_edit_scenario_desc_100(struct connection *pc)
100155{
100156#define FREE_PACKET_STRUCT(_packet) free_packet_edit_scenario_desc(_packet)
100157 RECEIVE_PACKET_START(packet_edit_scenario_desc, real_packet);
100158
100159#ifdef FREECIV_JSON_CONNECTION
100160 struct plocation field_addr;
100161 {
100162 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100163 field_addr = *field_addr_tmp;
100164 FC_FREE(field_addr_tmp);
100165 }
100166#endif /* FREECIV_JSON_CONNECTION */
100167
100168 log_packet_detailed("packet_edit_scenario_desc_100: got info about ()");
100169
100170#ifdef FREECIV_DELTA_PROTOCOL
100171 packet_edit_scenario_desc_100_fields fields;
100172 struct packet_edit_scenario_desc *old;
100173 struct genhash **hash = pc->phs.received + PACKET_EDIT_SCENARIO_DESC;
100174
100175 if (nullptr == *hash) {
100176 *hash = genhash_new_full(hash_packet_edit_scenario_desc_100, cmp_packet_edit_scenario_desc_100,
100177 nullptr, nullptr, nullptr, destroy_packet_edit_scenario_desc);
100178 }
100179
100180 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
100181 *real_packet = *old;
100182 } else {
100183 /* packet is already initialized empty */
100184 log_packet_detailed(" no old info");
100185 }
100186
100187#ifdef FREECIV_JSON_CONNECTION
100188 field_addr.name = "fields";
100189#endif /* FREECIV_JSON_CONNECTION */
100190 DIO_BV_GET(&din, &field_addr, fields);
100191
100192 if (BV_ISSET(fields, 0)) {
100193 log_packet_detailed(" got field 'scenario_desc'");
100194
100195#ifdef FREECIV_JSON_CONNECTION
100196 field_addr.name = "scenario_desc";
100197#endif /* FREECIV_JSON_CONNECTION */
100198
100199 if (!DIO_GET(string, &din, &field_addr, real_packet->scenario_desc, sizeof(real_packet->scenario_desc))) {
100200 RECEIVE_PACKET_FIELD_ERROR(scenario_desc);
100201 }
100202 }
100203
100204 if (nullptr == old) {
100205 old = fc_malloc(sizeof(*old));
100206 init_packet_edit_scenario_desc(old);
100207 *old = *real_packet;
100208 genhash_insert(*hash, old, old);
100209 } else {
100210 *old = *real_packet;
100211 }
100212
100213#else /* FREECIV_DELTA_PROTOCOL */
100214#ifdef FREECIV_JSON_CONNECTION
100215 field_addr.name = "scenario_desc";
100216#endif /* FREECIV_JSON_CONNECTION */
100217
100218 if (!DIO_GET(string, &din, &field_addr, real_packet->scenario_desc, sizeof(real_packet->scenario_desc))) {
100219 RECEIVE_PACKET_FIELD_ERROR(scenario_desc);
100220 }
100221#endif /* FREECIV_DELTA_PROTOCOL */
100222
100223 RECEIVE_PACKET_END(real_packet);
100224#undef FREE_PACKET_STRUCT
100225}
100226
100227 static int send_packet_edit_scenario_desc_100(struct connection *pc, const struct packet_edit_scenario_desc *packet)
100228{
100229 const struct packet_edit_scenario_desc *real_packet = packet;
100230 int e;
100231 SEND_PACKET_START(PACKET_EDIT_SCENARIO_DESC);
100232
100233 log_packet_detailed("packet_edit_scenario_desc_100: sending info about ()");
100234
100235#ifdef FREECIV_DELTA_PROTOCOL
100236 packet_edit_scenario_desc_100_fields fields;
100237 struct packet_edit_scenario_desc *old;
100238 bool differ;
100239 struct genhash **hash = pc->phs.sent + PACKET_EDIT_SCENARIO_DESC;
100240
100241 if (nullptr == *hash) {
100242 *hash = genhash_new_full(hash_packet_edit_scenario_desc_100, cmp_packet_edit_scenario_desc_100,
100243 nullptr, nullptr, nullptr, destroy_packet_edit_scenario_desc);
100244 }
100245 BV_CLR_ALL(fields);
100246
100247 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
100248 old = fc_malloc(sizeof(*old));
100249 /* temporary bitcopy just to insert correctly */
100250 *old = *real_packet;
100251 genhash_insert(*hash, old, old);
100252 init_packet_edit_scenario_desc(old);
100253 }
100254
100255 differ = (strcmp(old->scenario_desc, real_packet->scenario_desc) != 0);
100256 if (differ) {
100257 BV_SET(fields, 0);
100258 }
100259#endif /* FREECIV_DELTA_PROTOCOL */
100260
100261#ifdef FREECIV_JSON_CONNECTION
100262 struct plocation field_addr;
100263 {
100264 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100265 field_addr = *field_addr_tmp;
100266 FC_FREE(field_addr_tmp);
100267 }
100268#endif /* FREECIV_JSON_CONNECTION */
100269
100270#ifdef FREECIV_DELTA_PROTOCOL
100271#ifdef FREECIV_JSON_CONNECTION
100272 field_addr.name = "fields";
100273#endif /* FREECIV_JSON_CONNECTION */
100274 e = 0;
100275 e |= DIO_BV_PUT(&dout, &field_addr, fields);
100276 if (e) {
100277 log_packet_detailed("fields bitvector error detected");
100278 }
100279
100280 if (BV_ISSET(fields, 0)) {
100281 log_packet_detailed(" field 'scenario_desc' has changed");
100282
100283#ifdef FREECIV_JSON_CONNECTION
100284 field_addr.name = "scenario_desc";
100285#endif /* FREECIV_JSON_CONNECTION */
100286 e = 0;
100287
100288 e |= DIO_PUT(string, &dout, &field_addr, real_packet->scenario_desc);
100289
100290 if (e) {
100291 log_packet_detailed("'scenario_desc' field error detected");
100292 }
100293 }
100294
100295 *old = *real_packet;
100296
100297#else /* FREECIV_DELTA_PROTOCOL */
100298#ifdef FREECIV_JSON_CONNECTION
100299 field_addr.name = "scenario_desc";
100300#endif /* FREECIV_JSON_CONNECTION */
100301 e = 0;
100302
100303 e |= DIO_PUT(string, &dout, &field_addr, real_packet->scenario_desc);
100304
100305 if (e) {
100306 log_packet_detailed("'scenario_desc' field error detected");
100307 }
100308#endif /* FREECIV_DELTA_PROTOCOL */
100309
100310 SEND_PACKET_END(PACKET_EDIT_SCENARIO_DESC);
100311}
100312
100313 int send_packet_edit_scenario_desc(struct connection *pc, const struct packet_edit_scenario_desc *packet)
100314{
100315 if (!pc->used) {
100316 log_error("WARNING: trying to send data to the closed connection %s",
100317 conn_description(pc));
100318 return -1;
100319 }
100320 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_SCENARIO_DESC].packet != nullptr, -1,
100321 "Handler for PACKET_EDIT_SCENARIO_DESC not installed");
100322 return pc->phs.handlers->send[PACKET_EDIT_SCENARIO_DESC].packet(pc, packet);
100323}
100324
100325 static inline void init_packet_edit_object_created(struct packet_edit_object_created *packet)
100326{
100327 memset(packet, 0, sizeof(*packet));
100328}
100329
100330#define free_packet_edit_object_created(_packet) (void) 0
100331#define destroy_packet_edit_object_created free
100332
100333#ifdef FREECIV_DELTA_PROTOCOL
100334#define hash_packet_edit_object_created_100 hash_const
100335#define cmp_packet_edit_object_created_100 cmp_const
100336 BV_DEFINE(packet_edit_object_created_100_fields, 2);
100337#endif /* FREECIV_DELTA_PROTOCOL */
100338
100339 static struct packet_edit_object_created *receive_packet_edit_object_created_100(struct connection *pc)
100340{
100341#define FREE_PACKET_STRUCT(_packet) free_packet_edit_object_created(_packet)
100342 RECEIVE_PACKET_START(packet_edit_object_created, real_packet);
100343
100344#ifdef FREECIV_JSON_CONNECTION
100345 struct plocation field_addr;
100346 {
100347 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100348 field_addr = *field_addr_tmp;
100349 FC_FREE(field_addr_tmp);
100350 }
100351#endif /* FREECIV_JSON_CONNECTION */
100352
100353 log_packet_detailed("packet_edit_object_created_100: got info about ()");
100354
100355#ifdef FREECIV_DELTA_PROTOCOL
100356 packet_edit_object_created_100_fields fields;
100357 struct packet_edit_object_created *old;
100358 struct genhash **hash = pc->phs.received + PACKET_EDIT_OBJECT_CREATED;
100359
100360 if (nullptr == *hash) {
100361 *hash = genhash_new_full(hash_packet_edit_object_created_100, cmp_packet_edit_object_created_100,
100362 nullptr, nullptr, nullptr, destroy_packet_edit_object_created);
100363 }
100364
100365 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
100366 *real_packet = *old;
100367 } else {
100368 /* packet is already initialized empty */
100369 log_packet_detailed(" no old info");
100370 }
100371
100372#ifdef FREECIV_JSON_CONNECTION
100373 field_addr.name = "fields";
100374#endif /* FREECIV_JSON_CONNECTION */
100375 DIO_BV_GET(&din, &field_addr, fields);
100376
100377 if (BV_ISSET(fields, 0)) {
100378 log_packet_detailed(" got field 'tag'");
100379
100380#ifdef FREECIV_JSON_CONNECTION
100381 field_addr.name = "tag";
100382#endif /* FREECIV_JSON_CONNECTION */
100383
100384 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
100385 RECEIVE_PACKET_FIELD_ERROR(tag);
100386 }
100387 }
100388
100389 if (BV_ISSET(fields, 1)) {
100390 log_packet_detailed(" got field 'id'");
100391
100392#ifdef FREECIV_JSON_CONNECTION
100393 field_addr.name = "id";
100394#endif /* FREECIV_JSON_CONNECTION */
100395
100396 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->id)) {
100397 RECEIVE_PACKET_FIELD_ERROR(id);
100398 }
100399 }
100400
100401 if (nullptr == old) {
100402 old = fc_malloc(sizeof(*old));
100403 init_packet_edit_object_created(old);
100404 *old = *real_packet;
100405 genhash_insert(*hash, old, old);
100406 } else {
100407 *old = *real_packet;
100408 }
100409
100410#else /* FREECIV_DELTA_PROTOCOL */
100411#ifdef FREECIV_JSON_CONNECTION
100412 field_addr.name = "tag";
100413#endif /* FREECIV_JSON_CONNECTION */
100414
100415 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->tag)) {
100416 RECEIVE_PACKET_FIELD_ERROR(tag);
100417 }
100418
100419#ifdef FREECIV_JSON_CONNECTION
100420 field_addr.name = "id";
100421#endif /* FREECIV_JSON_CONNECTION */
100422
100423 if (!DIO_GET(sint32, &din, &field_addr, &real_packet->id)) {
100424 RECEIVE_PACKET_FIELD_ERROR(id);
100425 }
100426#endif /* FREECIV_DELTA_PROTOCOL */
100427
100428 RECEIVE_PACKET_END(real_packet);
100429#undef FREE_PACKET_STRUCT
100430}
100431
100432 static int send_packet_edit_object_created_100(struct connection *pc, const struct packet_edit_object_created *packet)
100433{
100434 const struct packet_edit_object_created *real_packet = packet;
100435 int e;
100436 SEND_PACKET_START(PACKET_EDIT_OBJECT_CREATED);
100437
100438 log_packet_detailed("packet_edit_object_created_100: sending info about ()");
100439
100440#ifdef FREECIV_DELTA_PROTOCOL
100441 packet_edit_object_created_100_fields fields;
100442 struct packet_edit_object_created *old;
100443 bool differ;
100444 struct genhash **hash = pc->phs.sent + PACKET_EDIT_OBJECT_CREATED;
100445
100446 if (nullptr == *hash) {
100447 *hash = genhash_new_full(hash_packet_edit_object_created_100, cmp_packet_edit_object_created_100,
100448 nullptr, nullptr, nullptr, destroy_packet_edit_object_created);
100449 }
100450 BV_CLR_ALL(fields);
100451
100452 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
100453 old = fc_malloc(sizeof(*old));
100454 /* temporary bitcopy just to insert correctly */
100455 *old = *real_packet;
100456 genhash_insert(*hash, old, old);
100457 init_packet_edit_object_created(old);
100458 }
100459
100460 differ = (old->tag != real_packet->tag);
100461 if (differ) {
100462 BV_SET(fields, 0);
100463 }
100464
100465 differ = (old->id != real_packet->id);
100466 if (differ) {
100467 BV_SET(fields, 1);
100468 }
100469#endif /* FREECIV_DELTA_PROTOCOL */
100470
100471#ifdef FREECIV_JSON_CONNECTION
100472 struct plocation field_addr;
100473 {
100474 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100475 field_addr = *field_addr_tmp;
100476 FC_FREE(field_addr_tmp);
100477 }
100478#endif /* FREECIV_JSON_CONNECTION */
100479
100480#ifdef FREECIV_DELTA_PROTOCOL
100481#ifdef FREECIV_JSON_CONNECTION
100482 field_addr.name = "fields";
100483#endif /* FREECIV_JSON_CONNECTION */
100484 e = 0;
100485 e |= DIO_BV_PUT(&dout, &field_addr, fields);
100486 if (e) {
100487 log_packet_detailed("fields bitvector error detected");
100488 }
100489
100490 if (BV_ISSET(fields, 0)) {
100491 log_packet_detailed(" field 'tag' has changed");
100492
100493#ifdef FREECIV_JSON_CONNECTION
100494 field_addr.name = "tag";
100495#endif /* FREECIV_JSON_CONNECTION */
100496 e = 0;
100497
100498 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
100499
100500 if (e) {
100501 log_packet_detailed("'tag' field error detected");
100502 }
100503 }
100504
100505 if (BV_ISSET(fields, 1)) {
100506 log_packet_detailed(" field 'id' has changed");
100507
100508#ifdef FREECIV_JSON_CONNECTION
100509 field_addr.name = "id";
100510#endif /* FREECIV_JSON_CONNECTION */
100511 e = 0;
100512
100513 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->id);
100514
100515 if (e) {
100516 log_packet_detailed("'id' field error detected");
100517 }
100518 }
100519
100520 *old = *real_packet;
100521
100522#else /* FREECIV_DELTA_PROTOCOL */
100523#ifdef FREECIV_JSON_CONNECTION
100524 field_addr.name = "tag";
100525#endif /* FREECIV_JSON_CONNECTION */
100526 e = 0;
100527
100528 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->tag);
100529
100530 if (e) {
100531 log_packet_detailed("'tag' field error detected");
100532 }
100533
100534#ifdef FREECIV_JSON_CONNECTION
100535 field_addr.name = "id";
100536#endif /* FREECIV_JSON_CONNECTION */
100537 e = 0;
100538
100539 e |= DIO_PUT(sint32, &dout, &field_addr, real_packet->id);
100540
100541 if (e) {
100542 log_packet_detailed("'id' field error detected");
100543 }
100544#endif /* FREECIV_DELTA_PROTOCOL */
100545
100546 SEND_PACKET_END(PACKET_EDIT_OBJECT_CREATED);
100547}
100548
100549 int send_packet_edit_object_created(struct connection *pc, const struct packet_edit_object_created *packet)
100550{
100551 if (!pc->used) {
100552 log_error("WARNING: trying to send data to the closed connection %s",
100553 conn_description(pc));
100554 return -1;
100555 }
100556 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_EDIT_OBJECT_CREATED].packet != nullptr, -1,
100557 "Handler for PACKET_EDIT_OBJECT_CREATED not installed");
100558 return pc->phs.handlers->send[PACKET_EDIT_OBJECT_CREATED].packet(pc, packet);
100559}
100560
100561 int dsend_packet_edit_object_created(struct connection *pc, int tag, int id)
100562{
100563 struct packet_edit_object_created packet, *real_packet = &packet;
100564
100565 real_packet->tag = tag;
100566 real_packet->id = id;
100567
100568 return send_packet_edit_object_created(pc, real_packet);
100569}
100570
100571 static inline void init_packet_play_music(struct packet_play_music *packet)
100572{
100573 memset(packet, 0, sizeof(*packet));
100574}
100575
100576#define free_packet_play_music(_packet) (void) 0
100577#define destroy_packet_play_music free
100578
100579#ifdef FREECIV_DELTA_PROTOCOL
100580#define hash_packet_play_music_100 hash_const
100581#define cmp_packet_play_music_100 cmp_const
100582 BV_DEFINE(packet_play_music_100_fields, 1);
100583#endif /* FREECIV_DELTA_PROTOCOL */
100584
100585 static struct packet_play_music *receive_packet_play_music_100(struct connection *pc)
100586{
100587#define FREE_PACKET_STRUCT(_packet) free_packet_play_music(_packet)
100588 RECEIVE_PACKET_START(packet_play_music, real_packet);
100589
100590#ifdef FREECIV_JSON_CONNECTION
100591 struct plocation field_addr;
100592 {
100593 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100594 field_addr = *field_addr_tmp;
100595 FC_FREE(field_addr_tmp);
100596 }
100597#endif /* FREECIV_JSON_CONNECTION */
100598
100599 log_packet_detailed("packet_play_music_100: got info about ()");
100600
100601#ifdef FREECIV_DELTA_PROTOCOL
100602 packet_play_music_100_fields fields;
100603 struct packet_play_music *old;
100604 struct genhash **hash = pc->phs.received + PACKET_PLAY_MUSIC;
100605
100606 if (nullptr == *hash) {
100607 *hash = genhash_new_full(hash_packet_play_music_100, cmp_packet_play_music_100,
100608 nullptr, nullptr, nullptr, destroy_packet_play_music);
100609 }
100610
100611 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
100612 *real_packet = *old;
100613 } else {
100614 /* packet is already initialized empty */
100615 log_packet_detailed(" no old info");
100616 }
100617
100618#ifdef FREECIV_JSON_CONNECTION
100619 field_addr.name = "fields";
100620#endif /* FREECIV_JSON_CONNECTION */
100621 DIO_BV_GET(&din, &field_addr, fields);
100622
100623 if (BV_ISSET(fields, 0)) {
100624 log_packet_detailed(" got field 'tag'");
100625
100626#ifdef FREECIV_JSON_CONNECTION
100627 field_addr.name = "tag";
100628#endif /* FREECIV_JSON_CONNECTION */
100629
100630 if (!DIO_GET(string, &din, &field_addr, real_packet->tag, sizeof(real_packet->tag))) {
100631 RECEIVE_PACKET_FIELD_ERROR(tag);
100632 }
100633 }
100634
100635 if (nullptr == old) {
100636 old = fc_malloc(sizeof(*old));
100637 init_packet_play_music(old);
100638 *old = *real_packet;
100639 genhash_insert(*hash, old, old);
100640 } else {
100641 *old = *real_packet;
100642 }
100643
100644#else /* FREECIV_DELTA_PROTOCOL */
100645#ifdef FREECIV_JSON_CONNECTION
100646 field_addr.name = "tag";
100647#endif /* FREECIV_JSON_CONNECTION */
100648
100649 if (!DIO_GET(string, &din, &field_addr, real_packet->tag, sizeof(real_packet->tag))) {
100650 RECEIVE_PACKET_FIELD_ERROR(tag);
100651 }
100652#endif /* FREECIV_DELTA_PROTOCOL */
100653
100654 RECEIVE_PACKET_END(real_packet);
100655#undef FREE_PACKET_STRUCT
100656}
100657
100658 static int send_packet_play_music_100(struct connection *pc, const struct packet_play_music *packet)
100659{
100660 const struct packet_play_music *real_packet = packet;
100661 int e;
100662 SEND_PACKET_START(PACKET_PLAY_MUSIC);
100663
100664 log_packet_detailed("packet_play_music_100: sending info about ()");
100665
100666#ifdef FREECIV_DELTA_PROTOCOL
100667 packet_play_music_100_fields fields;
100668 struct packet_play_music *old;
100669 bool differ;
100670 struct genhash **hash = pc->phs.sent + PACKET_PLAY_MUSIC;
100671
100672 if (nullptr == *hash) {
100673 *hash = genhash_new_full(hash_packet_play_music_100, cmp_packet_play_music_100,
100674 nullptr, nullptr, nullptr, destroy_packet_play_music);
100675 }
100676 BV_CLR_ALL(fields);
100677
100678 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
100679 old = fc_malloc(sizeof(*old));
100680 /* temporary bitcopy just to insert correctly */
100681 *old = *real_packet;
100682 genhash_insert(*hash, old, old);
100683 init_packet_play_music(old);
100684 }
100685
100686 differ = (strcmp(old->tag, real_packet->tag) != 0);
100687 if (differ) {
100688 BV_SET(fields, 0);
100689 }
100690#endif /* FREECIV_DELTA_PROTOCOL */
100691
100692#ifdef FREECIV_JSON_CONNECTION
100693 struct plocation field_addr;
100694 {
100695 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100696 field_addr = *field_addr_tmp;
100697 FC_FREE(field_addr_tmp);
100698 }
100699#endif /* FREECIV_JSON_CONNECTION */
100700
100701#ifdef FREECIV_DELTA_PROTOCOL
100702#ifdef FREECIV_JSON_CONNECTION
100703 field_addr.name = "fields";
100704#endif /* FREECIV_JSON_CONNECTION */
100705 e = 0;
100706 e |= DIO_BV_PUT(&dout, &field_addr, fields);
100707 if (e) {
100708 log_packet_detailed("fields bitvector error detected");
100709 }
100710
100711 if (BV_ISSET(fields, 0)) {
100712 log_packet_detailed(" field 'tag' has changed");
100713
100714#ifdef FREECIV_JSON_CONNECTION
100715 field_addr.name = "tag";
100716#endif /* FREECIV_JSON_CONNECTION */
100717 e = 0;
100718
100719 e |= DIO_PUT(string, &dout, &field_addr, real_packet->tag);
100720
100721 if (e) {
100722 log_packet_detailed("'tag' field error detected");
100723 }
100724 }
100725
100726 *old = *real_packet;
100727
100728#else /* FREECIV_DELTA_PROTOCOL */
100729#ifdef FREECIV_JSON_CONNECTION
100730 field_addr.name = "tag";
100731#endif /* FREECIV_JSON_CONNECTION */
100732 e = 0;
100733
100734 e |= DIO_PUT(string, &dout, &field_addr, real_packet->tag);
100735
100736 if (e) {
100737 log_packet_detailed("'tag' field error detected");
100738 }
100739#endif /* FREECIV_DELTA_PROTOCOL */
100740
100741 SEND_PACKET_END(PACKET_PLAY_MUSIC);
100742}
100743
100744 int send_packet_play_music(struct connection *pc, const struct packet_play_music *packet)
100745{
100746 if (!pc->used) {
100747 log_error("WARNING: trying to send data to the closed connection %s",
100748 conn_description(pc));
100749 return -1;
100750 }
100751 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_PLAY_MUSIC].packet != nullptr, -1,
100752 "Handler for PACKET_PLAY_MUSIC not installed");
100753 return pc->phs.handlers->send[PACKET_PLAY_MUSIC].packet(pc, packet);
100754}
100755
100756 void lsend_packet_play_music(struct conn_list *dest, const struct packet_play_music *packet)
100757{
100758 conn_list_iterate(dest, pconn) {
100759 send_packet_play_music(pconn, packet);
100760 } conn_list_iterate_end;
100761}
100762
100763 static inline void init_packet_popup_image(struct packet_popup_image *packet)
100764{
100765 memset(packet, 0, sizeof(*packet));
100766}
100767
100768#define free_packet_popup_image(_packet) (void) 0
100769#define destroy_packet_popup_image free
100770
100771#ifdef FREECIV_DELTA_PROTOCOL
100772#define hash_packet_popup_image_100 hash_const
100773#define cmp_packet_popup_image_100 cmp_const
100774 BV_DEFINE(packet_popup_image_100_fields, 1);
100775#endif /* FREECIV_DELTA_PROTOCOL */
100776
100777 static struct packet_popup_image *receive_packet_popup_image_100(struct connection *pc)
100778{
100779#define FREE_PACKET_STRUCT(_packet) free_packet_popup_image(_packet)
100780 RECEIVE_PACKET_START(packet_popup_image, real_packet);
100781
100782#ifdef FREECIV_JSON_CONNECTION
100783 struct plocation field_addr;
100784 {
100785 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100786 field_addr = *field_addr_tmp;
100787 FC_FREE(field_addr_tmp);
100788 }
100789#endif /* FREECIV_JSON_CONNECTION */
100790
100791 log_packet_detailed("packet_popup_image_100: got info about ()");
100792
100793#ifdef FREECIV_DELTA_PROTOCOL
100794 packet_popup_image_100_fields fields;
100795 struct packet_popup_image *old;
100796 struct genhash **hash = pc->phs.received + PACKET_POPUP_IMAGE;
100797
100798 if (nullptr == *hash) {
100799 *hash = genhash_new_full(hash_packet_popup_image_100, cmp_packet_popup_image_100,
100800 nullptr, nullptr, nullptr, destroy_packet_popup_image);
100801 }
100802
100803 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
100804 *real_packet = *old;
100805 } else {
100806 /* packet is already initialized empty */
100807 log_packet_detailed(" no old info");
100808 }
100809
100810#ifdef FREECIV_JSON_CONNECTION
100811 field_addr.name = "fields";
100812#endif /* FREECIV_JSON_CONNECTION */
100813 DIO_BV_GET(&din, &field_addr, fields);
100814
100815 if (BV_ISSET(fields, 0)) {
100816 log_packet_detailed(" got field 'tag'");
100817
100818#ifdef FREECIV_JSON_CONNECTION
100819 field_addr.name = "tag";
100820#endif /* FREECIV_JSON_CONNECTION */
100821
100822 if (!DIO_GET(string, &din, &field_addr, real_packet->tag, sizeof(real_packet->tag))) {
100823 RECEIVE_PACKET_FIELD_ERROR(tag);
100824 }
100825 }
100826
100827 if (nullptr == old) {
100828 old = fc_malloc(sizeof(*old));
100829 init_packet_popup_image(old);
100830 *old = *real_packet;
100831 genhash_insert(*hash, old, old);
100832 } else {
100833 *old = *real_packet;
100834 }
100835
100836#else /* FREECIV_DELTA_PROTOCOL */
100837#ifdef FREECIV_JSON_CONNECTION
100838 field_addr.name = "tag";
100839#endif /* FREECIV_JSON_CONNECTION */
100840
100841 if (!DIO_GET(string, &din, &field_addr, real_packet->tag, sizeof(real_packet->tag))) {
100842 RECEIVE_PACKET_FIELD_ERROR(tag);
100843 }
100844#endif /* FREECIV_DELTA_PROTOCOL */
100845
100846 RECEIVE_PACKET_END(real_packet);
100847#undef FREE_PACKET_STRUCT
100848}
100849
100850 static int send_packet_popup_image_100(struct connection *pc, const struct packet_popup_image *packet)
100851{
100852 const struct packet_popup_image *real_packet = packet;
100853 int e;
100854 SEND_PACKET_START(PACKET_POPUP_IMAGE);
100855
100856 log_packet_detailed("packet_popup_image_100: sending info about ()");
100857
100858#ifdef FREECIV_DELTA_PROTOCOL
100859 packet_popup_image_100_fields fields;
100860 struct packet_popup_image *old;
100861 bool differ;
100862 struct genhash **hash = pc->phs.sent + PACKET_POPUP_IMAGE;
100863
100864 if (nullptr == *hash) {
100865 *hash = genhash_new_full(hash_packet_popup_image_100, cmp_packet_popup_image_100,
100866 nullptr, nullptr, nullptr, destroy_packet_popup_image);
100867 }
100868 BV_CLR_ALL(fields);
100869
100870 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
100871 old = fc_malloc(sizeof(*old));
100872 /* temporary bitcopy just to insert correctly */
100873 *old = *real_packet;
100874 genhash_insert(*hash, old, old);
100875 init_packet_popup_image(old);
100876 }
100877
100878 differ = (strcmp(old->tag, real_packet->tag) != 0);
100879 if (differ) {
100880 BV_SET(fields, 0);
100881 }
100882#endif /* FREECIV_DELTA_PROTOCOL */
100883
100884#ifdef FREECIV_JSON_CONNECTION
100885 struct plocation field_addr;
100886 {
100887 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100888 field_addr = *field_addr_tmp;
100889 FC_FREE(field_addr_tmp);
100890 }
100891#endif /* FREECIV_JSON_CONNECTION */
100892
100893#ifdef FREECIV_DELTA_PROTOCOL
100894#ifdef FREECIV_JSON_CONNECTION
100895 field_addr.name = "fields";
100896#endif /* FREECIV_JSON_CONNECTION */
100897 e = 0;
100898 e |= DIO_BV_PUT(&dout, &field_addr, fields);
100899 if (e) {
100900 log_packet_detailed("fields bitvector error detected");
100901 }
100902
100903 if (BV_ISSET(fields, 0)) {
100904 log_packet_detailed(" field 'tag' has changed");
100905
100906#ifdef FREECIV_JSON_CONNECTION
100907 field_addr.name = "tag";
100908#endif /* FREECIV_JSON_CONNECTION */
100909 e = 0;
100910
100911 e |= DIO_PUT(string, &dout, &field_addr, real_packet->tag);
100912
100913 if (e) {
100914 log_packet_detailed("'tag' field error detected");
100915 }
100916 }
100917
100918 *old = *real_packet;
100919
100920#else /* FREECIV_DELTA_PROTOCOL */
100921#ifdef FREECIV_JSON_CONNECTION
100922 field_addr.name = "tag";
100923#endif /* FREECIV_JSON_CONNECTION */
100924 e = 0;
100925
100926 e |= DIO_PUT(string, &dout, &field_addr, real_packet->tag);
100927
100928 if (e) {
100929 log_packet_detailed("'tag' field error detected");
100930 }
100931#endif /* FREECIV_DELTA_PROTOCOL */
100932
100933 SEND_PACKET_END(PACKET_POPUP_IMAGE);
100934}
100935
100936 int send_packet_popup_image(struct connection *pc, const struct packet_popup_image *packet)
100937{
100938 if (!pc->used) {
100939 log_error("WARNING: trying to send data to the closed connection %s",
100940 conn_description(pc));
100941 return -1;
100942 }
100943 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_POPUP_IMAGE].packet != nullptr, -1,
100944 "Handler for PACKET_POPUP_IMAGE not installed");
100945 return pc->phs.handlers->send[PACKET_POPUP_IMAGE].packet(pc, packet);
100946}
100947
100948 void lsend_packet_popup_image(struct conn_list *dest, const struct packet_popup_image *packet)
100949{
100950 conn_list_iterate(dest, pconn) {
100951 send_packet_popup_image(pconn, packet);
100952 } conn_list_iterate_end;
100953}
100954
100955 static inline void init_packet_web_city_info_addition(struct packet_web_city_info_addition *packet)
100956{
100957 memset(packet, 0, sizeof(*packet));
100958}
100959
100960#define free_packet_web_city_info_addition(_packet) (void) 0
100961#define destroy_packet_web_city_info_addition free
100962
100963#ifdef FREECIV_DELTA_PROTOCOL
100964static genhash_val_t hash_packet_web_city_info_addition_100(const void *vkey)
100965{
100966 const struct packet_web_city_info_addition *key = (const struct packet_web_city_info_addition *) vkey;
100967 genhash_val_t result = 0;
100968
100969 result += key->id;
100970
100971 result &= 0xFFFFFFFF;
100972 return result;
100973}
100974
100975static bool cmp_packet_web_city_info_addition_100(const void *vkey1, const void *vkey2)
100976{
100977 const struct packet_web_city_info_addition *old = (const struct packet_web_city_info_addition *) vkey1;
100978 const struct packet_web_city_info_addition *real_packet = (const struct packet_web_city_info_addition *) vkey2;
100979 bool differ;
100980
100981 differ = (old->id != real_packet->id);
100982
100983 return !differ;
100984}
100985 BV_DEFINE(packet_web_city_info_addition_100_fields, 9);
100986#endif /* FREECIV_DELTA_PROTOCOL */
100987
100988 static struct packet_web_city_info_addition *receive_packet_web_city_info_addition_100(struct connection *pc)
100989{
100990#define FREE_PACKET_STRUCT(_packet) free_packet_web_city_info_addition(_packet)
100991 RECEIVE_PACKET_START(packet_web_city_info_addition, real_packet);
100992
100993#ifdef FREECIV_JSON_CONNECTION
100994 struct plocation field_addr;
100995 {
100996 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
100997 field_addr = *field_addr_tmp;
100998 FC_FREE(field_addr_tmp);
100999 }
101000#endif /* FREECIV_JSON_CONNECTION */
101001
101002#ifdef FREECIV_JSON_CONNECTION
101003 field_addr.name = "id";
101004#endif /* FREECIV_JSON_CONNECTION */
101005
101006 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
101007 RECEIVE_PACKET_FIELD_ERROR(id);
101008 }
101009
101010 log_packet_detailed("packet_web_city_info_addition_100: got info about (%d)",
101011 real_packet->id);
101012
101013#ifdef FREECIV_DELTA_PROTOCOL
101014 packet_web_city_info_addition_100_fields fields;
101015 struct packet_web_city_info_addition *old;
101016 struct genhash **hash = pc->phs.received + PACKET_WEB_CITY_INFO_ADDITION;
101017
101018 if (nullptr == *hash) {
101019 *hash = genhash_new_full(hash_packet_web_city_info_addition_100, cmp_packet_web_city_info_addition_100,
101020 nullptr, nullptr, nullptr, destroy_packet_web_city_info_addition);
101021 }
101022
101023 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
101024 *real_packet = *old;
101025 } else {
101026 /* packet is already initialized empty */
101027 log_packet_detailed(" no old info");
101028 }
101029
101030#ifdef FREECIV_JSON_CONNECTION
101031 field_addr.name = "fields";
101032#endif /* FREECIV_JSON_CONNECTION */
101033 DIO_BV_GET(&din, &field_addr, fields);
101034
101035 real_packet->cma_enabled = BV_ISSET(fields, 0);
101036
101037 if (BV_ISSET(fields, 1)) {
101038 log_packet_detailed(" got field 'cm_parameter'");
101039
101040#ifdef FREECIV_JSON_CONNECTION
101041 field_addr.name = "cm_parameter";
101042#endif /* FREECIV_JSON_CONNECTION */
101043
101044 if (!DIO_GET(cm_parameter, &din, &field_addr, &real_packet->cm_parameter)) {
101045 RECEIVE_PACKET_FIELD_ERROR(cm_parameter);
101046 }
101047 }
101048
101049 if (BV_ISSET(fields, 2)) {
101050 log_packet_detailed(" got field 'granary_size'");
101051
101052#ifdef FREECIV_JSON_CONNECTION
101053 field_addr.name = "granary_size";
101054#endif /* FREECIV_JSON_CONNECTION */
101055
101056 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granary_size)) {
101057 RECEIVE_PACKET_FIELD_ERROR(granary_size);
101058 }
101059 }
101060
101061 if (BV_ISSET(fields, 3)) {
101062 log_packet_detailed(" got field 'granary_turns'");
101063
101064#ifdef FREECIV_JSON_CONNECTION
101065 field_addr.name = "granary_turns";
101066#endif /* FREECIV_JSON_CONNECTION */
101067
101068 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->granary_turns)) {
101069 RECEIVE_PACKET_FIELD_ERROR(granary_turns);
101070 }
101071 }
101072
101073 if (BV_ISSET(fields, 4)) {
101074 log_packet_detailed(" got field 'can_build_unit'");
101075
101076#ifdef FREECIV_JSON_CONNECTION
101077 field_addr.name = "can_build_unit";
101078#endif /* FREECIV_JSON_CONNECTION */
101079
101080 if (!DIO_BV_GET(&din, &field_addr, real_packet->can_build_unit)) {
101081 RECEIVE_PACKET_FIELD_ERROR(can_build_unit);
101082 }
101083 }
101084
101085 if (BV_ISSET(fields, 5)) {
101086 log_packet_detailed(" got field 'can_build_improvement'");
101087
101088#ifdef FREECIV_JSON_CONNECTION
101089 field_addr.name = "can_build_improvement";
101090#endif /* FREECIV_JSON_CONNECTION */
101091
101092 if (!DIO_BV_GET(&din, &field_addr, real_packet->can_build_improvement)) {
101093 RECEIVE_PACKET_FIELD_ERROR(can_build_improvement);
101094 }
101095 }
101096
101097 if (BV_ISSET(fields, 6)) {
101098 log_packet_detailed(" got field 'output_food'");
101099
101100#ifdef FREECIV_JSON_CONNECTION
101101 field_addr.name = "output_food";
101102#endif /* FREECIV_JSON_CONNECTION */
101103
101104 {
101105 int i;
101106
101107
101108#ifdef FREECIV_JSON_CONNECTION
101109 /* Enter array. */
101110 field_addr.sub_location = plocation_elem_new(0);
101111#endif /* FREECIV_JSON_CONNECTION */
101112
101113 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101114#ifdef FREECIV_JSON_CONNECTION
101115 /* Next array element */
101116 field_addr.sub_location->number = i;
101117#endif /* FREECIV_JSON_CONNECTION */
101118
101119 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output_food[i])) {
101120 RECEIVE_PACKET_FIELD_ERROR(output_food);
101121 }
101122 }
101123
101124#ifdef FREECIV_JSON_CONNECTION
101125 /* Exit array. */
101126 FC_FREE(field_addr.sub_location);
101127#endif /* FREECIV_JSON_CONNECTION */
101128 }
101129 }
101130
101131 if (BV_ISSET(fields, 7)) {
101132 log_packet_detailed(" got field 'output_shield'");
101133
101134#ifdef FREECIV_JSON_CONNECTION
101135 field_addr.name = "output_shield";
101136#endif /* FREECIV_JSON_CONNECTION */
101137
101138 {
101139 int i;
101140
101141
101142#ifdef FREECIV_JSON_CONNECTION
101143 /* Enter array. */
101144 field_addr.sub_location = plocation_elem_new(0);
101145#endif /* FREECIV_JSON_CONNECTION */
101146
101147 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101148#ifdef FREECIV_JSON_CONNECTION
101149 /* Next array element */
101150 field_addr.sub_location->number = i;
101151#endif /* FREECIV_JSON_CONNECTION */
101152
101153 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output_shield[i])) {
101154 RECEIVE_PACKET_FIELD_ERROR(output_shield);
101155 }
101156 }
101157
101158#ifdef FREECIV_JSON_CONNECTION
101159 /* Exit array. */
101160 FC_FREE(field_addr.sub_location);
101161#endif /* FREECIV_JSON_CONNECTION */
101162 }
101163 }
101164
101165 if (BV_ISSET(fields, 8)) {
101166 log_packet_detailed(" got field 'output_trade'");
101167
101168#ifdef FREECIV_JSON_CONNECTION
101169 field_addr.name = "output_trade";
101170#endif /* FREECIV_JSON_CONNECTION */
101171
101172 {
101173 int i;
101174
101175
101176#ifdef FREECIV_JSON_CONNECTION
101177 /* Enter array. */
101178 field_addr.sub_location = plocation_elem_new(0);
101179#endif /* FREECIV_JSON_CONNECTION */
101180
101181 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101182#ifdef FREECIV_JSON_CONNECTION
101183 /* Next array element */
101184 field_addr.sub_location->number = i;
101185#endif /* FREECIV_JSON_CONNECTION */
101186
101187 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output_trade[i])) {
101188 RECEIVE_PACKET_FIELD_ERROR(output_trade);
101189 }
101190 }
101191
101192#ifdef FREECIV_JSON_CONNECTION
101193 /* Exit array. */
101194 FC_FREE(field_addr.sub_location);
101195#endif /* FREECIV_JSON_CONNECTION */
101196 }
101197 }
101198
101199 if (nullptr == old) {
101200 old = fc_malloc(sizeof(*old));
101201 init_packet_web_city_info_addition(old);
101202 *old = *real_packet;
101203 genhash_insert(*hash, old, old);
101204 } else {
101205 *old = *real_packet;
101206 }
101207
101208 hash = pc->phs.received + PACKET_CITY_SHORT_INFO;
101209 if (nullptr != *hash) {
101210 genhash_remove(*hash, real_packet);
101211 }
101212
101213#else /* FREECIV_DELTA_PROTOCOL */
101214#ifdef FREECIV_JSON_CONNECTION
101215 field_addr.name = "cma_enabled";
101216#endif /* FREECIV_JSON_CONNECTION */
101217
101218 if (!DIO_GET(bool8, &din, &field_addr, &real_packet->cma_enabled)) {
101219 RECEIVE_PACKET_FIELD_ERROR(cma_enabled);
101220 }
101221
101222#ifdef FREECIV_JSON_CONNECTION
101223 field_addr.name = "cm_parameter";
101224#endif /* FREECIV_JSON_CONNECTION */
101225
101226 if (!DIO_GET(cm_parameter, &din, &field_addr, &real_packet->cm_parameter)) {
101227 RECEIVE_PACKET_FIELD_ERROR(cm_parameter);
101228 }
101229
101230#ifdef FREECIV_JSON_CONNECTION
101231 field_addr.name = "granary_size";
101232#endif /* FREECIV_JSON_CONNECTION */
101233
101234 if (!DIO_GET(uint16, &din, &field_addr, &real_packet->granary_size)) {
101235 RECEIVE_PACKET_FIELD_ERROR(granary_size);
101236 }
101237
101238#ifdef FREECIV_JSON_CONNECTION
101239 field_addr.name = "granary_turns";
101240#endif /* FREECIV_JSON_CONNECTION */
101241
101242 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->granary_turns)) {
101243 RECEIVE_PACKET_FIELD_ERROR(granary_turns);
101244 }
101245
101246#ifdef FREECIV_JSON_CONNECTION
101247 field_addr.name = "can_build_unit";
101248#endif /* FREECIV_JSON_CONNECTION */
101249
101250 if (!DIO_BV_GET(&din, &field_addr, real_packet->can_build_unit)) {
101251 RECEIVE_PACKET_FIELD_ERROR(can_build_unit);
101252 }
101253
101254#ifdef FREECIV_JSON_CONNECTION
101255 field_addr.name = "can_build_improvement";
101256#endif /* FREECIV_JSON_CONNECTION */
101257
101258 if (!DIO_BV_GET(&din, &field_addr, real_packet->can_build_improvement)) {
101259 RECEIVE_PACKET_FIELD_ERROR(can_build_improvement);
101260 }
101261
101262#ifdef FREECIV_JSON_CONNECTION
101263 field_addr.name = "output_food";
101264#endif /* FREECIV_JSON_CONNECTION */
101265
101266 {
101267 int i;
101268
101269
101270#ifdef FREECIV_JSON_CONNECTION
101271 /* Enter array. */
101272 field_addr.sub_location = plocation_elem_new(0);
101273#endif /* FREECIV_JSON_CONNECTION */
101274
101275 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101276#ifdef FREECIV_JSON_CONNECTION
101277 /* Next array element */
101278 field_addr.sub_location->number = i;
101279#endif /* FREECIV_JSON_CONNECTION */
101280
101281 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output_food[i])) {
101282 RECEIVE_PACKET_FIELD_ERROR(output_food);
101283 }
101284 }
101285
101286#ifdef FREECIV_JSON_CONNECTION
101287 /* Exit array. */
101288 FC_FREE(field_addr.sub_location);
101289#endif /* FREECIV_JSON_CONNECTION */
101290 }
101291
101292#ifdef FREECIV_JSON_CONNECTION
101293 field_addr.name = "output_shield";
101294#endif /* FREECIV_JSON_CONNECTION */
101295
101296 {
101297 int i;
101298
101299
101300#ifdef FREECIV_JSON_CONNECTION
101301 /* Enter array. */
101302 field_addr.sub_location = plocation_elem_new(0);
101303#endif /* FREECIV_JSON_CONNECTION */
101304
101305 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101306#ifdef FREECIV_JSON_CONNECTION
101307 /* Next array element */
101308 field_addr.sub_location->number = i;
101309#endif /* FREECIV_JSON_CONNECTION */
101310
101311 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output_shield[i])) {
101312 RECEIVE_PACKET_FIELD_ERROR(output_shield);
101313 }
101314 }
101315
101316#ifdef FREECIV_JSON_CONNECTION
101317 /* Exit array. */
101318 FC_FREE(field_addr.sub_location);
101319#endif /* FREECIV_JSON_CONNECTION */
101320 }
101321
101322#ifdef FREECIV_JSON_CONNECTION
101323 field_addr.name = "output_trade";
101324#endif /* FREECIV_JSON_CONNECTION */
101325
101326 {
101327 int i;
101328
101329
101330#ifdef FREECIV_JSON_CONNECTION
101331 /* Enter array. */
101332 field_addr.sub_location = plocation_elem_new(0);
101333#endif /* FREECIV_JSON_CONNECTION */
101334
101335 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101336#ifdef FREECIV_JSON_CONNECTION
101337 /* Next array element */
101338 field_addr.sub_location->number = i;
101339#endif /* FREECIV_JSON_CONNECTION */
101340
101341 if (!DIO_GET(uint8, &din, &field_addr, &real_packet->output_trade[i])) {
101342 RECEIVE_PACKET_FIELD_ERROR(output_trade);
101343 }
101344 }
101345
101346#ifdef FREECIV_JSON_CONNECTION
101347 /* Exit array. */
101348 FC_FREE(field_addr.sub_location);
101349#endif /* FREECIV_JSON_CONNECTION */
101350 }
101351#endif /* FREECIV_DELTA_PROTOCOL */
101352
101353 RECEIVE_PACKET_END(real_packet);
101354#undef FREE_PACKET_STRUCT
101355}
101356
101357 static int send_packet_web_city_info_addition_100(struct connection *pc, const struct packet_web_city_info_addition *packet, bool force_to_send)
101358{
101359 const struct packet_web_city_info_addition *real_packet = packet;
101360 int e;
101361 SEND_PACKET_START(PACKET_WEB_CITY_INFO_ADDITION);
101362
101363 log_packet_detailed("packet_web_city_info_addition_100: sending info about (%d)",
101364 real_packet->id);
101365
101366#ifdef FREECIV_DELTA_PROTOCOL
101367 packet_web_city_info_addition_100_fields fields;
101368 struct packet_web_city_info_addition *old;
101369 bool differ;
101370 int different = force_to_send;
101371 struct genhash **hash = pc->phs.sent + PACKET_WEB_CITY_INFO_ADDITION;
101372
101373 if (nullptr == *hash) {
101374 *hash = genhash_new_full(hash_packet_web_city_info_addition_100, cmp_packet_web_city_info_addition_100,
101375 nullptr, nullptr, nullptr, destroy_packet_web_city_info_addition);
101376 }
101377 BV_CLR_ALL(fields);
101378
101379 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
101380 old = fc_malloc(sizeof(*old));
101381 /* temporary bitcopy just to insert correctly */
101382 *old = *real_packet;
101383 genhash_insert(*hash, old, old);
101384 init_packet_web_city_info_addition(old);
101385 different = 1; /* Force to send. */
101386 }
101387
101388 differ = (old->cma_enabled != real_packet->cma_enabled);
101389 if (differ) {
101390 different++;
101391 }
101392 /* folded into head */
101393 if (real_packet->cma_enabled) {
101394 BV_SET(fields, 0);
101395 }
101396
101397 differ = !cm_are_parameter_equal(&old->cm_parameter, &real_packet->cm_parameter);
101398 if (differ) {
101399 different++;
101400 BV_SET(fields, 1);
101401 }
101402
101403 differ = (old->granary_size != real_packet->granary_size);
101404 if (differ) {
101405 different++;
101406 BV_SET(fields, 2);
101407 }
101408
101409 differ = (old->granary_turns != real_packet->granary_turns);
101410 if (differ) {
101411 different++;
101412 BV_SET(fields, 3);
101413 }
101414
101415 differ = !BV_ARE_EQUAL(old->can_build_unit, real_packet->can_build_unit);
101416 if (differ) {
101417 different++;
101418 BV_SET(fields, 4);
101419 }
101420
101421 differ = !BV_ARE_EQUAL(old->can_build_improvement, real_packet->can_build_improvement);
101422 if (differ) {
101423 different++;
101424 BV_SET(fields, 5);
101425 }
101426
101427 differ = FALSE;
101428 {
101429 int i;
101430
101431 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101432 differ = (old->output_food[i] != real_packet->output_food[i]);
101433 if (differ) {
101434 break;
101435 }
101436 }
101437 }
101438 if (differ) {
101439 different++;
101440 BV_SET(fields, 6);
101441 }
101442
101443 differ = FALSE;
101444 {
101445 int i;
101446
101447 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101448 differ = (old->output_shield[i] != real_packet->output_shield[i]);
101449 if (differ) {
101450 break;
101451 }
101452 }
101453 }
101454 if (differ) {
101455 different++;
101456 BV_SET(fields, 7);
101457 }
101458
101459 differ = FALSE;
101460 {
101461 int i;
101462
101463 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101464 differ = (old->output_trade[i] != real_packet->output_trade[i]);
101465 if (differ) {
101466 break;
101467 }
101468 }
101469 }
101470 if (differ) {
101471 different++;
101472 BV_SET(fields, 8);
101473 }
101474
101475 if (different == 0) {
101476 log_packet_detailed(" no change -> discard");
101477 SEND_PACKET_DISCARD();
101478 }
101479#endif /* FREECIV_DELTA_PROTOCOL */
101480
101481#ifdef FREECIV_JSON_CONNECTION
101482 struct plocation field_addr;
101483 {
101484 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
101485 field_addr = *field_addr_tmp;
101486 FC_FREE(field_addr_tmp);
101487 }
101488#endif /* FREECIV_JSON_CONNECTION */
101489
101490#ifdef FREECIV_JSON_CONNECTION
101491 field_addr.name = "id";
101492#endif /* FREECIV_JSON_CONNECTION */
101493 e = 0;
101494
101495 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
101496
101497 if (e) {
101498 log_packet_detailed("'id' field error detected");
101499 }
101500
101501#ifdef FREECIV_DELTA_PROTOCOL
101502#ifdef FREECIV_JSON_CONNECTION
101503 field_addr.name = "fields";
101504#endif /* FREECIV_JSON_CONNECTION */
101505 e = 0;
101506 e |= DIO_BV_PUT(&dout, &field_addr, fields);
101507 if (e) {
101508 log_packet_detailed("fields bitvector error detected");
101509 }
101510
101511 /* field 0 is folded into the header */
101512
101513 if (BV_ISSET(fields, 1)) {
101514 log_packet_detailed(" field 'cm_parameter' has changed");
101515
101516#ifdef FREECIV_JSON_CONNECTION
101517 field_addr.name = "cm_parameter";
101518#endif /* FREECIV_JSON_CONNECTION */
101519 e = 0;
101520
101521 e |= DIO_PUT(cm_parameter, &dout, &field_addr, &real_packet->cm_parameter);
101522
101523 if (e) {
101524 log_packet_detailed("'cm_parameter' field error detected");
101525 }
101526 }
101527
101528 if (BV_ISSET(fields, 2)) {
101529 log_packet_detailed(" field 'granary_size' has changed");
101530
101531#ifdef FREECIV_JSON_CONNECTION
101532 field_addr.name = "granary_size";
101533#endif /* FREECIV_JSON_CONNECTION */
101534 e = 0;
101535
101536 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granary_size);
101537
101538 if (e) {
101539 log_packet_detailed("'granary_size' field error detected");
101540 }
101541 }
101542
101543 if (BV_ISSET(fields, 3)) {
101544 log_packet_detailed(" field 'granary_turns' has changed");
101545
101546#ifdef FREECIV_JSON_CONNECTION
101547 field_addr.name = "granary_turns";
101548#endif /* FREECIV_JSON_CONNECTION */
101549 e = 0;
101550
101551 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->granary_turns);
101552
101553 if (e) {
101554 log_packet_detailed("'granary_turns' field error detected");
101555 }
101556 }
101557
101558 if (BV_ISSET(fields, 4)) {
101559 log_packet_detailed(" field 'can_build_unit' has changed");
101560
101561#ifdef FREECIV_JSON_CONNECTION
101562 field_addr.name = "can_build_unit";
101563#endif /* FREECIV_JSON_CONNECTION */
101564 e = 0;
101565
101566 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->can_build_unit);
101567
101568 if (e) {
101569 log_packet_detailed("'can_build_unit' field error detected");
101570 }
101571 }
101572
101573 if (BV_ISSET(fields, 5)) {
101574 log_packet_detailed(" field 'can_build_improvement' has changed");
101575
101576#ifdef FREECIV_JSON_CONNECTION
101577 field_addr.name = "can_build_improvement";
101578#endif /* FREECIV_JSON_CONNECTION */
101579 e = 0;
101580
101581 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->can_build_improvement);
101582
101583 if (e) {
101584 log_packet_detailed("'can_build_improvement' field error detected");
101585 }
101586 }
101587
101588 if (BV_ISSET(fields, 6)) {
101589 log_packet_detailed(" field 'output_food' has changed");
101590
101591#ifdef FREECIV_JSON_CONNECTION
101592 field_addr.name = "output_food";
101593#endif /* FREECIV_JSON_CONNECTION */
101594 e = 0;
101595
101596 {
101597 int i;
101598
101599#ifdef FREECIV_JSON_CONNECTION
101600 /* Create the array. */
101601 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CITY_TILES + 1);
101602
101603 /* Enter array. */
101604 field_addr.sub_location = plocation_elem_new(0);
101605#endif /* FREECIV_JSON_CONNECTION */
101606
101607 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101608#ifdef FREECIV_JSON_CONNECTION
101609 /* Next array element. */
101610 field_addr.sub_location->number = i;
101611#endif /* FREECIV_JSON_CONNECTION */
101612
101613 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output_food[i]);
101614 }
101615
101616#ifdef FREECIV_JSON_CONNECTION
101617 /* Exit array. */
101618 FC_FREE(field_addr.sub_location);
101619#endif /* FREECIV_JSON_CONNECTION */
101620 }
101621
101622 if (e) {
101623 log_packet_detailed("'output_food' field error detected");
101624 }
101625 }
101626
101627 if (BV_ISSET(fields, 7)) {
101628 log_packet_detailed(" field 'output_shield' has changed");
101629
101630#ifdef FREECIV_JSON_CONNECTION
101631 field_addr.name = "output_shield";
101632#endif /* FREECIV_JSON_CONNECTION */
101633 e = 0;
101634
101635 {
101636 int i;
101637
101638#ifdef FREECIV_JSON_CONNECTION
101639 /* Create the array. */
101640 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CITY_TILES + 1);
101641
101642 /* Enter array. */
101643 field_addr.sub_location = plocation_elem_new(0);
101644#endif /* FREECIV_JSON_CONNECTION */
101645
101646 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101647#ifdef FREECIV_JSON_CONNECTION
101648 /* Next array element. */
101649 field_addr.sub_location->number = i;
101650#endif /* FREECIV_JSON_CONNECTION */
101651
101652 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output_shield[i]);
101653 }
101654
101655#ifdef FREECIV_JSON_CONNECTION
101656 /* Exit array. */
101657 FC_FREE(field_addr.sub_location);
101658#endif /* FREECIV_JSON_CONNECTION */
101659 }
101660
101661 if (e) {
101662 log_packet_detailed("'output_shield' field error detected");
101663 }
101664 }
101665
101666 if (BV_ISSET(fields, 8)) {
101667 log_packet_detailed(" field 'output_trade' has changed");
101668
101669#ifdef FREECIV_JSON_CONNECTION
101670 field_addr.name = "output_trade";
101671#endif /* FREECIV_JSON_CONNECTION */
101672 e = 0;
101673
101674 {
101675 int i;
101676
101677#ifdef FREECIV_JSON_CONNECTION
101678 /* Create the array. */
101679 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CITY_TILES + 1);
101680
101681 /* Enter array. */
101682 field_addr.sub_location = plocation_elem_new(0);
101683#endif /* FREECIV_JSON_CONNECTION */
101684
101685 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101686#ifdef FREECIV_JSON_CONNECTION
101687 /* Next array element. */
101688 field_addr.sub_location->number = i;
101689#endif /* FREECIV_JSON_CONNECTION */
101690
101691 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output_trade[i]);
101692 }
101693
101694#ifdef FREECIV_JSON_CONNECTION
101695 /* Exit array. */
101696 FC_FREE(field_addr.sub_location);
101697#endif /* FREECIV_JSON_CONNECTION */
101698 }
101699
101700 if (e) {
101701 log_packet_detailed("'output_trade' field error detected");
101702 }
101703 }
101704
101705 *old = *real_packet;
101706
101707 hash = pc->phs.sent + PACKET_CITY_SHORT_INFO;
101708 if (nullptr != *hash) {
101709 genhash_remove(*hash, real_packet);
101710 }
101711
101712#else /* FREECIV_DELTA_PROTOCOL */
101713#ifdef FREECIV_JSON_CONNECTION
101714 field_addr.name = "cma_enabled";
101715#endif /* FREECIV_JSON_CONNECTION */
101716 e = 0;
101717
101718 e |= DIO_PUT(bool8, &dout, &field_addr, real_packet->cma_enabled);
101719
101720 if (e) {
101721 log_packet_detailed("'cma_enabled' field error detected");
101722 }
101723
101724#ifdef FREECIV_JSON_CONNECTION
101725 field_addr.name = "cm_parameter";
101726#endif /* FREECIV_JSON_CONNECTION */
101727 e = 0;
101728
101729 e |= DIO_PUT(cm_parameter, &dout, &field_addr, &real_packet->cm_parameter);
101730
101731 if (e) {
101732 log_packet_detailed("'cm_parameter' field error detected");
101733 }
101734
101735#ifdef FREECIV_JSON_CONNECTION
101736 field_addr.name = "granary_size";
101737#endif /* FREECIV_JSON_CONNECTION */
101738 e = 0;
101739
101740 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->granary_size);
101741
101742 if (e) {
101743 log_packet_detailed("'granary_size' field error detected");
101744 }
101745
101746#ifdef FREECIV_JSON_CONNECTION
101747 field_addr.name = "granary_turns";
101748#endif /* FREECIV_JSON_CONNECTION */
101749 e = 0;
101750
101751 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->granary_turns);
101752
101753 if (e) {
101754 log_packet_detailed("'granary_turns' field error detected");
101755 }
101756
101757#ifdef FREECIV_JSON_CONNECTION
101758 field_addr.name = "can_build_unit";
101759#endif /* FREECIV_JSON_CONNECTION */
101760 e = 0;
101761
101762 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->can_build_unit);
101763
101764 if (e) {
101765 log_packet_detailed("'can_build_unit' field error detected");
101766 }
101767
101768#ifdef FREECIV_JSON_CONNECTION
101769 field_addr.name = "can_build_improvement";
101770#endif /* FREECIV_JSON_CONNECTION */
101771 e = 0;
101772
101773 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->can_build_improvement);
101774
101775 if (e) {
101776 log_packet_detailed("'can_build_improvement' field error detected");
101777 }
101778
101779#ifdef FREECIV_JSON_CONNECTION
101780 field_addr.name = "output_food";
101781#endif /* FREECIV_JSON_CONNECTION */
101782 e = 0;
101783
101784 {
101785 int i;
101786
101787#ifdef FREECIV_JSON_CONNECTION
101788 /* Create the array. */
101789 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CITY_TILES + 1);
101790
101791 /* Enter array. */
101792 field_addr.sub_location = plocation_elem_new(0);
101793#endif /* FREECIV_JSON_CONNECTION */
101794
101795 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101796#ifdef FREECIV_JSON_CONNECTION
101797 /* Next array element. */
101798 field_addr.sub_location->number = i;
101799#endif /* FREECIV_JSON_CONNECTION */
101800
101801 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output_food[i]);
101802 }
101803
101804#ifdef FREECIV_JSON_CONNECTION
101805 /* Exit array. */
101806 FC_FREE(field_addr.sub_location);
101807#endif /* FREECIV_JSON_CONNECTION */
101808 }
101809
101810 if (e) {
101811 log_packet_detailed("'output_food' field error detected");
101812 }
101813
101814#ifdef FREECIV_JSON_CONNECTION
101815 field_addr.name = "output_shield";
101816#endif /* FREECIV_JSON_CONNECTION */
101817 e = 0;
101818
101819 {
101820 int i;
101821
101822#ifdef FREECIV_JSON_CONNECTION
101823 /* Create the array. */
101824 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CITY_TILES + 1);
101825
101826 /* Enter array. */
101827 field_addr.sub_location = plocation_elem_new(0);
101828#endif /* FREECIV_JSON_CONNECTION */
101829
101830 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101831#ifdef FREECIV_JSON_CONNECTION
101832 /* Next array element. */
101833 field_addr.sub_location->number = i;
101834#endif /* FREECIV_JSON_CONNECTION */
101835
101836 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output_shield[i]);
101837 }
101838
101839#ifdef FREECIV_JSON_CONNECTION
101840 /* Exit array. */
101841 FC_FREE(field_addr.sub_location);
101842#endif /* FREECIV_JSON_CONNECTION */
101843 }
101844
101845 if (e) {
101846 log_packet_detailed("'output_shield' field error detected");
101847 }
101848
101849#ifdef FREECIV_JSON_CONNECTION
101850 field_addr.name = "output_trade";
101851#endif /* FREECIV_JSON_CONNECTION */
101852 e = 0;
101853
101854 {
101855 int i;
101856
101857#ifdef FREECIV_JSON_CONNECTION
101858 /* Create the array. */
101859 e |= DIO_PUT(farray, &dout, &field_addr, MAX_CITY_TILES + 1);
101860
101861 /* Enter array. */
101862 field_addr.sub_location = plocation_elem_new(0);
101863#endif /* FREECIV_JSON_CONNECTION */
101864
101865 for (i = 0; i < MAX_CITY_TILES + 1; i++) {
101866#ifdef FREECIV_JSON_CONNECTION
101867 /* Next array element. */
101868 field_addr.sub_location->number = i;
101869#endif /* FREECIV_JSON_CONNECTION */
101870
101871 e |= DIO_PUT(uint8, &dout, &field_addr, real_packet->output_trade[i]);
101872 }
101873
101874#ifdef FREECIV_JSON_CONNECTION
101875 /* Exit array. */
101876 FC_FREE(field_addr.sub_location);
101877#endif /* FREECIV_JSON_CONNECTION */
101878 }
101879
101880 if (e) {
101881 log_packet_detailed("'output_trade' field error detected");
101882 }
101883#endif /* FREECIV_DELTA_PROTOCOL */
101884
101885 SEND_PACKET_END(PACKET_WEB_CITY_INFO_ADDITION);
101886}
101887
101888 int send_packet_web_city_info_addition(struct connection *pc, const struct packet_web_city_info_addition *packet, bool force_to_send)
101889{
101890 if (!pc->used) {
101891 log_error("WARNING: trying to send data to the closed connection %s",
101892 conn_description(pc));
101893 return -1;
101894 }
101895 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WEB_CITY_INFO_ADDITION].force_to_send != nullptr, -1,
101896 "Handler for PACKET_WEB_CITY_INFO_ADDITION not installed");
101897 return pc->phs.handlers->send[PACKET_WEB_CITY_INFO_ADDITION].force_to_send(pc, packet, force_to_send);
101898}
101899
101900 void lsend_packet_web_city_info_addition(struct conn_list *dest, const struct packet_web_city_info_addition *packet, bool force_to_send)
101901{
101902 conn_list_iterate(dest, pconn) {
101903 send_packet_web_city_info_addition(pconn, packet, force_to_send);
101904 } conn_list_iterate_end;
101905}
101906
101907 static inline void init_packet_web_cma_set(struct packet_web_cma_set *packet)
101908{
101909 memset(packet, 0, sizeof(*packet));
101910}
101911
101912#define free_packet_web_cma_set(_packet) (void) 0
101913#define destroy_packet_web_cma_set free
101914
101915#ifdef FREECIV_DELTA_PROTOCOL
101916static genhash_val_t hash_packet_web_cma_set_100(const void *vkey)
101917{
101918 const struct packet_web_cma_set *key = (const struct packet_web_cma_set *) vkey;
101919 genhash_val_t result = 0;
101920
101921 result += key->id;
101922
101923 result &= 0xFFFFFFFF;
101924 return result;
101925}
101926
101927static bool cmp_packet_web_cma_set_100(const void *vkey1, const void *vkey2)
101928{
101929 const struct packet_web_cma_set *old = (const struct packet_web_cma_set *) vkey1;
101930 const struct packet_web_cma_set *real_packet = (const struct packet_web_cma_set *) vkey2;
101931 bool differ;
101932
101933 differ = (old->id != real_packet->id);
101934
101935 return !differ;
101936}
101937 BV_DEFINE(packet_web_cma_set_100_fields, 1);
101938#endif /* FREECIV_DELTA_PROTOCOL */
101939
101940 static struct packet_web_cma_set *receive_packet_web_cma_set_100(struct connection *pc)
101941{
101942#define FREE_PACKET_STRUCT(_packet) free_packet_web_cma_set(_packet)
101943 RECEIVE_PACKET_START(packet_web_cma_set, real_packet);
101944
101945#ifdef FREECIV_JSON_CONNECTION
101946 struct plocation field_addr;
101947 {
101948 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
101949 field_addr = *field_addr_tmp;
101950 FC_FREE(field_addr_tmp);
101951 }
101952#endif /* FREECIV_JSON_CONNECTION */
101953
101954#ifdef FREECIV_JSON_CONNECTION
101955 field_addr.name = "id";
101956#endif /* FREECIV_JSON_CONNECTION */
101957
101958 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
101959 RECEIVE_PACKET_FIELD_ERROR(id);
101960 }
101961
101962 log_packet_detailed("packet_web_cma_set_100: got info about (%d)",
101963 real_packet->id);
101964
101965#ifdef FREECIV_DELTA_PROTOCOL
101966 packet_web_cma_set_100_fields fields;
101967 struct packet_web_cma_set *old;
101968 struct genhash **hash = pc->phs.received + PACKET_WEB_CMA_SET;
101969
101970 if (nullptr == *hash) {
101971 *hash = genhash_new_full(hash_packet_web_cma_set_100, cmp_packet_web_cma_set_100,
101972 nullptr, nullptr, nullptr, destroy_packet_web_cma_set);
101973 }
101974
101975 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
101976 *real_packet = *old;
101977 } else {
101978 /* packet is already initialized empty */
101979 log_packet_detailed(" no old info");
101980 }
101981
101982#ifdef FREECIV_JSON_CONNECTION
101983 field_addr.name = "fields";
101984#endif /* FREECIV_JSON_CONNECTION */
101985 DIO_BV_GET(&din, &field_addr, fields);
101986
101987 if (BV_ISSET(fields, 0)) {
101988 log_packet_detailed(" got field 'cm_parameter'");
101989
101990#ifdef FREECIV_JSON_CONNECTION
101991 field_addr.name = "cm_parameter";
101992#endif /* FREECIV_JSON_CONNECTION */
101993
101994 if (!DIO_GET(cm_parameter, &din, &field_addr, &real_packet->cm_parameter)) {
101995 RECEIVE_PACKET_FIELD_ERROR(cm_parameter);
101996 }
101997 }
101998
101999 if (nullptr == old) {
102000 old = fc_malloc(sizeof(*old));
102001 init_packet_web_cma_set(old);
102002 *old = *real_packet;
102003 genhash_insert(*hash, old, old);
102004 } else {
102005 *old = *real_packet;
102006 }
102007
102008#else /* FREECIV_DELTA_PROTOCOL */
102009#ifdef FREECIV_JSON_CONNECTION
102010 field_addr.name = "cm_parameter";
102011#endif /* FREECIV_JSON_CONNECTION */
102012
102013 if (!DIO_GET(cm_parameter, &din, &field_addr, &real_packet->cm_parameter)) {
102014 RECEIVE_PACKET_FIELD_ERROR(cm_parameter);
102015 }
102016#endif /* FREECIV_DELTA_PROTOCOL */
102017
102018 RECEIVE_PACKET_END(real_packet);
102019#undef FREE_PACKET_STRUCT
102020}
102021
102022 static int send_packet_web_cma_set_100(struct connection *pc, const struct packet_web_cma_set *packet)
102023{
102024 const struct packet_web_cma_set *real_packet = packet;
102025 int e;
102026 SEND_PACKET_START(PACKET_WEB_CMA_SET);
102027
102028 log_packet_detailed("packet_web_cma_set_100: sending info about (%d)",
102029 real_packet->id);
102030
102031#ifdef FREECIV_DELTA_PROTOCOL
102032 packet_web_cma_set_100_fields fields;
102033 struct packet_web_cma_set *old;
102034 bool differ;
102035 struct genhash **hash = pc->phs.sent + PACKET_WEB_CMA_SET;
102036
102037 if (nullptr == *hash) {
102038 *hash = genhash_new_full(hash_packet_web_cma_set_100, cmp_packet_web_cma_set_100,
102039 nullptr, nullptr, nullptr, destroy_packet_web_cma_set);
102040 }
102041 BV_CLR_ALL(fields);
102042
102043 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
102044 old = fc_malloc(sizeof(*old));
102045 /* temporary bitcopy just to insert correctly */
102046 *old = *real_packet;
102047 genhash_insert(*hash, old, old);
102048 init_packet_web_cma_set(old);
102049 }
102050
102051 differ = !cm_are_parameter_equal(&old->cm_parameter, &real_packet->cm_parameter);
102052 if (differ) {
102053 BV_SET(fields, 0);
102054 }
102055#endif /* FREECIV_DELTA_PROTOCOL */
102056
102057#ifdef FREECIV_JSON_CONNECTION
102058 struct plocation field_addr;
102059 {
102060 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102061 field_addr = *field_addr_tmp;
102062 FC_FREE(field_addr_tmp);
102063 }
102064#endif /* FREECIV_JSON_CONNECTION */
102065
102066#ifdef FREECIV_JSON_CONNECTION
102067 field_addr.name = "id";
102068#endif /* FREECIV_JSON_CONNECTION */
102069 e = 0;
102070
102071 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
102072
102073 if (e) {
102074 log_packet_detailed("'id' field error detected");
102075 }
102076
102077#ifdef FREECIV_DELTA_PROTOCOL
102078#ifdef FREECIV_JSON_CONNECTION
102079 field_addr.name = "fields";
102080#endif /* FREECIV_JSON_CONNECTION */
102081 e = 0;
102082 e |= DIO_BV_PUT(&dout, &field_addr, fields);
102083 if (e) {
102084 log_packet_detailed("fields bitvector error detected");
102085 }
102086
102087 if (BV_ISSET(fields, 0)) {
102088 log_packet_detailed(" field 'cm_parameter' has changed");
102089
102090#ifdef FREECIV_JSON_CONNECTION
102091 field_addr.name = "cm_parameter";
102092#endif /* FREECIV_JSON_CONNECTION */
102093 e = 0;
102094
102095 e |= DIO_PUT(cm_parameter, &dout, &field_addr, &real_packet->cm_parameter);
102096
102097 if (e) {
102098 log_packet_detailed("'cm_parameter' field error detected");
102099 }
102100 }
102101
102102 *old = *real_packet;
102103
102104#else /* FREECIV_DELTA_PROTOCOL */
102105#ifdef FREECIV_JSON_CONNECTION
102106 field_addr.name = "cm_parameter";
102107#endif /* FREECIV_JSON_CONNECTION */
102108 e = 0;
102109
102110 e |= DIO_PUT(cm_parameter, &dout, &field_addr, &real_packet->cm_parameter);
102111
102112 if (e) {
102113 log_packet_detailed("'cm_parameter' field error detected");
102114 }
102115#endif /* FREECIV_DELTA_PROTOCOL */
102116
102117 SEND_PACKET_END(PACKET_WEB_CMA_SET);
102118}
102119
102120 int send_packet_web_cma_set(struct connection *pc, const struct packet_web_cma_set *packet)
102121{
102122 if (!pc->used) {
102123 log_error("WARNING: trying to send data to the closed connection %s",
102124 conn_description(pc));
102125 return -1;
102126 }
102127 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WEB_CMA_SET].packet != nullptr, -1,
102128 "Handler for PACKET_WEB_CMA_SET not installed");
102129 return pc->phs.handlers->send[PACKET_WEB_CMA_SET].packet(pc, packet);
102130}
102131
102132 static inline void init_packet_web_cma_clear(struct packet_web_cma_clear *packet)
102133{
102134 memset(packet, 0, sizeof(*packet));
102135}
102136
102137#define free_packet_web_cma_clear(_packet) (void) 0
102138#define destroy_packet_web_cma_clear free
102139
102140#ifdef FREECIV_DELTA_PROTOCOL
102141#define hash_packet_web_cma_clear_100 hash_const
102142#define cmp_packet_web_cma_clear_100 cmp_const
102143 BV_DEFINE(packet_web_cma_clear_100_fields, 1);
102144#endif /* FREECIV_DELTA_PROTOCOL */
102145
102146 static struct packet_web_cma_clear *receive_packet_web_cma_clear_100(struct connection *pc)
102147{
102148#define FREE_PACKET_STRUCT(_packet) free_packet_web_cma_clear(_packet)
102149 RECEIVE_PACKET_START(packet_web_cma_clear, real_packet);
102150
102151#ifdef FREECIV_JSON_CONNECTION
102152 struct plocation field_addr;
102153 {
102154 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102155 field_addr = *field_addr_tmp;
102156 FC_FREE(field_addr_tmp);
102157 }
102158#endif /* FREECIV_JSON_CONNECTION */
102159
102160 log_packet_detailed("packet_web_cma_clear_100: got info about ()");
102161
102162#ifdef FREECIV_DELTA_PROTOCOL
102163 packet_web_cma_clear_100_fields fields;
102164 struct packet_web_cma_clear *old;
102165 struct genhash **hash = pc->phs.received + PACKET_WEB_CMA_CLEAR;
102166
102167 if (nullptr == *hash) {
102168 *hash = genhash_new_full(hash_packet_web_cma_clear_100, cmp_packet_web_cma_clear_100,
102169 nullptr, nullptr, nullptr, destroy_packet_web_cma_clear);
102170 }
102171
102172 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
102173 *real_packet = *old;
102174 } else {
102175 /* packet is already initialized empty */
102176 log_packet_detailed(" no old info");
102177 }
102178
102179#ifdef FREECIV_JSON_CONNECTION
102180 field_addr.name = "fields";
102181#endif /* FREECIV_JSON_CONNECTION */
102182 DIO_BV_GET(&din, &field_addr, fields);
102183
102184 if (BV_ISSET(fields, 0)) {
102185 log_packet_detailed(" got field 'id'");
102186
102187#ifdef FREECIV_JSON_CONNECTION
102188 field_addr.name = "id";
102189#endif /* FREECIV_JSON_CONNECTION */
102190
102191 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
102192 RECEIVE_PACKET_FIELD_ERROR(id);
102193 }
102194 }
102195
102196 if (nullptr == old) {
102197 old = fc_malloc(sizeof(*old));
102198 init_packet_web_cma_clear(old);
102199 *old = *real_packet;
102200 genhash_insert(*hash, old, old);
102201 } else {
102202 *old = *real_packet;
102203 }
102204
102205#else /* FREECIV_DELTA_PROTOCOL */
102206#ifdef FREECIV_JSON_CONNECTION
102207 field_addr.name = "id";
102208#endif /* FREECIV_JSON_CONNECTION */
102209
102210 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->id)) {
102211 RECEIVE_PACKET_FIELD_ERROR(id);
102212 }
102213#endif /* FREECIV_DELTA_PROTOCOL */
102214
102215 RECEIVE_PACKET_END(real_packet);
102216#undef FREE_PACKET_STRUCT
102217}
102218
102219 static int send_packet_web_cma_clear_100(struct connection *pc, const struct packet_web_cma_clear *packet)
102220{
102221 const struct packet_web_cma_clear *real_packet = packet;
102222 int e;
102223 SEND_PACKET_START(PACKET_WEB_CMA_CLEAR);
102224
102225 log_packet_detailed("packet_web_cma_clear_100: sending info about ()");
102226
102227#ifdef FREECIV_DELTA_PROTOCOL
102228 packet_web_cma_clear_100_fields fields;
102229 struct packet_web_cma_clear *old;
102230 bool differ;
102231 struct genhash **hash = pc->phs.sent + PACKET_WEB_CMA_CLEAR;
102232
102233 if (nullptr == *hash) {
102234 *hash = genhash_new_full(hash_packet_web_cma_clear_100, cmp_packet_web_cma_clear_100,
102235 nullptr, nullptr, nullptr, destroy_packet_web_cma_clear);
102236 }
102237 BV_CLR_ALL(fields);
102238
102239 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
102240 old = fc_malloc(sizeof(*old));
102241 /* temporary bitcopy just to insert correctly */
102242 *old = *real_packet;
102243 genhash_insert(*hash, old, old);
102244 init_packet_web_cma_clear(old);
102245 }
102246
102247 differ = (old->id != real_packet->id);
102248 if (differ) {
102249 BV_SET(fields, 0);
102250 }
102251#endif /* FREECIV_DELTA_PROTOCOL */
102252
102253#ifdef FREECIV_JSON_CONNECTION
102254 struct plocation field_addr;
102255 {
102256 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102257 field_addr = *field_addr_tmp;
102258 FC_FREE(field_addr_tmp);
102259 }
102260#endif /* FREECIV_JSON_CONNECTION */
102261
102262#ifdef FREECIV_DELTA_PROTOCOL
102263#ifdef FREECIV_JSON_CONNECTION
102264 field_addr.name = "fields";
102265#endif /* FREECIV_JSON_CONNECTION */
102266 e = 0;
102267 e |= DIO_BV_PUT(&dout, &field_addr, fields);
102268 if (e) {
102269 log_packet_detailed("fields bitvector error detected");
102270 }
102271
102272 if (BV_ISSET(fields, 0)) {
102273 log_packet_detailed(" field 'id' has changed");
102274
102275#ifdef FREECIV_JSON_CONNECTION
102276 field_addr.name = "id";
102277#endif /* FREECIV_JSON_CONNECTION */
102278 e = 0;
102279
102280 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
102281
102282 if (e) {
102283 log_packet_detailed("'id' field error detected");
102284 }
102285 }
102286
102287 *old = *real_packet;
102288
102289#else /* FREECIV_DELTA_PROTOCOL */
102290#ifdef FREECIV_JSON_CONNECTION
102291 field_addr.name = "id";
102292#endif /* FREECIV_JSON_CONNECTION */
102293 e = 0;
102294
102295 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->id);
102296
102297 if (e) {
102298 log_packet_detailed("'id' field error detected");
102299 }
102300#endif /* FREECIV_DELTA_PROTOCOL */
102301
102302 SEND_PACKET_END(PACKET_WEB_CMA_CLEAR);
102303}
102304
102305 int send_packet_web_cma_clear(struct connection *pc, const struct packet_web_cma_clear *packet)
102306{
102307 if (!pc->used) {
102308 log_error("WARNING: trying to send data to the closed connection %s",
102309 conn_description(pc));
102310 return -1;
102311 }
102312 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WEB_CMA_CLEAR].packet != nullptr, -1,
102313 "Handler for PACKET_WEB_CMA_CLEAR not installed");
102314 return pc->phs.handlers->send[PACKET_WEB_CMA_CLEAR].packet(pc, packet);
102315}
102316
102317 static inline void init_packet_web_player_info_addition(struct packet_web_player_info_addition *packet)
102318{
102319 memset(packet, 0, sizeof(*packet));
102320}
102321
102322#define free_packet_web_player_info_addition(_packet) (void) 0
102323#define destroy_packet_web_player_info_addition free
102324
102325#ifdef FREECIV_DELTA_PROTOCOL
102326static genhash_val_t hash_packet_web_player_info_addition_100(const void *vkey)
102327{
102328 const struct packet_web_player_info_addition *key = (const struct packet_web_player_info_addition *) vkey;
102329 genhash_val_t result = 0;
102330
102331 result += key->playerno;
102332
102333 result &= 0xFFFFFFFF;
102334 return result;
102335}
102336
102337static bool cmp_packet_web_player_info_addition_100(const void *vkey1, const void *vkey2)
102338{
102339 const struct packet_web_player_info_addition *old = (const struct packet_web_player_info_addition *) vkey1;
102340 const struct packet_web_player_info_addition *real_packet = (const struct packet_web_player_info_addition *) vkey2;
102341 bool differ;
102342
102343 differ = (old->playerno != real_packet->playerno);
102344
102345 return !differ;
102346}
102347 BV_DEFINE(packet_web_player_info_addition_100_fields, 1);
102348#endif /* FREECIV_DELTA_PROTOCOL */
102349
102350 static struct packet_web_player_info_addition *receive_packet_web_player_info_addition_100(struct connection *pc)
102351{
102352#define FREE_PACKET_STRUCT(_packet) free_packet_web_player_info_addition(_packet)
102353 RECEIVE_PACKET_START(packet_web_player_info_addition, real_packet);
102354
102355#ifdef FREECIV_JSON_CONNECTION
102356 struct plocation field_addr;
102357 {
102358 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102359 field_addr = *field_addr_tmp;
102360 FC_FREE(field_addr_tmp);
102361 }
102362#endif /* FREECIV_JSON_CONNECTION */
102363
102364#ifdef FREECIV_JSON_CONNECTION
102365 field_addr.name = "playerno";
102366#endif /* FREECIV_JSON_CONNECTION */
102367
102368 if (!DIO_GET(sint16, &din, &field_addr, &real_packet->playerno)) {
102369 RECEIVE_PACKET_FIELD_ERROR(playerno);
102370 }
102371
102372 log_packet_detailed("packet_web_player_info_addition_100: got info about (%d)",
102373 real_packet->playerno);
102374
102375#ifdef FREECIV_DELTA_PROTOCOL
102376 packet_web_player_info_addition_100_fields fields;
102377 struct packet_web_player_info_addition *old;
102378 struct genhash **hash = pc->phs.received + PACKET_WEB_PLAYER_INFO_ADDITION;
102379
102380 if (nullptr == *hash) {
102381 *hash = genhash_new_full(hash_packet_web_player_info_addition_100, cmp_packet_web_player_info_addition_100,
102382 nullptr, nullptr, nullptr, destroy_packet_web_player_info_addition);
102383 }
102384
102385 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
102386 *real_packet = *old;
102387 } else {
102388 /* packet is already initialized empty */
102389 log_packet_detailed(" no old info");
102390 }
102391
102392#ifdef FREECIV_JSON_CONNECTION
102393 field_addr.name = "fields";
102394#endif /* FREECIV_JSON_CONNECTION */
102395 DIO_BV_GET(&din, &field_addr, fields);
102396
102397 if (BV_ISSET(fields, 0)) {
102398 log_packet_detailed(" got field 'expected_income'");
102399
102400#ifdef FREECIV_JSON_CONNECTION
102401 field_addr.name = "expected_income";
102402#endif /* FREECIV_JSON_CONNECTION */
102403
102404 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->expected_income)) {
102405 RECEIVE_PACKET_FIELD_ERROR(expected_income);
102406 }
102407 }
102408
102409 if (nullptr == old) {
102410 old = fc_malloc(sizeof(*old));
102411 init_packet_web_player_info_addition(old);
102412 *old = *real_packet;
102413 genhash_insert(*hash, old, old);
102414 } else {
102415 *old = *real_packet;
102416 }
102417
102418#else /* FREECIV_DELTA_PROTOCOL */
102419#ifdef FREECIV_JSON_CONNECTION
102420 field_addr.name = "expected_income";
102421#endif /* FREECIV_JSON_CONNECTION */
102422
102423 if (!DIO_GET(uint32, &din, &field_addr, &real_packet->expected_income)) {
102424 RECEIVE_PACKET_FIELD_ERROR(expected_income);
102425 }
102426#endif /* FREECIV_DELTA_PROTOCOL */
102427
102428 RECEIVE_PACKET_END(real_packet);
102429#undef FREE_PACKET_STRUCT
102430}
102431
102432 static int send_packet_web_player_info_addition_100(struct connection *pc, const struct packet_web_player_info_addition *packet)
102433{
102434 const struct packet_web_player_info_addition *real_packet = packet;
102435 int e;
102436 SEND_PACKET_START(PACKET_WEB_PLAYER_INFO_ADDITION);
102437
102438 log_packet_detailed("packet_web_player_info_addition_100: sending info about (%d)",
102439 real_packet->playerno);
102440
102441#ifdef FREECIV_DELTA_PROTOCOL
102442 packet_web_player_info_addition_100_fields fields;
102443 struct packet_web_player_info_addition *old;
102444 bool differ;
102445 int different = 0;
102446 struct genhash **hash = pc->phs.sent + PACKET_WEB_PLAYER_INFO_ADDITION;
102447
102448 if (nullptr == *hash) {
102449 *hash = genhash_new_full(hash_packet_web_player_info_addition_100, cmp_packet_web_player_info_addition_100,
102450 nullptr, nullptr, nullptr, destroy_packet_web_player_info_addition);
102451 }
102452 BV_CLR_ALL(fields);
102453
102454 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
102455 old = fc_malloc(sizeof(*old));
102456 /* temporary bitcopy just to insert correctly */
102457 *old = *real_packet;
102458 genhash_insert(*hash, old, old);
102459 init_packet_web_player_info_addition(old);
102460 different = 1; /* Force to send. */
102461 }
102462
102463 differ = (old->expected_income != real_packet->expected_income);
102464 if (differ) {
102465 different++;
102466 BV_SET(fields, 0);
102467 }
102468
102469 if (different == 0) {
102470 log_packet_detailed(" no change -> discard");
102471 SEND_PACKET_DISCARD();
102472 }
102473#endif /* FREECIV_DELTA_PROTOCOL */
102474
102475#ifdef FREECIV_JSON_CONNECTION
102476 struct plocation field_addr;
102477 {
102478 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102479 field_addr = *field_addr_tmp;
102480 FC_FREE(field_addr_tmp);
102481 }
102482#endif /* FREECIV_JSON_CONNECTION */
102483
102484#ifdef FREECIV_JSON_CONNECTION
102485 field_addr.name = "playerno";
102486#endif /* FREECIV_JSON_CONNECTION */
102487 e = 0;
102488
102489 e |= DIO_PUT(sint16, &dout, &field_addr, real_packet->playerno);
102490
102491 if (e) {
102492 log_packet_detailed("'playerno' field error detected");
102493 }
102494
102495#ifdef FREECIV_DELTA_PROTOCOL
102496#ifdef FREECIV_JSON_CONNECTION
102497 field_addr.name = "fields";
102498#endif /* FREECIV_JSON_CONNECTION */
102499 e = 0;
102500 e |= DIO_BV_PUT(&dout, &field_addr, fields);
102501 if (e) {
102502 log_packet_detailed("fields bitvector error detected");
102503 }
102504
102505 if (BV_ISSET(fields, 0)) {
102506 log_packet_detailed(" field 'expected_income' has changed");
102507
102508#ifdef FREECIV_JSON_CONNECTION
102509 field_addr.name = "expected_income";
102510#endif /* FREECIV_JSON_CONNECTION */
102511 e = 0;
102512
102513 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->expected_income);
102514
102515 if (e) {
102516 log_packet_detailed("'expected_income' field error detected");
102517 }
102518 }
102519
102520 *old = *real_packet;
102521
102522#else /* FREECIV_DELTA_PROTOCOL */
102523#ifdef FREECIV_JSON_CONNECTION
102524 field_addr.name = "expected_income";
102525#endif /* FREECIV_JSON_CONNECTION */
102526 e = 0;
102527
102528 e |= DIO_PUT(uint32, &dout, &field_addr, real_packet->expected_income);
102529
102530 if (e) {
102531 log_packet_detailed("'expected_income' field error detected");
102532 }
102533#endif /* FREECIV_DELTA_PROTOCOL */
102534
102535 SEND_PACKET_END(PACKET_WEB_PLAYER_INFO_ADDITION);
102536}
102537
102538 int send_packet_web_player_info_addition(struct connection *pc, const struct packet_web_player_info_addition *packet)
102539{
102540 if (!pc->used) {
102541 log_error("WARNING: trying to send data to the closed connection %s",
102542 conn_description(pc));
102543 return -1;
102544 }
102545 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WEB_PLAYER_INFO_ADDITION].packet != nullptr, -1,
102546 "Handler for PACKET_WEB_PLAYER_INFO_ADDITION not installed");
102547 return pc->phs.handlers->send[PACKET_WEB_PLAYER_INFO_ADDITION].packet(pc, packet);
102548}
102549
102550 static inline void init_packet_web_ruleset_unit_addition(struct packet_web_ruleset_unit_addition *packet)
102551{
102552 memset(packet, 0, sizeof(*packet));
102553}
102554
102555#define free_packet_web_ruleset_unit_addition(_packet) (void) 0
102556#define destroy_packet_web_ruleset_unit_addition free
102557
102558#ifdef FREECIV_DELTA_PROTOCOL
102559static genhash_val_t hash_packet_web_ruleset_unit_addition_100(const void *vkey)
102560{
102561 const struct packet_web_ruleset_unit_addition *key = (const struct packet_web_ruleset_unit_addition *) vkey;
102562 genhash_val_t result = 0;
102563
102564 result += key->id;
102565
102566 result &= 0xFFFFFFFF;
102567 return result;
102568}
102569
102570static bool cmp_packet_web_ruleset_unit_addition_100(const void *vkey1, const void *vkey2)
102571{
102572 const struct packet_web_ruleset_unit_addition *old = (const struct packet_web_ruleset_unit_addition *) vkey1;
102573 const struct packet_web_ruleset_unit_addition *real_packet = (const struct packet_web_ruleset_unit_addition *) vkey2;
102574 bool differ;
102575
102576 differ = (old->id != real_packet->id);
102577
102578 return !differ;
102579}
102580 BV_DEFINE(packet_web_ruleset_unit_addition_100_fields, 1);
102581#endif /* FREECIV_DELTA_PROTOCOL */
102582
102583 static struct packet_web_ruleset_unit_addition *receive_packet_web_ruleset_unit_addition_100(struct connection *pc)
102584{
102585#define FREE_PACKET_STRUCT(_packet) free_packet_web_ruleset_unit_addition(_packet)
102586 RECEIVE_PACKET_START(packet_web_ruleset_unit_addition, real_packet);
102587
102588#ifdef FREECIV_JSON_CONNECTION
102589 struct plocation field_addr;
102590 {
102591 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102592 field_addr = *field_addr_tmp;
102593 FC_FREE(field_addr_tmp);
102594 }
102595#endif /* FREECIV_JSON_CONNECTION */
102596
102597#ifdef FREECIV_JSON_CONNECTION
102598 field_addr.name = "id";
102599#endif /* FREECIV_JSON_CONNECTION */
102600
102601 {
102602 int readin;
102603
102604 if (!DIO_GET(uint16, &din, &field_addr, &readin)) {
102605 RECEIVE_PACKET_FIELD_ERROR(id);
102606 }
102607 real_packet->id = readin;
102608 }
102609
102610 log_packet_detailed("packet_web_ruleset_unit_addition_100: got info about (%d)",
102611 real_packet->id);
102612
102613#ifdef FREECIV_DELTA_PROTOCOL
102614 packet_web_ruleset_unit_addition_100_fields fields;
102615 struct packet_web_ruleset_unit_addition *old;
102616 struct genhash **hash = pc->phs.received + PACKET_WEB_RULESET_UNIT_ADDITION;
102617
102618 if (nullptr == *hash) {
102619 *hash = genhash_new_full(hash_packet_web_ruleset_unit_addition_100, cmp_packet_web_ruleset_unit_addition_100,
102620 nullptr, nullptr, nullptr, destroy_packet_web_ruleset_unit_addition);
102621 }
102622
102623 if (genhash_lookup(*hash, real_packet, (void **) &old)) {
102624 *real_packet = *old;
102625 } else {
102626 /* packet is already initialized empty */
102627 log_packet_detailed(" no old info");
102628 }
102629
102630#ifdef FREECIV_JSON_CONNECTION
102631 field_addr.name = "fields";
102632#endif /* FREECIV_JSON_CONNECTION */
102633 DIO_BV_GET(&din, &field_addr, fields);
102634
102635 if (BV_ISSET(fields, 0)) {
102636 log_packet_detailed(" got field 'utype_actions'");
102637
102638#ifdef FREECIV_JSON_CONNECTION
102639 field_addr.name = "utype_actions";
102640#endif /* FREECIV_JSON_CONNECTION */
102641
102642 if (!DIO_BV_GET(&din, &field_addr, real_packet->utype_actions)) {
102643 RECEIVE_PACKET_FIELD_ERROR(utype_actions);
102644 }
102645 }
102646
102647 if (nullptr == old) {
102648 old = fc_malloc(sizeof(*old));
102649 init_packet_web_ruleset_unit_addition(old);
102650 *old = *real_packet;
102651 genhash_insert(*hash, old, old);
102652 } else {
102653 *old = *real_packet;
102654 }
102655
102656#else /* FREECIV_DELTA_PROTOCOL */
102657#ifdef FREECIV_JSON_CONNECTION
102658 field_addr.name = "utype_actions";
102659#endif /* FREECIV_JSON_CONNECTION */
102660
102661 if (!DIO_BV_GET(&din, &field_addr, real_packet->utype_actions)) {
102662 RECEIVE_PACKET_FIELD_ERROR(utype_actions);
102663 }
102664#endif /* FREECIV_DELTA_PROTOCOL */
102665
102666 RECEIVE_PACKET_END(real_packet);
102667#undef FREE_PACKET_STRUCT
102668}
102669
102670 static int send_packet_web_ruleset_unit_addition_100(struct connection *pc, const struct packet_web_ruleset_unit_addition *packet)
102671{
102672 const struct packet_web_ruleset_unit_addition *real_packet = packet;
102673 int e;
102674 SEND_PACKET_START(PACKET_WEB_RULESET_UNIT_ADDITION);
102675
102676 log_packet_detailed("packet_web_ruleset_unit_addition_100: sending info about (%d)",
102677 real_packet->id);
102678
102679#ifdef FREECIV_DELTA_PROTOCOL
102680 packet_web_ruleset_unit_addition_100_fields fields;
102681 struct packet_web_ruleset_unit_addition *old;
102682 bool differ;
102683 struct genhash **hash = pc->phs.sent + PACKET_WEB_RULESET_UNIT_ADDITION;
102684
102685 if (nullptr == *hash) {
102686 *hash = genhash_new_full(hash_packet_web_ruleset_unit_addition_100, cmp_packet_web_ruleset_unit_addition_100,
102687 nullptr, nullptr, nullptr, destroy_packet_web_ruleset_unit_addition);
102688 }
102689 BV_CLR_ALL(fields);
102690
102691 if (!genhash_lookup(*hash, real_packet, (void **) &old)) {
102692 old = fc_malloc(sizeof(*old));
102693 /* temporary bitcopy just to insert correctly */
102694 *old = *real_packet;
102695 genhash_insert(*hash, old, old);
102696 init_packet_web_ruleset_unit_addition(old);
102697 }
102698
102699 differ = !BV_ARE_EQUAL(old->utype_actions, real_packet->utype_actions);
102700 if (differ) {
102701 BV_SET(fields, 0);
102702 }
102703#endif /* FREECIV_DELTA_PROTOCOL */
102704
102705#ifdef FREECIV_JSON_CONNECTION
102706 struct plocation field_addr;
102707 {
102708 struct plocation *field_addr_tmp = plocation_field_new(nullptr);
102709 field_addr = *field_addr_tmp;
102710 FC_FREE(field_addr_tmp);
102711 }
102712#endif /* FREECIV_JSON_CONNECTION */
102713
102714#ifdef FREECIV_JSON_CONNECTION
102715 field_addr.name = "id";
102716#endif /* FREECIV_JSON_CONNECTION */
102717 e = 0;
102718
102719 e |= DIO_PUT(uint16, &dout, &field_addr, real_packet->id);
102720
102721 if (e) {
102722 log_packet_detailed("'id' field error detected");
102723 }
102724
102725#ifdef FREECIV_DELTA_PROTOCOL
102726#ifdef FREECIV_JSON_CONNECTION
102727 field_addr.name = "fields";
102728#endif /* FREECIV_JSON_CONNECTION */
102729 e = 0;
102730 e |= DIO_BV_PUT(&dout, &field_addr, fields);
102731 if (e) {
102732 log_packet_detailed("fields bitvector error detected");
102733 }
102734
102735 if (BV_ISSET(fields, 0)) {
102736 log_packet_detailed(" field 'utype_actions' has changed");
102737
102738#ifdef FREECIV_JSON_CONNECTION
102739 field_addr.name = "utype_actions";
102740#endif /* FREECIV_JSON_CONNECTION */
102741 e = 0;
102742
102743 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->utype_actions);
102744
102745 if (e) {
102746 log_packet_detailed("'utype_actions' field error detected");
102747 }
102748 }
102749
102750 *old = *real_packet;
102751
102752#else /* FREECIV_DELTA_PROTOCOL */
102753#ifdef FREECIV_JSON_CONNECTION
102754 field_addr.name = "utype_actions";
102755#endif /* FREECIV_JSON_CONNECTION */
102756 e = 0;
102757
102758 e |= DIO_BV_PUT(&dout, &field_addr, real_packet->utype_actions);
102759
102760 if (e) {
102761 log_packet_detailed("'utype_actions' field error detected");
102762 }
102763#endif /* FREECIV_DELTA_PROTOCOL */
102764
102765 SEND_PACKET_END(PACKET_WEB_RULESET_UNIT_ADDITION);
102766}
102767
102768 int send_packet_web_ruleset_unit_addition(struct connection *pc, const struct packet_web_ruleset_unit_addition *packet)
102769{
102770 if (!pc->used) {
102771 log_error("WARNING: trying to send data to the closed connection %s",
102772 conn_description(pc));
102773 return -1;
102774 }
102775 fc_assert_ret_val_msg(pc->phs.handlers->send[PACKET_WEB_RULESET_UNIT_ADDITION].packet != nullptr, -1,
102776 "Handler for PACKET_WEB_RULESET_UNIT_ADDITION not installed");
102777 return pc->phs.handlers->send[PACKET_WEB_RULESET_UNIT_ADDITION].packet(pc, packet);
102778}
102779
102780 void lsend_packet_web_ruleset_unit_addition(struct conn_list *dest, const struct packet_web_ruleset_unit_addition *packet)
102781{
102782 conn_list_iterate(dest, pconn) {
102783 send_packet_web_ruleset_unit_addition(pconn, packet);
102784 } conn_list_iterate_end;
102785}
102786
102787 void packet_handlers_fill_initial(struct packet_handlers *phandlers)
102788{
102789 phandlers->send[PACKET_CITY_RALLY_POINT].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_city_rally_point_100;
102790 phandlers->receive[PACKET_CITY_RALLY_POINT] = (void *(*)(struct connection *)) receive_packet_city_rally_point_100;
102791 phandlers->send[PACKET_WORKER_TASK].packet = (int(*)(struct connection *, const void *)) send_packet_worker_task_100;
102792 phandlers->receive[PACKET_WORKER_TASK] = (void *(*)(struct connection *)) receive_packet_worker_task_100;
102793 phandlers->send[PACKET_PLAYER_ATTRIBUTE_CHUNK].packet = (int(*)(struct connection *, const void *)) send_packet_player_attribute_chunk_100;
102794 phandlers->receive[PACKET_PLAYER_ATTRIBUTE_CHUNK] = (void *(*)(struct connection *)) receive_packet_player_attribute_chunk_100;
102795 phandlers->send[PACKET_EDIT_STARTPOS].packet = (int(*)(struct connection *, const void *)) send_packet_edit_startpos_100;
102796 phandlers->receive[PACKET_EDIT_STARTPOS] = (void *(*)(struct connection *)) receive_packet_edit_startpos_100;
102797 phandlers->send[PACKET_EDIT_STARTPOS_FULL].packet = (int(*)(struct connection *, const void *)) send_packet_edit_startpos_full_100;
102798 phandlers->receive[PACKET_EDIT_STARTPOS_FULL] = (void *(*)(struct connection *)) receive_packet_edit_startpos_full_100;
102799 if (is_server()) {
102800 phandlers->send[PACKET_PROCESSING_STARTED].no_packet = (int(*)(struct connection *)) send_packet_processing_started_100;
102801 phandlers->send[PACKET_PROCESSING_FINISHED].no_packet = (int(*)(struct connection *)) send_packet_processing_finished_100;
102802 phandlers->send[PACKET_INVESTIGATE_STARTED].packet = (int(*)(struct connection *, const void *)) send_packet_investigate_started_100;
102803 phandlers->send[PACKET_INVESTIGATE_FINISHED].packet = (int(*)(struct connection *, const void *)) send_packet_investigate_finished_100;
102804 phandlers->send[PACKET_SERVER_JOIN_REPLY].packet = (int(*)(struct connection *, const void *)) send_packet_server_join_reply_100;
102805 phandlers->send[PACKET_AUTHENTICATION_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_authentication_req_100;
102806 phandlers->send[PACKET_SERVER_SHUTDOWN].no_packet = (int(*)(struct connection *)) send_packet_server_shutdown_100;
102807 phandlers->send[PACKET_ENDGAME_REPORT].packet = (int(*)(struct connection *, const void *)) send_packet_endgame_report_100;
102808 phandlers->send[PACKET_ENDGAME_PLAYER].packet = (int(*)(struct connection *, const void *)) send_packet_endgame_player_100;
102809 phandlers->send[PACKET_TILE_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_tile_info_100;
102810 phandlers->send[PACKET_GAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_game_info_100;
102811 phandlers->send[PACKET_CALENDAR_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_calendar_info_100;
102812 phandlers->send[PACKET_TIMEOUT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_timeout_info_100;
102813 phandlers->send[PACKET_MAP_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_map_info_100;
102814 phandlers->send[PACKET_NUKE_TILE_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_nuke_tile_info_100;
102815 phandlers->send[PACKET_TEAM_NAME_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_team_name_info_100;
102816 phandlers->send[PACKET_ACHIEVEMENT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_achievement_info_100;
102817 phandlers->send[PACKET_CHAT_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_chat_msg_100;
102818 phandlers->send[PACKET_EARLY_CHAT_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_early_chat_msg_100;
102819 phandlers->send[PACKET_CONNECT_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_connect_msg_100;
102820 phandlers->send[PACKET_SERVER_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_server_info_100;
102821 phandlers->send[PACKET_CITY_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_city_remove_100;
102822 phandlers->send[PACKET_CITY_INFO].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_city_info_100;
102823 phandlers->send[PACKET_CITY_NATIONALITIES].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_city_nationalities_100;
102824 phandlers->send[PACKET_CITY_UPDATE_COUNTERS].packet = (int(*)(struct connection *, const void *)) send_packet_city_update_counters_100;
102825 phandlers->send[PACKET_CITY_SHORT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_city_short_info_100;
102826 phandlers->send[PACKET_TRADE_ROUTE_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_trade_route_info_100;
102827 phandlers->send[PACKET_CITY_NAME_SUGGESTION_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_city_name_suggestion_info_100;
102828 phandlers->send[PACKET_CITY_SABOTAGE_LIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_sabotage_list_100;
102829 phandlers->send[PACKET_PLAYER_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_player_remove_100;
102830 phandlers->send[PACKET_PLAYER_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_player_info_100;
102831 phandlers->send[PACKET_PLAYER_DIPLSTATE].packet = (int(*)(struct connection *, const void *)) send_packet_player_diplstate_100;
102832 phandlers->send[PACKET_RESEARCH_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_research_info_100;
102833 phandlers->send[PACKET_UNKNOWN_RESEARCH].packet = (int(*)(struct connection *, const void *)) send_packet_unknown_research_100;
102834 phandlers->send[PACKET_UNIT_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_unit_remove_100;
102835 phandlers->send[PACKET_UNIT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_unit_info_100;
102836 phandlers->send[PACKET_UNIT_SHORT_INFO].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_unit_short_info_100;
102837 phandlers->send[PACKET_UNIT_COMBAT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_unit_combat_info_100;
102838 phandlers->send[PACKET_UNIT_ACTION_ANSWER].packet = (int(*)(struct connection *, const void *)) send_packet_unit_action_answer_100;
102839 phandlers->send[PACKET_UNIT_ACTIONS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_actions_100;
102840 phandlers->send[PACKET_DIPLOMACY_INIT_MEETING].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_init_meeting_100;
102841 phandlers->send[PACKET_DIPLOMACY_CANCEL_MEETING].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_cancel_meeting_100;
102842 phandlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_create_clause_100;
102843 phandlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_remove_clause_100;
102844 phandlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_accept_treaty_100;
102845 phandlers->send[PACKET_PAGE_MSG].packet = (int(*)(struct connection *, const void *)) send_packet_page_msg_100;
102846 phandlers->send[PACKET_PAGE_MSG_PART].packet = (int(*)(struct connection *, const void *)) send_packet_page_msg_part_100;
102847 phandlers->send[PACKET_CONN_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_conn_info_100;
102848 phandlers->send[PACKET_CONN_PING_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_conn_ping_info_100;
102849 phandlers->send[PACKET_CONN_PING].no_packet = (int(*)(struct connection *)) send_packet_conn_ping_100;
102850 phandlers->send[PACKET_END_PHASE].no_packet = (int(*)(struct connection *)) send_packet_end_phase_100;
102851 phandlers->send[PACKET_START_PHASE].packet = (int(*)(struct connection *, const void *)) send_packet_start_phase_100;
102852 phandlers->send[PACKET_NEW_YEAR].packet = (int(*)(struct connection *, const void *)) send_packet_new_year_100;
102853 phandlers->send[PACKET_BEGIN_TURN].no_packet = (int(*)(struct connection *)) send_packet_begin_turn_100;
102854 phandlers->send[PACKET_END_TURN].no_packet = (int(*)(struct connection *)) send_packet_end_turn_100;
102855 phandlers->send[PACKET_FREEZE_CLIENT].no_packet = (int(*)(struct connection *)) send_packet_freeze_client_100;
102856 phandlers->send[PACKET_THAW_CLIENT].no_packet = (int(*)(struct connection *)) send_packet_thaw_client_100;
102857 phandlers->send[PACKET_SPACESHIP_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_spaceship_info_100;
102858 phandlers->send[PACKET_RULESET_UNIT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_100;
102859 phandlers->send[PACKET_RULESET_UNIT_BONUS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_bonus_100;
102860 phandlers->send[PACKET_RULESET_UNIT_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_flag_100;
102861 phandlers->send[PACKET_RULESET_UNIT_CLASS_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_class_flag_100;
102862 phandlers->send[PACKET_RULESET_GAME].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_game_100;
102863 phandlers->send[PACKET_RULESET_SPECIALIST].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_specialist_100;
102864 phandlers->send[PACKET_RULESET_GOVERNMENT_RULER_TITLE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_government_ruler_title_100;
102865 phandlers->send[PACKET_RULESET_TECH].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_tech_100;
102866 phandlers->send[PACKET_RULESET_TECH_CLASS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_tech_class_100;
102867 phandlers->send[PACKET_RULESET_TECH_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_tech_flag_100;
102868 phandlers->send[PACKET_RULESET_GOVERNMENT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_government_100;
102869 phandlers->send[PACKET_RULESET_TERRAIN_CONTROL].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_terrain_control_100;
102870 phandlers->send[PACKET_RULESETS_READY].no_packet = (int(*)(struct connection *)) send_packet_rulesets_ready_100;
102871 phandlers->send[PACKET_RULESET_NATION_SETS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_nation_sets_100;
102872 phandlers->send[PACKET_RULESET_NATION_GROUPS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_nation_groups_100;
102873 phandlers->send[PACKET_RULESET_NATION].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_nation_100;
102874 phandlers->send[PACKET_NATION_AVAILABILITY].packet = (int(*)(struct connection *, const void *)) send_packet_nation_availability_100;
102875 phandlers->send[PACKET_RULESET_STYLE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_style_100;
102876 phandlers->send[PACKET_RULESET_CITY].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_city_100;
102877 phandlers->send[PACKET_RULESET_BUILDING].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_building_100;
102878 phandlers->send[PACKET_RULESET_IMPR_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_impr_flag_100;
102879 phandlers->send[PACKET_RULESET_TERRAIN].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_terrain_100;
102880 phandlers->send[PACKET_RULESET_TERRAIN_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_terrain_flag_100;
102881 phandlers->send[PACKET_RULESET_UNIT_CLASS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_unit_class_100;
102882 phandlers->send[PACKET_RULESET_EXTRA].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_extra_100;
102883 phandlers->send[PACKET_RULESET_EXTRA_FLAG].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_extra_flag_100;
102884 phandlers->send[PACKET_RULESET_BASE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_base_100;
102885 phandlers->send[PACKET_RULESET_ROAD].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_road_100;
102886 phandlers->send[PACKET_RULESET_GOODS].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_goods_100;
102887 phandlers->send[PACKET_RULESET_DISASTER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_disaster_100;
102888 phandlers->send[PACKET_RULESET_ACHIEVEMENT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_achievement_100;
102889 phandlers->send[PACKET_RULESET_TRADE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_trade_100;
102890 phandlers->send[PACKET_RULESET_ACTION].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_action_100;
102891 phandlers->send[PACKET_RULESET_ACTION_ENABLER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_action_enabler_100;
102892 phandlers->send[PACKET_RULESET_ACTION_AUTO].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_action_auto_100;
102893 phandlers->send[PACKET_RULESET_COUNTER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_counter_100;
102894 phandlers->send[PACKET_RULESET_MUSIC].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_music_100;
102895 phandlers->send[PACKET_RULESET_MULTIPLIER].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_multiplier_100;
102896 phandlers->send[PACKET_RULESET_CLAUSE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_clause_100;
102897 phandlers->send[PACKET_RULESET_CONTROL].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_control_100;
102898 phandlers->send[PACKET_RULESET_SUMMARY].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_summary_100;
102899 phandlers->send[PACKET_RULESET_DESCRIPTION_PART].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_description_part_100;
102900 phandlers->send[PACKET_SINGLE_WANT_HACK_REPLY].packet = (int(*)(struct connection *, const void *)) send_packet_single_want_hack_reply_100;
102901 phandlers->send[PACKET_RULESET_CHOICES].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_choices_100;
102902 phandlers->send[PACKET_GAME_LOAD].packet = (int(*)(struct connection *, const void *)) send_packet_game_load_100;
102903 phandlers->send[PACKET_SERVER_SETTING_CONTROL].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_control_100;
102904 phandlers->send[PACKET_SERVER_SETTING_CONST].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_const_100;
102905 phandlers->send[PACKET_SERVER_SETTING_BOOL].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_bool_100;
102906 phandlers->send[PACKET_SERVER_SETTING_INT].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_int_100;
102907 phandlers->send[PACKET_SERVER_SETTING_STR].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_str_100;
102908 phandlers->send[PACKET_SERVER_SETTING_ENUM].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_enum_100;
102909 phandlers->send[PACKET_SERVER_SETTING_BITWISE].packet = (int(*)(struct connection *, const void *)) send_packet_server_setting_bitwise_100;
102910 phandlers->send[PACKET_SET_TOPOLOGY].packet = (int(*)(struct connection *, const void *)) send_packet_set_topology_100;
102911 phandlers->send[PACKET_RULESET_EFFECT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_effect_100;
102912 phandlers->send[PACKET_RULESET_RESOURCE].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_resource_100;
102913 phandlers->send[PACKET_SCENARIO_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_scenario_info_100;
102914 phandlers->send[PACKET_SCENARIO_DESCRIPTION].packet = (int(*)(struct connection *, const void *)) send_packet_scenario_description_100;
102915 phandlers->send[PACKET_VOTE_NEW].packet = (int(*)(struct connection *, const void *)) send_packet_vote_new_100;
102916 phandlers->send[PACKET_VOTE_UPDATE].packet = (int(*)(struct connection *, const void *)) send_packet_vote_update_100;
102917 phandlers->send[PACKET_VOTE_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_vote_remove_100;
102918 phandlers->send[PACKET_VOTE_RESOLVE].packet = (int(*)(struct connection *, const void *)) send_packet_vote_resolve_100;
102919 phandlers->send[PACKET_EDIT_OBJECT_CREATED].packet = (int(*)(struct connection *, const void *)) send_packet_edit_object_created_100;
102920 phandlers->send[PACKET_PLAY_MUSIC].packet = (int(*)(struct connection *, const void *)) send_packet_play_music_100;
102921 phandlers->send[PACKET_POPUP_IMAGE].packet = (int(*)(struct connection *, const void *)) send_packet_popup_image_100;
102922 phandlers->send[PACKET_WEB_CITY_INFO_ADDITION].force_to_send = (int(*)(struct connection *, const void *, bool)) send_packet_web_city_info_addition_100;
102923 phandlers->send[PACKET_WEB_PLAYER_INFO_ADDITION].packet = (int(*)(struct connection *, const void *)) send_packet_web_player_info_addition_100;
102924 phandlers->send[PACKET_WEB_RULESET_UNIT_ADDITION].packet = (int(*)(struct connection *, const void *)) send_packet_web_ruleset_unit_addition_100;
102925 phandlers->receive[PACKET_SERVER_JOIN_REQ] = (void *(*)(struct connection *)) receive_packet_server_join_req_100;
102926 phandlers->receive[PACKET_AUTHENTICATION_REPLY] = (void *(*)(struct connection *)) receive_packet_authentication_reply_100;
102927 phandlers->receive[PACKET_NATION_SELECT_REQ] = (void *(*)(struct connection *)) receive_packet_nation_select_req_100;
102928 phandlers->receive[PACKET_PLAYER_READY] = (void *(*)(struct connection *)) receive_packet_player_ready_100;
102929 phandlers->receive[PACKET_CHAT_MSG_REQ] = (void *(*)(struct connection *)) receive_packet_chat_msg_req_100;
102930 phandlers->receive[PACKET_CITY_SELL] = (void *(*)(struct connection *)) receive_packet_city_sell_100;
102931 phandlers->receive[PACKET_CITY_BUY] = (void *(*)(struct connection *)) receive_packet_city_buy_100;
102932 phandlers->receive[PACKET_CITY_CHANGE] = (void *(*)(struct connection *)) receive_packet_city_change_100;
102933 phandlers->receive[PACKET_CITY_WORKLIST] = (void *(*)(struct connection *)) receive_packet_city_worklist_100;
102934 phandlers->receive[PACKET_CITY_MAKE_SPECIALIST] = (void *(*)(struct connection *)) receive_packet_city_make_specialist_100;
102935 phandlers->receive[PACKET_CITY_MAKE_WORKER] = (void *(*)(struct connection *)) receive_packet_city_make_worker_100;
102936 phandlers->receive[PACKET_CITY_CHANGE_SPECIALIST] = (void *(*)(struct connection *)) receive_packet_city_change_specialist_100;
102937 phandlers->receive[PACKET_CITY_RENAME] = (void *(*)(struct connection *)) receive_packet_city_rename_100;
102938 phandlers->receive[PACKET_CITY_OPTIONS_REQ] = (void *(*)(struct connection *)) receive_packet_city_options_req_100;
102939 phandlers->receive[PACKET_CITY_REFRESH] = (void *(*)(struct connection *)) receive_packet_city_refresh_100;
102940 phandlers->receive[PACKET_CITY_NAME_SUGGESTION_REQ] = (void *(*)(struct connection *)) receive_packet_city_name_suggestion_req_100;
102941 phandlers->receive[PACKET_PLAYER_PHASE_DONE] = (void *(*)(struct connection *)) receive_packet_player_phase_done_100;
102942 phandlers->receive[PACKET_PLAYER_RATES] = (void *(*)(struct connection *)) receive_packet_player_rates_100;
102943 phandlers->receive[PACKET_PLAYER_CHANGE_GOVERNMENT] = (void *(*)(struct connection *)) receive_packet_player_change_government_100;
102944 phandlers->receive[PACKET_PLAYER_PLACE_INFRA] = (void *(*)(struct connection *)) receive_packet_player_place_infra_100;
102945 phandlers->receive[PACKET_PLAYER_ATTRIBUTE_BLOCK] = (void *(*)(struct connection *)) receive_packet_player_attribute_block_100;
102946 phandlers->receive[PACKET_PLAYER_MULTIPLIER] = (void *(*)(struct connection *)) receive_packet_player_multiplier_100;
102947 phandlers->receive[PACKET_PLAYER_RESEARCH] = (void *(*)(struct connection *)) receive_packet_player_research_100;
102948 phandlers->receive[PACKET_PLAYER_TECH_GOAL] = (void *(*)(struct connection *)) receive_packet_player_tech_goal_100;
102949 phandlers->receive[PACKET_UNIT_SSCS_SET] = (void *(*)(struct connection *)) receive_packet_unit_sscs_set_100;
102950 phandlers->receive[PACKET_UNIT_ORDERS] = (void *(*)(struct connection *)) receive_packet_unit_orders_100;
102951 phandlers->receive[PACKET_UNIT_SERVER_SIDE_AGENT_SET] = (void *(*)(struct connection *)) receive_packet_unit_server_side_agent_set_100;
102952 phandlers->receive[PACKET_UNIT_ACTION_QUERY] = (void *(*)(struct connection *)) receive_packet_unit_action_query_100;
102953 phandlers->receive[PACKET_UNIT_TYPE_UPGRADE] = (void *(*)(struct connection *)) receive_packet_unit_type_upgrade_100;
102954 phandlers->receive[PACKET_UNIT_DO_ACTION] = (void *(*)(struct connection *)) receive_packet_unit_do_action_100;
102955 phandlers->receive[PACKET_UNIT_GET_ACTIONS] = (void *(*)(struct connection *)) receive_packet_unit_get_actions_100;
102956 phandlers->receive[PACKET_UNIT_CHANGE_ACTIVITY] = (void *(*)(struct connection *)) receive_packet_unit_change_activity_100;
102957 phandlers->receive[PACKET_DIPLOMACY_INIT_MEETING_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_init_meeting_req_100;
102958 phandlers->receive[PACKET_DIPLOMACY_CANCEL_MEETING_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_cancel_meeting_req_100;
102959 phandlers->receive[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_create_clause_req_100;
102960 phandlers->receive[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_remove_clause_req_100;
102961 phandlers->receive[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ] = (void *(*)(struct connection *)) receive_packet_diplomacy_accept_treaty_req_100;
102962 phandlers->receive[PACKET_DIPLOMACY_CANCEL_PACT] = (void *(*)(struct connection *)) receive_packet_diplomacy_cancel_pact_100;
102963 phandlers->receive[PACKET_REPORT_REQ] = (void *(*)(struct connection *)) receive_packet_report_req_100;
102964 phandlers->receive[PACKET_CONN_PONG] = (void *(*)(struct connection *)) receive_packet_conn_pong_100;
102965 phandlers->receive[PACKET_CLIENT_HEARTBEAT] = (void *(*)(struct connection *)) receive_packet_client_heartbeat_100;
102966 phandlers->receive[PACKET_CLIENT_INFO] = (void *(*)(struct connection *)) receive_packet_client_info_100;
102967 phandlers->receive[PACKET_SPACESHIP_LAUNCH] = (void *(*)(struct connection *)) receive_packet_spaceship_launch_100;
102968 phandlers->receive[PACKET_SPACESHIP_PLACE] = (void *(*)(struct connection *)) receive_packet_spaceship_place_100;
102969 phandlers->receive[PACKET_SINGLE_WANT_HACK_REQ] = (void *(*)(struct connection *)) receive_packet_single_want_hack_req_100;
102970 phandlers->receive[PACKET_RULESET_SELECT] = (void *(*)(struct connection *)) receive_packet_ruleset_select_100;
102971 phandlers->receive[PACKET_SAVE_SCENARIO] = (void *(*)(struct connection *)) receive_packet_save_scenario_100;
102972 phandlers->receive[PACKET_VOTE_SUBMIT] = (void *(*)(struct connection *)) receive_packet_vote_submit_100;
102973 phandlers->receive[PACKET_EDIT_MODE] = (void *(*)(struct connection *)) receive_packet_edit_mode_100;
102974 phandlers->receive[PACKET_EDIT_RECALCULATE_BORDERS] = (void *(*)(struct connection *)) receive_packet_edit_recalculate_borders_100;
102975 phandlers->receive[PACKET_EDIT_CHECK_TILES] = (void *(*)(struct connection *)) receive_packet_edit_check_tiles_100;
102976 phandlers->receive[PACKET_EDIT_TOGGLE_FOGOFWAR] = (void *(*)(struct connection *)) receive_packet_edit_toggle_fogofwar_100;
102977 phandlers->receive[PACKET_EDIT_TILE_TERRAIN] = (void *(*)(struct connection *)) receive_packet_edit_tile_terrain_100;
102978 phandlers->receive[PACKET_EDIT_TILE_EXTRA] = (void *(*)(struct connection *)) receive_packet_edit_tile_extra_100;
102979 phandlers->receive[PACKET_EDIT_TILE] = (void *(*)(struct connection *)) receive_packet_edit_tile_100;
102980 phandlers->receive[PACKET_EDIT_UNIT_CREATE] = (void *(*)(struct connection *)) receive_packet_edit_unit_create_100;
102981 phandlers->receive[PACKET_EDIT_UNIT_REMOVE] = (void *(*)(struct connection *)) receive_packet_edit_unit_remove_100;
102982 phandlers->receive[PACKET_EDIT_UNIT_REMOVE_BY_ID] = (void *(*)(struct connection *)) receive_packet_edit_unit_remove_by_id_100;
102983 phandlers->receive[PACKET_EDIT_UNIT] = (void *(*)(struct connection *)) receive_packet_edit_unit_100;
102984 phandlers->receive[PACKET_EDIT_CITY_CREATE] = (void *(*)(struct connection *)) receive_packet_edit_city_create_100;
102985 phandlers->receive[PACKET_EDIT_CITY_REMOVE] = (void *(*)(struct connection *)) receive_packet_edit_city_remove_100;
102986 phandlers->receive[PACKET_EDIT_CITY] = (void *(*)(struct connection *)) receive_packet_edit_city_100;
102987 phandlers->receive[PACKET_EDIT_PLAYER_CREATE] = (void *(*)(struct connection *)) receive_packet_edit_player_create_100;
102988 phandlers->receive[PACKET_EDIT_PLAYER_REMOVE] = (void *(*)(struct connection *)) receive_packet_edit_player_remove_100;
102989 phandlers->receive[PACKET_EDIT_PLAYER] = (void *(*)(struct connection *)) receive_packet_edit_player_100;
102990 phandlers->receive[PACKET_EDIT_PLAYER_VISION] = (void *(*)(struct connection *)) receive_packet_edit_player_vision_100;
102991 phandlers->receive[PACKET_EDIT_GAME] = (void *(*)(struct connection *)) receive_packet_edit_game_100;
102992 phandlers->receive[PACKET_EDIT_SCENARIO_DESC] = (void *(*)(struct connection *)) receive_packet_edit_scenario_desc_100;
102993 phandlers->receive[PACKET_WEB_CMA_SET] = (void *(*)(struct connection *)) receive_packet_web_cma_set_100;
102994 phandlers->receive[PACKET_WEB_CMA_CLEAR] = (void *(*)(struct connection *)) receive_packet_web_cma_clear_100;
102995 } else /* not is_server() */ {
102996 phandlers->send[PACKET_SERVER_JOIN_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_server_join_req_100;
102997 phandlers->send[PACKET_AUTHENTICATION_REPLY].packet = (int(*)(struct connection *, const void *)) send_packet_authentication_reply_100;
102998 phandlers->send[PACKET_NATION_SELECT_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_nation_select_req_100;
102999 phandlers->send[PACKET_PLAYER_READY].packet = (int(*)(struct connection *, const void *)) send_packet_player_ready_100;
103000 phandlers->send[PACKET_CHAT_MSG_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_chat_msg_req_100;
103001 phandlers->send[PACKET_CITY_SELL].packet = (int(*)(struct connection *, const void *)) send_packet_city_sell_100;
103002 phandlers->send[PACKET_CITY_BUY].packet = (int(*)(struct connection *, const void *)) send_packet_city_buy_100;
103003 phandlers->send[PACKET_CITY_CHANGE].packet = (int(*)(struct connection *, const void *)) send_packet_city_change_100;
103004 phandlers->send[PACKET_CITY_WORKLIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_worklist_100;
103005 phandlers->send[PACKET_CITY_MAKE_SPECIALIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_make_specialist_100;
103006 phandlers->send[PACKET_CITY_MAKE_WORKER].packet = (int(*)(struct connection *, const void *)) send_packet_city_make_worker_100;
103007 phandlers->send[PACKET_CITY_CHANGE_SPECIALIST].packet = (int(*)(struct connection *, const void *)) send_packet_city_change_specialist_100;
103008 phandlers->send[PACKET_CITY_RENAME].packet = (int(*)(struct connection *, const void *)) send_packet_city_rename_100;
103009 phandlers->send[PACKET_CITY_OPTIONS_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_city_options_req_100;
103010 phandlers->send[PACKET_CITY_REFRESH].packet = (int(*)(struct connection *, const void *)) send_packet_city_refresh_100;
103011 phandlers->send[PACKET_CITY_NAME_SUGGESTION_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_city_name_suggestion_req_100;
103012 phandlers->send[PACKET_PLAYER_PHASE_DONE].packet = (int(*)(struct connection *, const void *)) send_packet_player_phase_done_100;
103013 phandlers->send[PACKET_PLAYER_RATES].packet = (int(*)(struct connection *, const void *)) send_packet_player_rates_100;
103014 phandlers->send[PACKET_PLAYER_CHANGE_GOVERNMENT].packet = (int(*)(struct connection *, const void *)) send_packet_player_change_government_100;
103015 phandlers->send[PACKET_PLAYER_PLACE_INFRA].packet = (int(*)(struct connection *, const void *)) send_packet_player_place_infra_100;
103016 phandlers->send[PACKET_PLAYER_ATTRIBUTE_BLOCK].no_packet = (int(*)(struct connection *)) send_packet_player_attribute_block_100;
103017 phandlers->send[PACKET_PLAYER_MULTIPLIER].packet = (int(*)(struct connection *, const void *)) send_packet_player_multiplier_100;
103018 phandlers->send[PACKET_PLAYER_RESEARCH].packet = (int(*)(struct connection *, const void *)) send_packet_player_research_100;
103019 phandlers->send[PACKET_PLAYER_TECH_GOAL].packet = (int(*)(struct connection *, const void *)) send_packet_player_tech_goal_100;
103020 phandlers->send[PACKET_UNIT_SSCS_SET].packet = (int(*)(struct connection *, const void *)) send_packet_unit_sscs_set_100;
103021 phandlers->send[PACKET_UNIT_ORDERS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_orders_100;
103022 phandlers->send[PACKET_UNIT_SERVER_SIDE_AGENT_SET].packet = (int(*)(struct connection *, const void *)) send_packet_unit_server_side_agent_set_100;
103023 phandlers->send[PACKET_UNIT_ACTION_QUERY].packet = (int(*)(struct connection *, const void *)) send_packet_unit_action_query_100;
103024 phandlers->send[PACKET_UNIT_TYPE_UPGRADE].packet = (int(*)(struct connection *, const void *)) send_packet_unit_type_upgrade_100;
103025 phandlers->send[PACKET_UNIT_DO_ACTION].packet = (int(*)(struct connection *, const void *)) send_packet_unit_do_action_100;
103026 phandlers->send[PACKET_UNIT_GET_ACTIONS].packet = (int(*)(struct connection *, const void *)) send_packet_unit_get_actions_100;
103027 phandlers->send[PACKET_UNIT_CHANGE_ACTIVITY].packet = (int(*)(struct connection *, const void *)) send_packet_unit_change_activity_100;
103028 phandlers->send[PACKET_DIPLOMACY_INIT_MEETING_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_init_meeting_req_100;
103029 phandlers->send[PACKET_DIPLOMACY_CANCEL_MEETING_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_cancel_meeting_req_100;
103030 phandlers->send[PACKET_DIPLOMACY_CREATE_CLAUSE_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_create_clause_req_100;
103031 phandlers->send[PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_remove_clause_req_100;
103032 phandlers->send[PACKET_DIPLOMACY_ACCEPT_TREATY_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_accept_treaty_req_100;
103033 phandlers->send[PACKET_DIPLOMACY_CANCEL_PACT].packet = (int(*)(struct connection *, const void *)) send_packet_diplomacy_cancel_pact_100;
103034 phandlers->send[PACKET_REPORT_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_report_req_100;
103035 phandlers->send[PACKET_CONN_PONG].no_packet = (int(*)(struct connection *)) send_packet_conn_pong_100;
103036 phandlers->send[PACKET_CLIENT_HEARTBEAT].no_packet = (int(*)(struct connection *)) send_packet_client_heartbeat_100;
103037 phandlers->send[PACKET_CLIENT_INFO].packet = (int(*)(struct connection *, const void *)) send_packet_client_info_100;
103038 phandlers->send[PACKET_SPACESHIP_LAUNCH].no_packet = (int(*)(struct connection *)) send_packet_spaceship_launch_100;
103039 phandlers->send[PACKET_SPACESHIP_PLACE].packet = (int(*)(struct connection *, const void *)) send_packet_spaceship_place_100;
103040 phandlers->send[PACKET_SINGLE_WANT_HACK_REQ].packet = (int(*)(struct connection *, const void *)) send_packet_single_want_hack_req_100;
103041 phandlers->send[PACKET_RULESET_SELECT].packet = (int(*)(struct connection *, const void *)) send_packet_ruleset_select_100;
103042 phandlers->send[PACKET_SAVE_SCENARIO].packet = (int(*)(struct connection *, const void *)) send_packet_save_scenario_100;
103043 phandlers->send[PACKET_VOTE_SUBMIT].packet = (int(*)(struct connection *, const void *)) send_packet_vote_submit_100;
103044 phandlers->send[PACKET_EDIT_MODE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_mode_100;
103045 phandlers->send[PACKET_EDIT_RECALCULATE_BORDERS].no_packet = (int(*)(struct connection *)) send_packet_edit_recalculate_borders_100;
103046 phandlers->send[PACKET_EDIT_CHECK_TILES].no_packet = (int(*)(struct connection *)) send_packet_edit_check_tiles_100;
103047 phandlers->send[PACKET_EDIT_TOGGLE_FOGOFWAR].packet = (int(*)(struct connection *, const void *)) send_packet_edit_toggle_fogofwar_100;
103048 phandlers->send[PACKET_EDIT_TILE_TERRAIN].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_terrain_100;
103049 phandlers->send[PACKET_EDIT_TILE_EXTRA].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_extra_100;
103050 phandlers->send[PACKET_EDIT_TILE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_tile_100;
103051 phandlers->send[PACKET_EDIT_UNIT_CREATE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_create_100;
103052 phandlers->send[PACKET_EDIT_UNIT_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_remove_100;
103053 phandlers->send[PACKET_EDIT_UNIT_REMOVE_BY_ID].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_remove_by_id_100;
103054 phandlers->send[PACKET_EDIT_UNIT].packet = (int(*)(struct connection *, const void *)) send_packet_edit_unit_100;
103055 phandlers->send[PACKET_EDIT_CITY_CREATE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_city_create_100;
103056 phandlers->send[PACKET_EDIT_CITY_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_city_remove_100;
103057 phandlers->send[PACKET_EDIT_CITY].packet = (int(*)(struct connection *, const void *)) send_packet_edit_city_100;
103058 phandlers->send[PACKET_EDIT_PLAYER_CREATE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_create_100;
103059 phandlers->send[PACKET_EDIT_PLAYER_REMOVE].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_remove_100;
103060 phandlers->send[PACKET_EDIT_PLAYER].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_100;
103061 phandlers->send[PACKET_EDIT_PLAYER_VISION].packet = (int(*)(struct connection *, const void *)) send_packet_edit_player_vision_100;
103062 phandlers->send[PACKET_EDIT_GAME].packet = (int(*)(struct connection *, const void *)) send_packet_edit_game_100;
103063 phandlers->send[PACKET_EDIT_SCENARIO_DESC].packet = (int(*)(struct connection *, const void *)) send_packet_edit_scenario_desc_100;
103064 phandlers->send[PACKET_WEB_CMA_SET].packet = (int(*)(struct connection *, const void *)) send_packet_web_cma_set_100;
103065 phandlers->send[PACKET_WEB_CMA_CLEAR].packet = (int(*)(struct connection *, const void *)) send_packet_web_cma_clear_100;
103066 phandlers->receive[PACKET_PROCESSING_STARTED] = (void *(*)(struct connection *)) receive_packet_processing_started_100;
103067 phandlers->receive[PACKET_PROCESSING_FINISHED] = (void *(*)(struct connection *)) receive_packet_processing_finished_100;
103068 phandlers->receive[PACKET_INVESTIGATE_STARTED] = (void *(*)(struct connection *)) receive_packet_investigate_started_100;
103069 phandlers->receive[PACKET_INVESTIGATE_FINISHED] = (void *(*)(struct connection *)) receive_packet_investigate_finished_100;
103070 phandlers->receive[PACKET_SERVER_JOIN_REPLY] = (void *(*)(struct connection *)) receive_packet_server_join_reply_100;
103071 phandlers->receive[PACKET_AUTHENTICATION_REQ] = (void *(*)(struct connection *)) receive_packet_authentication_req_100;
103072 phandlers->receive[PACKET_SERVER_SHUTDOWN] = (void *(*)(struct connection *)) receive_packet_server_shutdown_100;
103073 phandlers->receive[PACKET_ENDGAME_REPORT] = (void *(*)(struct connection *)) receive_packet_endgame_report_100;
103074 phandlers->receive[PACKET_ENDGAME_PLAYER] = (void *(*)(struct connection *)) receive_packet_endgame_player_100;
103075 phandlers->receive[PACKET_TILE_INFO] = (void *(*)(struct connection *)) receive_packet_tile_info_100;
103076 phandlers->receive[PACKET_GAME_INFO] = (void *(*)(struct connection *)) receive_packet_game_info_100;
103077 phandlers->receive[PACKET_CALENDAR_INFO] = (void *(*)(struct connection *)) receive_packet_calendar_info_100;
103078 phandlers->receive[PACKET_TIMEOUT_INFO] = (void *(*)(struct connection *)) receive_packet_timeout_info_100;
103079 phandlers->receive[PACKET_MAP_INFO] = (void *(*)(struct connection *)) receive_packet_map_info_100;
103080 phandlers->receive[PACKET_NUKE_TILE_INFO] = (void *(*)(struct connection *)) receive_packet_nuke_tile_info_100;
103081 phandlers->receive[PACKET_TEAM_NAME_INFO] = (void *(*)(struct connection *)) receive_packet_team_name_info_100;
103082 phandlers->receive[PACKET_ACHIEVEMENT_INFO] = (void *(*)(struct connection *)) receive_packet_achievement_info_100;
103083 phandlers->receive[PACKET_CHAT_MSG] = (void *(*)(struct connection *)) receive_packet_chat_msg_100;
103084 phandlers->receive[PACKET_EARLY_CHAT_MSG] = (void *(*)(struct connection *)) receive_packet_early_chat_msg_100;
103085 phandlers->receive[PACKET_CONNECT_MSG] = (void *(*)(struct connection *)) receive_packet_connect_msg_100;
103086 phandlers->receive[PACKET_SERVER_INFO] = (void *(*)(struct connection *)) receive_packet_server_info_100;
103087 phandlers->receive[PACKET_CITY_REMOVE] = (void *(*)(struct connection *)) receive_packet_city_remove_100;
103088 phandlers->receive[PACKET_CITY_INFO] = (void *(*)(struct connection *)) receive_packet_city_info_100;
103089 phandlers->receive[PACKET_CITY_NATIONALITIES] = (void *(*)(struct connection *)) receive_packet_city_nationalities_100;
103090 phandlers->receive[PACKET_CITY_UPDATE_COUNTERS] = (void *(*)(struct connection *)) receive_packet_city_update_counters_100;
103091 phandlers->receive[PACKET_CITY_SHORT_INFO] = (void *(*)(struct connection *)) receive_packet_city_short_info_100;
103092 phandlers->receive[PACKET_TRADE_ROUTE_INFO] = (void *(*)(struct connection *)) receive_packet_trade_route_info_100;
103093 phandlers->receive[PACKET_CITY_NAME_SUGGESTION_INFO] = (void *(*)(struct connection *)) receive_packet_city_name_suggestion_info_100;
103094 phandlers->receive[PACKET_CITY_SABOTAGE_LIST] = (void *(*)(struct connection *)) receive_packet_city_sabotage_list_100;
103095 phandlers->receive[PACKET_PLAYER_REMOVE] = (void *(*)(struct connection *)) receive_packet_player_remove_100;
103096 phandlers->receive[PACKET_PLAYER_INFO] = (void *(*)(struct connection *)) receive_packet_player_info_100;
103097 phandlers->receive[PACKET_PLAYER_DIPLSTATE] = (void *(*)(struct connection *)) receive_packet_player_diplstate_100;
103098 phandlers->receive[PACKET_RESEARCH_INFO] = (void *(*)(struct connection *)) receive_packet_research_info_100;
103099 phandlers->receive[PACKET_UNKNOWN_RESEARCH] = (void *(*)(struct connection *)) receive_packet_unknown_research_100;
103100 phandlers->receive[PACKET_UNIT_REMOVE] = (void *(*)(struct connection *)) receive_packet_unit_remove_100;
103101 phandlers->receive[PACKET_UNIT_INFO] = (void *(*)(struct connection *)) receive_packet_unit_info_100;
103102 phandlers->receive[PACKET_UNIT_SHORT_INFO] = (void *(*)(struct connection *)) receive_packet_unit_short_info_100;
103103 phandlers->receive[PACKET_UNIT_COMBAT_INFO] = (void *(*)(struct connection *)) receive_packet_unit_combat_info_100;
103104 phandlers->receive[PACKET_UNIT_ACTION_ANSWER] = (void *(*)(struct connection *)) receive_packet_unit_action_answer_100;
103105 phandlers->receive[PACKET_UNIT_ACTIONS] = (void *(*)(struct connection *)) receive_packet_unit_actions_100;
103106 phandlers->receive[PACKET_DIPLOMACY_INIT_MEETING] = (void *(*)(struct connection *)) receive_packet_diplomacy_init_meeting_100;
103107 phandlers->receive[PACKET_DIPLOMACY_CANCEL_MEETING] = (void *(*)(struct connection *)) receive_packet_diplomacy_cancel_meeting_100;
103108 phandlers->receive[PACKET_DIPLOMACY_CREATE_CLAUSE] = (void *(*)(struct connection *)) receive_packet_diplomacy_create_clause_100;
103109 phandlers->receive[PACKET_DIPLOMACY_REMOVE_CLAUSE] = (void *(*)(struct connection *)) receive_packet_diplomacy_remove_clause_100;
103110 phandlers->receive[PACKET_DIPLOMACY_ACCEPT_TREATY] = (void *(*)(struct connection *)) receive_packet_diplomacy_accept_treaty_100;
103111 phandlers->receive[PACKET_PAGE_MSG] = (void *(*)(struct connection *)) receive_packet_page_msg_100;
103112 phandlers->receive[PACKET_PAGE_MSG_PART] = (void *(*)(struct connection *)) receive_packet_page_msg_part_100;
103113 phandlers->receive[PACKET_CONN_INFO] = (void *(*)(struct connection *)) receive_packet_conn_info_100;
103114 phandlers->receive[PACKET_CONN_PING_INFO] = (void *(*)(struct connection *)) receive_packet_conn_ping_info_100;
103115 phandlers->receive[PACKET_CONN_PING] = (void *(*)(struct connection *)) receive_packet_conn_ping_100;
103116 phandlers->receive[PACKET_END_PHASE] = (void *(*)(struct connection *)) receive_packet_end_phase_100;
103117 phandlers->receive[PACKET_START_PHASE] = (void *(*)(struct connection *)) receive_packet_start_phase_100;
103118 phandlers->receive[PACKET_NEW_YEAR] = (void *(*)(struct connection *)) receive_packet_new_year_100;
103119 phandlers->receive[PACKET_BEGIN_TURN] = (void *(*)(struct connection *)) receive_packet_begin_turn_100;
103120 phandlers->receive[PACKET_END_TURN] = (void *(*)(struct connection *)) receive_packet_end_turn_100;
103121 phandlers->receive[PACKET_FREEZE_CLIENT] = (void *(*)(struct connection *)) receive_packet_freeze_client_100;
103122 phandlers->receive[PACKET_THAW_CLIENT] = (void *(*)(struct connection *)) receive_packet_thaw_client_100;
103123 phandlers->receive[PACKET_SPACESHIP_INFO] = (void *(*)(struct connection *)) receive_packet_spaceship_info_100;
103124 phandlers->receive[PACKET_RULESET_UNIT] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_100;
103125 phandlers->receive[PACKET_RULESET_UNIT_BONUS] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_bonus_100;
103126 phandlers->receive[PACKET_RULESET_UNIT_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_flag_100;
103127 phandlers->receive[PACKET_RULESET_UNIT_CLASS_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_class_flag_100;
103128 phandlers->receive[PACKET_RULESET_GAME] = (void *(*)(struct connection *)) receive_packet_ruleset_game_100;
103129 phandlers->receive[PACKET_RULESET_SPECIALIST] = (void *(*)(struct connection *)) receive_packet_ruleset_specialist_100;
103130 phandlers->receive[PACKET_RULESET_GOVERNMENT_RULER_TITLE] = (void *(*)(struct connection *)) receive_packet_ruleset_government_ruler_title_100;
103131 phandlers->receive[PACKET_RULESET_TECH] = (void *(*)(struct connection *)) receive_packet_ruleset_tech_100;
103132 phandlers->receive[PACKET_RULESET_TECH_CLASS] = (void *(*)(struct connection *)) receive_packet_ruleset_tech_class_100;
103133 phandlers->receive[PACKET_RULESET_TECH_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_tech_flag_100;
103134 phandlers->receive[PACKET_RULESET_GOVERNMENT] = (void *(*)(struct connection *)) receive_packet_ruleset_government_100;
103135 phandlers->receive[PACKET_RULESET_TERRAIN_CONTROL] = (void *(*)(struct connection *)) receive_packet_ruleset_terrain_control_100;
103136 phandlers->receive[PACKET_RULESETS_READY] = (void *(*)(struct connection *)) receive_packet_rulesets_ready_100;
103137 phandlers->receive[PACKET_RULESET_NATION_SETS] = (void *(*)(struct connection *)) receive_packet_ruleset_nation_sets_100;
103138 phandlers->receive[PACKET_RULESET_NATION_GROUPS] = (void *(*)(struct connection *)) receive_packet_ruleset_nation_groups_100;
103139 phandlers->receive[PACKET_RULESET_NATION] = (void *(*)(struct connection *)) receive_packet_ruleset_nation_100;
103140 phandlers->receive[PACKET_NATION_AVAILABILITY] = (void *(*)(struct connection *)) receive_packet_nation_availability_100;
103141 phandlers->receive[PACKET_RULESET_STYLE] = (void *(*)(struct connection *)) receive_packet_ruleset_style_100;
103142 phandlers->receive[PACKET_RULESET_CITY] = (void *(*)(struct connection *)) receive_packet_ruleset_city_100;
103143 phandlers->receive[PACKET_RULESET_BUILDING] = (void *(*)(struct connection *)) receive_packet_ruleset_building_100;
103144 phandlers->receive[PACKET_RULESET_IMPR_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_impr_flag_100;
103145 phandlers->receive[PACKET_RULESET_TERRAIN] = (void *(*)(struct connection *)) receive_packet_ruleset_terrain_100;
103146 phandlers->receive[PACKET_RULESET_TERRAIN_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_terrain_flag_100;
103147 phandlers->receive[PACKET_RULESET_UNIT_CLASS] = (void *(*)(struct connection *)) receive_packet_ruleset_unit_class_100;
103148 phandlers->receive[PACKET_RULESET_EXTRA] = (void *(*)(struct connection *)) receive_packet_ruleset_extra_100;
103149 phandlers->receive[PACKET_RULESET_EXTRA_FLAG] = (void *(*)(struct connection *)) receive_packet_ruleset_extra_flag_100;
103150 phandlers->receive[PACKET_RULESET_BASE] = (void *(*)(struct connection *)) receive_packet_ruleset_base_100;
103151 phandlers->receive[PACKET_RULESET_ROAD] = (void *(*)(struct connection *)) receive_packet_ruleset_road_100;
103152 phandlers->receive[PACKET_RULESET_GOODS] = (void *(*)(struct connection *)) receive_packet_ruleset_goods_100;
103153 phandlers->receive[PACKET_RULESET_DISASTER] = (void *(*)(struct connection *)) receive_packet_ruleset_disaster_100;
103154 phandlers->receive[PACKET_RULESET_ACHIEVEMENT] = (void *(*)(struct connection *)) receive_packet_ruleset_achievement_100;
103155 phandlers->receive[PACKET_RULESET_TRADE] = (void *(*)(struct connection *)) receive_packet_ruleset_trade_100;
103156 phandlers->receive[PACKET_RULESET_ACTION] = (void *(*)(struct connection *)) receive_packet_ruleset_action_100;
103157 phandlers->receive[PACKET_RULESET_ACTION_ENABLER] = (void *(*)(struct connection *)) receive_packet_ruleset_action_enabler_100;
103158 phandlers->receive[PACKET_RULESET_ACTION_AUTO] = (void *(*)(struct connection *)) receive_packet_ruleset_action_auto_100;
103159 phandlers->receive[PACKET_RULESET_COUNTER] = (void *(*)(struct connection *)) receive_packet_ruleset_counter_100;
103160 phandlers->receive[PACKET_RULESET_MUSIC] = (void *(*)(struct connection *)) receive_packet_ruleset_music_100;
103161 phandlers->receive[PACKET_RULESET_MULTIPLIER] = (void *(*)(struct connection *)) receive_packet_ruleset_multiplier_100;
103162 phandlers->receive[PACKET_RULESET_CLAUSE] = (void *(*)(struct connection *)) receive_packet_ruleset_clause_100;
103163 phandlers->receive[PACKET_RULESET_CONTROL] = (void *(*)(struct connection *)) receive_packet_ruleset_control_100;
103164 phandlers->receive[PACKET_RULESET_SUMMARY] = (void *(*)(struct connection *)) receive_packet_ruleset_summary_100;
103165 phandlers->receive[PACKET_RULESET_DESCRIPTION_PART] = (void *(*)(struct connection *)) receive_packet_ruleset_description_part_100;
103166 phandlers->receive[PACKET_SINGLE_WANT_HACK_REPLY] = (void *(*)(struct connection *)) receive_packet_single_want_hack_reply_100;
103167 phandlers->receive[PACKET_RULESET_CHOICES] = (void *(*)(struct connection *)) receive_packet_ruleset_choices_100;
103168 phandlers->receive[PACKET_GAME_LOAD] = (void *(*)(struct connection *)) receive_packet_game_load_100;
103169 phandlers->receive[PACKET_SERVER_SETTING_CONTROL] = (void *(*)(struct connection *)) receive_packet_server_setting_control_100;
103170 phandlers->receive[PACKET_SERVER_SETTING_CONST] = (void *(*)(struct connection *)) receive_packet_server_setting_const_100;
103171 phandlers->receive[PACKET_SERVER_SETTING_BOOL] = (void *(*)(struct connection *)) receive_packet_server_setting_bool_100;
103172 phandlers->receive[PACKET_SERVER_SETTING_INT] = (void *(*)(struct connection *)) receive_packet_server_setting_int_100;
103173 phandlers->receive[PACKET_SERVER_SETTING_STR] = (void *(*)(struct connection *)) receive_packet_server_setting_str_100;
103174 phandlers->receive[PACKET_SERVER_SETTING_ENUM] = (void *(*)(struct connection *)) receive_packet_server_setting_enum_100;
103175 phandlers->receive[PACKET_SERVER_SETTING_BITWISE] = (void *(*)(struct connection *)) receive_packet_server_setting_bitwise_100;
103176 phandlers->receive[PACKET_SET_TOPOLOGY] = (void *(*)(struct connection *)) receive_packet_set_topology_100;
103177 phandlers->receive[PACKET_RULESET_EFFECT] = (void *(*)(struct connection *)) receive_packet_ruleset_effect_100;
103178 phandlers->receive[PACKET_RULESET_RESOURCE] = (void *(*)(struct connection *)) receive_packet_ruleset_resource_100;
103179 phandlers->receive[PACKET_SCENARIO_INFO] = (void *(*)(struct connection *)) receive_packet_scenario_info_100;
103180 phandlers->receive[PACKET_SCENARIO_DESCRIPTION] = (void *(*)(struct connection *)) receive_packet_scenario_description_100;
103181 phandlers->receive[PACKET_VOTE_NEW] = (void *(*)(struct connection *)) receive_packet_vote_new_100;
103182 phandlers->receive[PACKET_VOTE_UPDATE] = (void *(*)(struct connection *)) receive_packet_vote_update_100;
103183 phandlers->receive[PACKET_VOTE_REMOVE] = (void *(*)(struct connection *)) receive_packet_vote_remove_100;
103184 phandlers->receive[PACKET_VOTE_RESOLVE] = (void *(*)(struct connection *)) receive_packet_vote_resolve_100;
103185 phandlers->receive[PACKET_EDIT_OBJECT_CREATED] = (void *(*)(struct connection *)) receive_packet_edit_object_created_100;
103186 phandlers->receive[PACKET_PLAY_MUSIC] = (void *(*)(struct connection *)) receive_packet_play_music_100;
103187 phandlers->receive[PACKET_POPUP_IMAGE] = (void *(*)(struct connection *)) receive_packet_popup_image_100;
103188 phandlers->receive[PACKET_WEB_CITY_INFO_ADDITION] = (void *(*)(struct connection *)) receive_packet_web_city_info_addition_100;
103189 phandlers->receive[PACKET_WEB_PLAYER_INFO_ADDITION] = (void *(*)(struct connection *)) receive_packet_web_player_info_addition_100;
103190 phandlers->receive[PACKET_WEB_RULESET_UNIT_ADDITION] = (void *(*)(struct connection *)) receive_packet_web_ruleset_unit_addition_100;
103191 }
103192}
103193
103194 void packet_handlers_fill_capability(struct packet_handlers *phandlers,
103195 const char *capability)
103196{
103197}
103198
103199 void packet_destroy(void *packet, enum packet_type type)
103200{
103201 static void (*const destroy_handlers[PACKET_LAST])(void *packet) = {
103202 [PACKET_PROCESSING_STARTED] = destroy_packet_processing_started,
103203 [PACKET_PROCESSING_FINISHED] = destroy_packet_processing_finished,
103204 [PACKET_INVESTIGATE_STARTED] = destroy_packet_investigate_started,
103205 [PACKET_INVESTIGATE_FINISHED] = destroy_packet_investigate_finished,
103206 [PACKET_SERVER_JOIN_REQ] = destroy_packet_server_join_req,
103207 [PACKET_SERVER_JOIN_REPLY] = destroy_packet_server_join_reply,
103208 [PACKET_AUTHENTICATION_REQ] = destroy_packet_authentication_req,
103209 [PACKET_AUTHENTICATION_REPLY] = destroy_packet_authentication_reply,
103210 [PACKET_SERVER_SHUTDOWN] = destroy_packet_server_shutdown,
103211 [PACKET_NATION_SELECT_REQ] = destroy_packet_nation_select_req,
103212 [PACKET_PLAYER_READY] = destroy_packet_player_ready,
103213 [PACKET_ENDGAME_REPORT] = destroy_packet_endgame_report,
103214 [PACKET_ENDGAME_PLAYER] = destroy_packet_endgame_player,
103215 [PACKET_TILE_INFO] = destroy_packet_tile_info,
103216 [PACKET_GAME_INFO] = destroy_packet_game_info,
103217 [PACKET_CALENDAR_INFO] = destroy_packet_calendar_info,
103218 [PACKET_TIMEOUT_INFO] = destroy_packet_timeout_info,
103219 [PACKET_MAP_INFO] = destroy_packet_map_info,
103220 [PACKET_NUKE_TILE_INFO] = destroy_packet_nuke_tile_info,
103221 [PACKET_TEAM_NAME_INFO] = destroy_packet_team_name_info,
103222 [PACKET_ACHIEVEMENT_INFO] = destroy_packet_achievement_info,
103223 [PACKET_CHAT_MSG] = destroy_packet_chat_msg,
103224 [PACKET_EARLY_CHAT_MSG] = destroy_packet_early_chat_msg,
103225 [PACKET_CHAT_MSG_REQ] = destroy_packet_chat_msg_req,
103226 [PACKET_CONNECT_MSG] = destroy_packet_connect_msg,
103227 [PACKET_SERVER_INFO] = destroy_packet_server_info,
103228 [PACKET_CITY_REMOVE] = destroy_packet_city_remove,
103229 [PACKET_CITY_INFO] = destroy_packet_city_info,
103230 [PACKET_CITY_NATIONALITIES] = destroy_packet_city_nationalities,
103231 [PACKET_CITY_UPDATE_COUNTERS] = destroy_packet_city_update_counters,
103232 [PACKET_CITY_SHORT_INFO] = destroy_packet_city_short_info,
103233 [PACKET_TRADE_ROUTE_INFO] = destroy_packet_trade_route_info,
103234 [PACKET_CITY_SELL] = destroy_packet_city_sell,
103235 [PACKET_CITY_BUY] = destroy_packet_city_buy,
103236 [PACKET_CITY_CHANGE] = destroy_packet_city_change,
103237 [PACKET_CITY_WORKLIST] = destroy_packet_city_worklist,
103238 [PACKET_CITY_MAKE_SPECIALIST] = destroy_packet_city_make_specialist,
103239 [PACKET_CITY_MAKE_WORKER] = destroy_packet_city_make_worker,
103240 [PACKET_CITY_CHANGE_SPECIALIST] = destroy_packet_city_change_specialist,
103241 [PACKET_CITY_RENAME] = destroy_packet_city_rename,
103242 [PACKET_CITY_OPTIONS_REQ] = destroy_packet_city_options_req,
103243 [PACKET_CITY_REFRESH] = destroy_packet_city_refresh,
103244 [PACKET_CITY_NAME_SUGGESTION_REQ] = destroy_packet_city_name_suggestion_req,
103245 [PACKET_CITY_NAME_SUGGESTION_INFO] = destroy_packet_city_name_suggestion_info,
103246 [PACKET_CITY_SABOTAGE_LIST] = destroy_packet_city_sabotage_list,
103247 [PACKET_CITY_RALLY_POINT] = destroy_packet_city_rally_point,
103248 [PACKET_WORKER_TASK] = destroy_packet_worker_task,
103249 [PACKET_PLAYER_REMOVE] = destroy_packet_player_remove,
103250 [PACKET_PLAYER_INFO] = destroy_packet_player_info,
103251 [PACKET_PLAYER_PHASE_DONE] = destroy_packet_player_phase_done,
103252 [PACKET_PLAYER_RATES] = destroy_packet_player_rates,
103253 [PACKET_PLAYER_CHANGE_GOVERNMENT] = destroy_packet_player_change_government,
103254 [PACKET_PLAYER_PLACE_INFRA] = destroy_packet_player_place_infra,
103255 [PACKET_PLAYER_ATTRIBUTE_BLOCK] = destroy_packet_player_attribute_block,
103256 [PACKET_PLAYER_ATTRIBUTE_CHUNK] = destroy_packet_player_attribute_chunk,
103257 [PACKET_PLAYER_DIPLSTATE] = destroy_packet_player_diplstate,
103258 [PACKET_PLAYER_MULTIPLIER] = destroy_packet_player_multiplier,
103259 [PACKET_RESEARCH_INFO] = destroy_packet_research_info,
103260 [PACKET_UNKNOWN_RESEARCH] = destroy_packet_unknown_research,
103261 [PACKET_PLAYER_RESEARCH] = destroy_packet_player_research,
103262 [PACKET_PLAYER_TECH_GOAL] = destroy_packet_player_tech_goal,
103263 [PACKET_UNIT_REMOVE] = destroy_packet_unit_remove,
103264 [PACKET_UNIT_INFO] = destroy_packet_unit_info,
103265 [PACKET_UNIT_SHORT_INFO] = destroy_packet_unit_short_info,
103266 [PACKET_UNIT_COMBAT_INFO] = destroy_packet_unit_combat_info,
103267 [PACKET_UNIT_SSCS_SET] = destroy_packet_unit_sscs_set,
103268 [PACKET_UNIT_ORDERS] = destroy_packet_unit_orders,
103269 [PACKET_UNIT_SERVER_SIDE_AGENT_SET] = destroy_packet_unit_server_side_agent_set,
103270 [PACKET_UNIT_ACTION_QUERY] = destroy_packet_unit_action_query,
103271 [PACKET_UNIT_TYPE_UPGRADE] = destroy_packet_unit_type_upgrade,
103272 [PACKET_UNIT_DO_ACTION] = destroy_packet_unit_do_action,
103273 [PACKET_UNIT_ACTION_ANSWER] = destroy_packet_unit_action_answer,
103274 [PACKET_UNIT_GET_ACTIONS] = destroy_packet_unit_get_actions,
103275 [PACKET_UNIT_ACTIONS] = destroy_packet_unit_actions,
103276 [PACKET_UNIT_CHANGE_ACTIVITY] = destroy_packet_unit_change_activity,
103277 [PACKET_DIPLOMACY_INIT_MEETING_REQ] = destroy_packet_diplomacy_init_meeting_req,
103278 [PACKET_DIPLOMACY_INIT_MEETING] = destroy_packet_diplomacy_init_meeting,
103279 [PACKET_DIPLOMACY_CANCEL_MEETING_REQ] = destroy_packet_diplomacy_cancel_meeting_req,
103280 [PACKET_DIPLOMACY_CANCEL_MEETING] = destroy_packet_diplomacy_cancel_meeting,
103281 [PACKET_DIPLOMACY_CREATE_CLAUSE_REQ] = destroy_packet_diplomacy_create_clause_req,
103282 [PACKET_DIPLOMACY_CREATE_CLAUSE] = destroy_packet_diplomacy_create_clause,
103283 [PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ] = destroy_packet_diplomacy_remove_clause_req,
103284 [PACKET_DIPLOMACY_REMOVE_CLAUSE] = destroy_packet_diplomacy_remove_clause,
103285 [PACKET_DIPLOMACY_ACCEPT_TREATY_REQ] = destroy_packet_diplomacy_accept_treaty_req,
103286 [PACKET_DIPLOMACY_ACCEPT_TREATY] = destroy_packet_diplomacy_accept_treaty,
103287 [PACKET_DIPLOMACY_CANCEL_PACT] = destroy_packet_diplomacy_cancel_pact,
103288 [PACKET_PAGE_MSG] = destroy_packet_page_msg,
103289 [PACKET_PAGE_MSG_PART] = destroy_packet_page_msg_part,
103290 [PACKET_REPORT_REQ] = destroy_packet_report_req,
103291 [PACKET_CONN_INFO] = destroy_packet_conn_info,
103292 [PACKET_CONN_PING_INFO] = destroy_packet_conn_ping_info,
103293 [PACKET_CONN_PING] = destroy_packet_conn_ping,
103294 [PACKET_CONN_PONG] = destroy_packet_conn_pong,
103295 [PACKET_CLIENT_HEARTBEAT] = destroy_packet_client_heartbeat,
103296 [PACKET_CLIENT_INFO] = destroy_packet_client_info,
103297 [PACKET_END_PHASE] = destroy_packet_end_phase,
103298 [PACKET_START_PHASE] = destroy_packet_start_phase,
103299 [PACKET_NEW_YEAR] = destroy_packet_new_year,
103300 [PACKET_BEGIN_TURN] = destroy_packet_begin_turn,
103301 [PACKET_END_TURN] = destroy_packet_end_turn,
103302 [PACKET_FREEZE_CLIENT] = destroy_packet_freeze_client,
103303 [PACKET_THAW_CLIENT] = destroy_packet_thaw_client,
103304 [PACKET_SPACESHIP_LAUNCH] = destroy_packet_spaceship_launch,
103305 [PACKET_SPACESHIP_PLACE] = destroy_packet_spaceship_place,
103306 [PACKET_SPACESHIP_INFO] = destroy_packet_spaceship_info,
103307 [PACKET_RULESET_UNIT] = destroy_packet_ruleset_unit,
103308 [PACKET_RULESET_UNIT_BONUS] = destroy_packet_ruleset_unit_bonus,
103309 [PACKET_RULESET_UNIT_FLAG] = destroy_packet_ruleset_unit_flag,
103310 [PACKET_RULESET_UNIT_CLASS_FLAG] = destroy_packet_ruleset_unit_class_flag,
103311 [PACKET_RULESET_GAME] = destroy_packet_ruleset_game,
103312 [PACKET_RULESET_SPECIALIST] = destroy_packet_ruleset_specialist,
103313 [PACKET_RULESET_GOVERNMENT_RULER_TITLE] = destroy_packet_ruleset_government_ruler_title,
103314 [PACKET_RULESET_TECH] = destroy_packet_ruleset_tech,
103315 [PACKET_RULESET_TECH_CLASS] = destroy_packet_ruleset_tech_class,
103316 [PACKET_RULESET_TECH_FLAG] = destroy_packet_ruleset_tech_flag,
103317 [PACKET_RULESET_GOVERNMENT] = destroy_packet_ruleset_government,
103318 [PACKET_RULESET_TERRAIN_CONTROL] = destroy_packet_ruleset_terrain_control,
103319 [PACKET_RULESETS_READY] = destroy_packet_rulesets_ready,
103320 [PACKET_RULESET_NATION_SETS] = destroy_packet_ruleset_nation_sets,
103321 [PACKET_RULESET_NATION_GROUPS] = destroy_packet_ruleset_nation_groups,
103322 [PACKET_RULESET_NATION] = destroy_packet_ruleset_nation,
103323 [PACKET_NATION_AVAILABILITY] = destroy_packet_nation_availability,
103324 [PACKET_RULESET_STYLE] = destroy_packet_ruleset_style,
103325 [PACKET_RULESET_CITY] = destroy_packet_ruleset_city,
103326 [PACKET_RULESET_BUILDING] = destroy_packet_ruleset_building,
103327 [PACKET_RULESET_IMPR_FLAG] = destroy_packet_ruleset_impr_flag,
103328 [PACKET_RULESET_TERRAIN] = destroy_packet_ruleset_terrain,
103329 [PACKET_RULESET_TERRAIN_FLAG] = destroy_packet_ruleset_terrain_flag,
103330 [PACKET_RULESET_UNIT_CLASS] = destroy_packet_ruleset_unit_class,
103331 [PACKET_RULESET_EXTRA] = destroy_packet_ruleset_extra,
103332 [PACKET_RULESET_EXTRA_FLAG] = destroy_packet_ruleset_extra_flag,
103333 [PACKET_RULESET_BASE] = destroy_packet_ruleset_base,
103334 [PACKET_RULESET_ROAD] = destroy_packet_ruleset_road,
103335 [PACKET_RULESET_GOODS] = destroy_packet_ruleset_goods,
103336 [PACKET_RULESET_DISASTER] = destroy_packet_ruleset_disaster,
103337 [PACKET_RULESET_ACHIEVEMENT] = destroy_packet_ruleset_achievement,
103338 [PACKET_RULESET_TRADE] = destroy_packet_ruleset_trade,
103339 [PACKET_RULESET_ACTION] = destroy_packet_ruleset_action,
103340 [PACKET_RULESET_ACTION_ENABLER] = destroy_packet_ruleset_action_enabler,
103341 [PACKET_RULESET_ACTION_AUTO] = destroy_packet_ruleset_action_auto,
103342 [PACKET_RULESET_COUNTER] = destroy_packet_ruleset_counter,
103343 [PACKET_RULESET_MUSIC] = destroy_packet_ruleset_music,
103344 [PACKET_RULESET_MULTIPLIER] = destroy_packet_ruleset_multiplier,
103345 [PACKET_RULESET_CLAUSE] = destroy_packet_ruleset_clause,
103346 [PACKET_RULESET_CONTROL] = destroy_packet_ruleset_control,
103347 [PACKET_RULESET_SUMMARY] = destroy_packet_ruleset_summary,
103348 [PACKET_RULESET_DESCRIPTION_PART] = destroy_packet_ruleset_description_part,
103349 [PACKET_SINGLE_WANT_HACK_REQ] = destroy_packet_single_want_hack_req,
103350 [PACKET_SINGLE_WANT_HACK_REPLY] = destroy_packet_single_want_hack_reply,
103351 [PACKET_RULESET_CHOICES] = destroy_packet_ruleset_choices,
103352 [PACKET_RULESET_SELECT] = destroy_packet_ruleset_select,
103353 [PACKET_GAME_LOAD] = destroy_packet_game_load,
103354 [PACKET_SERVER_SETTING_CONTROL] = destroy_packet_server_setting_control,
103355 [PACKET_SERVER_SETTING_CONST] = destroy_packet_server_setting_const,
103356 [PACKET_SERVER_SETTING_BOOL] = destroy_packet_server_setting_bool,
103357 [PACKET_SERVER_SETTING_INT] = destroy_packet_server_setting_int,
103358 [PACKET_SERVER_SETTING_STR] = destroy_packet_server_setting_str,
103359 [PACKET_SERVER_SETTING_ENUM] = destroy_packet_server_setting_enum,
103360 [PACKET_SERVER_SETTING_BITWISE] = destroy_packet_server_setting_bitwise,
103361 [PACKET_SET_TOPOLOGY] = destroy_packet_set_topology,
103362 [PACKET_RULESET_EFFECT] = destroy_packet_ruleset_effect,
103363 [PACKET_RULESET_RESOURCE] = destroy_packet_ruleset_resource,
103364 [PACKET_SCENARIO_INFO] = destroy_packet_scenario_info,
103365 [PACKET_SCENARIO_DESCRIPTION] = destroy_packet_scenario_description,
103366 [PACKET_SAVE_SCENARIO] = destroy_packet_save_scenario,
103367 [PACKET_VOTE_NEW] = destroy_packet_vote_new,
103368 [PACKET_VOTE_UPDATE] = destroy_packet_vote_update,
103369 [PACKET_VOTE_REMOVE] = destroy_packet_vote_remove,
103370 [PACKET_VOTE_RESOLVE] = destroy_packet_vote_resolve,
103371 [PACKET_VOTE_SUBMIT] = destroy_packet_vote_submit,
103372 [PACKET_EDIT_MODE] = destroy_packet_edit_mode,
103373 [PACKET_EDIT_RECALCULATE_BORDERS] = destroy_packet_edit_recalculate_borders,
103374 [PACKET_EDIT_CHECK_TILES] = destroy_packet_edit_check_tiles,
103375 [PACKET_EDIT_TOGGLE_FOGOFWAR] = destroy_packet_edit_toggle_fogofwar,
103376 [PACKET_EDIT_TILE_TERRAIN] = destroy_packet_edit_tile_terrain,
103377 [PACKET_EDIT_TILE_EXTRA] = destroy_packet_edit_tile_extra,
103378 [PACKET_EDIT_STARTPOS] = destroy_packet_edit_startpos,
103379 [PACKET_EDIT_STARTPOS_FULL] = destroy_packet_edit_startpos_full,
103380 [PACKET_EDIT_TILE] = destroy_packet_edit_tile,
103381 [PACKET_EDIT_UNIT_CREATE] = destroy_packet_edit_unit_create,
103382 [PACKET_EDIT_UNIT_REMOVE] = destroy_packet_edit_unit_remove,
103383 [PACKET_EDIT_UNIT_REMOVE_BY_ID] = destroy_packet_edit_unit_remove_by_id,
103384 [PACKET_EDIT_UNIT] = destroy_packet_edit_unit,
103385 [PACKET_EDIT_CITY_CREATE] = destroy_packet_edit_city_create,
103386 [PACKET_EDIT_CITY_REMOVE] = destroy_packet_edit_city_remove,
103387 [PACKET_EDIT_CITY] = destroy_packet_edit_city,
103388 [PACKET_EDIT_PLAYER_CREATE] = destroy_packet_edit_player_create,
103389 [PACKET_EDIT_PLAYER_REMOVE] = destroy_packet_edit_player_remove,
103390 [PACKET_EDIT_PLAYER] = destroy_packet_edit_player,
103391 [PACKET_EDIT_PLAYER_VISION] = destroy_packet_edit_player_vision,
103392 [PACKET_EDIT_GAME] = destroy_packet_edit_game,
103393 [PACKET_EDIT_SCENARIO_DESC] = destroy_packet_edit_scenario_desc,
103394 [PACKET_EDIT_OBJECT_CREATED] = destroy_packet_edit_object_created,
103395 [PACKET_PLAY_MUSIC] = destroy_packet_play_music,
103396 [PACKET_POPUP_IMAGE] = destroy_packet_popup_image,
103397 [PACKET_WEB_CITY_INFO_ADDITION] = destroy_packet_web_city_info_addition,
103398 [PACKET_WEB_CMA_SET] = destroy_packet_web_cma_set,
103399 [PACKET_WEB_CMA_CLEAR] = destroy_packet_web_cma_clear,
103400 [PACKET_WEB_PLAYER_INFO_ADDITION] = destroy_packet_web_player_info_addition,
103401 [PACKET_WEB_RULESET_UNIT_ADDITION] = destroy_packet_web_ruleset_unit_addition,
103402 };
103403 void (*handler)(void *packet) = (type < PACKET_LAST ? destroy_handlers[type] : nullptr);
103404
103405 fc_assert_action_msg(handler != nullptr, handler = free,
103406 "packet_destroy(): invalid packet type %d", type);
103407
103408 handler(packet);
103409}
are_action_probabilitys_equal
bool are_action_probabilitys_equal(const struct act_prob *ap1, const struct act_prob *ap2)
Definition actions.c:5095
MAX_NUM_ACTIONS
#define MAX_NUM_ACTIONS
Definition actions.h:58
bitvector.h
BV_DEFINE
#define BV_DEFINE(name, bits)
Definition bitvector.h:132
BV_CLR_ALL
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
BV_SET
#define BV_SET(bv, bit)
Definition bitvector.h:81
BV_ARE_EQUAL
#define BV_ARE_EQUAL(vec1, vec2)
Definition bitvector.h:113
BV_ISSET
#define BV_ISSET(bv, bit)
Definition bitvector.h:78
capability.h
capstr.h
FEELING_LAST
@ FEELING_LAST
Definition city.h:285
cm_are_parameter_equal
bool cm_are_parameter_equal(const struct cm_parameter *const p1, const struct cm_parameter *const p2)
Definition cm.c:2138
calendar_fragments
char * calendar_fragments
Definition comments.c:100
resources
char * resources
Definition comments.c:36
world_peace_turns
char * world_peace_turns
Definition comments.c:99
disasters
char * disasters
Definition comments.c:45
culture_migration_pml
char * culture_migration_pml
Definition comments.c:98
incite_cost
char * incite_cost
Definition comments.c:74
ATTRIBUTE_CHUNK_SIZE
#define ATTRIBUTE_CHUNK_SIZE
Definition conn_types.h:66
MAX_LEN_PACKET
#define MAX_LEN_PACKET
Definition conn_types.h:29
report_type
report_type
Definition conn_types.h:49
MAX_LEN_ROUTE
#define MAX_LEN_ROUTE
Definition conn_types.h:38
authentication_type
authentication_type
Definition conn_types.h:41
conn_description
const char * conn_description(const struct connection *pconn)
Definition connection.c:474
connection.h
conn_list_iterate
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
conn_list_iterate_end
#define conn_list_iterate_end
Definition connection.h:110
counters
static struct counter counters[MAX_COUNTERS]
Definition counters.c:31
dataio.h
DIO_BV_PUT
#define DIO_BV_PUT(pdout, location, bv)
Definition dataio_json.h:198
DIO_BV_GET
#define DIO_BV_GET(pdin, location, bv)
Definition dataio_json.h:123
DIO_GET
#define DIO_GET(f, d, l,...)
Definition dataio_json.h:127
DIO_PUT
#define DIO_PUT(f, d, l,...)
Definition dataio_json.h:201
plocation_field_new
struct plocation * plocation_field_new(char *name)
Definition dataio_raw.c:1100
plocation_elem_new
struct plocation * plocation_elem_new(int number)
Definition dataio_raw.c:1114
airlift
static void airlift(QVariant data1, QVariant data2)
Definition dialogs.cpp:1839
caption
const char * caption
Definition dialogs_g.h:37
headline
const char const char * headline
Definition dialogs_g.h:38
cost
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int cost
Definition dialogs_g.h:74
diplomat_investigate
bool diplomat_investigate(struct player *pplayer, struct unit *pdiplomat, struct city *pcity, const struct action *paction)
Definition diplomats.c:324
id
int int id
Definition editgui_g.h:28
effects
struct effect_list * effects[EFT_COUNT]
Definition effects.c:127
reqs
struct @21::@22 reqs
event
enum event_type event
Definition events.c:81
extras
static struct extra_type extras[MAX_EXTRA_TYPES]
Definition extras.c:31
extra_count
int extra_count(void)
Definition extras.c:153
is_server
static bool is_server(void)
Definition fc_interface.h:69
MAX_NUM_CONNECTIONS
#define MAX_NUM_CONNECTIONS
Definition fc_types.h:38
MAX_CITY_NATIONALITIES
#define MAX_CITY_NATIONALITIES
Definition fc_types.h:89
MAX_VET_LEVELS
#define MAX_VET_LEVELS
Definition fc_types.h:49
MAX_GRANARY_INIS
#define MAX_GRANARY_INIS
Definition fc_types.h:72
MAX_NUM_NATIONS
#define MAX_NUM_NATIONS
Definition fc_types.h:60
MAX_NUM_RULESETS
#define MAX_NUM_RULESETS
Definition fc_types.h:414
MAX_NUM_NATION_SETS
#define MAX_NUM_NATION_SETS
Definition fc_types.h:57
MAX_NUM_BUILDING_LIST
#define MAX_NUM_BUILDING_LIST
Definition fc_types.h:46
Nation_type_id
int Nation_type_id
Definition fc_types.h:384
Terrain_type_id
int Terrain_type_id
Definition fc_types.h:377
action_id
int action_id
Definition fc_types.h:393
SP_MAX
#define SP_MAX
Definition fc_types.h:412
Specialist_type_id
int Specialist_type_id
Definition fc_types.h:379
Government_type_id
int Government_type_id
Definition fc_types.h:385
MAX_CALENDAR_FRAGMENTS
#define MAX_CALENDAR_FRAGMENTS
Definition fc_types.h:62
MAX_NUM_NATION_GROUPS
#define MAX_NUM_NATION_GROUPS
Definition fc_types.h:58
MAX_NUM_PLAYER_SLOTS
#define MAX_NUM_PLAYER_SLOTS
Definition fc_types.h:32
MAX_NUM_LEADERS
#define MAX_NUM_LEADERS
Definition fc_types.h:56
MAX_NUM_MULTIPLIERS
#define MAX_NUM_MULTIPLIERS
Definition fc_types.h:55
MAX_NUM_UNIT_LIST
#define MAX_NUM_UNIT_LIST
Definition fc_types.h:45
MAX_EXTRA_TYPES
#define MAX_EXTRA_TYPES
Definition fc_types.h:50
spaceship_place_type
spaceship_place_type
Definition fc_types.h:1277
Unit_type_id
int Unit_type_id
Definition fc_types.h:386
MAX_NUM_TECH_LIST
#define MAX_NUM_TECH_LIST
Definition fc_types.h:44
O_LAST
@ O_LAST
Definition fc_types.h:101
MAX_CITY_TILES
#define MAX_CITY_TILES
Definition fc_types.h:87
MAX_COUNTERS
#define MAX_COUNTERS
Definition fc_types.h:106
game.h
genhash_new_full
struct genhash * genhash_new_full(genhash_val_fn_t key_val_func, genhash_comp_fn_t key_comp_func, genhash_copy_fn_t key_copy_func, genhash_free_fn_t key_free_func, genhash_copy_fn_t data_copy_func, genhash_free_fn_t data_free_func)
Definition genhash.c:268
genhash_insert
bool genhash_insert(struct genhash *pgenhash, const void *key, const void *data)
Definition genhash.c:604
genhash_lookup
bool genhash_lookup(const struct genhash *pgenhash, const void *key, void **pdata)
Definition genhash.c:681
genhash_remove
bool genhash_remove(struct genhash *pgenhash, const void *key)
Definition genhash.c:702
genhash.h
genhash_val_t
unsigned int genhash_val_t
Definition genhash.h:32
government_count
Government_type_id government_count(void)
Definition government.c:71
actor_unit_id
static int actor_unit_id
Definition action_dialog.c:68
target_extra_id
static int target_extra_id
Definition action_dialog.c:70
owner
struct city * owner
Definition citydlg.c:226
load_filename
static void load_filename(const char *filename)
Definition pages.c:2854
scenario_authors
static GtkWidget * scenario_authors
Definition pages.c:64
persistent
static GtkWidget * persistent
Definition rallypointdlg.c:40
type
GType type
Definition repodlgs.c:1313
hash
static GHashTable * hash
Definition wldlg.c:322
leader_name
static char * leader_name
Definition dialogs.c:97
B_LAST
#define B_LAST
Definition improvement.h:42
name
const char * name
Definition inputfile.c:127
log.h
log_packet_detailed
#define log_packet_detailed
Definition log.h:138
fc_assert
#define fc_assert(condition)
Definition log.h:176
fc_assert_action_msg
#define fc_assert_action_msg(condition, action, message,...)
Definition log.h:201
log_error
#define log_error(message,...)
Definition log.h:103
FC_STATIC_ASSERT
#define FC_STATIC_ASSERT(cond, tag)
Definition log.h:235
fc_assert_ret_val_msg
#define fc_assert_ret_val_msg(condition, val, message,...)
Definition log.h:208
nuclear_winter
void nuclear_winter(int effect)
Definition maphand.c:119
global_warming
void global_warming(int effect)
Definition maphand.c:106
mem.h
FC_FREE
#define FC_FREE(ptr)
Definition mem.h:41
fc_malloc
#define fc_malloc(sz)
Definition mem.h:34
gui
static mpgui * gui
Definition mpgui_qt.cpp:52
worker
static mpqt_worker * worker
Definition mpgui_qt.cpp:54
multipliers
static struct multiplier multipliers[MAX_NUM_MULTIPLIERS]
Definition multipliers.c:23
nation_count
Nation_type_id nation_count(void)
Definition nation.c:507
num_nation_sets
static int num_nation_sets
Definition nation.c:48
num_nation_groups
static int num_nation_groups
Definition nation.c:50
nations
static struct nation_type * nations
Definition nation.c:46
post_receive_packet_server_join_reply
void post_receive_packet_server_join_reply(struct connection *pconn, const struct packet_server_join_reply *packet)
Definition packets.c:652
pre_send_packet_player_attribute_chunk
void pre_send_packet_player_attribute_chunk(struct connection *pc, struct packet_player_attribute_chunk *packet)
Definition packets.c:793
post_send_packet_server_join_reply
void post_send_packet_server_join_reply(struct connection *pconn, const struct packet_server_join_reply *packet)
Definition packets.c:640
packets.h
SEND_PACKET_START
#define SEND_PACKET_START(packet_type)
Definition packets.h:129
SEND_PACKET_DISCARD
#define SEND_PACKET_DISCARD()
Definition packets.h:147
RECEIVE_PACKET_START
#define RECEIVE_PACKET_START(packet_type, result)
Definition packets.h:150
SEND_PACKET_END
#define SEND_PACKET_END(packet_type)
Definition packets.h:137
RECEIVE_PACKET_FIELD_ERROR
#define RECEIVE_PACKET_FIELD_ERROR(field,...)
Definition packets.h:176
RECEIVE_PACKET_END
#define RECEIVE_PACKET_END(result)
Definition packets.h:166
init_packet_vote_update
static void init_packet_vote_update(struct packet_vote_update *packet)
Definition packets_gen.c:90102
destroy_packet_city_worklist
#define destroy_packet_city_worklist
Definition packets_gen.c:21759
send_packet_map_info_100
static int send_packet_map_info_100(struct connection *pc, const struct packet_map_info *packet)
Definition packets_gen.c:12018
init_packet_endgame_report
static void init_packet_endgame_report(struct packet_endgame_report *packet)
Definition packets_gen.c:2543
receive_packet_set_topology_100
static struct packet_set_topology * receive_packet_set_topology_100(struct connection *pc)
Definition packets_gen.c:87620
receive_packet_chat_msg_100
static struct packet_chat_msg * receive_packet_chat_msg_100(struct connection *pc)
Definition packets_gen.c:13000
send_packet_city_sabotage_list_100
static int send_packet_city_sabotage_list_100(struct connection *pc, const struct packet_city_sabotage_list *packet)
Definition packets_gen.c:24129
send_packet_ruleset_nation_100
static int send_packet_ruleset_nation_100(struct connection *pc, const struct packet_ruleset_nation *packet)
Definition packets_gen.c:60138
receive_packet_edit_tile_100
static struct packet_edit_tile * receive_packet_edit_tile_100(struct connection *pc)
Definition packets_gen.c:92378
send_packet_page_msg_part_100
static int send_packet_page_msg_part_100(struct connection *pc, const struct packet_page_msg_part *packet)
Definition packets_gen.c:43063
init_packet_authentication_req
static void init_packet_authentication_req(struct packet_authentication_req *packet)
Definition packets_gen.c:1441
dsend_packet_edit_city_create
int dsend_packet_edit_city_create(struct connection *pc, int owner, int tile, int size, int tag)
Definition packets_gen.c:95064
dsend_packet_unit_change_activity
int dsend_packet_unit_change_activity(struct connection *pc, int unit_id, enum unit_activity activity, int target)
Definition packets_gen.c:39447
send_packet_ruleset_unit_100
static int send_packet_ruleset_unit_100(struct connection *pc, const struct packet_ruleset_unit *packet)
Definition packets_gen.c:48686
lsend_packet_ruleset_summary
void lsend_packet_ruleset_summary(struct conn_list *dest, const struct packet_ruleset_summary *packet)
Definition packets_gen.c:82466
send_packet_diplomacy_remove_clause_req_100
static int send_packet_diplomacy_remove_clause_req_100(struct connection *pc, const struct packet_diplomacy_remove_clause_req *packet)
Definition packets_gen.c:41268
init_packet_achievement_info
static void init_packet_achievement_info(struct packet_achievement_info *packet)
Definition packets_gen.c:12738
receive_packet_thaw_client_100
static struct packet_thaw_client * receive_packet_thaw_client_100(struct connection *pc)
Definition packets_gen.c:45567
dsend_packet_diplomacy_create_clause_req
int dsend_packet_diplomacy_create_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:40720
init_packet_processing_finished
static void init_packet_processing_finished(struct packet_processing_finished *packet)
Definition packets_gen.c:634
send_packet_conn_ping
int send_packet_conn_ping(struct connection *pc)
Definition packets_gen.c:44466
lsend_packet_diplomacy_create_clause
void lsend_packet_diplomacy_create_clause(struct conn_list *dest, const struct packet_diplomacy_create_clause *packet)
Definition packets_gen.c:41080
send_packet_endgame_player_100
static int send_packet_endgame_player_100(struct connection *pc, const struct packet_endgame_player *packet)
Definition packets_gen.c:2809
send_packet_diplomacy_cancel_meeting_100
static int send_packet_diplomacy_cancel_meeting_100(struct connection *pc, const struct packet_diplomacy_cancel_meeting *packet)
Definition packets_gen.c:40216
destroy_packet_ruleset_terrain_flag
#define destroy_packet_ruleset_terrain_flag
Definition packets_gen.c:67476
receive_packet_unit_actions_100
static struct packet_unit_actions * receive_packet_unit_actions_100(struct connection *pc)
Definition packets_gen.c:38550
init_packet_vote_submit
static void init_packet_vote_submit(struct packet_vote_submit *packet)
Definition packets_gen.c:90889
send_packet_player_change_government
int send_packet_player_change_government(struct connection *pc, const struct packet_player_change_government *packet)
Definition packets_gen.c:29236
send_packet_diplomacy_accept_treaty
int send_packet_diplomacy_accept_treaty(struct connection *pc, const struct packet_diplomacy_accept_treaty *packet)
Definition packets_gen.c:42273
send_packet_ruleset_counter
int send_packet_ruleset_counter(struct connection *pc, const struct packet_ruleset_counter *packet)
Definition packets_gen.c:78267
destroy_packet_end_turn
#define destroy_packet_end_turn
Definition packets_gen.c:45467
destroy_packet_edit_recalculate_borders
#define destroy_packet_edit_recalculate_borders
Definition packets_gen.c:91163
send_packet_ruleset_terrain_100
static int send_packet_ruleset_terrain_100(struct connection *pc, const struct packet_ruleset_terrain *packet)
Definition packets_gen.c:65823
init_packet_ruleset_description_part
static void init_packet_ruleset_description_part(struct packet_ruleset_description_part *packet)
Definition packets_gen.c:82473
send_packet_player_attribute_chunk_100
static int send_packet_player_attribute_chunk_100(struct connection *pc, const struct packet_player_attribute_chunk *packet)
Definition packets_gen.c:29706
send_packet_city_rally_point
int send_packet_city_rally_point(struct connection *pc, const struct packet_city_rally_point *packet, bool force_to_send)
Definition packets_gen.c:24815
delta_stats_reset
void delta_stats_reset(void)
Definition packets_gen.c:45
init_packet_authentication_reply
static void init_packet_authentication_reply(struct packet_authentication_reply *packet)
Definition packets_gen.c:1697
destroy_packet_scenario_description
#define destroy_packet_scenario_description
Definition packets_gen.c:89340
destroy_packet_ruleset_summary
#define destroy_packet_ruleset_summary
Definition packets_gen.c:82287
send_packet_connect_msg_100
static int send_packet_connect_msg_100(struct connection *pc, const struct packet_connect_msg *packet)
Definition packets_gen.c:14181
send_packet_vote_resolve
int send_packet_vote_resolve(struct connection *pc, const struct packet_vote_resolve *packet)
Definition packets_gen.c:90877
init_packet_single_want_hack_reply
static void init_packet_single_want_hack_reply(struct packet_single_want_hack_reply *packet)
Definition packets_gen.c:82850
lsend_packet_start_phase
void lsend_packet_start_phase(struct conn_list *dest, const struct packet_start_phase *packet)
Definition packets_gen.c:45093
lsend_packet_ruleset_building
void lsend_packet_ruleset_building(struct conn_list *dest, const struct packet_ruleset_building *packet)
Definition packets_gen.c:64142
destroy_packet_edit_game
#define destroy_packet_edit_game
Definition packets_gen.c:99714
send_packet_edit_city
int send_packet_edit_city(struct connection *pc, const struct packet_edit_city *packet)
Definition packets_gen.c:97424
init_packet_ruleset_tech_class
static void init_packet_ruleset_tech_class(struct packet_ruleset_tech_class *packet)
Definition packets_gen.c:55693
send_packet_server_setting_bitwise
int send_packet_server_setting_bitwise(struct connection *pc, const struct packet_server_setting_bitwise *packet)
Definition packets_gen.c:87594
lsend_packet_new_year
void lsend_packet_new_year(struct conn_list *dest, const struct packet_new_year *packet)
Definition packets_gen.c:45405
receive_packet_game_info_100
static struct packet_game_info * receive_packet_game_info_100(struct connection *pc)
Definition packets_gen.c:3845
send_packet_ruleset_choices_100
static int send_packet_ruleset_choices_100(struct connection *pc, const struct packet_ruleset_choices *packet)
Definition packets_gen.c:83177
destroy_packet_server_setting_int
#define destroy_packet_server_setting_int
Definition packets_gen.c:84992
lsend_packet_endgame_player
void lsend_packet_endgame_player(struct conn_list *dest, const struct packet_endgame_player *packet)
Definition packets_gen.c:2920
init_packet_player_diplstate
static void init_packet_player_diplstate(struct packet_player_diplstate *packet)
Definition packets_gen.c:29883
send_packet_player_attribute_block_100
static int send_packet_player_attribute_block_100(struct connection *pc)
Definition packets_gen.c:29524
send_packet_ruleset_music_100
static int send_packet_ruleset_music_100(struct connection *pc, const struct packet_ruleset_music *packet)
Definition packets_gen.c:78504
destroy_packet_authentication_reply
#define destroy_packet_authentication_reply
Definition packets_gen.c:1703
send_packet_conn_pong_100
static int send_packet_conn_pong_100(struct connection *pc)
Definition packets_gen.c:44499
send_packet_ruleset_game
int send_packet_ruleset_game(struct connection *pc, const struct packet_ruleset_game *packet)
Definition packets_gen.c:53355
lsend_packet_ruleset_unit_class_flag
void lsend_packet_ruleset_unit_class_flag(struct conn_list *dest, const struct packet_ruleset_unit_class_flag *packet)
Definition packets_gen.c:51746
destroy_packet_popup_image
#define destroy_packet_popup_image
Definition packets_gen.c:100769
send_packet_unknown_research
int send_packet_unknown_research(struct connection *pc, const struct packet_unknown_research *packet)
Definition packets_gen.c:31512
lsend_packet_tile_info
void lsend_packet_tile_info(struct conn_list *dest, const struct packet_tile_info *packet)
Definition packets_gen.c:3824
init_packet_end_phase
static void init_packet_end_phase(struct packet_end_phase *packet)
Definition packets_gen.c:44859
send_packet_player_diplstate_100
static int send_packet_player_diplstate_100(struct connection *pc, const struct packet_player_diplstate *packet)
Definition packets_gen.c:30108
receive_packet_ruleset_control_100
static struct packet_ruleset_control * receive_packet_ruleset_control_100(struct connection *pc)
Definition packets_gen.c:80596
init_packet_ruleset_impr_flag
static void init_packet_ruleset_impr_flag(struct packet_ruleset_impr_flag *packet)
Definition packets_gen.c:64149
send_packet_ruleset_resource
int send_packet_ruleset_resource(struct connection *pc, const struct packet_ruleset_resource *packet)
Definition packets_gen.c:88697
receive_packet_unit_action_query_100
static struct packet_unit_action_query * receive_packet_unit_action_query_100(struct connection *pc)
Definition packets_gen.c:36760
dsend_packet_player_rates
int dsend_packet_player_rates(struct connection *pc, int tax, int luxury, int science)
Definition packets_gen.c:29042
dsend_packet_spaceship_place
int dsend_packet_spaceship_place(struct connection *pc, enum spaceship_place_type type, int num)
Definition packets_gen.c:45896
dlsend_packet_city_remove
void dlsend_packet_city_remove(struct conn_list *dest, int city_id)
Definition packets_gen.c:14941
send_packet_processing_finished_100
static int send_packet_processing_finished_100(struct connection *pc)
Definition packets_gen.c:655
destroy_packet_edit_player_remove
#define destroy_packet_edit_player_remove
Definition packets_gen.c:97636
send_packet_ruleset_unit_bonus
int send_packet_ruleset_unit_bonus(struct connection *pc, const struct packet_ruleset_unit_bonus *packet)
Definition packets_gen.c:51146
init_packet_ruleset_road
static void init_packet_ruleset_road(struct packet_ruleset_road *packet)
Definition packets_gen.c:71990
send_packet_edit_unit_create
int send_packet_edit_unit_create(struct connection *pc, const struct packet_edit_unit_create *packet)
Definition packets_gen.c:93242
send_packet_spaceship_info_100
static int send_packet_spaceship_info_100(struct connection *pc, const struct packet_spaceship_info *packet)
Definition packets_gen.c:46341
lsend_packet_edit_player
void lsend_packet_edit_player(struct conn_list *dest, const struct packet_edit_player *packet)
Definition packets_gen.c:99374
receive_packet_ruleset_nation_sets_100
static struct packet_ruleset_nation_sets * receive_packet_ruleset_nation_sets_100(struct connection *pc)
Definition packets_gen.c:58013
send_packet_end_turn
int send_packet_end_turn(struct connection *pc)
Definition packets_gen.c:45491
send_packet_city_short_info_100
static int send_packet_city_short_info_100(struct connection *pc, const struct packet_city_short_info *packet)
Definition packets_gen.c:20081
init_packet_ruleset_nation_sets
static void init_packet_ruleset_nation_sets(struct packet_ruleset_nation_sets *packet)
Definition packets_gen.c:57999
send_packet_ruleset_achievement
int send_packet_ruleset_achievement(struct connection *pc, const struct packet_ruleset_achievement *packet)
Definition packets_gen.c:75218
destroy_packet_diplomacy_accept_treaty_req
#define destroy_packet_diplomacy_accept_treaty_req
Definition packets_gen.c:41856
init_packet_player_info
static void init_packet_player_info(struct packet_player_info *packet)
Definition packets_gen.c:25444
send_packet_ruleset_action_auto_100
static int send_packet_ruleset_action_auto_100(struct connection *pc, const struct packet_ruleset_action_auto *packet)
Definition packets_gen.c:77232
send_packet_edit_player_vision_100
static int send_packet_edit_player_vision_100(struct connection *pc, const struct packet_edit_player_vision *packet)
Definition packets_gen.c:99518
destroy_packet_ruleset_action
#define destroy_packet_ruleset_action
Definition packets_gen.c:75608
receive_packet_conn_ping_100
static struct packet_conn_ping * receive_packet_conn_ping_100(struct connection *pc)
Definition packets_gen.c:44444
send_packet_edit_city_create
int send_packet_edit_city_create(struct connection *pc, const struct packet_edit_city_create *packet)
Definition packets_gen.c:95052
init_packet_server_setting_bitwise
static void init_packet_server_setting_bitwise(struct packet_server_setting_bitwise *packet)
Definition packets_gen.c:86791
lsend_packet_research_info
void lsend_packet_research_info(struct conn_list *dest, const struct packet_research_info *packet)
Definition packets_gen.c:31314
send_packet_worker_task
int send_packet_worker_task(struct connection *pc, const struct packet_worker_task *packet)
Definition packets_gen.c:25221
destroy_packet_edit_tile_extra
#define destroy_packet_edit_tile_extra
Definition packets_gen.c:91738
init_packet_edit_tile
static void init_packet_edit_tile(struct packet_edit_tile *packet)
Definition packets_gen.c:92345
lsend_packet_city_update_counters
void lsend_packet_city_update_counters(struct conn_list *dest, const struct packet_city_update_counters *packet)
Definition packets_gen.c:19739
lsend_packet_web_ruleset_unit_addition
void lsend_packet_web_ruleset_unit_addition(struct conn_list *dest, const struct packet_web_ruleset_unit_addition *packet)
Definition packets_gen.c:102780
init_packet_unit_short_info
static void init_packet_unit_short_info(struct packet_unit_short_info *packet)
Definition packets_gen.c:34374
lsend_packet_map_info
void lsend_packet_map_info(struct conn_list *dest, const struct packet_map_info *packet)
Definition packets_gen.c:12289
receive_packet_ruleset_nation_groups_100
static struct packet_ruleset_nation_groups * receive_packet_ruleset_nation_groups_100(struct connection *pc)
Definition packets_gen.c:58682
receive_packet_ruleset_city_100
static struct packet_ruleset_city * receive_packet_ruleset_city_100(struct connection *pc)
Definition packets_gen.c:62058
init_packet_unit_action_answer
static void init_packet_unit_action_answer(struct packet_unit_action_answer *packet)
Definition packets_gen.c:37722
receive_packet_ruleset_choices_100
static struct packet_ruleset_choices * receive_packet_ruleset_choices_100(struct connection *pc)
Definition packets_gen.c:83034
init_packet_ruleset_nation_groups
static void init_packet_ruleset_nation_groups(struct packet_ruleset_nation_groups *packet)
Definition packets_gen.c:58668
destroy_packet_ruleset_unit_class
static void destroy_packet_ruleset_unit_class(void *packet)
Definition packets_gen.c:67779
destroy_packet_player_info
#define destroy_packet_player_info
Definition packets_gen.c:25450
dsend_packet_connect_msg
int dsend_packet_connect_msg(struct connection *pc, const char *message)
Definition packets_gen.c:14279
receive_packet_rulesets_ready_100
static struct packet_rulesets_ready * receive_packet_rulesets_ready_100(struct connection *pc)
Definition packets_gen.c:57958
send_packet_edit_toggle_fogofwar
int send_packet_edit_toggle_fogofwar(struct connection *pc, const struct packet_edit_toggle_fogofwar *packet)
Definition packets_gen.c:91414
lsend_packet_game_load
void lsend_packet_game_load(struct conn_list *dest, const struct packet_game_load *packet)
Definition packets_gen.c:83762
lsend_packet_ruleset_achievement
void lsend_packet_ruleset_achievement(struct conn_list *dest, const struct packet_ruleset_achievement *packet)
Definition packets_gen.c:75230
destroy_packet_unit_sscs_set
#define destroy_packet_unit_sscs_set
Definition packets_gen.c:35635
receive_packet_ruleset_unit_100
static struct packet_ruleset_unit * receive_packet_ruleset_unit_100(struct connection *pc)
Definition packets_gen.c:47007
receive_packet_report_req_100
static struct packet_report_req * receive_packet_report_req_100(struct connection *pc)
Definition packets_gen.c:43182
lsend_packet_ruleset_nation_sets
void lsend_packet_ruleset_nation_sets(struct conn_list *dest, const struct packet_ruleset_nation_sets *packet)
Definition packets_gen.c:58661
send_packet_city_name_suggestion_info
int send_packet_city_name_suggestion_info(struct connection *pc, const struct packet_city_name_suggestion_info *packet)
Definition packets_gen.c:23913
send_packet_ruleset_government
int send_packet_ruleset_government(struct connection *pc, const struct packet_ruleset_government *packet)
Definition packets_gen.c:57224
receive_packet_city_info_100
static struct packet_city_info * receive_packet_city_info_100(struct connection *pc)
Definition packets_gen.c:14983
receive_packet_edit_object_created_100
static struct packet_edit_object_created * receive_packet_edit_object_created_100(struct connection *pc)
Definition packets_gen.c:100339
send_packet_unit_remove
int send_packet_unit_remove(struct connection *pc, const struct packet_unit_remove *packet)
Definition packets_gen.c:32105
send_packet_nation_select_req_100
static int send_packet_nation_select_req_100(struct connection *pc, const struct packet_nation_select_req *packet)
Definition packets_gen.c:2098
lsend_packet_city_nationalities
void lsend_packet_city_nationalities(struct conn_list *dest, const struct packet_city_nationalities *packet, bool force_to_send)
Definition packets_gen.c:19339
send_packet_popup_image
int send_packet_popup_image(struct connection *pc, const struct packet_popup_image *packet)
Definition packets_gen.c:100936
send_packet_web_cma_clear_100
static int send_packet_web_cma_clear_100(struct connection *pc, const struct packet_web_cma_clear *packet)
Definition packets_gen.c:102219
send_packet_player_phase_done
int send_packet_player_phase_done(struct connection *pc, const struct packet_player_phase_done *packet)
Definition packets_gen.c:28734
send_packet_scenario_info_100
static int send_packet_scenario_info_100(struct connection *pc, const struct packet_scenario_info *packet)
Definition packets_gen.c:88963
destroy_packet_server_join_req
#define destroy_packet_server_join_req
Definition packets_gen.c:1102
destroy_packet_unit_get_actions
#define destroy_packet_unit_get_actions
Definition packets_gen.c:38140
receive_packet_edit_startpos_full_100
static struct packet_edit_startpos_full * receive_packet_edit_startpos_full_100(struct connection *pc)
Definition packets_gen.c:92236
receive_packet_ruleset_multiplier_100
static struct packet_ruleset_multiplier * receive_packet_ruleset_multiplier_100(struct connection *pc)
Definition packets_gen.c:78792
init_packet_ruleset_tech
static void init_packet_ruleset_tech(struct packet_ruleset_tech *packet)
Definition packets_gen.c:54595
init_packet_unit_do_action
static void init_packet_unit_do_action(struct packet_unit_do_action *packet)
Definition packets_gen.c:37310
receive_packet_tile_info_100
static struct packet_tile_info * receive_packet_tile_info_100(struct connection *pc)
Definition packets_gen.c:2960
destroy_packet_diplomacy_remove_clause
#define destroy_packet_diplomacy_remove_clause
Definition packets_gen.c:41477
receive_packet_page_msg_100
static struct packet_page_msg * receive_packet_page_msg_100(struct connection *pc)
Definition packets_gen.c:42584
receive_packet_vote_update_100
static struct packet_vote_update * receive_packet_vote_update_100(struct connection *pc)
Definition packets_gen.c:90135
send_packet_edit_tile_100
static int send_packet_edit_tile_100(struct connection *pc, const struct packet_edit_tile *packet)
Definition packets_gen.c:92590
destroy_packet_edit_unit_remove
#define destroy_packet_edit_unit_remove
Definition packets_gen.c:93273
lsend_packet_ruleset_multiplier
void lsend_packet_ruleset_multiplier(struct conn_list *dest, const struct packet_ruleset_multiplier *packet)
Definition packets_gen.c:79832
destroy_packet_ruleset_government_ruler_title
#define destroy_packet_ruleset_government_ruler_title
Definition packets_gen.c:54236
receive_packet_team_name_info_100
static struct packet_team_name_info * receive_packet_team_name_info_100(struct connection *pc)
Definition packets_gen.c:12539
send_packet_ruleset_clause_100
static int send_packet_ruleset_clause_100(struct connection *pc, const struct packet_ruleset_clause *packet)
Definition packets_gen.c:80188
init_packet_edit_player_vision
static void init_packet_edit_player_vision(struct packet_edit_player_vision *packet)
Definition packets_gen.c:99381
receive_packet_unit_do_action_100
static struct packet_unit_do_action * receive_packet_unit_do_action_100(struct connection *pc)
Definition packets_gen.c:37324
init_packet_diplomacy_cancel_meeting_req
static void init_packet_diplomacy_cancel_meeting_req(struct packet_diplomacy_cancel_meeting_req *packet)
Definition packets_gen.c:39915
send_packet_ruleset_tech_class_100
static int send_packet_ruleset_tech_class_100(struct connection *pc, const struct packet_ruleset_tech_class *packet)
Definition packets_gen.c:55840
send_packet_edit_check_tiles_100
static int send_packet_edit_check_tiles_100(struct connection *pc)
Definition packets_gen.c:91220
init_packet_server_setting_const
static void init_packet_server_setting_const(struct packet_server_setting_const *packet)
Definition packets_gen.c:84194
init_packet_diplomacy_accept_treaty
static void init_packet_diplomacy_accept_treaty(struct packet_diplomacy_accept_treaty *packet)
Definition packets_gen.c:42044
destroy_packet_player_change_government
#define destroy_packet_player_change_government
Definition packets_gen.c:29059
send_packet_player_ready_100
static int send_packet_player_ready_100(struct connection *pc, const struct packet_player_ready *packet)
Definition packets_gen.c:2417
init_packet_city_nationalities
static void init_packet_city_nationalities(struct packet_city_nationalities *packet)
Definition packets_gen.c:18786
send_packet_conn_ping_100
static int send_packet_conn_ping_100(struct connection *pc)
Definition packets_gen.c:44457
destroy_packet_edit_player_create
#define destroy_packet_edit_player_create
Definition packets_gen.c:97442
dsend_packet_diplomacy_cancel_meeting
int dsend_packet_diplomacy_cancel_meeting(struct connection *pc, int counterpart, int initiated_from)
Definition packets_gen.c:40352
receive_packet_endgame_report_100
static struct packet_endgame_report * receive_packet_endgame_report_100(struct connection *pc)
Definition packets_gen.c:2551
send_packet_game_load_100
static int send_packet_game_load_100(struct connection *pc, const struct packet_game_load *packet)
Definition packets_gen.c:83646
init_packet_ruleset_unit_bonus
static void init_packet_ruleset_unit_bonus(struct packet_ruleset_unit_bonus *packet)
Definition packets_gen.c:50762
destroy_packet_ruleset_action_auto
static void destroy_packet_ruleset_action_auto(void *packet)
Definition packets_gen.c:76915
receive_packet_ruleset_action_auto_100
static struct packet_ruleset_action_auto * receive_packet_ruleset_action_auto_100(struct connection *pc)
Definition packets_gen.c:76927
init_packet_edit_game
static void init_packet_edit_game(struct packet_edit_game *packet)
Definition packets_gen.c:99708
destroy_packet_vote_new
#define destroy_packet_vote_new
Definition packets_gen.c:89719
dsend_packet_player_remove
int dsend_packet_player_remove(struct connection *pc, int playerno)
Definition packets_gen.c:25435
init_packet_server_join_req
static void init_packet_server_join_req(struct packet_server_join_req *packet)
Definition packets_gen.c:1096
packet_has_game_info_flag
bool packet_has_game_info_flag(enum packet_type type)
Definition packets_gen.c:571
lsend_packet_ruleset_city
void lsend_packet_ruleset_city(struct conn_list *dest, const struct packet_ruleset_city *packet)
Definition packets_gen.c:62669
send_packet_edit_recalculate_borders_100
static int send_packet_edit_recalculate_borders_100(struct connection *pc)
Definition packets_gen.c:91178
send_packet_edit_game
int send_packet_edit_game(struct connection *pc, const struct packet_edit_game *packet)
Definition packets_gen.c:100128
destroy_packet_city_buy
#define destroy_packet_city_buy
Definition packets_gen.c:21267
receive_packet_unit_type_upgrade_100
static struct packet_unit_type_upgrade * receive_packet_unit_type_upgrade_100(struct connection *pc)
Definition packets_gen.c:37120
init_packet_city_options_req
static void init_packet_city_options_req(struct packet_city_options_req *packet)
Definition packets_gen.c:23055
init_packet_city_sabotage_list
static void init_packet_city_sabotage_list(struct packet_city_sabotage_list *packet)
Definition packets_gen.c:23952
lsend_packet_diplomacy_cancel_meeting
void lsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, const struct packet_diplomacy_cancel_meeting *packet)
Definition packets_gen.c:40345
init_packet_trade_route_info
static void init_packet_trade_route_info(struct packet_trade_route_info *packet)
Definition packets_gen.c:20548
dsend_packet_diplomacy_cancel_pact
int dsend_packet_diplomacy_cancel_pact(struct connection *pc, int other_player_id, enum clause_type clause)
Definition packets_gen.c:42560
receive_packet_unit_combat_info_100
static struct packet_unit_combat_info * receive_packet_unit_combat_info_100(struct connection *pc)
Definition packets_gen.c:35242
send_packet_nation_availability
int send_packet_nation_availability(struct connection *pc, const struct packet_nation_availability *packet)
Definition packets_gen.c:61721
send_packet_ruleset_terrain_control_100
static int send_packet_ruleset_terrain_control_100(struct connection *pc, const struct packet_ruleset_terrain_control *packet)
Definition packets_gen.c:57530
dsend_packet_authentication_req
int dsend_packet_authentication_req(struct connection *pc, enum authentication_type type, const char *message)
Definition packets_gen.c:1687
send_packet_ruleset_nation_sets
int send_packet_ruleset_nation_sets(struct connection *pc, const struct packet_ruleset_nation_sets *packet)
Definition packets_gen.c:58649
dsend_packet_city_sell
int dsend_packet_city_sell(struct connection *pc, int city_id, int build_id)
Definition packets_gen.c:21251
destroy_packet_diplomacy_cancel_meeting_req
#define destroy_packet_diplomacy_cancel_meeting_req
Definition packets_gen.c:39921
destroy_packet_server_join_reply
#define destroy_packet_server_join_reply
Definition packets_gen.c:1290
receive_packet_city_rally_point_100
static struct packet_city_rally_point * receive_packet_city_rally_point_100(struct connection *pc)
Definition packets_gen.c:24372
lsend_packet_ruleset_unit
void lsend_packet_ruleset_unit(struct conn_list *dest, const struct packet_ruleset_unit *packet)
Definition packets_gen.c:50755
destroy_packet_ruleset_style
#define destroy_packet_ruleset_style
Definition packets_gen.c:61746
destroy_packet_nuke_tile_info
#define destroy_packet_nuke_tile_info
Definition packets_gen.c:12302
destroy_packet_trade_route_info
#define destroy_packet_trade_route_info
Definition packets_gen.c:20554
send_packet_server_setting_int_100
static int send_packet_server_setting_int_100(struct connection *pc, const struct packet_server_setting_int *packet)
Definition packets_gen.c:85221
destroy_packet_city_update_counters
#define destroy_packet_city_update_counters
Definition packets_gen.c:19352
send_packet_unit_action_query
int send_packet_unit_action_query(struct connection *pc, const struct packet_unit_action_query *packet)
Definition packets_gen.c:37082
init_packet_ruleset_extra
static void init_packet_ruleset_extra(struct packet_ruleset_extra *packet)
Definition packets_gen.c:68498
dsend_packet_diplomacy_init_meeting_req
int dsend_packet_diplomacy_init_meeting_req(struct connection *pc, int counterpart)
Definition packets_gen.c:39643
send_packet_ruleset_control_100
static int send_packet_ruleset_control_100(struct connection *pc, const struct packet_ruleset_control *packet)
Definition packets_gen.c:81259
init_packet_edit_city_create
static void init_packet_edit_city_create(struct packet_edit_city_create *packet)
Definition packets_gen.c:94726
destroy_packet_ruleset_terrain
static void destroy_packet_ruleset_terrain(void *packet)
Definition packets_gen.c:64458
dsend_packet_unit_do_action
int dsend_packet_unit_do_action(struct connection *pc, int actor_id, int target_id, int sub_tgt_id, const char *name, action_id action_type)
Definition packets_gen.c:37709
send_packet_city_make_specialist
int send_packet_city_make_specialist(struct connection *pc, const struct packet_city_make_specialist *packet)
Definition packets_gen.c:22223
receive_packet_server_setting_bitwise_100
static struct packet_server_setting_bitwise * receive_packet_server_setting_bitwise_100(struct connection *pc)
Definition packets_gen.c:86824
destroy_packet_ruleset_game
#define destroy_packet_ruleset_game
Definition packets_gen.c:51759
send_packet_ruleset_unit_class
int send_packet_ruleset_unit_class(struct connection *pc, const struct packet_ruleset_unit_class *packet)
Definition packets_gen.c:68479
receive_packet_spaceship_info_100
static struct packet_spaceship_info * receive_packet_spaceship_info_100(struct connection *pc)
Definition packets_gen.c:45939
destroy_packet_server_setting_str
#define destroy_packet_server_setting_str
Definition packets_gen.c:85539
destroy_packet_server_setting_const
#define destroy_packet_server_setting_const
Definition packets_gen.c:84200
destroy_packet_unit_remove
#define destroy_packet_unit_remove
Definition packets_gen.c:31918
send_packet_ruleset_multiplier
int send_packet_ruleset_multiplier(struct connection *pc, const struct packet_ruleset_multiplier *packet)
Definition packets_gen.c:79820
receive_packet_city_worklist_100
static struct packet_city_worklist * receive_packet_city_worklist_100(struct connection *pc)
Definition packets_gen.c:21767
send_packet_ruleset_extra_flag
int send_packet_ruleset_extra_flag(struct connection *pc, const struct packet_ruleset_extra_flag *packet)
Definition packets_gen.c:71514
init_packet_begin_turn
static void init_packet_begin_turn(struct packet_begin_turn *packet)
Definition packets_gen.c:45412
lsend_packet_unit_remove
void lsend_packet_unit_remove(struct conn_list *dest, const struct packet_unit_remove *packet)
Definition packets_gen.c:32117
dsend_packet_diplomacy_remove_clause
int dsend_packet_diplomacy_remove_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:41826
send_packet_city_rename
int send_packet_city_rename(struct connection *pc, const struct packet_city_rename *packet)
Definition packets_gen.c:23033
send_packet_edit_unit_remove_100
static int send_packet_edit_unit_remove_100(struct connection *pc, const struct packet_edit_unit_remove *packet)
Definition packets_gen.c:93424
receive_packet_ruleset_game_100
static struct packet_ruleset_game * receive_packet_ruleset_game_100(struct connection *pc)
Definition packets_gen.c:51767
dlsend_packet_diplomacy_init_meeting
void dlsend_packet_diplomacy_init_meeting(struct conn_list *dest, int counterpart, int initiated_from)
Definition packets_gen.c:39905
send_packet_ruleset_select
int send_packet_ruleset_select(struct connection *pc, const struct packet_ruleset_select *packet)
Definition packets_gen.c:83537
receive_packet_ruleset_unit_flag_100
static struct packet_ruleset_unit_flag * receive_packet_ruleset_unit_flag_100(struct connection *pc)
Definition packets_gen.c:51179
send_packet_city_nationalities_100
static int send_packet_city_nationalities_100(struct connection *pc, const struct packet_city_nationalities *packet, bool force_to_send)
Definition packets_gen.c:19041
receive_packet_diplomacy_cancel_pact_100
static struct packet_diplomacy_cancel_pact * receive_packet_diplomacy_cancel_pact_100(struct connection *pc)
Definition packets_gen.c:42328
send_packet_chat_msg_100
static int send_packet_chat_msg_100(struct connection *pc, const struct packet_chat_msg *packet)
Definition packets_gen.c:13183
destroy_packet_ruleset_description_part
#define destroy_packet_ruleset_description_part
Definition packets_gen.c:82479
destroy_packet_ruleset_unit_bonus
#define destroy_packet_ruleset_unit_bonus
Definition packets_gen.c:50768
send_packet_endgame_player
int send_packet_endgame_player(struct connection *pc, const struct packet_endgame_player *packet)
Definition packets_gen.c:2908
lsend_packet_ruleset_clause
void lsend_packet_ruleset_clause(struct conn_list *dest, const struct packet_ruleset_clause *packet)
Definition packets_gen.c:80575
send_packet_new_year
int send_packet_new_year(struct connection *pc, const struct packet_new_year *packet)
Definition packets_gen.c:45393
receive_packet_edit_mode_100
static struct packet_edit_mode * receive_packet_edit_mode_100(struct connection *pc)
Definition packets_gen.c:91001
receive_packet_spaceship_place_100
static struct packet_spaceship_place * receive_packet_spaceship_place_100(struct connection *pc)
Definition packets_gen.c:45664
receive_packet_single_want_hack_reply_100
static struct packet_single_want_hack_reply * receive_packet_single_want_hack_reply_100(struct connection *pc)
Definition packets_gen.c:82864
send_packet_ruleset_road_100
static int send_packet_ruleset_road_100(struct connection *pc, const struct packet_ruleset_road *packet)
Definition packets_gen.c:72585
send_packet_server_setting_str
int send_packet_server_setting_str(struct connection *pc, const struct packet_server_setting_str *packet)
Definition packets_gen.c:85964
destroy_packet_chat_msg_req
#define destroy_packet_chat_msg_req
Definition packets_gen.c:13906
send_packet_ruleset_road
int send_packet_ruleset_road(struct connection *pc, const struct packet_ruleset_road *packet)
Definition packets_gen.c:73241
lsend_packet_chat_msg
void lsend_packet_chat_msg(struct conn_list *dest, const struct packet_chat_msg *packet)
Definition packets_gen.c:13436
init_packet_ruleset_effect
static void init_packet_ruleset_effect(struct packet_ruleset_effect *packet)
Definition packets_gen.c:87842
send_packet_ruleset_unit_flag
int send_packet_ruleset_unit_flag(struct connection *pc, const struct packet_ruleset_unit_flag *packet)
Definition packets_gen.c:51440
init_packet_diplomacy_remove_clause_req
static void init_packet_diplomacy_remove_clause_req(struct packet_diplomacy_remove_clause_req *packet)
Definition packets_gen.c:41111
init_packet_server_join_reply
static void init_packet_server_join_reply(struct packet_server_join_reply *packet)
Definition packets_gen.c:1284
init_packet_edit_unit_create
static void init_packet_edit_unit_create(struct packet_edit_unit_create *packet)
Definition packets_gen.c:92855
send_packet_edit_game_100
static int send_packet_edit_game_100(struct connection *pc, const struct packet_edit_game *packet)
Definition packets_gen.c:99885
destroy_packet_unit_action_query
#define destroy_packet_unit_action_query
Definition packets_gen.c:36752
send_packet_ruleset_city
int send_packet_ruleset_city(struct connection *pc, const struct packet_ruleset_city *packet)
Definition packets_gen.c:62657
send_packet_ruleset_goods
int send_packet_ruleset_goods(struct connection *pc, const struct packet_ruleset_goods *packet)
Definition packets_gen.c:74197
destroy_packet_edit_player_vision
#define destroy_packet_edit_player_vision
Definition packets_gen.c:99387
receive_packet_server_join_req_100
static struct packet_server_join_req * receive_packet_server_join_req_100(struct connection *pc)
Definition packets_gen.c:1104
destroy_packet_edit_city_create
#define destroy_packet_edit_city_create
Definition packets_gen.c:94732
lsend_packet_begin_turn
void lsend_packet_begin_turn(struct conn_list *dest)
Definition packets_gen.c:45454
send_packet_thaw_client_100
static int send_packet_thaw_client_100(struct connection *pc)
Definition packets_gen.c:45580
init_packet_map_info
static void init_packet_map_info(struct packet_map_info *packet)
Definition packets_gen.c:11821
send_packet_unit_type_upgrade
int send_packet_unit_type_upgrade(struct connection *pc, const struct packet_unit_type_upgrade *packet)
Definition packets_gen.c:37289
destroy_packet_edit_tile
#define destroy_packet_edit_tile
Definition packets_gen.c:92351
init_packet_diplomacy_init_meeting
static void init_packet_diplomacy_init_meeting(struct packet_diplomacy_init_meeting *packet)
Definition packets_gen.c:39652
receive_packet_ruleset_building_100
static struct packet_ruleset_building * receive_packet_ruleset_building_100(struct connection *pc)
Definition packets_gen.c:62707
init_packet_conn_ping
static void init_packet_conn_ping(struct packet_conn_ping *packet)
Definition packets_gen.c:44436
receive_packet_ruleset_description_part_100
static struct packet_ruleset_description_part * receive_packet_ruleset_description_part_100(struct connection *pc)
Definition packets_gen.c:82487
init_packet_player_change_government
static void init_packet_player_change_government(struct packet_player_change_government *packet)
Definition packets_gen.c:29053
delta_stats_report
void delta_stats_report(void)
Definition packets_gen.c:44
send_packet_processing_finished
int send_packet_processing_finished(struct connection *pc)
Definition packets_gen.c:664
send_packet_authentication_reply_100
static int send_packet_authentication_reply_100(struct connection *pc, const struct packet_authentication_reply *packet)
Definition packets_gen.c:1784
lsend_packet_ruleset_unit_flag
void lsend_packet_ruleset_unit_flag(struct conn_list *dest, const struct packet_ruleset_unit_flag *packet)
Definition packets_gen.c:51452
send_packet_player_rates_100
static int send_packet_player_rates_100(struct connection *pc, const struct packet_player_rates *packet)
Definition packets_gen.c:28882
destroy_packet_ruleset_unit_flag
#define destroy_packet_ruleset_unit_flag
Definition packets_gen.c:51171
send_packet_page_msg
int send_packet_page_msg(struct connection *pc, const struct packet_page_msg *packet)
Definition packets_gen.c:42957
destroy_packet_player_phase_done
#define destroy_packet_player_phase_done
Definition packets_gen.c:28567
destroy_packet_edit_startpos_full
#define destroy_packet_edit_startpos_full
Definition packets_gen.c:92234
send_packet_conn_pong
int send_packet_conn_pong(struct connection *pc)
Definition packets_gen.c:44508
send_packet_trade_route_info_100
static int send_packet_trade_route_info_100(struct connection *pc, const struct packet_trade_route_info *packet)
Definition packets_gen.c:20755
init_packet_edit_tile_extra
static void init_packet_edit_tile_extra(struct packet_edit_tile_extra *packet)
Definition packets_gen.c:91732
send_packet_player_multiplier
int send_packet_player_multiplier(struct connection *pc, const struct packet_player_multiplier *packet)
Definition packets_gen.c:30705
send_packet_ruleset_style_100
static int send_packet_ruleset_style_100(struct connection *pc, const struct packet_ruleset_style *packet)
Definition packets_gen.c:61867
send_packet_ruleset_counter_100
static int send_packet_ruleset_counter_100(struct connection *pc, const struct packet_ruleset_counter *packet)
Definition packets_gen.c:77919
destroy_packet_ruleset_road
static void destroy_packet_ruleset_road(void *packet)
Definition packets_gen.c:72002
send_packet_server_join_req
int send_packet_server_join_req(struct connection *pc, const struct packet_server_join_req *packet)
Definition packets_gen.c:1258
lsend_packet_endgame_report
void lsend_packet_endgame_report(struct conn_list *dest, const struct packet_endgame_report *packet)
Definition packets_gen.c:2709
send_packet_endgame_report
int send_packet_endgame_report(struct connection *pc, const struct packet_endgame_report *packet)
Definition packets_gen.c:2697
free_packet_ruleset_effect
static void free_packet_ruleset_effect(struct packet_ruleset_effect *packet)
Definition packets_gen.c:87849
send_packet_ruleset_city_100
static int send_packet_ruleset_city_100(struct connection *pc, const struct packet_ruleset_city *packet)
Definition packets_gen.c:62321
init_packet_unit_sscs_set
static void init_packet_unit_sscs_set(struct packet_unit_sscs_set *packet)
Definition packets_gen.c:35629
send_packet_vote_remove_100
static int send_packet_vote_remove_100(struct connection *pc, const struct packet_vote_remove *packet)
Definition packets_gen.c:90578
destroy_packet_research_info
#define destroy_packet_research_info
Definition packets_gen.c:30723
send_packet_server_setting_const
int send_packet_server_setting_const(struct connection *pc, const struct packet_server_setting_const *packet)
Definition packets_gen.c:84571
init_packet_nation_availability
static void init_packet_nation_availability(struct packet_nation_availability *packet)
Definition packets_gen.c:61361
send_packet_city_remove_100
static int send_packet_city_remove_100(struct connection *pc, const struct packet_city_remove *packet)
Definition packets_gen.c:14802
receive_packet_edit_city_remove_100
static struct packet_edit_city_remove * receive_packet_edit_city_remove_100(struct connection *pc)
Definition packets_gen.c:95090
destroy_packet_save_scenario
#define destroy_packet_save_scenario
Definition packets_gen.c:89525
send_packet_city_remove
int send_packet_city_remove(struct connection *pc, const struct packet_city_remove *packet)
Definition packets_gen.c:14913
destroy_packet_worker_task
#define destroy_packet_worker_task
Definition packets_gen.c:24840
destroy_packet_conn_ping
#define destroy_packet_conn_ping
Definition packets_gen.c:44442
init_packet_ruleset_city
static void init_packet_ruleset_city(struct packet_ruleset_city *packet)
Definition packets_gen.c:62034
send_packet_server_setting_bool_100
static int send_packet_server_setting_bool_100(struct connection *pc, const struct packet_server_setting_bool *packet)
Definition packets_gen.c:84758
destroy_packet_early_chat_msg
#define destroy_packet_early_chat_msg
Definition packets_gen.c:13449
destroy_packet_ruleset_choices
#define destroy_packet_ruleset_choices
Definition packets_gen.c:83026
send_packet_ruleset_government_ruler_title_100
static int send_packet_ruleset_government_ruler_title_100(struct connection *pc, const struct packet_ruleset_government_ruler_title *packet)
Definition packets_gen.c:54397
destroy_packet_city_refresh
#define destroy_packet_city_refresh
Definition packets_gen.c:23307
dsend_packet_city_options_req
int dsend_packet_city_options_req(struct connection *pc, int city_id, bv_city_options options)
Definition packets_gen.c:23291
lsend_packet_conn_info
void lsend_packet_conn_info(struct conn_list *dest, const struct packet_conn_info *packet)
Definition packets_gen.c:43919
init_packet_diplomacy_remove_clause
static void init_packet_diplomacy_remove_clause(struct packet_diplomacy_remove_clause *packet)
Definition packets_gen.c:41471
send_packet_edit_tile_terrain_100
static int send_packet_edit_tile_terrain_100(struct connection *pc, const struct packet_edit_tile_terrain *packet)
Definition packets_gen.c:91580
send_packet_unit_orders_100
static int send_packet_unit_orders_100(struct connection *pc, const struct packet_unit_orders *packet)
Definition packets_gen.c:36174
send_packet_server_info
int send_packet_server_info(struct connection *pc, const struct packet_server_info *packet)
Definition packets_gen.c:14665
receive_packet_achievement_info_100
static struct packet_achievement_info * receive_packet_achievement_info_100(struct connection *pc)
Definition packets_gen.c:12752
receive_packet_authentication_reply_100
static struct packet_authentication_reply * receive_packet_authentication_reply_100(struct connection *pc)
Definition packets_gen.c:1711
send_packet_server_join_reply_100
static int send_packet_server_join_reply_100(struct connection *pc, const struct packet_server_join_reply *packet)
Definition packets_gen.c:1353
init_packet_chat_msg_req
static void init_packet_chat_msg_req(struct packet_chat_msg_req *packet)
Definition packets_gen.c:13900
destroy_packet_single_want_hack_reply
#define destroy_packet_single_want_hack_reply
Definition packets_gen.c:82856
destroy_packet_unit_action_answer
#define destroy_packet_unit_action_answer
Definition packets_gen.c:37728
init_packet_rulesets_ready
static void init_packet_rulesets_ready(struct packet_rulesets_ready *packet)
Definition packets_gen.c:57950
receive_packet_map_info_100
static struct packet_map_info * receive_packet_map_info_100(struct connection *pc)
Definition packets_gen.c:11835
receive_packet_server_info_100
static struct packet_server_info * receive_packet_server_info_100(struct connection *pc)
Definition packets_gen.c:14302
send_packet_single_want_hack_reply_100
static int send_packet_single_want_hack_reply_100(struct connection *pc, const struct packet_single_want_hack_reply *packet)
Definition packets_gen.c:82927
init_packet_client_info
static void init_packet_client_info(struct packet_client_info *packet)
Definition packets_gen.c:44562
init_packet_web_city_info_addition
static void init_packet_web_city_info_addition(struct packet_web_city_info_addition *packet)
Definition packets_gen.c:100955
receive_packet_city_remove_100
static struct packet_city_remove * receive_packet_city_remove_100(struct connection *pc)
Definition packets_gen.c:14704
receive_packet_server_setting_enum_100
static struct packet_server_setting_enum * receive_packet_server_setting_enum_100(struct connection *pc)
Definition packets_gen.c:86009
init_packet_edit_mode
static void init_packet_edit_mode(struct packet_edit_mode *packet)
Definition packets_gen.c:90987
receive_packet_unit_action_answer_100
static struct packet_unit_action_answer * receive_packet_unit_action_answer_100(struct connection *pc)
Definition packets_gen.c:37736
send_packet_edit_unit_remove
int send_packet_edit_unit_remove(struct connection *pc, const struct packet_edit_unit_remove *packet)
Definition packets_gen.c:93603
init_packet_unit_server_side_agent_set
static void init_packet_unit_server_side_agent_set(struct packet_unit_server_side_agent_set *packet)
Definition packets_gen.c:36490
send_packet_game_info_100
static int send_packet_game_info_100(struct connection *pc, const struct packet_game_info *packet)
Definition packets_gen.c:6692
init_packet_diplomacy_cancel_meeting
static void init_packet_diplomacy_cancel_meeting(struct packet_diplomacy_cancel_meeting *packet)
Definition packets_gen.c:40109
send_packet_freeze_client_100
static int send_packet_freeze_client_100(struct connection *pc)
Definition packets_gen.c:45531
destroy_packet_unit_info
#define destroy_packet_unit_info
Definition packets_gen.c:32148
receive_packet_spaceship_launch_100
static struct packet_spaceship_launch * receive_packet_spaceship_launch_100(struct connection *pc)
Definition packets_gen.c:45616
send_packet_unit_server_side_agent_set
int send_packet_unit_server_side_agent_set(struct connection *pc, const struct packet_unit_server_side_agent_set *packet)
Definition packets_gen.c:36724
destroy_packet_ruleset_nation
#define destroy_packet_ruleset_nation
Definition packets_gen.c:59184
lsend_packet_early_chat_msg
void lsend_packet_early_chat_msg(struct conn_list *dest, const struct packet_early_chat_msg *packet)
Definition packets_gen.c:13893
send_packet_city_name_suggestion_req
int send_packet_city_name_suggestion_req(struct connection *pc, const struct packet_city_name_suggestion_req *packet)
Definition packets_gen.c:23668
free_packet_ruleset_counter
static void free_packet_ruleset_counter(struct packet_ruleset_counter *packet)
Definition packets_gen.c:77594
destroy_packet_web_player_info_addition
#define destroy_packet_web_player_info_addition
Definition packets_gen.c:102323
free_packet_ruleset_unit_class
static void free_packet_ruleset_unit_class(struct packet_ruleset_unit_class *packet)
Definition packets_gen.c:67771
init_packet_ruleset_summary
static void init_packet_ruleset_summary(struct packet_ruleset_summary *packet)
Definition packets_gen.c:82281
init_packet_set_topology
static void init_packet_set_topology(struct packet_set_topology *packet)
Definition packets_gen.c:87606
receive_packet_nation_availability_100
static struct packet_nation_availability * receive_packet_nation_availability_100(struct connection *pc)
Definition packets_gen.c:61375
init_packet_spaceship_launch
static void init_packet_spaceship_launch(struct packet_spaceship_launch *packet)
Definition packets_gen.c:45608
send_packet_ruleset_extra
int send_packet_ruleset_extra(struct connection *pc, const struct packet_ruleset_extra *packet)
Definition packets_gen.c:71220
send_packet_city_info
int send_packet_city_info(struct connection *pc, const struct packet_city_info *packet, bool force_to_send)
Definition packets_gen.c:18767
lsend_packet_ruleset_action
void lsend_packet_ruleset_action(struct conn_list *dest, const struct packet_ruleset_action *packet)
Definition packets_gen.c:76352
receive_packet_ruleset_effect_100
static struct packet_ruleset_effect * receive_packet_ruleset_effect_100(struct connection *pc)
Definition packets_gen.c:87866
send_packet_unit_actions
int send_packet_unit_actions(struct connection *pc, const struct packet_unit_actions *packet)
Definition packets_gen.c:39117
receive_packet_player_multiplier_100
static struct packet_player_multiplier * receive_packet_player_multiplier_100(struct connection *pc)
Definition packets_gen.c:30387
init_packet_investigate_started
static void init_packet_investigate_started(struct packet_investigate_started *packet)
Definition packets_gen.c:676
init_packet_ruleset_achievement
static void init_packet_ruleset_achievement(struct packet_ruleset_achievement *packet)
Definition packets_gen.c:74803
send_packet_ruleset_tech_class
int send_packet_ruleset_tech_class(struct connection *pc, const struct packet_ruleset_tech_class *packet)
Definition packets_gen.c:56019
send_packet_ruleset_tech_flag_100
static int send_packet_ruleset_tech_flag_100(struct connection *pc, const struct packet_ruleset_tech_flag *packet)
Definition packets_gen.c:56165
destroy_packet_server_setting_enum
#define destroy_packet_server_setting_enum
Definition packets_gen.c:85982
receive_packet_unit_server_side_agent_set_100
static struct packet_unit_server_side_agent_set * receive_packet_unit_server_side_agent_set_100(struct connection *pc)
Definition packets_gen.c:36504
destroy_packet_player_attribute_block
#define destroy_packet_player_attribute_block
Definition packets_gen.c:29509
receive_packet_save_scenario_100
static struct packet_save_scenario * receive_packet_save_scenario_100(struct connection *pc)
Definition packets_gen.c:89533
receive_packet_edit_tile_terrain_100
static struct packet_edit_tile_terrain * receive_packet_edit_tile_terrain_100(struct connection *pc)
Definition packets_gen.c:91468
lsend_packet_trade_route_info
void lsend_packet_trade_route_info(struct conn_list *dest, const struct packet_trade_route_info *packet)
Definition packets_gen.c:21008
lsend_packet_diplomacy_accept_treaty
void lsend_packet_diplomacy_accept_treaty(struct conn_list *dest, const struct packet_diplomacy_accept_treaty *packet)
Definition packets_gen.c:42285
dsend_packet_server_join_req
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)
Definition packets_gen.c:1270
receive_packet_city_update_counters_100
static struct packet_city_update_counters * receive_packet_city_update_counters_100(struct connection *pc)
Definition packets_gen.c:19379
destroy_packet_conn_pong
#define destroy_packet_conn_pong
Definition packets_gen.c:44484
destroy_packet_player_rates
#define destroy_packet_player_rates
Definition packets_gen.c:28761
send_packet_ruleset_summary
int send_packet_ruleset_summary(struct connection *pc, const struct packet_ruleset_summary *packet)
Definition packets_gen.c:82454
lsend_packet_ruleset_extra
void lsend_packet_ruleset_extra(struct conn_list *dest, const struct packet_ruleset_extra *packet)
Definition packets_gen.c:71232
send_packet_edit_tile_extra
int send_packet_edit_tile_extra(struct connection *pc, const struct packet_edit_tile_extra *packet)
Definition packets_gen.c:92075
receive_packet_edit_game_100
static struct packet_edit_game * receive_packet_edit_game_100(struct connection *pc)
Definition packets_gen.c:99722
destroy_packet_diplomacy_remove_clause_req
#define destroy_packet_diplomacy_remove_clause_req
Definition packets_gen.c:41117
packet_handlers_fill_capability
void packet_handlers_fill_capability(struct packet_handlers *phandlers, const char *capability)
Definition packets_gen.c:103194
dsend_packet_server_info
int dsend_packet_server_info(struct connection *pc, const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
Definition packets_gen.c:14677
destroy_packet_end_phase
#define destroy_packet_end_phase
Definition packets_gen.c:44865
lsend_packet_ruleset_nation_groups
void lsend_packet_ruleset_nation_groups(struct conn_list *dest, const struct packet_ruleset_nation_groups *packet)
Definition packets_gen.c:59171
send_packet_edit_unit_remove_by_id_100
static int send_packet_edit_unit_remove_by_id_100(struct connection *pc, const struct packet_edit_unit_remove_by_id *packet)
Definition packets_gen.c:93714
init_packet_ruleset_tech_flag
static void init_packet_ruleset_tech_flag(struct packet_ruleset_tech_flag *packet)
Definition packets_gen.c:56038
destroy_packet_player_research
#define destroy_packet_player_research
Definition packets_gen.c:31530
receive_packet_ruleset_counter_100
static struct packet_ruleset_counter * receive_packet_ruleset_counter_100(struct connection *pc)
Definition packets_gen.c:77614
init_packet_ruleset_unit_flag
static void init_packet_ruleset_unit_flag(struct packet_ruleset_unit_flag *packet)
Definition packets_gen.c:51165
receive_packet_edit_player_100
static struct packet_edit_player * receive_packet_edit_player_100(struct connection *pc)
Definition packets_gen.c:97857
init_packet_server_setting_int
static void init_packet_server_setting_int(struct packet_server_setting_int *packet)
Definition packets_gen.c:84986
free_packet_ruleset_road
static void free_packet_ruleset_road(struct packet_ruleset_road *packet)
Definition packets_gen.c:71997
init_packet_ruleset_control
static void init_packet_ruleset_control(struct packet_ruleset_control *packet)
Definition packets_gen.c:80582
lsend_packet_ruleset_terrain_control
void lsend_packet_ruleset_terrain_control(struct conn_list *dest, const struct packet_ruleset_terrain_control *packet)
Definition packets_gen.c:57943
send_packet_single_want_hack_req
int send_packet_single_want_hack_req(struct connection *pc, const struct packet_single_want_hack_req *packet)
Definition packets_gen.c:82838
dlsend_packet_diplomacy_remove_clause
void dlsend_packet_diplomacy_remove_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:41838
send_packet_unit_change_activity_100
static int send_packet_unit_change_activity_100(struct connection *pc, const struct packet_unit_change_activity *packet)
Definition packets_gen.c:39287
dlsend_packet_investigate_finished
void dlsend_packet_investigate_finished(struct conn_list *dest, int city_id)
Definition packets_gen.c:1087
receive_packet_ruleset_trade_100
static struct packet_ruleset_trade * receive_packet_ruleset_trade_100(struct connection *pc)
Definition packets_gen.c:75251
lsend_packet_ruleset_government_ruler_title
void lsend_packet_ruleset_government_ruler_title(struct conn_list *dest, const struct packet_ruleset_government_ruler_title *packet)
Definition packets_gen.c:54588
send_packet_scenario_info
int send_packet_scenario_info(struct connection *pc, const struct packet_scenario_info *packet)
Definition packets_gen.c:89322
destroy_packet_ruleset_nation_groups
#define destroy_packet_ruleset_nation_groups
Definition packets_gen.c:58674
init_packet_play_music
static void init_packet_play_music(struct packet_play_music *packet)
Definition packets_gen.c:100571
receive_packet_server_setting_str_100
static struct packet_server_setting_str * receive_packet_server_setting_str_100(struct connection *pc)
Definition packets_gen.c:85566
destroy_packet_edit_unit_create
#define destroy_packet_edit_unit_create
Definition packets_gen.c:92861
send_packet_ruleset_base
int send_packet_ruleset_base(struct connection *pc, const struct packet_ruleset_base *packet)
Definition packets_gen.c:71971
destroy_packet_unit_do_action
#define destroy_packet_unit_do_action
Definition packets_gen.c:37316
receive_packet_edit_unit_remove_100
static struct packet_edit_unit_remove * receive_packet_edit_unit_remove_100(struct connection *pc)
Definition packets_gen.c:93281
receive_packet_ruleset_extra_flag_100
static struct packet_ruleset_extra_flag * receive_packet_ruleset_extra_flag_100(struct connection *pc)
Definition packets_gen.c:71253
destroy_packet_city_rally_point
#define destroy_packet_city_rally_point
Definition packets_gen.c:24364
destroy_packet_authentication_req
#define destroy_packet_authentication_req
Definition packets_gen.c:1447
destroy_packet_edit_player
#define destroy_packet_edit_player
Definition packets_gen.c:97830
dlsend_packet_unit_remove
void dlsend_packet_unit_remove(struct conn_list *dest, int unit_id)
Definition packets_gen.c:32133
destroy_packet_ruleset_disaster
static void destroy_packet_ruleset_disaster(void *packet)
Definition packets_gen.c:74228
init_packet_ruleset_game
static void init_packet_ruleset_game(struct packet_ruleset_game *packet)
Definition packets_gen.c:51753
receive_packet_edit_player_vision_100
static struct packet_edit_player_vision * receive_packet_edit_player_vision_100(struct connection *pc)
Definition packets_gen.c:99395
init_packet_city_rename
static void init_packet_city_rename(struct packet_city_rename *packet)
Definition packets_gen.c:22809
receive_packet_nuke_tile_info_100
static struct packet_nuke_tile_info * receive_packet_nuke_tile_info_100(struct connection *pc)
Definition packets_gen.c:12310
init_packet_unit_orders
static void init_packet_unit_orders(struct packet_unit_orders *packet)
Definition packets_gen.c:35937
destroy_packet_ruleset_impr_flag
#define destroy_packet_ruleset_impr_flag
Definition packets_gen.c:64155
send_packet_server_setting_int
int send_packet_server_setting_int(struct connection *pc, const struct packet_server_setting_int *packet)
Definition packets_gen.c:85521
send_packet_web_ruleset_unit_addition
int send_packet_web_ruleset_unit_addition(struct connection *pc, const struct packet_web_ruleset_unit_addition *packet)
Definition packets_gen.c:102768
init_packet_ruleset_specialist
static void init_packet_ruleset_specialist(struct packet_ruleset_specialist *packet)
Definition packets_gen.c:53374
destroy_packet_chat_msg
#define destroy_packet_chat_msg
Definition packets_gen.c:12992
init_packet_timeout_info
static void init_packet_timeout_info(struct packet_timeout_info *packet)
Definition packets_gen.c:11585
destroy_packet_diplomacy_init_meeting_req
#define destroy_packet_diplomacy_init_meeting_req
Definition packets_gen.c:39464
lsend_packet_ruleset_music
void lsend_packet_ruleset_music(struct conn_list *dest, const struct packet_ruleset_music *packet)
Definition packets_gen.c:78756
send_packet_ruleset_choices
int send_packet_ruleset_choices(struct connection *pc, const struct packet_ruleset_choices *packet)
Definition packets_gen.c:83352
destroy_packet_city_short_info
#define destroy_packet_city_short_info
Definition packets_gen.c:19752
receive_packet_edit_city_create_100
static struct packet_edit_city_create * receive_packet_edit_city_create_100(struct connection *pc)
Definition packets_gen.c:94740
init_packet_ruleset_select
static void init_packet_ruleset_select(struct packet_ruleset_select *packet)
Definition packets_gen.c:83364
send_packet_server_setting_control
int send_packet_server_setting_control(struct connection *pc, const struct packet_server_setting_control *packet)
Definition packets_gen.c:84182
receive_packet_timeout_info_100
static struct packet_timeout_info * receive_packet_timeout_info_100(struct connection *pc)
Definition packets_gen.c:11599
init_packet_worker_task
static void init_packet_worker_task(struct packet_worker_task *packet)
Definition packets_gen.c:24834
send_packet_ruleset_trade_100
static int send_packet_ruleset_trade_100(struct connection *pc, const struct packet_ruleset_trade *packet)
Definition packets_gen.c:75404
receive_packet_ruleset_tech_100
static struct packet_ruleset_tech * receive_packet_ruleset_tech_100(struct connection *pc)
Definition packets_gen.c:54624
send_packet_diplomacy_init_meeting_req_100
static int send_packet_diplomacy_init_meeting_req_100(struct connection *pc, const struct packet_diplomacy_init_meeting_req *packet)
Definition packets_gen.c:39545
destroy_packet_spaceship_place
#define destroy_packet_spaceship_place
Definition packets_gen.c:45656
init_packet_research_info
static void init_packet_research_info(struct packet_research_info *packet)
Definition packets_gen.c:30717
dsend_packet_chat_msg_req
int dsend_packet_chat_msg_req(struct connection *pc, const char *message)
Definition packets_gen.c:14085
receive_packet_server_join_reply_100
static struct packet_server_join_reply * receive_packet_server_join_reply_100(struct connection *pc)
Definition packets_gen.c:1292
send_packet_play_music
int send_packet_play_music(struct connection *pc, const struct packet_play_music *packet)
Definition packets_gen.c:100744
init_packet_ruleset_building
static void init_packet_ruleset_building(struct packet_ruleset_building *packet)
Definition packets_gen.c:62676
send_packet_unit_short_info_100
static int send_packet_unit_short_info_100(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
Definition packets_gen.c:34734
send_packet_server_setting_bool
int send_packet_server_setting_bool(struct connection *pc, const struct packet_server_setting_bool *packet)
Definition packets_gen.c:84974
init_packet_ruleset_terrain
static void init_packet_ruleset_terrain(struct packet_ruleset_terrain *packet)
Definition packets_gen.c:64443
receive_packet_player_tech_goal_100
static struct packet_player_tech_goal * receive_packet_player_tech_goal_100(struct connection *pc)
Definition packets_gen.c:31732
dsend_packet_unit_remove
int dsend_packet_unit_remove(struct connection *pc, int unit_id)
Definition packets_gen.c:32124
dsend_packet_city_worklist
int dsend_packet_city_worklist(struct connection *pc, int city_id, const struct worklist *worklist)
Definition packets_gen.c:21989
receive_packet_city_change_specialist_100
static struct packet_city_change_specialist * receive_packet_city_change_specialist_100(struct connection *pc)
Definition packets_gen.c:22505
send_packet_tile_info_100
static int send_packet_tile_info_100(struct connection *pc, const struct packet_tile_info *packet)
Definition packets_gen.c:3322
receive_packet_city_rename_100
static struct packet_city_rename * receive_packet_city_rename_100(struct connection *pc)
Definition packets_gen.c:22823
init_packet_web_ruleset_unit_addition
static void init_packet_web_ruleset_unit_addition(struct packet_web_ruleset_unit_addition *packet)
Definition packets_gen.c:102550
receive_packet_investigate_started_100
static struct packet_investigate_started * receive_packet_investigate_started_100(struct connection *pc)
Definition packets_gen.c:690
init_packet_unit_action_query
static void init_packet_unit_action_query(struct packet_unit_action_query *packet)
Definition packets_gen.c:36746
init_packet_new_year
static void init_packet_new_year(struct packet_new_year *packet)
Definition packets_gen.c:45118
send_packet_edit_startpos_full_100
static int send_packet_edit_startpos_full_100(struct connection *pc, const struct packet_edit_startpos_full *packet)
Definition packets_gen.c:92280
destroy_packet_ruleset_base
#define destroy_packet_ruleset_base
Definition packets_gen.c:71539
send_packet_city_change
int send_packet_city_change(struct connection *pc, const struct packet_city_change *packet)
Definition packets_gen.c:21730
receive_packet_server_setting_const_100
static struct packet_server_setting_const * receive_packet_server_setting_const_100(struct connection *pc)
Definition packets_gen.c:84227
send_packet_processing_started
int send_packet_processing_started(struct connection *pc)
Definition packets_gen.c:622
destroy_packet_thaw_client
#define destroy_packet_thaw_client
Definition packets_gen.c:45565
receive_packet_vote_new_100
static struct packet_vote_new * receive_packet_vote_new_100(struct connection *pc)
Definition packets_gen.c:89727
receive_packet_unit_orders_100
static struct packet_unit_orders * receive_packet_unit_orders_100(struct connection *pc)
Definition packets_gen.c:35951
send_packet_report_req
int send_packet_report_req(struct connection *pc, const struct packet_report_req *packet)
Definition packets_gen.c:43351
dsend_packet_diplomacy_create_clause
int dsend_packet_diplomacy_create_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:41087
send_packet_edit_player_100
static int send_packet_edit_player_100(struct connection *pc, const struct packet_edit_player *packet)
Definition packets_gen.c:98472
init_packet_edit_city
static void init_packet_edit_city(struct packet_edit_city *packet)
Definition packets_gen.c:95270
send_packet_vote_submit
int send_packet_vote_submit(struct connection *pc, const struct packet_vote_submit *packet)
Definition packets_gen.c:90975
init_packet_early_chat_msg
static void init_packet_early_chat_msg(struct packet_early_chat_msg *packet)
Definition packets_gen.c:13443
send_packet_trade_route_info
int send_packet_trade_route_info(struct connection *pc, const struct packet_trade_route_info *packet)
Definition packets_gen.c:20996
init_packet_ruleset_terrain_flag
static void init_packet_ruleset_terrain_flag(struct packet_ruleset_terrain_flag *packet)
Definition packets_gen.c:67470
receive_packet_unit_info_100
static struct packet_unit_info * receive_packet_unit_info_100(struct connection *pc)
Definition packets_gen.c:32175
receive_packet_new_year_100
static struct packet_new_year * receive_packet_new_year_100(struct connection *pc)
Definition packets_gen.c:45132
lsend_packet_city_info
void lsend_packet_city_info(struct conn_list *dest, const struct packet_city_info *packet, bool force_to_send)
Definition packets_gen.c:18779
free_packet_ruleset_specialist
static void free_packet_ruleset_specialist(struct packet_ruleset_specialist *packet)
Definition packets_gen.c:53382
packet_functional_capability
const char *const packet_functional_capability
Definition packets_gen.c:30
destroy_packet_ruleset_city
static void destroy_packet_ruleset_city(void *packet)
Definition packets_gen.c:62046
init_packet_unit_type_upgrade
static void init_packet_unit_type_upgrade(struct packet_unit_type_upgrade *packet)
Definition packets_gen.c:37106
destroy_packet_edit_city
#define destroy_packet_edit_city
Definition packets_gen.c:95276
send_packet_server_join_req_100
static int send_packet_server_join_req_100(struct connection *pc, const struct packet_server_join_req *packet)
Definition packets_gen.c:1172
dsend_packet_city_make_specialist
int dsend_packet_city_make_specialist(struct connection *pc, int city_id, int tile_id)
Definition packets_gen.c:22235
destroy_packet_client_info
#define destroy_packet_client_info
Definition packets_gen.c:44568
send_packet_chat_msg
int send_packet_chat_msg(struct connection *pc, const struct packet_chat_msg *packet)
Definition packets_gen.c:13424
send_packet_diplomacy_accept_treaty_req_100
static int send_packet_diplomacy_accept_treaty_req_100(struct connection *pc, const struct packet_diplomacy_accept_treaty_req *packet)
Definition packets_gen.c:41937
lsend_packet_ruleset_control
void lsend_packet_ruleset_control(struct conn_list *dest, const struct packet_ruleset_control *packet)
Definition packets_gen.c:82274
destroy_packet_player_multiplier
#define destroy_packet_player_multiplier
Definition packets_gen.c:30379
init_packet_player_multiplier
static void init_packet_player_multiplier(struct packet_player_multiplier *packet)
Definition packets_gen.c:30373
init_packet_player_phase_done
static void init_packet_player_phase_done(struct packet_player_phase_done *packet)
Definition packets_gen.c:28561
init_packet_ruleset_base
static void init_packet_ruleset_base(struct packet_ruleset_base *packet)
Definition packets_gen.c:71533
destroy_packet_unit_type_upgrade
#define destroy_packet_unit_type_upgrade
Definition packets_gen.c:37112
lsend_packet_popup_image
void lsend_packet_popup_image(struct conn_list *dest, const struct packet_popup_image *packet)
Definition packets_gen.c:100948
init_packet_player_place_infra
static void init_packet_player_place_infra(struct packet_player_place_infra *packet)
Definition packets_gen.c:29257
send_packet_edit_startpos_100
static int send_packet_edit_startpos_100(struct connection *pc, const struct packet_edit_startpos *packet)
Definition packets_gen.c:92152
send_packet_unit_do_action
int send_packet_unit_do_action(struct connection *pc, const struct packet_unit_do_action *packet)
Definition packets_gen.c:37697
send_packet_diplomacy_accept_treaty_100
static int send_packet_diplomacy_accept_treaty_100(struct connection *pc, const struct packet_diplomacy_accept_treaty *packet)
Definition packets_gen.c:42151
receive_packet_nation_select_req_100
static struct packet_nation_select_req * receive_packet_nation_select_req_100(struct connection *pc)
Definition packets_gen.c:1945
send_packet_early_chat_msg
int send_packet_early_chat_msg(struct connection *pc, const struct packet_early_chat_msg *packet)
Definition packets_gen.c:13881
send_packet_ruleset_tech_100
static int send_packet_ruleset_tech_100(struct connection *pc, const struct packet_ruleset_tech *packet)
Definition packets_gen.c:55089
receive_packet_city_buy_100
static struct packet_city_buy * receive_packet_city_buy_100(struct connection *pc)
Definition packets_gen.c:21275
destroy_packet_ruleset_tech
static void destroy_packet_ruleset_tech(void *packet)
Definition packets_gen.c:54612
receive_packet_edit_unit_remove_by_id_100
static struct packet_edit_unit_remove_by_id * receive_packet_edit_unit_remove_by_id_100(struct connection *pc)
Definition packets_gen.c:93641
send_packet_ruleset_select_100
static int send_packet_ruleset_select_100(struct connection *pc, const struct packet_ruleset_select *packet)
Definition packets_gen.c:83451
send_packet_ruleset_action_auto
int send_packet_ruleset_action_auto(struct connection *pc, const struct packet_ruleset_action_auto *packet)
Definition packets_gen.c:77568
dsend_packet_nuke_tile_info
int dsend_packet_nuke_tile_info(struct connection *pc, int tile)
Definition packets_gen.c:12488
send_packet_research_info_100
static int send_packet_research_info_100(struct connection *pc, const struct packet_research_info *packet)
Definition packets_gen.c:30972
send_packet_city_make_worker
int send_packet_city_make_worker(struct connection *pc, const struct packet_city_make_worker *packet)
Definition packets_gen.c:22469
free_packet_ruleset_tech
static void free_packet_ruleset_tech(struct packet_ruleset_tech *packet)
Definition packets_gen.c:54603
send_packet_ruleset_description_part_100
static int send_packet_ruleset_description_part_100(struct connection *pc, const struct packet_ruleset_description_part *packet)
Definition packets_gen.c:82560
send_packet_calendar_info_100
static int send_packet_calendar_info_100(struct connection *pc, const struct packet_calendar_info *packet)
Definition packets_gen.c:11303
destroy_packet_scenario_info
#define destroy_packet_scenario_info
Definition packets_gen.c:88722
send_packet_diplomacy_remove_clause_req
int send_packet_diplomacy_remove_clause_req(struct connection *pc, const struct packet_diplomacy_remove_clause_req *packet)
Definition packets_gen.c:41447
dsend_packet_diplomacy_cancel_meeting_req
int dsend_packet_diplomacy_cancel_meeting_req(struct connection *pc, int counterpart)
Definition packets_gen.c:40100
send_packet_unit_orders
int send_packet_unit_orders(struct connection *pc, const struct packet_unit_orders *packet)
Definition packets_gen.c:36478
send_packet_conn_ping_info
int send_packet_conn_ping_info(struct connection *pc, const struct packet_conn_ping_info *packet)
Definition packets_gen.c:44417
dsend_packet_unit_get_actions
int dsend_packet_unit_get_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_tile_id, int target_extra_id, int request_kind)
Definition packets_gen.c:38523
dsend_packet_player_tech_goal
int dsend_packet_player_tech_goal(struct connection *pc, int tech)
Definition packets_gen.c:31903
send_packet_ruleset_action_enabler_100
static int send_packet_ruleset_action_enabler_100(struct connection *pc, const struct packet_ruleset_action_enabler *packet)
Definition packets_gen.c:76618
send_packet_player_rates
int send_packet_player_rates(struct connection *pc, const struct packet_player_rates *packet)
Definition packets_gen.c:29030
send_packet_player_diplstate
int send_packet_player_diplstate(struct connection *pc, const struct packet_player_diplstate *packet)
Definition packets_gen.c:30361
dsend_packet_city_change
int dsend_packet_city_change(struct connection *pc, int city_id, int production_kind, int production_value)
Definition packets_gen.c:21742
destroy_packet_vote_resolve
#define destroy_packet_vote_resolve
Definition packets_gen.c:90682
init_packet_calendar_info
static void init_packet_calendar_info(struct packet_calendar_info *packet)
Definition packets_gen.c:11102
send_packet_edit_player_remove
int send_packet_edit_player_remove(struct connection *pc, const struct packet_edit_player_remove *packet)
Definition packets_gen.c:97803
receive_packet_web_cma_clear_100
static struct packet_web_cma_clear * receive_packet_web_cma_clear_100(struct connection *pc)
Definition packets_gen.c:102146
receive_packet_server_setting_bool_100
static struct packet_server_setting_bool * receive_packet_server_setting_bool_100(struct connection *pc)
Definition packets_gen.c:84616
receive_packet_endgame_player_100
static struct packet_endgame_player * receive_packet_endgame_player_100(struct connection *pc)
Definition packets_gen.c:2724
init_packet_page_msg
static void init_packet_page_msg(struct packet_page_msg *packet)
Definition packets_gen.c:42570
init_packet_unit_info
static void init_packet_unit_info(struct packet_unit_info *packet)
Definition packets_gen.c:32142
send_packet_city_make_specialist_100
static int send_packet_city_make_specialist_100(struct connection *pc, const struct packet_city_make_specialist *packet)
Definition packets_gen.c:22106
destroy_packet_ruleset_clause
static void destroy_packet_ruleset_clause(void *packet)
Definition packets_gen.c:79855
send_packet_edit_toggle_fogofwar_100
static int send_packet_edit_toggle_fogofwar_100(struct connection *pc, const struct packet_edit_toggle_fogofwar *packet)
Definition packets_gen.c:91328
receive_packet_diplomacy_cancel_meeting_100
static struct packet_diplomacy_cancel_meeting * receive_packet_diplomacy_cancel_meeting_100(struct connection *pc)
Definition packets_gen.c:40123
send_packet_city_sabotage_list
int send_packet_city_sabotage_list(struct connection *pc, const struct packet_city_sabotage_list *packet)
Definition packets_gen.c:24339
send_packet_edit_unit_create_100
static int send_packet_edit_unit_create_100(struct connection *pc, const struct packet_edit_unit_create *packet)
Definition packets_gen.c:93032
free_packet_ruleset_extra
static void free_packet_ruleset_extra(struct packet_ruleset_extra *packet)
Definition packets_gen.c:68509
send_packet_city_refresh_100
static int send_packet_city_refresh_100(struct connection *pc, const struct packet_city_refresh *packet)
Definition packets_gen.c:23388
send_packet_conn_ping_info_100
static int send_packet_conn_ping_info_100(struct connection *pc, const struct packet_conn_ping_info *packet)
Definition packets_gen.c:44153
send_packet_diplomacy_create_clause_req_100
static int send_packet_diplomacy_create_clause_req_100(struct connection *pc, const struct packet_diplomacy_create_clause_req *packet)
Definition packets_gen.c:40529
lsend_packet_team_name_info
void lsend_packet_team_name_info(struct conn_list *dest, const struct packet_team_name_info *packet)
Definition packets_gen.c:12731
send_packet_client_info_100
static int send_packet_client_info_100(struct connection *pc, const struct packet_client_info *packet)
Definition packets_gen.c:44699
receive_packet_edit_unit_create_100
static struct packet_edit_unit_create * receive_packet_edit_unit_create_100(struct connection *pc)
Definition packets_gen.c:92869
receive_packet_city_nationalities_100
static struct packet_city_nationalities * receive_packet_city_nationalities_100(struct connection *pc)
Definition packets_gen.c:18819
destroy_packet_page_msg_part
#define destroy_packet_page_msg_part
Definition packets_gen.c:42982
send_packet_web_cma_clear
int send_packet_web_cma_clear(struct connection *pc, const struct packet_web_cma_clear *packet)
Definition packets_gen.c:102305
lsend_packet_ruleset_effect
void lsend_packet_ruleset_effect(struct conn_list *dest, const struct packet_ruleset_effect *packet)
Definition packets_gen.c:88364
send_packet_vote_new_100
static int send_packet_vote_new_100(struct connection *pc, const struct packet_vote_new *packet)
Definition packets_gen.c:89880
destroy_packet_diplomacy_cancel_pact
#define destroy_packet_diplomacy_cancel_pact
Definition packets_gen.c:42320
init_packet_edit_player_create
static void init_packet_edit_player_create(struct packet_edit_player_create *packet)
Definition packets_gen.c:97436
send_packet_city_refresh
int send_packet_city_refresh(struct connection *pc, const struct packet_city_refresh *packet)
Definition packets_gen.c:23474
init_packet_ruleset_multiplier
static void init_packet_ruleset_multiplier(struct packet_ruleset_multiplier *packet)
Definition packets_gen.c:78763
destroy_packet_ruleset_terrain_control
#define destroy_packet_ruleset_terrain_control
Definition packets_gen.c:57249
init_packet_edit_object_created
static void init_packet_edit_object_created(struct packet_edit_object_created *packet)
Definition packets_gen.c:100325
lsend_packet_unit_short_info
void lsend_packet_unit_short_info(struct conn_list *dest, const struct packet_unit_short_info *packet, bool force_to_send)
Definition packets_gen.c:35221
send_packet_city_buy_100
static int send_packet_city_buy_100(struct connection *pc, const struct packet_city_buy *packet)
Definition packets_gen.c:21348
init_packet_game_info
static void init_packet_game_info(struct packet_game_info *packet)
Definition packets_gen.c:3831
send_packet_city_name_suggestion_req_100
static int send_packet_city_name_suggestion_req_100(struct connection *pc, const struct packet_city_name_suggestion_req *packet)
Definition packets_gen.c:23582
send_packet_diplomacy_accept_treaty_req
int send_packet_diplomacy_accept_treaty_req(struct connection *pc, const struct packet_diplomacy_accept_treaty_req *packet)
Definition packets_gen.c:42023
destroy_packet_investigate_started
#define destroy_packet_investigate_started
Definition packets_gen.c:682
send_packet_unit_action_answer
int send_packet_unit_action_answer(struct connection *pc, const struct packet_unit_action_answer *packet)
Definition packets_gen.c:38109
send_packet_scenario_description_100
static int send_packet_scenario_description_100(struct connection *pc, const struct packet_scenario_description *packet)
Definition packets_gen.c:89421
init_packet_nation_select_req
static void init_packet_nation_select_req(struct packet_nation_select_req *packet)
Definition packets_gen.c:1931
lsend_packet_ruleset_terrain_flag
void lsend_packet_ruleset_terrain_flag(struct conn_list *dest, const struct packet_ruleset_terrain_flag *packet)
Definition packets_gen.c:67757
init_packet_scenario_info
static void init_packet_scenario_info(struct packet_scenario_info *packet)
Definition packets_gen.c:88716
lsend_packet_ruleset_unit_class
void lsend_packet_ruleset_unit_class(struct conn_list *dest, const struct packet_ruleset_unit_class *packet)
Definition packets_gen.c:68491
send_packet_city_update_counters_100
static int send_packet_city_update_counters_100(struct connection *pc, const struct packet_city_update_counters *packet)
Definition packets_gen.c:19531
receive_packet_chat_msg_req_100
static struct packet_chat_msg_req * receive_packet_chat_msg_req_100(struct connection *pc)
Definition packets_gen.c:13914
receive_packet_web_cma_set_100
static struct packet_web_cma_set * receive_packet_web_cma_set_100(struct connection *pc)
Definition packets_gen.c:101940
destroy_packet_ruleset_music
static void destroy_packet_ruleset_music(void *packet)
Definition packets_gen.c:78298
send_packet_timeout_info_100
static int send_packet_timeout_info_100(struct connection *pc, const struct packet_timeout_info *packet)
Definition packets_gen.c:11692
receive_packet_diplomacy_create_clause_req_100
static struct packet_diplomacy_create_clause_req * receive_packet_diplomacy_create_clause_req_100(struct connection *pc)
Definition packets_gen.c:40386
dsend_packet_unit_server_side_agent_set
int dsend_packet_unit_server_side_agent_set(struct connection *pc, int unit_id, enum server_side_agent agent)
Definition packets_gen.c:36736
destroy_packet_edit_startpos
#define destroy_packet_edit_startpos
Definition packets_gen.c:92106
send_packet_edit_player_vision
int send_packet_edit_player_vision(struct connection *pc, const struct packet_edit_player_vision *packet)
Definition packets_gen.c:99684
send_packet_single_want_hack_reply
int send_packet_single_want_hack_reply(struct connection *pc, const struct packet_single_want_hack_reply *packet)
Definition packets_gen.c:82999
destroy_packet_ruleset_trade
#define destroy_packet_ruleset_trade
Definition packets_gen.c:75243
receive_packet_ruleset_terrain_100
static struct packet_ruleset_terrain * receive_packet_ruleset_terrain_100(struct connection *pc)
Definition packets_gen.c:64470
send_packet_ruleset_unit_class_100
static int send_packet_ruleset_unit_class_100(struct connection *pc, const struct packet_ruleset_unit_class *packet)
Definition packets_gen.c:68099
init_packet_client_heartbeat
static void init_packet_client_heartbeat(struct packet_client_heartbeat *packet)
Definition packets_gen.c:44520
send_packet_player_info_100
static int send_packet_player_info_100(struct connection *pc, const struct packet_player_info *packet)
Definition packets_gen.c:26716
destroy_packet_edit_mode
#define destroy_packet_edit_mode
Definition packets_gen.c:90993
send_packet_end_phase
int send_packet_end_phase(struct connection *pc)
Definition packets_gen.c:44889
init_packet_tile_info
static void init_packet_tile_info(struct packet_tile_info *packet)
Definition packets_gen.c:2927
init_packet_end_turn
static void init_packet_end_turn(struct packet_end_turn *packet)
Definition packets_gen.c:45461
init_packet_server_setting_str
static void init_packet_server_setting_str(struct packet_server_setting_str *packet)
Definition packets_gen.c:85533
destroy_packet_processing_started
#define destroy_packet_processing_started
Definition packets_gen.c:598
send_packet_edit_startpos_full
int send_packet_edit_startpos_full(struct connection *pc, const struct packet_edit_startpos_full *packet)
Definition packets_gen.c:92333
lsend_packet_ruleset_disaster
void lsend_packet_ruleset_disaster(struct conn_list *dest, const struct packet_ruleset_disaster *packet)
Definition packets_gen.c:74796
lsend_packet_spaceship_info
void lsend_packet_spaceship_info(struct conn_list *dest, const struct packet_spaceship_info *packet)
Definition packets_gen.c:46971
dsend_packet_diplomacy_init_meeting
int dsend_packet_diplomacy_init_meeting(struct connection *pc, int counterpart, int initiated_from)
Definition packets_gen.c:39895
receive_packet_trade_route_info_100
static struct packet_trade_route_info * receive_packet_trade_route_info_100(struct connection *pc)
Definition packets_gen.c:20562
receive_packet_edit_player_create_100
static struct packet_edit_player_create * receive_packet_edit_player_create_100(struct connection *pc)
Definition packets_gen.c:97450
send_packet_save_scenario_100
static int send_packet_save_scenario_100(struct connection *pc, const struct packet_save_scenario *packet)
Definition packets_gen.c:89606
dsend_packet_city_change_specialist
int dsend_packet_city_change_specialist(struct connection *pc, int city_id, Specialist_type_id from, Specialist_type_id to)
Definition packets_gen.c:22798
send_packet_ruleset_terrain
int send_packet_ruleset_terrain(struct connection *pc, const struct packet_ruleset_terrain *packet)
Definition packets_gen.c:67451
send_packet_ruleset_unit_class_flag_100
static int send_packet_ruleset_unit_class_flag_100(struct connection *pc, const struct packet_ruleset_unit_class_flag *packet)
Definition packets_gen.c:51586
send_packet_edit_tile_extra_100
static int send_packet_edit_tile_extra_100(struct connection *pc, const struct packet_edit_tile_extra *packet)
Definition packets_gen.c:91897
send_packet_city_name_suggestion_info_100
static int send_packet_city_name_suggestion_info_100(struct connection *pc, const struct packet_city_name_suggestion_info *packet)
Definition packets_gen.c:23796
lsend_packet_page_msg
void lsend_packet_page_msg(struct conn_list *dest, const struct packet_page_msg *packet)
Definition packets_gen.c:42969
send_packet_unit_type_upgrade_100
static int send_packet_unit_type_upgrade_100(struct connection *pc, const struct packet_unit_type_upgrade *packet)
Definition packets_gen.c:37203
send_packet_player_info
int send_packet_player_info(struct connection *pc, const struct packet_player_info *packet)
Definition packets_gen.c:28549
init_packet_ruleset_unit_class_flag
static void init_packet_ruleset_unit_class_flag(struct packet_ruleset_unit_class_flag *packet)
Definition packets_gen.c:51459
send_packet_player_place_infra_100
static int send_packet_player_place_infra_100(struct connection *pc, const struct packet_player_place_infra *packet)
Definition packets_gen.c:29364
destroy_packet_ruleset_resource
#define destroy_packet_ruleset_resource
Definition packets_gen.c:88377
send_packet_city_options_req
int send_packet_city_options_req(struct connection *pc, const struct packet_city_options_req *packet)
Definition packets_gen.c:23279
send_packet_end_phase_100
static int send_packet_end_phase_100(struct connection *pc)
Definition packets_gen.c:44880
dsend_packet_nation_select_req
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)
Definition packets_gen.c:2307
send_packet_ruleset_clause
int send_packet_ruleset_clause(struct connection *pc, const struct packet_ruleset_clause *packet)
Definition packets_gen.c:80563
send_packet_diplomacy_create_clause_req
int send_packet_diplomacy_create_clause_req(struct connection *pc, const struct packet_diplomacy_create_clause_req *packet)
Definition packets_gen.c:40708
send_packet_worker_task_100
static int send_packet_worker_task_100(struct connection *pc, const struct packet_worker_task *packet)
Definition packets_gen.c:25011
receive_packet_ruleset_government_100
static struct packet_ruleset_government * receive_packet_ruleset_government_100(struct connection *pc)
Definition packets_gen.c:56361
send_packet_spaceship_launch_100
static int send_packet_spaceship_launch_100(struct connection *pc)
Definition packets_gen.c:45629
send_packet_city_nationalities
int send_packet_city_nationalities(struct connection *pc, const struct packet_city_nationalities *packet, bool force_to_send)
Definition packets_gen.c:19327
destroy_packet_unit_combat_info
#define destroy_packet_unit_combat_info
Definition packets_gen.c:35234
send_packet_edit_player_remove_100
static int send_packet_edit_player_remove_100(struct connection *pc, const struct packet_edit_player_remove *packet)
Definition packets_gen.c:97717
dsend_packet_edit_startpos
int dsend_packet_edit_startpos(struct connection *pc, int id, bool removal, int tag)
Definition packets_gen.c:92217
receive_packet_ruleset_music_100
static struct packet_ruleset_music * receive_packet_ruleset_music_100(struct connection *pc)
Definition packets_gen.c:78310
send_packet_unit_do_action_100
static int send_packet_unit_do_action_100(struct connection *pc, const struct packet_unit_do_action *packet)
Definition packets_gen.c:37487
send_packet_nation_select_req
int send_packet_nation_select_req(struct connection *pc, const struct packet_nation_select_req *packet)
Definition packets_gen.c:2295
receive_packet_ruleset_unit_class_100
static struct packet_ruleset_unit_class * receive_packet_ruleset_unit_class_100(struct connection *pc)
Definition packets_gen.c:67791
lsend_packet_ruleset_description_part
void lsend_packet_ruleset_description_part(struct conn_list *dest, const struct packet_ruleset_description_part *packet)
Definition packets_gen.c:82658
destroy_packet_ruleset_tech_flag
#define destroy_packet_ruleset_tech_flag
Definition packets_gen.c:56044
send_packet_end_turn_100
static int send_packet_end_turn_100(struct connection *pc)
Definition packets_gen.c:45482
destroy_packet_web_cma_set
#define destroy_packet_web_cma_set
Definition packets_gen.c:101913
receive_packet_connect_msg_100
static struct packet_connect_msg * receive_packet_connect_msg_100(struct connection *pc)
Definition packets_gen.c:14108
lsend_packet_city_short_info
void lsend_packet_city_short_info(struct conn_list *dest, const struct packet_city_short_info *packet)
Definition packets_gen.c:20541
dsend_packet_city_refresh
int dsend_packet_city_refresh(struct connection *pc, int city_id)
Definition packets_gen.c:23486
lsend_packet_ruleset_government
void lsend_packet_ruleset_government(struct conn_list *dest, const struct packet_ruleset_government *packet)
Definition packets_gen.c:57236
send_packet_ruleset_tech
int send_packet_ruleset_tech(struct connection *pc, const struct packet_ruleset_tech *packet)
Definition packets_gen.c:55674
destroy_packet_timeout_info
#define destroy_packet_timeout_info
Definition packets_gen.c:11591
send_packet_nuke_tile_info_100
static int send_packet_nuke_tile_info_100(struct connection *pc, const struct packet_nuke_tile_info *packet)
Definition packets_gen.c:12383
init_packet_server_setting_bool
static void init_packet_server_setting_bool(struct packet_server_setting_bool *packet)
Definition packets_gen.c:84583
send_packet_server_setting_enum_100
static int send_packet_server_setting_enum_100(struct connection *pc, const struct packet_server_setting_enum *packet)
Definition packets_gen.c:86331
destroy_packet_tile_info
#define destroy_packet_tile_info
Definition packets_gen.c:2933
receive_packet_ruleset_action_enabler_100
static struct packet_ruleset_action_enabler * receive_packet_ruleset_action_enabler_100(struct connection *pc)
Definition packets_gen.c:76385
init_packet_ruleset_action_enabler
static void init_packet_ruleset_action_enabler(struct packet_ruleset_action_enabler *packet)
Definition packets_gen.c:76359
receive_packet_unit_change_activity_100
static struct packet_unit_change_activity * receive_packet_unit_change_activity_100(struct connection *pc)
Definition packets_gen.c:39164
send_packet_diplomacy_remove_clause_100
static int send_packet_diplomacy_remove_clause_100(struct connection *pc, const struct packet_diplomacy_remove_clause *packet)
Definition packets_gen.c:41628
send_packet_player_phase_done_100
static int send_packet_player_phase_done_100(struct connection *pc, const struct packet_player_phase_done *packet)
Definition packets_gen.c:28648
send_packet_player_place_infra
int send_packet_player_place_infra(struct connection *pc, const struct packet_player_place_infra *packet)
Definition packets_gen.c:29481
destroy_packet_ruleset_unit_class_flag
#define destroy_packet_ruleset_unit_class_flag
Definition packets_gen.c:51465
destroy_packet_begin_turn
#define destroy_packet_begin_turn
Definition packets_gen.c:45418
destroy_packet_game_load
#define destroy_packet_game_load
Definition packets_gen.c:83555
destroy_packet_single_want_hack_req
#define destroy_packet_single_want_hack_req
Definition packets_gen.c:82671
destroy_packet_start_phase
#define destroy_packet_start_phase
Definition packets_gen.c:44914
send_packet_ruleset_nation
int send_packet_ruleset_nation(struct connection *pc, const struct packet_ruleset_nation *packet)
Definition packets_gen.c:61342
destroy_packet_city_name_suggestion_info
#define destroy_packet_city_name_suggestion_info
Definition packets_gen.c:23695
send_packet_city_make_worker_100
static int send_packet_city_make_worker_100(struct connection *pc, const struct packet_city_make_worker *packet)
Definition packets_gen.c:22352
init_packet_unit_remove
static void init_packet_unit_remove(struct packet_unit_remove *packet)
Definition packets_gen.c:31912
send_packet_server_shutdown_100
static int send_packet_server_shutdown_100(struct connection *pc)
Definition packets_gen.c:1903
send_packet_begin_turn
int send_packet_begin_turn(struct connection *pc)
Definition packets_gen.c:45442
free_packet_ruleset_multiplier
static void free_packet_ruleset_multiplier(struct packet_ruleset_multiplier *packet)
Definition packets_gen.c:78771
lsend_packet_ruleset_unit_bonus
void lsend_packet_ruleset_unit_bonus(struct conn_list *dest, const struct packet_ruleset_unit_bonus *packet)
Definition packets_gen.c:51158
destroy_packet_vote_remove
#define destroy_packet_vote_remove
Definition packets_gen.c:90497
destroy_packet_city_make_specialist
#define destroy_packet_city_make_specialist
Definition packets_gen.c:22005
destroy_packet_city_rename
#define destroy_packet_city_rename
Definition packets_gen.c:22815
receive_packet_unit_sscs_set_100
static struct packet_unit_sscs_set * receive_packet_unit_sscs_set_100(struct connection *pc)
Definition packets_gen.c:35643
send_packet_ruleset_base_100
static int send_packet_ruleset_base_100(struct connection *pc, const struct packet_ruleset_base *packet)
Definition packets_gen.c:71730
dlsend_packet_nuke_tile_info
void dlsend_packet_nuke_tile_info(struct conn_list *dest, int tile)
Definition packets_gen.c:12497
receive_packet_client_info_100
static struct packet_client_info * receive_packet_client_info_100(struct connection *pc)
Definition packets_gen.c:44576
destroy_packet_ruleset_goods
static void destroy_packet_ruleset_goods(void *packet)
Definition packets_gen.c:73277
send_packet_connect_msg
int send_packet_connect_msg(struct connection *pc, const struct packet_connect_msg *packet)
Definition packets_gen.c:14267
receive_packet_unit_remove_100
static struct packet_unit_remove * receive_packet_unit_remove_100(struct connection *pc)
Definition packets_gen.c:31926
dsend_packet_city_make_worker
int dsend_packet_city_make_worker(struct connection *pc, int city_id, int tile_id)
Definition packets_gen.c:22481
send_packet_ruleset_effect_100
static int send_packet_ruleset_effect_100(struct connection *pc, const struct packet_ruleset_effect *packet)
Definition packets_gen.c:88093
send_packet_ruleset_game_100
static int send_packet_ruleset_game_100(struct connection *pc, const struct packet_ruleset_game *packet)
Definition packets_gen.c:52460
init_packet_city_remove
static void init_packet_city_remove(struct packet_city_remove *packet)
Definition packets_gen.c:14690
receive_packet_calendar_info_100
static struct packet_calendar_info * receive_packet_calendar_info_100(struct connection *pc)
Definition packets_gen.c:11116
destroy_packet_ruleset_control
#define destroy_packet_ruleset_control
Definition packets_gen.c:80588
send_packet_player_remove
int send_packet_player_remove(struct connection *pc, const struct packet_player_remove *packet)
Definition packets_gen.c:25423
receive_packet_diplomacy_create_clause_100
static struct packet_diplomacy_create_clause * receive_packet_diplomacy_create_clause_100(struct connection *pc)
Definition packets_gen.c:40746
init_packet_player_remove
static void init_packet_player_remove(struct packet_player_remove *packet)
Definition packets_gen.c:25240
receive_packet_web_player_info_addition_100
static struct packet_web_player_info_addition * receive_packet_web_player_info_addition_100(struct connection *pc)
Definition packets_gen.c:102350
destroy_packet_connect_msg
#define destroy_packet_connect_msg
Definition packets_gen.c:14100
send_packet_diplomacy_cancel_meeting_req
int send_packet_diplomacy_cancel_meeting_req(struct connection *pc, const struct packet_diplomacy_cancel_meeting_req *packet)
Definition packets_gen.c:40088
receive_packet_play_music_100
static struct packet_play_music * receive_packet_play_music_100(struct connection *pc)
Definition packets_gen.c:100585
lsend_packet_worker_task
void lsend_packet_worker_task(struct conn_list *dest, const struct packet_worker_task *packet)
Definition packets_gen.c:25233
destroy_packet_edit_object_created
#define destroy_packet_edit_object_created
Definition packets_gen.c:100331
dsend_packet_player_phase_done
int dsend_packet_player_phase_done(struct connection *pc, int turn)
Definition packets_gen.c:28746
send_packet_unit_sscs_set_100
static int send_packet_unit_sscs_set_100(struct connection *pc, const struct packet_unit_sscs_set *packet)
Definition packets_gen.c:35766
send_packet_investigate_started
int send_packet_investigate_started(struct connection *pc, const struct packet_investigate_started *packet)
Definition packets_gen.c:849
send_packet_early_chat_msg_100
static int send_packet_early_chat_msg_100(struct connection *pc, const struct packet_early_chat_msg *packet)
Definition packets_gen.c:13640
send_packet_unit_action_answer_100
static int send_packet_unit_action_answer_100(struct connection *pc, const struct packet_unit_action_answer *packet)
Definition packets_gen.c:37899
receive_packet_city_name_suggestion_info_100
static struct packet_city_name_suggestion_info * receive_packet_city_name_suggestion_info_100(struct connection *pc)
Definition packets_gen.c:23703
send_packet_investigate_finished
int send_packet_investigate_finished(struct connection *pc, const struct packet_investigate_finished *packet)
Definition packets_gen.c:1059
init_packet_diplomacy_accept_treaty_req
static void init_packet_diplomacy_accept_treaty_req(struct packet_diplomacy_accept_treaty_req *packet)
Definition packets_gen.c:41850
destroy_packet_player_diplstate
#define destroy_packet_player_diplstate
Definition packets_gen.c:29889
send_packet_play_music_100
static int send_packet_play_music_100(struct connection *pc, const struct packet_play_music *packet)
Definition packets_gen.c:100658
send_packet_client_heartbeat
int send_packet_client_heartbeat(struct connection *pc)
Definition packets_gen.c:44550
send_packet_city_short_info
int send_packet_city_short_info(struct connection *pc, const struct packet_city_short_info *packet)
Definition packets_gen.c:20529
send_packet_edit_object_created
int send_packet_edit_object_created(struct connection *pc, const struct packet_edit_object_created *packet)
Definition packets_gen.c:100549
init_packet_server_shutdown
static void init_packet_server_shutdown(struct packet_server_shutdown *packet)
Definition packets_gen.c:1882
send_packet_player_multiplier_100
static int send_packet_player_multiplier_100(struct connection *pc, const struct packet_player_multiplier *packet)
Definition packets_gen.c:30530
send_packet_authentication_reply
int send_packet_authentication_reply(struct connection *pc, const struct packet_authentication_reply *packet)
Definition packets_gen.c:1870
send_packet_edit_player
int send_packet_edit_player(struct connection *pc, const struct packet_edit_player *packet)
Definition packets_gen.c:99362
send_packet_city_change_specialist_100
static int send_packet_city_change_specialist_100(struct connection *pc, const struct packet_city_change_specialist *packet)
Definition packets_gen.c:22638
send_packet_edit_city_remove_100
static int send_packet_edit_city_remove_100(struct connection *pc, const struct packet_edit_city_remove *packet)
Definition packets_gen.c:95163
receive_packet_ruleset_style_100
static struct packet_ruleset_style * receive_packet_ruleset_style_100(struct connection *pc)
Definition packets_gen.c:61754
destroy_packet_ruleset_specialist
static void destroy_packet_ruleset_specialist(void *packet)
Definition packets_gen.c:53391
destroy_packet_vote_update
#define destroy_packet_vote_update
Definition packets_gen.c:90108
init_packet_unit_get_actions
static void init_packet_unit_get_actions(struct packet_unit_get_actions *packet)
Definition packets_gen.c:38134
init_packet_player_ready
static void init_packet_player_ready(struct packet_player_ready *packet)
Definition packets_gen.c:2320
init_packet_city_change_specialist
static void init_packet_city_change_specialist(struct packet_city_change_specialist *packet)
Definition packets_gen.c:22491
destroy_packet_nation_select_req
#define destroy_packet_nation_select_req
Definition packets_gen.c:1937
destroy_packet_edit_city_remove
#define destroy_packet_edit_city_remove
Definition packets_gen.c:95082
send_packet_edit_city_100
static int send_packet_edit_city_100(struct connection *pc, const struct packet_edit_city *packet)
Definition packets_gen.c:96164
lsend_packet_ruleset_base
void lsend_packet_ruleset_base(struct conn_list *dest, const struct packet_ruleset_base *packet)
Definition packets_gen.c:71983
dsend_packet_game_load
int dsend_packet_game_load(struct connection *pc, bool load_successful, const char *load_filename)
Definition packets_gen.c:83769
destroy_packet_ruleset_extra_flag
#define destroy_packet_ruleset_extra_flag
Definition packets_gen.c:71245
dsend_packet_unit_actions
int dsend_packet_unit_actions(struct connection *pc, int actor_unit_id, int target_unit_id, int target_city_id, int target_tile_id, int target_extra_id, int request_kind, const struct act_prob *action_probabilities)
Definition packets_gen.c:39129
send_packet_diplomacy_create_clause_100
static int send_packet_diplomacy_create_clause_100(struct connection *pc, const struct packet_diplomacy_create_clause *packet)
Definition packets_gen.c:40889
send_packet_ruleset_impr_flag_100
static int send_packet_ruleset_impr_flag_100(struct connection *pc, const struct packet_ruleset_impr_flag *packet)
Definition packets_gen.c:64276
send_packet_unit_short_info
int send_packet_unit_short_info(struct connection *pc, const struct packet_unit_short_info *packet, bool force_to_send)
Definition packets_gen.c:35209
receive_packet_end_turn_100
static struct packet_end_turn * receive_packet_end_turn_100(struct connection *pc)
Definition packets_gen.c:45469
init_packet_spaceship_info
static void init_packet_spaceship_info(struct packet_spaceship_info *packet)
Definition packets_gen.c:45906
send_packet_ruleset_terrain_flag
int send_packet_ruleset_terrain_flag(struct connection *pc, const struct packet_ruleset_terrain_flag *packet)
Definition packets_gen.c:67745
lsend_packet_unit_info
void lsend_packet_unit_info(struct conn_list *dest, const struct packet_unit_info *packet)
Definition packets_gen.c:34367
free_packet_ruleset_terrain
static void free_packet_ruleset_terrain(struct packet_ruleset_terrain *packet)
Definition packets_gen.c:64450
dsend_packet_player_change_government
int dsend_packet_player_change_government(struct connection *pc, Government_type_id government)
Definition packets_gen.c:29248
destroy_packet_player_tech_goal
#define destroy_packet_player_tech_goal
Definition packets_gen.c:31724
lsend_packet_ruleset_resource
void lsend_packet_ruleset_resource(struct conn_list *dest, const struct packet_ruleset_resource *packet)
Definition packets_gen.c:88709
destroy_packet_ruleset_effect
static void destroy_packet_ruleset_effect(void *packet)
Definition packets_gen.c:87854
destroy_packet_unit_actions
#define destroy_packet_unit_actions
Definition packets_gen.c:38542
send_packet_vote_update_100
static int send_packet_vote_update_100(struct connection *pc, const struct packet_vote_update *packet)
Definition packets_gen.c:90277
dlsend_packet_diplomacy_create_clause
void dlsend_packet_diplomacy_create_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:41099
receive_packet_vote_remove_100
static struct packet_vote_remove * receive_packet_vote_remove_100(struct connection *pc)
Definition packets_gen.c:90505
send_packet_city_update_counters
int send_packet_city_update_counters(struct connection *pc, const struct packet_city_update_counters *packet)
Definition packets_gen.c:19727
lsend_packet_ruleset_specialist
void lsend_packet_ruleset_specialist(struct conn_list *dest, const struct packet_ruleset_specialist *packet)
Definition packets_gen.c:54223
send_packet_conn_info
int send_packet_conn_info(struct connection *pc, const struct packet_conn_info *packet)
Definition packets_gen.c:43907
lsend_packet_play_music
void lsend_packet_play_music(struct conn_list *dest, const struct packet_play_music *packet)
Definition packets_gen.c:100756
send_packet_player_tech_goal_100
static int send_packet_player_tech_goal_100(struct connection *pc, const struct packet_player_tech_goal *packet)
Definition packets_gen.c:31805
receive_packet_diplomacy_init_meeting_req_100
static struct packet_diplomacy_init_meeting_req * receive_packet_diplomacy_init_meeting_req_100(struct connection *pc)
Definition packets_gen.c:39472
send_packet_city_change_100
static int send_packet_city_change_100(struct connection *pc, const struct packet_city_change *packet)
Definition packets_gen.c:21582
send_packet_game_info
int send_packet_game_info(struct connection *pc, const struct packet_game_info *packet)
Definition packets_gen.c:11090
send_packet_ruleset_goods_100
static int send_packet_ruleset_goods_100(struct connection *pc, const struct packet_ruleset_goods *packet)
Definition packets_gen.c:73695
init_packet_ruleset_clause
static void init_packet_ruleset_clause(struct packet_ruleset_clause *packet)
Definition packets_gen.c:79839
dsend_packet_edit_player_create
int dsend_packet_edit_player_create(struct connection *pc, int tag)
Definition packets_gen.c:97621
lsend_packet_city_name_suggestion_info
void lsend_packet_city_name_suggestion_info(struct conn_list *dest, const struct packet_city_name_suggestion_info *packet)
Definition packets_gen.c:23925
destroy_packet_map_info
#define destroy_packet_map_info
Definition packets_gen.c:11827
send_packet_endgame_report_100
static int send_packet_endgame_report_100(struct connection *pc, const struct packet_endgame_report *packet)
Definition packets_gen.c:2620
send_packet_server_setting_bitwise_100
static int send_packet_server_setting_bitwise_100(struct connection *pc, const struct packet_server_setting_bitwise *packet)
Definition packets_gen.c:87146
send_packet_web_city_info_addition
int send_packet_web_city_info_addition(struct connection *pc, const struct packet_web_city_info_addition *packet, bool force_to_send)
Definition packets_gen.c:101888
send_packet_edit_unit_remove_by_id
int send_packet_edit_unit_remove_by_id(struct connection *pc, const struct packet_edit_unit_remove_by_id *packet)
Definition packets_gen.c:93800
destroy_packet_edit_unit
#define destroy_packet_edit_unit
Definition packets_gen.c:93827
send_packet_diplomacy_cancel_pact
int send_packet_diplomacy_cancel_pact(struct connection *pc, const struct packet_diplomacy_cancel_pact *packet)
Definition packets_gen.c:42548
receive_packet_vote_resolve_100
static struct packet_vote_resolve * receive_packet_vote_resolve_100(struct connection *pc)
Definition packets_gen.c:90690
dlsend_packet_diplomacy_accept_treaty
void dlsend_packet_diplomacy_accept_treaty(struct conn_list *dest, int counterpart, bool I_accepted, bool other_accepted)
Definition packets_gen.c:42303
receive_packet_ruleset_resource_100
static struct packet_ruleset_resource * receive_packet_ruleset_resource_100(struct connection *pc)
Definition packets_gen.c:88385
receive_packet_research_info_100
static struct packet_research_info * receive_packet_research_info_100(struct connection *pc)
Definition packets_gen.c:30750
send_packet_report_req_100
static int send_packet_report_req_100(struct connection *pc, const struct packet_report_req *packet)
Definition packets_gen.c:43265
receive_packet_ruleset_goods_100
static struct packet_ruleset_goods * receive_packet_ruleset_goods_100(struct connection *pc)
Definition packets_gen.c:73289
send_packet_edit_recalculate_borders
int send_packet_edit_recalculate_borders(struct connection *pc)
Definition packets_gen.c:91187
send_packet_conn_info_100
static int send_packet_conn_info_100(struct connection *pc, const struct packet_conn_info *packet)
Definition packets_gen.c:43607
destroy_packet_city_sell
#define destroy_packet_city_sell
Definition packets_gen.c:21021
init_packet_ruleset_choices
static void init_packet_ruleset_choices(struct packet_ruleset_choices *packet)
Definition packets_gen.c:83020
send_packet_set_topology
int send_packet_set_topology(struct connection *pc, const struct packet_set_topology *packet)
Definition packets_gen.c:87830
send_packet_web_city_info_addition_100
static int send_packet_web_city_info_addition_100(struct connection *pc, const struct packet_web_city_info_addition *packet, bool force_to_send)
Definition packets_gen.c:101357
send_packet_spaceship_place
int send_packet_spaceship_place(struct connection *pc, const struct packet_spaceship_place *packet)
Definition packets_gen.c:45884
dlsend_packet_start_phase
void dlsend_packet_start_phase(struct conn_list *dest, int phase)
Definition packets_gen.c:45109
receive_packet_ruleset_tech_flag_100
static struct packet_ruleset_tech_flag * receive_packet_ruleset_tech_flag_100(struct connection *pc)
Definition packets_gen.c:56052
dlsend_packet_city_name_suggestion_info
void dlsend_packet_city_name_suggestion_info(struct conn_list *dest, int unit_id, const char *name)
Definition packets_gen.c:23942
lsend_packet_ruleset_tech
void lsend_packet_ruleset_tech(struct conn_list *dest, const struct packet_ruleset_tech *packet)
Definition packets_gen.c:55686
send_packet_authentication_req
int send_packet_authentication_req(struct connection *pc, const struct packet_authentication_req *packet)
Definition packets_gen.c:1675
lsend_packet_ruleset_trade
void lsend_packet_ruleset_trade(struct conn_list *dest, const struct packet_ruleset_trade *packet)
Definition packets_gen.c:75595
destroy_packet_game_info
#define destroy_packet_game_info
Definition packets_gen.c:3837
receive_packet_edit_recalculate_borders_100
static struct packet_edit_recalculate_borders * receive_packet_edit_recalculate_borders_100(struct connection *pc)
Definition packets_gen.c:91165
destroy_packet_set_topology
#define destroy_packet_set_topology
Definition packets_gen.c:87612
destroy_packet_report_req
#define destroy_packet_report_req
Definition packets_gen.c:43174
init_packet_server_setting_enum
static void init_packet_server_setting_enum(struct packet_server_setting_enum *packet)
Definition packets_gen.c:85976
send_packet_map_info
int send_packet_map_info(struct connection *pc, const struct packet_map_info *packet)
Definition packets_gen.c:12277
send_packet_freeze_client
int send_packet_freeze_client(struct connection *pc)
Definition packets_gen.c:45540
receive_packet_ruleset_impr_flag_100
static struct packet_ruleset_impr_flag * receive_packet_ruleset_impr_flag_100(struct connection *pc)
Definition packets_gen.c:64163
send_packet_player_attribute_chunk
int send_packet_player_attribute_chunk(struct connection *pc, const struct packet_player_attribute_chunk *packet)
Definition packets_gen.c:29871
send_packet_tile_info
int send_packet_tile_info(struct connection *pc, const struct packet_tile_info *packet)
Definition packets_gen.c:3812
send_packet_edit_unit
int send_packet_edit_unit(struct connection *pc, const struct packet_edit_unit *packet)
Definition packets_gen.c:94714
destroy_packet_web_cma_clear
#define destroy_packet_web_cma_clear
Definition packets_gen.c:102138
receive_packet_scenario_description_100
static struct packet_scenario_description * receive_packet_scenario_description_100(struct connection *pc)
Definition packets_gen.c:89348
send_packet_single_want_hack_req_100
static int send_packet_single_want_hack_req_100(struct connection *pc, const struct packet_single_want_hack_req *packet)
Definition packets_gen.c:82752
send_packet_start_phase_100
static int send_packet_start_phase_100(struct connection *pc, const struct packet_start_phase *packet)
Definition packets_gen.c:44995
dsend_packet_player_research
int dsend_packet_player_research(struct connection *pc, int tech)
Definition packets_gen.c:31709
init_packet_edit_player
static void init_packet_edit_player(struct packet_edit_player *packet)
Definition packets_gen.c:97824
receive_packet_ruleset_unit_class_flag_100
static struct packet_ruleset_unit_class_flag * receive_packet_ruleset_unit_class_flag_100(struct connection *pc)
Definition packets_gen.c:51473
receive_packet_city_options_req_100
static struct packet_city_options_req * receive_packet_city_options_req_100(struct connection *pc)
Definition packets_gen.c:23069
receive_packet_client_heartbeat_100
static struct packet_client_heartbeat * receive_packet_client_heartbeat_100(struct connection *pc)
Definition packets_gen.c:44528
init_packet_edit_toggle_fogofwar
static void init_packet_edit_toggle_fogofwar(struct packet_edit_toggle_fogofwar *packet)
Definition packets_gen.c:91241
receive_packet_begin_turn_100
static struct packet_begin_turn * receive_packet_begin_turn_100(struct connection *pc)
Definition packets_gen.c:45420
send_packet_investigate_finished_100
static int send_packet_investigate_finished_100(struct connection *pc, const struct packet_investigate_finished *packet)
Definition packets_gen.c:973
init_packet_ruleset_goods
static void init_packet_ruleset_goods(struct packet_ruleset_goods *packet)
Definition packets_gen.c:73260
receive_packet_processing_started_100
static struct packet_processing_started * receive_packet_processing_started_100(struct connection *pc)
Definition packets_gen.c:600
dsend_packet_unit_action_query
int dsend_packet_unit_action_query(struct connection *pc, int actor_id, int target_id, action_id action_type, int request_kind)
Definition packets_gen.c:37094
free_packet_ruleset_goods
static void free_packet_ruleset_goods(struct packet_ruleset_goods *packet)
Definition packets_gen.c:73268
dsend_packet_city_remove
int dsend_packet_city_remove(struct connection *pc, int city_id)
Definition packets_gen.c:14932
receive_packet_investigate_finished_100
static struct packet_investigate_finished * receive_packet_investigate_finished_100(struct connection *pc)
Definition packets_gen.c:900
destroy_packet_diplomacy_cancel_meeting
#define destroy_packet_diplomacy_cancel_meeting
Definition packets_gen.c:40115
send_packet_nuke_tile_info
int send_packet_nuke_tile_info(struct connection *pc, const struct packet_nuke_tile_info *packet)
Definition packets_gen.c:12469
destroy_packet_diplomacy_create_clause_req
#define destroy_packet_diplomacy_create_clause_req
Definition packets_gen.c:40378
send_packet_ruleset_unit_class_flag
int send_packet_ruleset_unit_class_flag(struct connection *pc, const struct packet_ruleset_unit_class_flag *packet)
Definition packets_gen.c:51734
receive_packet_edit_check_tiles_100
static struct packet_edit_check_tiles * receive_packet_edit_check_tiles_100(struct connection *pc)
Definition packets_gen.c:91207
dsend_packet_city_rename
int dsend_packet_city_rename(struct connection *pc, int city_id, const char *name)
Definition packets_gen.c:23045
send_packet_ruleset_specialist_100
static int send_packet_ruleset_specialist_100(struct connection *pc, const struct packet_ruleset_specialist *packet)
Definition packets_gen.c:53773
send_packet_set_topology_100
static int send_packet_set_topology_100(struct connection *pc, const struct packet_set_topology *packet)
Definition packets_gen.c:87713
send_packet_ruleset_extra_flag_100
static int send_packet_ruleset_extra_flag_100(struct connection *pc, const struct packet_ruleset_extra_flag *packet)
Definition packets_gen.c:71366
send_packet_ruleset_disaster_100
static int send_packet_ruleset_disaster_100(struct connection *pc, const struct packet_ruleset_disaster *packet)
Definition packets_gen.c:74480
receive_packet_diplomacy_cancel_meeting_req_100
static struct packet_diplomacy_cancel_meeting_req * receive_packet_diplomacy_cancel_meeting_req_100(struct connection *pc)
Definition packets_gen.c:39929
init_packet_investigate_finished
static void init_packet_investigate_finished(struct packet_investigate_finished *packet)
Definition packets_gen.c:886
destroy_packet_page_msg
#define destroy_packet_page_msg
Definition packets_gen.c:42576
init_packet_unit_change_activity
static void init_packet_unit_change_activity(struct packet_unit_change_activity *packet)
Definition packets_gen.c:39150
receive_packet_ruleset_disaster_100
static struct packet_ruleset_disaster * receive_packet_ruleset_disaster_100(struct connection *pc)
Definition packets_gen.c:74240
dsend_packet_investigate_finished
int dsend_packet_investigate_finished(struct connection *pc, int city_id)
Definition packets_gen.c:1078
send_packet_ruleset_terrain_control
int send_packet_ruleset_terrain_control(struct connection *pc, const struct packet_ruleset_terrain_control *packet)
Definition packets_gen.c:57931
receive_packet_diplomacy_remove_clause_100
static struct packet_diplomacy_remove_clause * receive_packet_diplomacy_remove_clause_100(struct connection *pc)
Definition packets_gen.c:41485
lsend_packet_ruleset_action_enabler
void lsend_packet_ruleset_action_enabler(struct conn_list *dest, const struct packet_ruleset_action_enabler *packet)
Definition packets_gen.c:76896
destroy_packet_unit_short_info
#define destroy_packet_unit_short_info
Definition packets_gen.c:34380
receive_packet_ruleset_nation_100
static struct packet_ruleset_nation * receive_packet_ruleset_nation_100(struct connection *pc)
Definition packets_gen.c:59211
send_packet_city_buy
int send_packet_city_buy(struct connection *pc, const struct packet_city_buy *packet)
Definition packets_gen.c:21434
init_packet_nuke_tile_info
static void init_packet_nuke_tile_info(struct packet_nuke_tile_info *packet)
Definition packets_gen.c:12296
destroy_packet_ruleset_counter
static void destroy_packet_ruleset_counter(void *packet)
Definition packets_gen.c:77602
dlsend_packet_game_load
void dlsend_packet_game_load(struct conn_list *dest, bool load_successful, const char *load_filename)
Definition packets_gen.c:83779
destroy_packet_player_ready
#define destroy_packet_player_ready
Definition packets_gen.c:2326
destroy_packet_rulesets_ready
#define destroy_packet_rulesets_ready
Definition packets_gen.c:57956
dsend_packet_edit_object_created
int dsend_packet_edit_object_created(struct connection *pc, int tag, int id)
Definition packets_gen.c:100561
init_packet_ruleset_resource
static void init_packet_ruleset_resource(struct packet_ruleset_resource *packet)
Definition packets_gen.c:88371
send_packet_ruleset_unit_flag_100
static int send_packet_ruleset_unit_flag_100(struct connection *pc, const struct packet_ruleset_unit_flag *packet)
Definition packets_gen.c:51292
destroy_packet_unit_server_side_agent_set
#define destroy_packet_unit_server_side_agent_set
Definition packets_gen.c:36496
receive_packet_city_sell_100
static struct packet_city_sell * receive_packet_city_sell_100(struct connection *pc)
Definition packets_gen.c:21029
send_packet_edit_scenario_desc
int send_packet_edit_scenario_desc(struct connection *pc, const struct packet_edit_scenario_desc *packet)
Definition packets_gen.c:100313
init_packet_city_update_counters
static void init_packet_city_update_counters(struct packet_city_update_counters *packet)
Definition packets_gen.c:19346
destroy_packet_web_ruleset_unit_addition
#define destroy_packet_web_ruleset_unit_addition
Definition packets_gen.c:102556
packet_name
const char * packet_name(enum packet_type type)
Definition packets_gen.c:47
send_packet_ruleset_multiplier_100
static int send_packet_ruleset_multiplier_100(struct connection *pc, const struct packet_ruleset_multiplier *packet)
Definition packets_gen.c:79254
init_packet_city_buy
static void init_packet_city_buy(struct packet_city_buy *packet)
Definition packets_gen.c:21261
receive_packet_scenario_info_100
static struct packet_scenario_info * receive_packet_scenario_info_100(struct connection *pc)
Definition packets_gen.c:88730
send_packet_ruleset_extra_100
static int send_packet_ruleset_extra_100(struct connection *pc, const struct packet_ruleset_extra *packet)
Definition packets_gen.c:69706
send_packet_diplomacy_create_clause
int send_packet_diplomacy_create_clause(struct connection *pc, const struct packet_diplomacy_create_clause *packet)
Definition packets_gen.c:41068
init_packet_conn_info
static void init_packet_conn_info(struct packet_conn_info *packet)
Definition packets_gen.c:43372
receive_packet_ruleset_select_100
static struct packet_ruleset_select * receive_packet_ruleset_select_100(struct connection *pc)
Definition packets_gen.c:83378
send_packet_ruleset_trade
int send_packet_ruleset_trade(struct connection *pc, const struct packet_ruleset_trade *packet)
Definition packets_gen.c:75583
send_packet_player_change_government_100
static int send_packet_player_change_government_100(struct connection *pc, const struct packet_player_change_government *packet)
Definition packets_gen.c:29150
send_packet_player_ready
int send_packet_player_ready(struct connection *pc, const struct packet_player_ready *packet)
Definition packets_gen.c:2521
destroy_packet_city_remove
#define destroy_packet_city_remove
Definition packets_gen.c:14696
destroy_packet_processing_finished
#define destroy_packet_processing_finished
Definition packets_gen.c:640
receive_packet_edit_unit_100
static struct packet_edit_unit * receive_packet_edit_unit_100(struct connection *pc)
Definition packets_gen.c:93854
init_packet_player_attribute_chunk
static void init_packet_player_attribute_chunk(struct packet_player_attribute_chunk *packet)
Definition packets_gen.c:29545
receive_packet_diplomacy_accept_treaty_req_100
static struct packet_diplomacy_accept_treaty_req * receive_packet_diplomacy_accept_treaty_req_100(struct connection *pc)
Definition packets_gen.c:41864
init_packet_ruleset_nation
static void init_packet_ruleset_nation(struct packet_ruleset_nation *packet)
Definition packets_gen.c:59178
init_packet_connect_msg
static void init_packet_connect_msg(struct packet_connect_msg *packet)
Definition packets_gen.c:14094
destroy_packet_unknown_research
#define destroy_packet_unknown_research
Definition packets_gen.c:31327
receive_packet_server_setting_control_100
static struct packet_server_setting_control * receive_packet_server_setting_control_100(struct connection *pc)
Definition packets_gen.c:83803
destroy_packet_server_setting_bool
#define destroy_packet_server_setting_bool
Definition packets_gen.c:84589
receive_packet_player_remove_100
static struct packet_player_remove * receive_packet_player_remove_100(struct connection *pc)
Definition packets_gen.c:25254
receive_packet_vote_submit_100
static struct packet_vote_submit * receive_packet_vote_submit_100(struct connection *pc)
Definition packets_gen.c:90897
init_packet_ruleset_music
static void init_packet_ruleset_music(struct packet_ruleset_music *packet)
Definition packets_gen.c:78286
send_packet_diplomacy_cancel_pact_100
static int send_packet_diplomacy_cancel_pact_100(struct connection *pc, const struct packet_diplomacy_cancel_pact *packet)
Definition packets_gen.c:42431
lsend_packet_nuke_tile_info
void lsend_packet_nuke_tile_info(struct conn_list *dest, const struct packet_nuke_tile_info *packet)
Definition packets_gen.c:12481
lsend_packet_freeze_client
void lsend_packet_freeze_client(struct conn_list *dest)
Definition packets_gen.c:45552
dlsend_packet_diplomacy_cancel_meeting
void dlsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, int counterpart, int initiated_from)
Definition packets_gen.c:40362
send_packet_ruleset_unit_bonus_100
static int send_packet_ruleset_unit_bonus_100(struct connection *pc, const struct packet_ruleset_unit_bonus *packet)
Definition packets_gen.c:50949
destroy_packet_city_info
#define destroy_packet_city_info
Definition packets_gen.c:14956
lsend_packet_nation_availability
void lsend_packet_nation_availability(struct conn_list *dest, const struct packet_nation_availability *packet)
Definition packets_gen.c:61733
init_packet_endgame_player
static void init_packet_endgame_player(struct packet_endgame_player *packet)
Definition packets_gen.c:2716
free_packet_ruleset_government
static void free_packet_ruleset_government(struct packet_ruleset_government *packet)
Definition packets_gen.c:56340
dsend_packet_edit_unit_remove
int dsend_packet_edit_unit_remove(struct connection *pc, int owner, int tile, Unit_type_id type, int count)
Definition packets_gen.c:93615
destroy_packet_city_change
#define destroy_packet_city_change
Definition packets_gen.c:21461
send_packet_edit_unit_100
static int send_packet_edit_unit_100(struct connection *pc, const struct packet_edit_unit *packet)
Definition packets_gen.c:94216
send_packet_city_change_specialist
int send_packet_city_change_specialist(struct connection *pc, const struct packet_city_change_specialist *packet)
Definition packets_gen.c:22786
send_packet_web_cma_set_100
static int send_packet_web_cma_set_100(struct connection *pc, const struct packet_web_cma_set *packet)
Definition packets_gen.c:102022
destroy_packet_edit_tile_terrain
#define destroy_packet_edit_tile_terrain
Definition packets_gen.c:91441
receive_packet_ruleset_terrain_flag_100
static struct packet_ruleset_terrain_flag * receive_packet_ruleset_terrain_flag_100(struct connection *pc)
Definition packets_gen.c:67484
lsend_packet_web_city_info_addition
void lsend_packet_web_city_info_addition(struct conn_list *dest, const struct packet_web_city_info_addition *packet, bool force_to_send)
Definition packets_gen.c:101900
init_packet_city_rally_point
static void init_packet_city_rally_point(struct packet_city_rally_point *packet)
Definition packets_gen.c:24358
send_packet_edit_object_created_100
static int send_packet_edit_object_created_100(struct connection *pc, const struct packet_edit_object_created *packet)
Definition packets_gen.c:100432
send_packet_calendar_info
int send_packet_calendar_info(struct connection *pc, const struct packet_calendar_info *packet)
Definition packets_gen.c:11573
init_packet_web_cma_clear
static void init_packet_web_cma_clear(struct packet_web_cma_clear *packet)
Definition packets_gen.c:102132
init_packet_diplomacy_create_clause_req
static void init_packet_diplomacy_create_clause_req(struct packet_diplomacy_create_clause_req *packet)
Definition packets_gen.c:40372
dsend_packet_edit_unit_remove_by_id
int dsend_packet_edit_unit_remove_by_id(struct connection *pc, int id)
Definition packets_gen.c:93812
receive_packet_unknown_research_100
static struct packet_unknown_research * receive_packet_unknown_research_100(struct connection *pc)
Definition packets_gen.c:31335
receive_packet_player_place_infra_100
static struct packet_player_place_infra * receive_packet_player_place_infra_100(struct connection *pc)
Definition packets_gen.c:29271
send_packet_player_remove_100
static int send_packet_player_remove_100(struct connection *pc, const struct packet_player_remove *packet)
Definition packets_gen.c:25332
init_packet_server_setting_control
static void init_packet_server_setting_control(struct packet_server_setting_control *packet)
Definition packets_gen.c:83789
dsend_packet_investigate_started
int dsend_packet_investigate_started(struct connection *pc, int city_id)
Definition packets_gen.c:868
receive_packet_authentication_req_100
static struct packet_authentication_req * receive_packet_authentication_req_100(struct connection *pc)
Definition packets_gen.c:1455
dsend_packet_diplomacy_remove_clause_req
int dsend_packet_diplomacy_remove_clause_req(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
Definition packets_gen.c:41459
receive_packet_edit_scenario_desc_100
static struct packet_edit_scenario_desc * receive_packet_edit_scenario_desc_100(struct connection *pc)
Definition packets_gen.c:100154
receive_packet_city_make_specialist_100
static struct packet_city_make_specialist * receive_packet_city_make_specialist_100(struct connection *pc)
Definition packets_gen.c:22013
receive_packet_edit_toggle_fogofwar_100
static struct packet_edit_toggle_fogofwar * receive_packet_edit_toggle_fogofwar_100(struct connection *pc)
Definition packets_gen.c:91255
receive_packet_player_ready_100
static struct packet_player_ready * receive_packet_player_ready_100(struct connection *pc)
Definition packets_gen.c:2334
send_packet_vote_remove
int send_packet_vote_remove(struct connection *pc, const struct packet_vote_remove *packet)
Definition packets_gen.c:90664
dsend_packet_city_buy
int dsend_packet_city_buy(struct connection *pc, int city_id)
Definition packets_gen.c:21446
send_packet_unit_get_actions
int send_packet_unit_get_actions(struct connection *pc, const struct packet_unit_get_actions *packet)
Definition packets_gen.c:38511
init_packet_edit_tile_terrain
static void init_packet_edit_tile_terrain(struct packet_edit_tile_terrain *packet)
Definition packets_gen.c:91435
send_packet_unit_change_activity
int send_packet_unit_change_activity(struct connection *pc, const struct packet_unit_change_activity *packet)
Definition packets_gen.c:39435
destroy_packet_city_nationalities
#define destroy_packet_city_nationalities
Definition packets_gen.c:18792
destroy_packet_web_city_info_addition
#define destroy_packet_web_city_info_addition
Definition packets_gen.c:100961
init_packet_city_sell
static void init_packet_city_sell(struct packet_city_sell *packet)
Definition packets_gen.c:21015
receive_packet_city_refresh_100
static struct packet_city_refresh * receive_packet_city_refresh_100(struct connection *pc)
Definition packets_gen.c:23315
dlsend_packet_investigate_started
void dlsend_packet_investigate_started(struct conn_list *dest, int city_id)
Definition packets_gen.c:877
dsend_packet_start_phase
int dsend_packet_start_phase(struct connection *pc, int phase)
Definition packets_gen.c:45100
send_packet_unit_server_side_agent_set_100
static int send_packet_unit_server_side_agent_set_100(struct connection *pc, const struct packet_unit_server_side_agent_set *packet)
Definition packets_gen.c:36607
receive_packet_game_load_100
static struct packet_game_load * receive_packet_game_load_100(struct connection *pc)
Definition packets_gen.c:83563
send_packet_edit_mode_100
static int send_packet_edit_mode_100(struct connection *pc, const struct packet_edit_mode *packet)
Definition packets_gen.c:91064
destroy_packet_investigate_finished
#define destroy_packet_investigate_finished
Definition packets_gen.c:892
send_packet_server_setting_const_100
static int send_packet_server_setting_const_100(struct connection *pc, const struct packet_server_setting_const *packet)
Definition packets_gen.c:84369
lsend_packet_ruleset_style
void lsend_packet_ruleset_style(struct conn_list *dest, const struct packet_ruleset_style *packet)
Definition packets_gen.c:62027
send_packet_chat_msg_req
int send_packet_chat_msg_req(struct connection *pc, const struct packet_chat_msg_req *packet)
Definition packets_gen.c:14073
lsend_packet_conn_ping_info
void lsend_packet_conn_ping_info(struct conn_list *dest, const struct packet_conn_ping_info *packet)
Definition packets_gen.c:44429
send_packet_server_info_100
static int send_packet_server_info_100(struct connection *pc, const struct packet_server_info *packet)
Definition packets_gen.c:14455
send_packet_ruleset_building_100
static int send_packet_ruleset_building_100(struct connection *pc, const struct packet_ruleset_building *packet)
Definition packets_gen.c:63346
init_packet_ruleset_counter
static void init_packet_ruleset_counter(struct packet_ruleset_counter *packet)
Definition packets_gen.c:77587
lsend_packet_end_phase
void lsend_packet_end_phase(struct conn_list *dest)
Definition packets_gen.c:44901
dsend_packet_edit_unit_create
int dsend_packet_edit_unit_create(struct connection *pc, int owner, int tile, Unit_type_id type, int count, int tag)
Definition packets_gen.c:93254
dsend_packet_edit_player_remove
int dsend_packet_edit_player_remove(struct connection *pc, int id)
Definition packets_gen.c:97815
dsend_packet_unit_type_upgrade
int dsend_packet_unit_type_upgrade(struct connection *pc, Unit_type_id type)
Definition packets_gen.c:37301
send_packet_ruleset_action
int send_packet_ruleset_action(struct connection *pc, const struct packet_ruleset_action *packet)
Definition packets_gen.c:76340
lsend_packet_unit_combat_info
void lsend_packet_unit_combat_info(struct conn_list *dest, const struct packet_unit_combat_info *packet)
Definition packets_gen.c:35622
send_packet_unit_get_actions_100
static int send_packet_unit_get_actions_100(struct connection *pc, const struct packet_unit_get_actions *packet)
Definition packets_gen.c:38301
init_packet_game_load
static void init_packet_game_load(struct packet_game_load *packet)
Definition packets_gen.c:83549
init_packet_popup_image
static void init_packet_popup_image(struct packet_popup_image *packet)
Definition packets_gen.c:100763
init_packet_vote_resolve
static void init_packet_vote_resolve(struct packet_vote_resolve *packet)
Definition packets_gen.c:90676
destroy_packet_spaceship_info
#define destroy_packet_spaceship_info
Definition packets_gen.c:45912
receive_packet_player_diplstate_100
static struct packet_player_diplstate * receive_packet_player_diplstate_100(struct connection *pc)
Definition packets_gen.c:29916
receive_packet_edit_city_100
static struct packet_edit_city * receive_packet_edit_city_100(struct connection *pc)
Definition packets_gen.c:95303
receive_packet_conn_pong_100
static struct packet_conn_pong * receive_packet_conn_pong_100(struct connection *pc)
Definition packets_gen.c:44486
init_packet_page_msg_part
static void init_packet_page_msg_part(struct packet_page_msg_part *packet)
Definition packets_gen.c:42976
init_packet_chat_msg
static void init_packet_chat_msg(struct packet_chat_msg *packet)
Definition packets_gen.c:12986
init_packet_edit_unit_remove
static void init_packet_edit_unit_remove(struct packet_edit_unit_remove *packet)
Definition packets_gen.c:93267
receive_packet_ruleset_tech_class_100
static struct packet_ruleset_tech_class * receive_packet_ruleset_tech_class_100(struct connection *pc)
Definition packets_gen.c:55707
init_packet_thaw_client
static void init_packet_thaw_client(struct packet_thaw_client *packet)
Definition packets_gen.c:45559
send_packet_edit_city_remove
int send_packet_edit_city_remove(struct connection *pc, const struct packet_edit_city_remove *packet)
Definition packets_gen.c:95249
receive_packet_diplomacy_init_meeting_100
static struct packet_diplomacy_init_meeting * receive_packet_diplomacy_init_meeting_100(struct connection *pc)
Definition packets_gen.c:39666
destroy_packet_diplomacy_create_clause
#define destroy_packet_diplomacy_create_clause
Definition packets_gen.c:40738
send_packet_ruleset_effect
int send_packet_ruleset_effect(struct connection *pc, const struct packet_ruleset_effect *packet)
Definition packets_gen.c:88352
destroy_packet_city_make_worker
#define destroy_packet_city_make_worker
Definition packets_gen.c:22251
send_packet_ruleset_action_100
static int send_packet_ruleset_action_100(struct connection *pc, const struct packet_ruleset_action *packet)
Definition packets_gen.c:75939
send_packet_server_setting_str_100
static int send_packet_server_setting_str_100(struct connection *pc, const struct packet_server_setting_str *packet)
Definition packets_gen.c:85728
receive_packet_ruleset_action_100
static struct packet_ruleset_action * receive_packet_ruleset_action_100(struct connection *pc)
Definition packets_gen.c:75616
destroy_packet_city_sabotage_list
#define destroy_packet_city_sabotage_list
Definition packets_gen.c:23958
init_packet_unknown_research
static void init_packet_unknown_research(struct packet_unknown_research *packet)
Definition packets_gen.c:31321
send_packet_edit_mode
int send_packet_edit_mode(struct connection *pc, const struct packet_edit_mode *packet)
Definition packets_gen.c:91136
destroy_packet_ruleset_extra
static void destroy_packet_ruleset_extra(void *packet)
Definition packets_gen.c:68521
send_packet_ruleset_summary_100
static int send_packet_ruleset_summary_100(struct connection *pc, const struct packet_ruleset_summary *packet)
Definition packets_gen.c:82368
init_packet_city_short_info
static void init_packet_city_short_info(struct packet_city_short_info *packet)
Definition packets_gen.c:19746
dsend_packet_player_place_infra
int dsend_packet_player_place_infra(struct connection *pc, int tile, int extra)
Definition packets_gen.c:29493
send_packet_ruleset_style
int send_packet_ruleset_style(struct connection *pc, const struct packet_ruleset_style *packet)
Definition packets_gen.c:62015
receive_packet_ruleset_road_100
static struct packet_ruleset_road * receive_packet_ruleset_road_100(struct connection *pc)
Definition packets_gen.c:72014
send_packet_ruleset_disaster
int send_packet_ruleset_disaster(struct connection *pc, const struct packet_ruleset_disaster *packet)
Definition packets_gen.c:74784
destroy_packet_freeze_client
#define destroy_packet_freeze_client
Definition packets_gen.c:45516
send_packet_unit_actions_100
static int send_packet_unit_actions_100(struct connection *pc, const struct packet_unit_actions *packet)
Definition packets_gen.c:38787
init_packet_city_info
static void init_packet_city_info(struct packet_city_info *packet)
Definition packets_gen.c:14950
packet_destroy
void packet_destroy(void *packet, enum packet_type type)
Definition packets_gen.c:103199
lsend_packet_server_shutdown
void lsend_packet_server_shutdown(struct conn_list *dest)
Definition packets_gen.c:1924
send_packet_edit_scenario_desc_100
static int send_packet_edit_scenario_desc_100(struct connection *pc, const struct packet_edit_scenario_desc *packet)
Definition packets_gen.c:100227
dsend_packet_diplomacy_accept_treaty
int dsend_packet_diplomacy_accept_treaty(struct connection *pc, int counterpart, bool I_accepted, bool other_accepted)
Definition packets_gen.c:42292
receive_packet_player_info_100
static struct packet_player_info * receive_packet_player_info_100(struct connection *pc)
Definition packets_gen.c:25477
init_packet_edit_city_remove
static void init_packet_edit_city_remove(struct packet_edit_city_remove *packet)
Definition packets_gen.c:95076
send_packet_ruleset_unit
int send_packet_ruleset_unit(struct connection *pc, const struct packet_ruleset_unit *packet)
Definition packets_gen.c:50743
init_packet_city_change
static void init_packet_city_change(struct packet_city_change *packet)
Definition packets_gen.c:21455
init_packet_single_want_hack_req
static void init_packet_single_want_hack_req(struct packet_single_want_hack_req *packet)
Definition packets_gen.c:82665
init_packet_conn_pong
static void init_packet_conn_pong(struct packet_conn_pong *packet)
Definition packets_gen.c:44478
send_packet_ruleset_achievement_100
static int send_packet_ruleset_achievement_100(struct connection *pc, const struct packet_ruleset_achievement *packet)
Definition packets_gen.c:74990
destroy_packet_server_info
#define destroy_packet_server_info
Definition packets_gen.c:14294
receive_packet_early_chat_msg_100
static struct packet_early_chat_msg * receive_packet_early_chat_msg_100(struct connection *pc)
Definition packets_gen.c:13457
send_packet_ruleset_terrain_flag_100
static int send_packet_ruleset_terrain_flag_100(struct connection *pc, const struct packet_ruleset_terrain_flag *packet)
Definition packets_gen.c:67597
receive_packet_edit_player_remove_100
static struct packet_edit_player_remove * receive_packet_edit_player_remove_100(struct connection *pc)
Definition packets_gen.c:97644
send_packet_popup_image_100
static int send_packet_popup_image_100(struct connection *pc, const struct packet_popup_image *packet)
Definition packets_gen.c:100850
receive_packet_ruleset_government_ruler_title_100
static struct packet_ruleset_government_ruler_title * receive_packet_ruleset_government_ruler_title_100(struct connection *pc)
Definition packets_gen.c:54244
send_packet_vote_update
int send_packet_vote_update(struct connection *pc, const struct packet_vote_update *packet)
Definition packets_gen.c:90479
init_packet_spaceship_place
static void init_packet_spaceship_place(struct packet_spaceship_place *packet)
Definition packets_gen.c:45650
dsend_packet_save_scenario
int dsend_packet_save_scenario(struct connection *pc, const char *name)
Definition packets_gen.c:89704
receive_packet_player_phase_done_100
static struct packet_player_phase_done * receive_packet_player_phase_done_100(struct connection *pc)
Definition packets_gen.c:28575
init_packet_city_make_specialist
static void init_packet_city_make_specialist(struct packet_city_make_specialist *packet)
Definition packets_gen.c:21999
free_packet_ruleset_music
static void free_packet_ruleset_music(struct packet_ruleset_music *packet)
Definition packets_gen.c:78293
send_packet_investigate_started_100
static int send_packet_investigate_started_100(struct connection *pc, const struct packet_investigate_started *packet)
Definition packets_gen.c:763
destroy_packet_server_shutdown
#define destroy_packet_server_shutdown
Definition packets_gen.c:1888
destroy_packet_edit_toggle_fogofwar
#define destroy_packet_edit_toggle_fogofwar
Definition packets_gen.c:91247
destroy_packet_ruleset_achievement
#define destroy_packet_ruleset_achievement
Definition packets_gen.c:74809
dsend_packet_edit_tile_extra
int dsend_packet_edit_tile_extra(struct connection *pc, int tile, int extra_type_id, bool removal, int eowner, int size)
Definition packets_gen.c:92087
send_packet_ruleset_nation_groups
int send_packet_ruleset_nation_groups(struct connection *pc, const struct packet_ruleset_nation_groups *packet)
Definition packets_gen.c:59159
send_packet_server_join_reply
int send_packet_server_join_reply(struct connection *pc, const struct packet_server_join_reply *packet)
Definition packets_gen.c:1429
init_packet_ruleset_unit
static void init_packet_ruleset_unit(struct packet_ruleset_unit *packet)
Definition packets_gen.c:46978
send_packet_edit_startpos
int send_packet_edit_startpos(struct connection *pc, const struct packet_edit_startpos *packet)
Definition packets_gen.c:92205
lsend_packet_ruleset_tech_flag
void lsend_packet_ruleset_tech_flag(struct conn_list *dest, const struct packet_ruleset_tech_flag *packet)
Definition packets_gen.c:56325
destroy_packet_play_music
#define destroy_packet_play_music
Definition packets_gen.c:100577
lsend_packet_investigate_finished
void lsend_packet_investigate_finished(struct conn_list *dest, const struct packet_investigate_finished *packet)
Definition packets_gen.c:1071
dsend_packet_unit_action_answer
int dsend_packet_unit_action_answer(struct connection *pc, int actor_id, int target_id, int cost, action_id action_type, int request_kind)
Definition packets_gen.c:38121
send_packet_edit_tile_terrain
int send_packet_edit_tile_terrain(struct connection *pc, const struct packet_edit_tile_terrain *packet)
Definition packets_gen.c:91709
receive_packet_city_short_info_100
static struct packet_city_short_info * receive_packet_city_short_info_100(struct connection *pc)
Definition packets_gen.c:19779
send_packet_unit_action_query_100
static int send_packet_unit_action_query_100(struct connection *pc, const struct packet_unit_action_query *packet)
Definition packets_gen.c:36903
send_packet_edit_tile
int send_packet_edit_tile(struct connection *pc, const struct packet_edit_tile *packet)
Definition packets_gen.c:92843
receive_packet_diplomacy_remove_clause_req_100
static struct packet_diplomacy_remove_clause_req * receive_packet_diplomacy_remove_clause_req_100(struct connection *pc)
Definition packets_gen.c:41125
destroy_packet_player_remove
#define destroy_packet_player_remove
Definition packets_gen.c:25246
init_packet_edit_unit_remove_by_id
static void init_packet_edit_unit_remove_by_id(struct packet_edit_unit_remove_by_id *packet)
Definition packets_gen.c:93627
send_packet_server_setting_control_100
static int send_packet_server_setting_control_100(struct connection *pc, const struct packet_server_setting_control *packet)
Definition packets_gen.c:83966
init_packet_player_research
static void init_packet_player_research(struct packet_player_research *packet)
Definition packets_gen.c:31524
receive_packet_player_change_government_100
static struct packet_player_change_government * receive_packet_player_change_government_100(struct connection *pc)
Definition packets_gen.c:29067
send_packet_server_setting_enum
int send_packet_server_setting_enum(struct connection *pc, const struct packet_server_setting_enum *packet)
Definition packets_gen.c:86779
lsend_packet_achievement_info
void lsend_packet_achievement_info(struct conn_list *dest, const struct packet_achievement_info *packet)
Definition packets_gen.c:12979
send_packet_edit_check_tiles
int send_packet_edit_check_tiles(struct connection *pc)
Definition packets_gen.c:91229
destroy_packet_ruleset_select
#define destroy_packet_ruleset_select
Definition packets_gen.c:83370
send_packet_ruleset_control
int send_packet_ruleset_control(struct connection *pc, const struct packet_ruleset_control *packet)
Definition packets_gen.c:82262
send_packet_chat_msg_req_100
static int send_packet_chat_msg_req_100(struct connection *pc, const struct packet_chat_msg_req *packet)
Definition packets_gen.c:13987
destroy_packet_ruleset_government
static void destroy_packet_ruleset_government(void *packet)
Definition packets_gen.c:56349
init_packet_ruleset_action
static void init_packet_ruleset_action(struct packet_ruleset_action *packet)
Definition packets_gen.c:75602
init_packet_ruleset_terrain_control
static void init_packet_ruleset_terrain_control(struct packet_ruleset_terrain_control *packet)
Definition packets_gen.c:57243
lsend_packet_city_sabotage_list
void lsend_packet_city_sabotage_list(struct conn_list *dest, const struct packet_city_sabotage_list *packet)
Definition packets_gen.c:24351
receive_packet_web_city_info_addition_100
static struct packet_web_city_info_addition * receive_packet_web_city_info_addition_100(struct connection *pc)
Definition packets_gen.c:100988
destroy_packet_player_attribute_chunk
#define destroy_packet_player_attribute_chunk
Definition packets_gen.c:29551
receive_packet_player_attribute_chunk_100
static struct packet_player_attribute_chunk * receive_packet_player_attribute_chunk_100(struct connection *pc)
Definition packets_gen.c:29578
send_packet_diplomacy_remove_clause
int send_packet_diplomacy_remove_clause(struct connection *pc, const struct packet_diplomacy_remove_clause *packet)
Definition packets_gen.c:41807
send_packet_new_year_100
static int send_packet_new_year_100(struct connection *pc, const struct packet_new_year *packet)
Definition packets_gen.c:45245
send_packet_ruleset_government_ruler_title
int send_packet_ruleset_government_ruler_title(struct connection *pc, const struct packet_ruleset_government_ruler_title *packet)
Definition packets_gen.c:54576
send_packet_diplomacy_cancel_meeting
int send_packet_diplomacy_cancel_meeting(struct connection *pc, const struct packet_diplomacy_cancel_meeting *packet)
Definition packets_gen.c:40333
send_packet_unit_combat_info_100
static int send_packet_unit_combat_info_100(struct connection *pc, const struct packet_unit_combat_info *packet)
Definition packets_gen.c:35395
receive_packet_conn_info_100
static struct packet_conn_info * receive_packet_conn_info_100(struct connection *pc)
Definition packets_gen.c:43405
send_packet_thaw_client
int send_packet_thaw_client(struct connection *pc)
Definition packets_gen.c:45589
send_packet_city_rename_100
static int send_packet_city_rename_100(struct connection *pc, const struct packet_city_rename *packet)
Definition packets_gen.c:22916
init_packet_ruleset_trade
static void init_packet_ruleset_trade(struct packet_ruleset_trade *packet)
Definition packets_gen.c:75237
receive_packet_ruleset_extra_100
static struct packet_ruleset_extra * receive_packet_ruleset_extra_100(struct connection *pc)
Definition packets_gen.c:68533
send_packet_edit_player_create
int send_packet_edit_player_create(struct connection *pc, const struct packet_edit_player_create *packet)
Definition packets_gen.c:97609
send_packet_unit_info
int send_packet_unit_info(struct connection *pc, const struct packet_unit_info *packet)
Definition packets_gen.c:34355
send_packet_ruleset_action_enabler
int send_packet_ruleset_action_enabler(struct connection *pc, const struct packet_ruleset_action_enabler *packet)
Definition packets_gen.c:76884
send_packet_authentication_req_100
static int send_packet_authentication_req_100(struct connection *pc, const struct packet_authentication_req *packet)
Definition packets_gen.c:1558
destroy_packet_unit_change_activity
#define destroy_packet_unit_change_activity
Definition packets_gen.c:39156
send_packet_city_worklist_100
static int send_packet_city_worklist_100(struct connection *pc, const struct packet_city_worklist *packet)
Definition packets_gen.c:21860
init_packet_ruleset_style
static void init_packet_ruleset_style(struct packet_ruleset_style *packet)
Definition packets_gen.c:61740
init_packet_web_player_info_addition
static void init_packet_web_player_info_addition(struct packet_web_player_info_addition *packet)
Definition packets_gen.c:102317
destroy_packet_conn_ping_info
#define destroy_packet_conn_ping_info
Definition packets_gen.c:43932
init_packet_edit_player_remove
static void init_packet_edit_player_remove(struct packet_edit_player_remove *packet)
Definition packets_gen.c:97630
send_packet_rulesets_ready_100
static int send_packet_rulesets_ready_100(struct connection *pc)
Definition packets_gen.c:57971
init_packet_ruleset_government_ruler_title
static void init_packet_ruleset_government_ruler_title(struct packet_ruleset_government_ruler_title *packet)
Definition packets_gen.c:54230
init_packet_player_rates
static void init_packet_player_rates(struct packet_player_rates *packet)
Definition packets_gen.c:28755
send_packet_player_tech_goal
int send_packet_player_tech_goal(struct connection *pc, const struct packet_player_tech_goal *packet)
Definition packets_gen.c:31891
init_packet_diplomacy_create_clause
static void init_packet_diplomacy_create_clause(struct packet_diplomacy_create_clause *packet)
Definition packets_gen.c:40732
send_packet_diplomacy_init_meeting
int send_packet_diplomacy_init_meeting(struct connection *pc, const struct packet_diplomacy_init_meeting *packet)
Definition packets_gen.c:39876
receive_packet_diplomacy_accept_treaty_100
static struct packet_diplomacy_accept_treaty * receive_packet_diplomacy_accept_treaty_100(struct connection *pc)
Definition packets_gen.c:42058
destroy_packet_city_name_suggestion_req
#define destroy_packet_city_name_suggestion_req
Definition packets_gen.c:23501
init_packet_server_info
static void init_packet_server_info(struct packet_server_info *packet)
Definition packets_gen.c:14288
send_packet_unit_info_100
static int send_packet_unit_info_100(struct connection *pc, const struct packet_unit_info *packet)
Definition packets_gen.c:33056
init_packet_start_phase
static void init_packet_start_phase(struct packet_start_phase *packet)
Definition packets_gen.c:44908
send_packet_team_name_info
int send_packet_team_name_info(struct connection *pc, const struct packet_team_name_info *packet)
Definition packets_gen.c:12719
init_packet_city_make_worker
static void init_packet_city_make_worker(struct packet_city_make_worker *packet)
Definition packets_gen.c:22245
receive_packet_edit_tile_extra_100
static struct packet_edit_tile_extra * receive_packet_edit_tile_extra_100(struct connection *pc)
Definition packets_gen.c:91765
destroy_packet_team_name_info
#define destroy_packet_team_name_info
Definition packets_gen.c:12512
receive_packet_server_shutdown_100
static struct packet_server_shutdown * receive_packet_server_shutdown_100(struct connection *pc)
Definition packets_gen.c:1890
dsend_packet_single_want_hack_reply
int dsend_packet_single_want_hack_reply(struct connection *pc, bool you_have_hack)
Definition packets_gen.c:83011
send_packet_client_heartbeat_100
static int send_packet_client_heartbeat_100(struct connection *pc)
Definition packets_gen.c:44541
send_packet_server_shutdown
int send_packet_server_shutdown(struct connection *pc)
Definition packets_gen.c:1912
destroy_packet_nation_availability
#define destroy_packet_nation_availability
Definition packets_gen.c:61367
send_packet_city_options_req_100
static int send_packet_city_options_req_100(struct connection *pc, const struct packet_city_options_req *packet)
Definition packets_gen.c:23162
send_packet_research_info
int send_packet_research_info(struct connection *pc, const struct packet_research_info *packet)
Definition packets_gen.c:31302
receive_packet_server_setting_int_100
static struct packet_server_setting_int * receive_packet_server_setting_int_100(struct connection *pc)
Definition packets_gen.c:85019
init_packet_edit_unit
static void init_packet_edit_unit(struct packet_edit_unit *packet)
Definition packets_gen.c:93821
destroy_packet_unit_orders
#define destroy_packet_unit_orders
Definition packets_gen.c:35943
init_packet_web_cma_set
static void init_packet_web_cma_set(struct packet_web_cma_set *packet)
Definition packets_gen.c:101907
send_packet_player_research_100
static int send_packet_player_research_100(struct connection *pc, const struct packet_player_research *packet)
Definition packets_gen.c:31611
receive_packet_freeze_client_100
static struct packet_freeze_client * receive_packet_freeze_client_100(struct connection *pc)
Definition packets_gen.c:45518
send_packet_vote_new
int send_packet_vote_new(struct connection *pc, const struct packet_vote_new *packet)
Definition packets_gen.c:90090
destroy_packet_ruleset_building
static void destroy_packet_ruleset_building(void *packet)
Definition packets_gen.c:62695
send_packet_unit_sscs_set
int send_packet_unit_sscs_set(struct connection *pc, const struct packet_unit_sscs_set *packet)
Definition packets_gen.c:35914
lsend_packet_ruleset_tech_class
void lsend_packet_ruleset_tech_class(struct conn_list *dest, const struct packet_ruleset_tech_class *packet)
Definition packets_gen.c:56031
destroy_packet_edit_check_tiles
#define destroy_packet_edit_check_tiles
Definition packets_gen.c:91205
destroy_packet_endgame_report
#define destroy_packet_endgame_report
Definition packets_gen.c:2549
send_packet_scenario_description
int send_packet_scenario_description(struct connection *pc, const struct packet_scenario_description *packet)
Definition packets_gen.c:89507
send_packet_player_attribute_block
int send_packet_player_attribute_block(struct connection *pc)
Definition packets_gen.c:29533
send_packet_ruleset_nation_sets_100
static int send_packet_ruleset_nation_sets_100(struct connection *pc, const struct packet_ruleset_nation_sets *packet)
Definition packets_gen.c:58296
send_packet_diplomacy_cancel_meeting_req_100
static int send_packet_diplomacy_cancel_meeting_req_100(struct connection *pc, const struct packet_diplomacy_cancel_meeting_req *packet)
Definition packets_gen.c:40002
send_packet_achievement_info
int send_packet_achievement_info(struct connection *pc, const struct packet_achievement_info *packet)
Definition packets_gen.c:12967
send_packet_web_player_info_addition
int send_packet_web_player_info_addition(struct connection *pc, const struct packet_web_player_info_addition *packet)
Definition packets_gen.c:102538
send_packet_web_cma_set
int send_packet_web_cma_set(struct connection *pc, const struct packet_web_cma_set *packet)
Definition packets_gen.c:102120
destroy_packet_diplomacy_init_meeting
#define destroy_packet_diplomacy_init_meeting
Definition packets_gen.c:39658
receive_packet_start_phase_100
static struct packet_start_phase * receive_packet_start_phase_100(struct connection *pc)
Definition packets_gen.c:44922
send_packet_web_player_info_addition_100
static int send_packet_web_player_info_addition_100(struct connection *pc, const struct packet_web_player_info_addition *packet)
Definition packets_gen.c:102432
receive_packet_unit_get_actions_100
static struct packet_unit_get_actions * receive_packet_unit_get_actions_100(struct connection *pc)
Definition packets_gen.c:38148
dsend_packet_report_req
int dsend_packet_report_req(struct connection *pc, enum report_type type)
Definition packets_gen.c:43363
destroy_packet_server_setting_control
#define destroy_packet_server_setting_control
Definition packets_gen.c:83795
destroy_packet_server_setting_bitwise
#define destroy_packet_server_setting_bitwise
Definition packets_gen.c:86797
receive_packet_player_research_100
static struct packet_player_research * receive_packet_player_research_100(struct connection *pc)
Definition packets_gen.c:31538
lsend_packet_ruleset_goods
void lsend_packet_ruleset_goods(struct conn_list *dest, const struct packet_ruleset_goods *packet)
Definition packets_gen.c:74209
send_packet_spaceship_launch
int send_packet_spaceship_launch(struct connection *pc)
Definition packets_gen.c:45638
send_packet_team_name_info_100
static int send_packet_team_name_info_100(struct connection *pc, const struct packet_team_name_info *packet)
Definition packets_gen.c:12621
lsend_packet_end_turn
void lsend_packet_end_turn(struct conn_list *dest)
Definition packets_gen.c:45503
send_packet_web_ruleset_unit_addition_100
static int send_packet_web_ruleset_unit_addition_100(struct connection *pc, const struct packet_web_ruleset_unit_addition *packet)
Definition packets_gen.c:102670
lsend_packet_diplomacy_remove_clause
void lsend_packet_diplomacy_remove_clause(struct conn_list *dest, const struct packet_diplomacy_remove_clause *packet)
Definition packets_gen.c:41819
free_packet_ruleset_clause
static void free_packet_ruleset_clause(struct packet_ruleset_clause *packet)
Definition packets_gen.c:79848
receive_packet_ruleset_terrain_control_100
static struct packet_ruleset_terrain_control * receive_packet_ruleset_terrain_control_100(struct connection *pc)
Definition packets_gen.c:57257
send_packet_spaceship_info
int send_packet_spaceship_info(struct connection *pc, const struct packet_spaceship_info *packet)
Definition packets_gen.c:46959
send_packet_nation_availability_100
static int send_packet_nation_availability_100(struct connection *pc, const struct packet_nation_availability *packet)
Definition packets_gen.c:61528
receive_packet_edit_startpos_100
static struct packet_edit_startpos * receive_packet_edit_startpos_100(struct connection *pc)
Definition packets_gen.c:92108
destroy_packet_city_options_req
#define destroy_packet_city_options_req
Definition packets_gen.c:23061
destroy_packet_diplomacy_accept_treaty
#define destroy_packet_diplomacy_accept_treaty
Definition packets_gen.c:42050
init_packet_ruleset_extra_flag
static void init_packet_ruleset_extra_flag(struct packet_ruleset_extra_flag *packet)
Definition packets_gen.c:71239
receive_packet_ruleset_specialist_100
static struct packet_ruleset_specialist * receive_packet_ruleset_specialist_100(struct connection *pc)
Definition packets_gen.c:53403
send_packet_page_msg_part
int send_packet_page_msg_part(struct connection *pc, const struct packet_page_msg_part *packet)
Definition packets_gen.c:43149
init_packet_city_refresh
static void init_packet_city_refresh(struct packet_city_refresh *packet)
Definition packets_gen.c:23301
lsend_packet_ruleset_game
void lsend_packet_ruleset_game(struct conn_list *dest, const struct packet_ruleset_game *packet)
Definition packets_gen.c:53367
send_packet_ruleset_building
int send_packet_ruleset_building(struct connection *pc, const struct packet_ruleset_building *packet)
Definition packets_gen.c:64130
send_packet_city_info_100
static int send_packet_city_info_100(struct connection *pc, const struct packet_city_info *packet, bool force_to_send)
Definition packets_gen.c:16500
send_packet_page_msg_100
static int send_packet_page_msg_100(struct connection *pc, const struct packet_page_msg *packet)
Definition packets_gen.c:42747
init_packet_scenario_description
static void init_packet_scenario_description(struct packet_scenario_description *packet)
Definition packets_gen.c:89334
lsend_packet_page_msg_part
void lsend_packet_page_msg_part(struct conn_list *dest, const struct packet_page_msg_part *packet)
Definition packets_gen.c:43161
destroy_packet_ruleset_nation_sets
#define destroy_packet_ruleset_nation_sets
Definition packets_gen.c:58005
lsend_packet_ruleset_nation
void lsend_packet_ruleset_nation(struct conn_list *dest, const struct packet_ruleset_nation *packet)
Definition packets_gen.c:61354
send_packet_diplomacy_init_meeting_req
int send_packet_diplomacy_init_meeting_req(struct connection *pc, const struct packet_diplomacy_init_meeting_req *packet)
Definition packets_gen.c:39631
init_packet_city_name_suggestion_req
static void init_packet_city_name_suggestion_req(struct packet_city_name_suggestion_req *packet)
Definition packets_gen.c:23495
send_packet_achievement_info_100
static int send_packet_achievement_info_100(struct connection *pc, const struct packet_achievement_info *packet)
Definition packets_gen.c:12845
dsend_packet_edit_tile_terrain
int dsend_packet_edit_tile_terrain(struct connection *pc, int tile, Terrain_type_id terrain, int size)
Definition packets_gen.c:91721
free_packet_ruleset_building
static void free_packet_ruleset_building(struct packet_ruleset_building *packet)
Definition packets_gen.c:62685
lsend_packet_ruleset_counter
void lsend_packet_ruleset_counter(struct conn_list *dest, const struct packet_ruleset_counter *packet)
Definition packets_gen.c:78279
init_packet_diplomacy_init_meeting_req
static void init_packet_diplomacy_init_meeting_req(struct packet_diplomacy_init_meeting_req *packet)
Definition packets_gen.c:39458
destroy_packet_endgame_player
#define destroy_packet_endgame_player
Definition packets_gen.c:2722
receive_packet_ruleset_summary_100
static struct packet_ruleset_summary * receive_packet_ruleset_summary_100(struct connection *pc)
Definition packets_gen.c:82295
lsend_packet_rulesets_ready
void lsend_packet_rulesets_ready(struct conn_list *dest)
Definition packets_gen.c:57992
send_packet_unknown_research_100
static int send_packet_unknown_research_100(struct connection *pc, const struct packet_unknown_research *packet)
Definition packets_gen.c:31413
send_packet_ruleset_nation_groups_100
static int send_packet_ruleset_nation_groups_100(struct connection *pc, const struct packet_ruleset_nation_groups *packet)
Definition packets_gen.c:58895
dsend_packet_edit_city_remove
int dsend_packet_edit_city_remove(struct connection *pc, int id)
Definition packets_gen.c:95261
receive_packet_ruleset_clause_100
static struct packet_ruleset_clause * receive_packet_ruleset_clause_100(struct connection *pc)
Definition packets_gen.c:79867
free_packet_ruleset_unit
static void free_packet_ruleset_unit(struct packet_ruleset_unit *packet)
Definition packets_gen.c:46986
dsend_packet_diplomacy_accept_treaty_req
int dsend_packet_diplomacy_accept_treaty_req(struct connection *pc, int counterpart)
Definition packets_gen.c:42035
dsend_packet_city_name_suggestion_req
int dsend_packet_city_name_suggestion_req(struct connection *pc, int unit_id)
Definition packets_gen.c:23680
receive_packet_web_ruleset_unit_addition_100
static struct packet_web_ruleset_unit_addition * receive_packet_web_ruleset_unit_addition_100(struct connection *pc)
Definition packets_gen.c:102583
send_packet_vote_resolve_100
static int send_packet_vote_resolve_100(struct connection *pc, const struct packet_vote_resolve *packet)
Definition packets_gen.c:90773
init_packet_edit_startpos
static void init_packet_edit_startpos(struct packet_edit_startpos *packet)
Definition packets_gen.c:92100
receive_packet_end_phase_100
static struct packet_end_phase * receive_packet_end_phase_100(struct connection *pc)
Definition packets_gen.c:44867
send_packet_processing_started_100
static int send_packet_processing_started_100(struct connection *pc)
Definition packets_gen.c:613
send_packet_rulesets_ready
int send_packet_rulesets_ready(struct connection *pc)
Definition packets_gen.c:57980
send_packet_edit_player_create_100
static int send_packet_edit_player_create_100(struct connection *pc, const struct packet_edit_player_create *packet)
Definition packets_gen.c:97523
init_packet_unit_actions
static void init_packet_unit_actions(struct packet_unit_actions *packet)
Definition packets_gen.c:38536
init_packet_vote_remove
static void init_packet_vote_remove(struct packet_vote_remove *packet)
Definition packets_gen.c:90491
lsend_packet_city_remove
void lsend_packet_city_remove(struct conn_list *dest, const struct packet_city_remove *packet)
Definition packets_gen.c:14925
send_packet_timeout_info
int send_packet_timeout_info(struct connection *pc, const struct packet_timeout_info *packet)
Definition packets_gen.c:11809
init_packet_player_tech_goal
static void init_packet_player_tech_goal(struct packet_player_tech_goal *packet)
Definition packets_gen.c:31718
destroy_packet_vote_submit
#define destroy_packet_vote_submit
Definition packets_gen.c:90895
send_packet_player_research
int send_packet_player_research(struct connection *pc, const struct packet_player_research *packet)
Definition packets_gen.c:31697
init_packet_team_name_info
static void init_packet_team_name_info(struct packet_team_name_info *packet)
Definition packets_gen.c:12506
lsend_packet_ruleset_impr_flag
void lsend_packet_ruleset_impr_flag(struct conn_list *dest, const struct packet_ruleset_impr_flag *packet)
Definition packets_gen.c:64436
free_packet_ruleset_action_auto
static void free_packet_ruleset_action_auto(struct packet_ruleset_action_auto *packet)
Definition packets_gen.c:76910
send_packet_ruleset_music
int send_packet_ruleset_music(struct connection *pc, const struct packet_ruleset_music *packet)
Definition packets_gen.c:78744
send_packet_start_phase
int send_packet_start_phase(struct connection *pc, const struct packet_start_phase *packet)
Definition packets_gen.c:45081
destroy_packet_conn_info
#define destroy_packet_conn_info
Definition packets_gen.c:43378
destroy_packet_new_year
#define destroy_packet_new_year
Definition packets_gen.c:45124
send_packet_unit_remove_100
static int send_packet_unit_remove_100(struct connection *pc, const struct packet_unit_remove *packet)
Definition packets_gen.c:32009
destroy_packet_player_place_infra
#define destroy_packet_player_place_infra
Definition packets_gen.c:29263
init_packet_processing_started
static void init_packet_processing_started(struct packet_processing_started *packet)
Definition packets_gen.c:592
receive_packet_worker_task_100
static struct packet_worker_task * receive_packet_worker_task_100(struct connection *pc)
Definition packets_gen.c:24848
init_packet_vote_new
static void init_packet_vote_new(struct packet_vote_new *packet)
Definition packets_gen.c:89713
init_packet_freeze_client
static void init_packet_freeze_client(struct packet_freeze_client *packet)
Definition packets_gen.c:45510
receive_packet_popup_image_100
static struct packet_popup_image * receive_packet_popup_image_100(struct connection *pc)
Definition packets_gen.c:100777
lsend_packet_ruleset_extra_flag
void lsend_packet_ruleset_extra_flag(struct conn_list *dest, const struct packet_ruleset_extra_flag *packet)
Definition packets_gen.c:71526
init_packet_diplomacy_cancel_pact
static void init_packet_diplomacy_cancel_pact(struct packet_diplomacy_cancel_pact *packet)
Definition packets_gen.c:42314
receive_packet_city_make_worker_100
static struct packet_city_make_worker * receive_packet_city_make_worker_100(struct connection *pc)
Definition packets_gen.c:22259
send_packet_city_worklist
int send_packet_city_worklist(struct connection *pc, const struct packet_city_worklist *packet)
Definition packets_gen.c:21977
send_packet_edit_city_create_100
static int send_packet_edit_city_create_100(struct connection *pc, const struct packet_edit_city_create *packet)
Definition packets_gen.c:94873
destroy_packet_ruleset_multiplier
static void destroy_packet_ruleset_multiplier(void *packet)
Definition packets_gen.c:78780
destroy_packet_calendar_info
#define destroy_packet_calendar_info
Definition packets_gen.c:11108
lsend_packet_diplomacy_init_meeting
void lsend_packet_diplomacy_init_meeting(struct conn_list *dest, const struct packet_diplomacy_init_meeting *packet)
Definition packets_gen.c:39888
destroy_packet_spaceship_launch
#define destroy_packet_spaceship_launch
Definition packets_gen.c:45614
lsend_packet_ruleset_road
void lsend_packet_ruleset_road(struct conn_list *dest, const struct packet_ruleset_road *packet)
Definition packets_gen.c:73253
send_packet_diplomacy_init_meeting_100
static int send_packet_diplomacy_init_meeting_100(struct connection *pc, const struct packet_diplomacy_init_meeting *packet)
Definition packets_gen.c:39759
destroy_packet_achievement_info
#define destroy_packet_achievement_info
Definition packets_gen.c:12744
destroy_packet_client_heartbeat
#define destroy_packet_client_heartbeat
Definition packets_gen.c:44526
lsend_packet_investigate_started
void lsend_packet_investigate_started(struct conn_list *dest, const struct packet_investigate_started *packet)
Definition packets_gen.c:861
receive_packet_single_want_hack_req_100
static struct packet_single_want_hack_req * receive_packet_single_want_hack_req_100(struct connection *pc)
Definition packets_gen.c:82679
receive_packet_city_name_suggestion_req_100
static struct packet_city_name_suggestion_req * receive_packet_city_name_suggestion_req_100(struct connection *pc)
Definition packets_gen.c:23509
init_packet_ruleset_action_auto
static void init_packet_ruleset_action_auto(struct packet_ruleset_action_auto *packet)
Definition packets_gen.c:76903
send_packet_city_rally_point_100
static int send_packet_city_rally_point_100(struct connection *pc, const struct packet_city_rally_point *packet, bool force_to_send)
Definition packets_gen.c:24555
send_packet_ruleset_tech_flag
int send_packet_ruleset_tech_flag(struct connection *pc, const struct packet_ruleset_tech_flag *packet)
Definition packets_gen.c:56313
free_packet_ruleset_city
static void free_packet_ruleset_city(struct packet_ruleset_city *packet)
Definition packets_gen.c:62041
lsend_packet_thaw_client
void lsend_packet_thaw_client(struct conn_list *dest)
Definition packets_gen.c:45601
send_packet_ruleset_description_part
int send_packet_ruleset_description_part(struct connection *pc, const struct packet_ruleset_description_part *packet)
Definition packets_gen.c:82646
receive_packet_ruleset_base_100
static struct packet_ruleset_base * receive_packet_ruleset_base_100(struct connection *pc)
Definition packets_gen.c:71547
send_packet_vote_submit_100
static int send_packet_vote_submit_100(struct connection *pc, const struct packet_vote_submit *packet)
Definition packets_gen.c:90933
init_packet_city_worklist
static void init_packet_city_worklist(struct packet_city_worklist *packet)
Definition packets_gen.c:21753
init_packet_conn_ping_info
static void init_packet_conn_ping_info(struct packet_conn_ping_info *packet)
Definition packets_gen.c:43926
init_packet_edit_recalculate_borders
static void init_packet_edit_recalculate_borders(struct packet_edit_recalculate_borders *packet)
Definition packets_gen.c:91157
dsend_packet_edit_player_vision
int dsend_packet_edit_player_vision(struct connection *pc, int player, int tile, bool known, int size)
Definition packets_gen.c:99696
init_packet_player_attribute_block
static void init_packet_player_attribute_block(struct packet_player_attribute_block *packet)
Definition packets_gen.c:29503
dsend_packet_edit_toggle_fogofwar
int dsend_packet_edit_toggle_fogofwar(struct connection *pc, int player)
Definition packets_gen.c:91426
send_packet_spaceship_place_100
static int send_packet_spaceship_place_100(struct connection *pc, const struct packet_spaceship_place *packet)
Definition packets_gen.c:45767
destroy_packet_edit_scenario_desc
#define destroy_packet_edit_scenario_desc
Definition packets_gen.c:100146
lsend_packet_ruleset_terrain
void lsend_packet_ruleset_terrain(struct conn_list *dest, const struct packet_ruleset_terrain *packet)
Definition packets_gen.c:67463
init_packet_report_req
static void init_packet_report_req(struct packet_report_req *packet)
Definition packets_gen.c:43168
init_packet_ruleset_disaster
static void init_packet_ruleset_disaster(struct packet_ruleset_disaster *packet)
Definition packets_gen.c:74216
free_packet_ruleset_disaster
static void free_packet_ruleset_disaster(struct packet_ruleset_disaster *packet)
Definition packets_gen.c:74223
dsend_packet_unit_sscs_set
int dsend_packet_unit_sscs_set(struct connection *pc, int unit_id, enum unit_ss_data_type type, int value)
Definition packets_gen.c:35926
init_packet_edit_check_tiles
static void init_packet_edit_check_tiles(struct packet_edit_check_tiles *packet)
Definition packets_gen.c:91199
send_packet_city_sell_100
static int send_packet_city_sell_100(struct connection *pc, const struct packet_city_sell *packet)
Definition packets_gen.c:21122
receive_packet_conn_ping_info_100
static struct packet_conn_ping_info * receive_packet_conn_ping_info_100(struct connection *pc)
Definition packets_gen.c:43940
receive_packet_city_sabotage_list_100
static struct packet_city_sabotage_list * receive_packet_city_sabotage_list_100(struct connection *pc)
Definition packets_gen.c:23966
receive_packet_city_change_100
static struct packet_city_change * receive_packet_city_change_100(struct connection *pc)
Definition packets_gen.c:21469
destroy_packet_ruleset_action_enabler
static void destroy_packet_ruleset_action_enabler(void *packet)
Definition packets_gen.c:76373
receive_packet_processing_finished_100
static struct packet_processing_finished * receive_packet_processing_finished_100(struct connection *pc)
Definition packets_gen.c:642
send_packet_begin_turn_100
static int send_packet_begin_turn_100(struct connection *pc)
Definition packets_gen.c:45433
destroy_packet_city_change_specialist
#define destroy_packet_city_change_specialist
Definition packets_gen.c:22497
init_packet_unit_combat_info
static void init_packet_unit_combat_info(struct packet_unit_combat_info *packet)
Definition packets_gen.c:35228
destroy_packet_ruleset_unit
static void destroy_packet_ruleset_unit(void *packet)
Definition packets_gen.c:46995
receive_packet_ruleset_achievement_100
static struct packet_ruleset_achievement * receive_packet_ruleset_achievement_100(struct connection *pc)
Definition packets_gen.c:74817
send_packet_ruleset_impr_flag
int send_packet_ruleset_impr_flag(struct connection *pc, const struct packet_ruleset_impr_flag *packet)
Definition packets_gen.c:64424
lsend_packet_ruleset_action_auto
void lsend_packet_ruleset_action_auto(struct conn_list *dest, const struct packet_ruleset_action_auto *packet)
Definition packets_gen.c:77580
init_packet_edit_startpos_full
static void init_packet_edit_startpos_full(struct packet_edit_startpos_full *packet)
Definition packets_gen.c:92228
init_packet_city_name_suggestion_info
static void init_packet_city_name_suggestion_info(struct packet_city_name_suggestion_info *packet)
Definition packets_gen.c:23689
receive_packet_ruleset_unit_bonus_100
static struct packet_ruleset_unit_bonus * receive_packet_ruleset_unit_bonus_100(struct connection *pc)
Definition packets_gen.c:50776
send_packet_ruleset_government_100
static int send_packet_ruleset_government_100(struct connection *pc, const struct packet_ruleset_government *packet)
Definition packets_gen.c:56754
send_packet_ruleset_specialist
int send_packet_ruleset_specialist(struct connection *pc, const struct packet_ruleset_specialist *packet)
Definition packets_gen.c:54211
dsend_packet_player_ready
int dsend_packet_player_ready(struct connection *pc, int player_no, bool is_ready)
Definition packets_gen.c:2533
init_packet_ruleset_government
static void init_packet_ruleset_government(struct packet_ruleset_government *packet)
Definition packets_gen.c:56332
receive_packet_unit_short_info_100
static struct packet_unit_short_info * receive_packet_unit_short_info_100(struct connection *pc)
Definition packets_gen.c:34407
send_packet_client_info
int send_packet_client_info(struct connection *pc, const struct packet_client_info *packet)
Definition packets_gen.c:44847
send_packet_ruleset_resource_100
static int send_packet_ruleset_resource_100(struct connection *pc, const struct packet_ruleset_resource *packet)
Definition packets_gen.c:88522
packet_handlers_fill_initial
void packet_handlers_fill_initial(struct packet_handlers *phandlers)
Definition packets_gen.c:102787
send_packet_game_load
int send_packet_game_load(struct connection *pc, const struct packet_game_load *packet)
Definition packets_gen.c:83750
dsend_packet_edit_mode
int dsend_packet_edit_mode(struct connection *pc, bool state)
Definition packets_gen.c:91148
destroy_packet_edit_unit_remove_by_id
#define destroy_packet_edit_unit_remove_by_id
Definition packets_gen.c:93633
destroy_packet_ruleset_tech_class
#define destroy_packet_ruleset_tech_class
Definition packets_gen.c:55699
init_packet_save_scenario
static void init_packet_save_scenario(struct packet_save_scenario *packet)
Definition packets_gen.c:89519
receive_packet_player_attribute_block_100
static struct packet_player_attribute_block * receive_packet_player_attribute_block_100(struct connection *pc)
Definition packets_gen.c:29511
send_packet_city_sell
int send_packet_city_sell(struct connection *pc, const struct packet_city_sell *packet)
Definition packets_gen.c:21239
receive_packet_player_rates_100
static struct packet_player_rates * receive_packet_player_rates_100(struct connection *pc)
Definition packets_gen.c:28769
send_packet_save_scenario
int send_packet_save_scenario(struct connection *pc, const struct packet_save_scenario *packet)
Definition packets_gen.c:89692
free_packet_ruleset_action_enabler
static void free_packet_ruleset_action_enabler(struct packet_ruleset_action_enabler *packet)
Definition packets_gen.c:76367
receive_packet_page_msg_part_100
static struct packet_page_msg_part * receive_packet_page_msg_part_100(struct connection *pc)
Definition packets_gen.c:42990
init_packet_ruleset_unit_class
static void init_packet_ruleset_unit_class(struct packet_ruleset_unit_class *packet)
Definition packets_gen.c:67764
init_packet_edit_scenario_desc
static void init_packet_edit_scenario_desc(struct packet_edit_scenario_desc *packet)
Definition packets_gen.c:100140
dsend_packet_city_name_suggestion_info
int dsend_packet_city_name_suggestion_info(struct connection *pc, int unit_id, const char *name)
Definition packets_gen.c:23932
send_packet_unit_combat_info
int send_packet_unit_combat_info(struct connection *pc, const struct packet_unit_combat_info *packet)
Definition packets_gen.c:35610
lsend_packet_city_rally_point
void lsend_packet_city_rally_point(struct conn_list *dest, const struct packet_city_rally_point *packet, bool force_to_send)
Definition packets_gen.c:24827
packet_type
packet_type
Definition packets_gen.h:1884
PACKET_PLAYER_MULTIPLIER
@ PACKET_PLAYER_MULTIPLIER
Definition packets_gen.h:2062
PACKET_DIPLOMACY_ACCEPT_TREATY
@ PACKET_DIPLOMACY_ACCEPT_TREATY
Definition packets_gen.h:1965
PACKET_PLAYER_CHANGE_GOVERNMENT
@ PACKET_PLAYER_CHANGE_GOVERNMENT
Definition packets_gen.h:1932
PACKET_WEB_PLAYER_INFO_ADDITION
@ PACKET_WEB_PLAYER_INFO_ADDITION
Definition packets_gen.h:2079
PACKET_SAVE_SCENARIO
@ PACKET_SAVE_SCENARIO
Definition packets_gen.h:2013
PACKET_RULESET_MULTIPLIER
@ PACKET_RULESET_MULTIPLIER
Definition packets_gen.h:2063
PACKET_THAW_CLIENT
@ PACKET_THAW_CLIENT
Definition packets_gen.h:1978
PACKET_EDIT_TOGGLE_FOGOFWAR
@ PACKET_EDIT_TOGGLE_FOGOFWAR
Definition packets_gen.h:2022
PACKET_WEB_CMA_SET
@ PACKET_WEB_CMA_SET
Definition packets_gen.h:2077
PACKET_EDIT_MODE
@ PACKET_EDIT_MODE
Definition packets_gen.h:2019
PACKET_RULESET_MUSIC
@ PACKET_RULESET_MUSIC
Definition packets_gen.h:2060
PACKET_LAST
@ PACKET_LAST
Definition packets_gen.h:2086
PACKET_RULESET_GOODS
@ PACKET_RULESET_GOODS
Definition packets_gen.h:2068
PACKET_ENDGAME_PLAYER
@ PACKET_ENDGAME_PLAYER
Definition packets_gen.h:2043
PACKET_UNIT_ACTION_ANSWER
@ PACKET_UNIT_ACTION_ANSWER
Definition packets_gen.h:1951
PACKET_EDIT_PLAYER
@ PACKET_EDIT_PLAYER
Definition packets_gen.h:2037
PACKET_DIPLOMACY_CANCEL_MEETING_REQ
@ PACKET_DIPLOMACY_CANCEL_MEETING_REQ
Definition packets_gen.h:1958
PACKET_SERVER_SETTING_ENUM
@ PACKET_SERVER_SETTING_ENUM
Definition packets_gen.h:2007
PACKET_SET_TOPOLOGY
@ PACKET_SET_TOPOLOGY
Definition packets_gen.h:2073
PACKET_WEB_CITY_INFO_ADDITION
@ PACKET_WEB_CITY_INFO_ADDITION
Definition packets_gen.h:2076
PACKET_CONN_PING
@ PACKET_CONN_PING
Definition packets_gen.h:1953
PACKET_CITY_MAKE_WORKER
@ PACKET_CITY_MAKE_WORKER
Definition packets_gen.h:1919
PACKET_CITY_OPTIONS_REQ
@ PACKET_CITY_OPTIONS_REQ
Definition packets_gen.h:1922
PACKET_RULESET_COUNTER
@ PACKET_RULESET_COUNTER
Definition packets_gen.h:2082
PACKET_VOTE_UPDATE
@ PACKET_VOTE_UPDATE
Definition packets_gen.h:2015
PACKET_CITY_NAME_SUGGESTION_INFO
@ PACKET_CITY_NAME_SUGGESTION_INFO
Definition packets_gen.h:1925
PACKET_CITY_CHANGE
@ PACKET_CITY_CHANGE
Definition packets_gen.h:1916
PACKET_UNIT_SSCS_SET
@ PACKET_UNIT_SSCS_SET
Definition packets_gen.h:1945
PACKET_PROCESSING_STARTED
@ PACKET_PROCESSING_STARTED
Definition packets_gen.h:1885
PACKET_UNIT_DO_ACTION
@ PACKET_UNIT_DO_ACTION
Definition packets_gen.h:1950
PACKET_UNIT_REMOVE
@ PACKET_UNIT_REMOVE
Definition packets_gen.h:1940
PACKET_END_PHASE
@ PACKET_END_PHASE
Definition packets_gen.h:1972
PACKET_SERVER_SETTING_INT
@ PACKET_SERVER_SETTING_INT
Definition packets_gen.h:2005
PACKET_RULESET_EXTRA
@ PACKET_RULESET_EXTRA
Definition packets_gen.h:2052
PACKET_EDIT_PLAYER_CREATE
@ PACKET_EDIT_PLAYER_CREATE
Definition packets_gen.h:2035
PACKET_EDIT_GAME
@ PACKET_EDIT_GAME
Definition packets_gen.h:2039
PACKET_CONN_PING_INFO
@ PACKET_CONN_PING_INFO
Definition packets_gen.h:1970
PACKET_END_TURN
@ PACKET_END_TURN
Definition packets_gen.h:1976
PACKET_EDIT_TILE_EXTRA
@ PACKET_EDIT_TILE_EXTRA
Definition packets_gen.h:2024
PACKET_SPACESHIP_PLACE
@ PACKET_SPACESHIP_PLACE
Definition packets_gen.h:1980
PACKET_NEW_YEAR
@ PACKET_NEW_YEAR
Definition packets_gen.h:1974
PACKET_NATION_SELECT_REQ
@ PACKET_NATION_SELECT_REQ
Definition packets_gen.h:1893
PACKET_ENDGAME_REPORT
@ PACKET_ENDGAME_REPORT
Definition packets_gen.h:1895
PACKET_RULESET_ACTION_AUTO
@ PACKET_RULESET_ACTION_AUTO
Definition packets_gen.h:2072
PACKET_UNIT_COMBAT_INFO
@ PACKET_UNIT_COMBAT_INFO
Definition packets_gen.h:1943
PACKET_RULESETS_READY
@ PACKET_RULESETS_READY
Definition packets_gen.h:2045
PACKET_UNIT_SHORT_INFO
@ PACKET_UNIT_SHORT_INFO
Definition packets_gen.h:1942
PACKET_SERVER_JOIN_REQ
@ PACKET_SERVER_JOIN_REQ
Definition packets_gen.h:1887
PACKET_REPORT_REQ
@ PACKET_REPORT_REQ
Definition packets_gen.h:1968
PACKET_RULESET_UNIT_CLASS_FLAG
@ PACKET_RULESET_UNIT_CLASS_FLAG
Definition packets_gen.h:2050
PACKET_RULESET_TECH_CLASS
@ PACKET_RULESET_TECH_CLASS
Definition packets_gen.h:1892
PACKET_EDIT_CITY_CREATE
@ PACKET_EDIT_CITY_CREATE
Definition packets_gen.h:2032
PACKET_SINGLE_WANT_HACK_REPLY
@ PACKET_SINGLE_WANT_HACK_REPLY
Definition packets_gen.h:1999
PACKET_GAME_INFO
@ PACKET_GAME_INFO
Definition packets_gen.h:1899
PACKET_DIPLOMACY_INIT_MEETING_REQ
@ PACKET_DIPLOMACY_INIT_MEETING_REQ
Definition packets_gen.h:1956
PACKET_PROCESSING_FINISHED
@ PACKET_PROCESSING_FINISHED
Definition packets_gen.h:1886
PACKET_RULESET_ACTION
@ PACKET_RULESET_ACTION
Definition packets_gen.h:2066
PACKET_PLAYER_ATTRIBUTE_BLOCK
@ PACKET_PLAYER_ATTRIBUTE_BLOCK
Definition packets_gen.h:1935
PACKET_CITY_SELL
@ PACKET_CITY_SELL
Definition packets_gen.h:1914
PACKET_CITY_NAME_SUGGESTION_REQ
@ PACKET_CITY_NAME_SUGGESTION_REQ
Definition packets_gen.h:1924
PACKET_UNKNOWN_RESEARCH
@ PACKET_UNKNOWN_RESEARCH
Definition packets_gen.h:1944
PACKET_CHAT_MSG_REQ
@ PACKET_CHAT_MSG_REQ
Definition packets_gen.h:1907
PACKET_NUKE_TILE_INFO
@ PACKET_NUKE_TILE_INFO
Definition packets_gen.h:1901
PACKET_PLAYER_DIPLSTATE
@ PACKET_PLAYER_DIPLSTATE
Definition packets_gen.h:1937
PACKET_RULESET_IMPR_FLAG
@ PACKET_RULESET_IMPR_FLAG
Definition packets_gen.h:1903
PACKET_RULESET_TECH
@ PACKET_RULESET_TECH
Definition packets_gen.h:1987
PACKET_CLIENT_HEARTBEAT
@ PACKET_CLIENT_HEARTBEAT
Definition packets_gen.h:2074
PACKET_RULESET_ROAD
@ PACKET_RULESET_ROAD
Definition packets_gen.h:2041
PACKET_RULESET_NATION_SETS
@ PACKET_RULESET_NATION_SETS
Definition packets_gen.h:2056
PACKET_CITY_SABOTAGE_LIST
@ PACKET_CITY_SABOTAGE_LIST
Definition packets_gen.h:1926
PACKET_MAP_INFO
@ PACKET_MAP_INFO
Definition packets_gen.h:1900
PACKET_RULESET_CLAUSE
@ PACKET_RULESET_CLAUSE
Definition packets_gen.h:2081
PACKET_DIPLOMACY_CREATE_CLAUSE_REQ
@ PACKET_DIPLOMACY_CREATE_CLAUSE_REQ
Definition packets_gen.h:1960
PACKET_CITY_BUY
@ PACKET_CITY_BUY
Definition packets_gen.h:1915
PACKET_CHAT_MSG
@ PACKET_CHAT_MSG
Definition packets_gen.h:1906
PACKET_EDIT_CITY_REMOVE
@ PACKET_EDIT_CITY_REMOVE
Definition packets_gen.h:2033
PACKET_EDIT_STARTPOS
@ PACKET_EDIT_STARTPOS
Definition packets_gen.h:2025
PACKET_SERVER_SETTING_CONST
@ PACKET_SERVER_SETTING_CONST
Definition packets_gen.h:2003
PACKET_PLAYER_RESEARCH
@ PACKET_PLAYER_RESEARCH
Definition packets_gen.h:1933
PACKET_BEGIN_TURN
@ PACKET_BEGIN_TURN
Definition packets_gen.h:1975
PACKET_RULESET_TERRAIN_CONTROL
@ PACKET_RULESET_TERRAIN_CONTROL
Definition packets_gen.h:1989
PACKET_PLAYER_PHASE_DONE
@ PACKET_PLAYER_PHASE_DONE
Definition packets_gen.h:1930
PACKET_RULESET_SELECT
@ PACKET_RULESET_SELECT
Definition packets_gen.h:2009
PACKET_GAME_LOAD
@ PACKET_GAME_LOAD
Definition packets_gen.h:2001
PACKET_CITY_UPDATE_COUNTERS
@ PACKET_CITY_UPDATE_COUNTERS
Definition packets_gen.h:2083
PACKET_PLAYER_REMOVE
@ PACKET_PLAYER_REMOVE
Definition packets_gen.h:1928
PACKET_CLIENT_INFO
@ PACKET_CLIENT_INFO
Definition packets_gen.h:1971
PACKET_CITY_WORKLIST
@ PACKET_CITY_WORKLIST
Definition packets_gen.h:1917
PACKET_DIPLOMACY_CANCEL_MEETING
@ PACKET_DIPLOMACY_CANCEL_MEETING
Definition packets_gen.h:1959
PACKET_UNIT_TYPE_UPGRADE
@ PACKET_UNIT_TYPE_UPGRADE
Definition packets_gen.h:1949
PACKET_START_PHASE
@ PACKET_START_PHASE
Definition packets_gen.h:1973
PACKET_AUTHENTICATION_REPLY
@ PACKET_AUTHENTICATION_REPLY
Definition packets_gen.h:1890
PACKET_SPACESHIP_INFO
@ PACKET_SPACESHIP_INFO
Definition packets_gen.h:1981
PACKET_UNIT_GET_ACTIONS
@ PACKET_UNIT_GET_ACTIONS
Definition packets_gen.h:1952
PACKET_PLAYER_ATTRIBUTE_CHUNK
@ PACKET_PLAYER_ATTRIBUTE_CHUNK
Definition packets_gen.h:1936
PACKET_RULESET_TERRAIN_FLAG
@ PACKET_RULESET_TERRAIN_FLAG
Definition packets_gen.h:2051
PACKET_CITY_MAKE_SPECIALIST
@ PACKET_CITY_MAKE_SPECIALIST
Definition packets_gen.h:1918
PACKET_RULESET_ACHIEVEMENT
@ PACKET_RULESET_ACHIEVEMENT
Definition packets_gen.h:2053
PACKET_RULESET_EFFECT
@ PACKET_RULESET_EFFECT
Definition packets_gen.h:2010
PACKET_RULESET_DISASTER
@ PACKET_RULESET_DISASTER
Definition packets_gen.h:2044
PACKET_RULESET_CONTROL
@ PACKET_RULESET_CONTROL
Definition packets_gen.h:1997
PACKET_SINGLE_WANT_HACK_REQ
@ PACKET_SINGLE_WANT_HACK_REQ
Definition packets_gen.h:1998
PACKET_PLAYER_PLACE_INFRA
@ PACKET_PLAYER_PLACE_INFRA
Definition packets_gen.h:1939
PACKET_VOTE_NEW
@ PACKET_VOTE_NEW
Definition packets_gen.h:2014
PACKET_AUTHENTICATION_REQ
@ PACKET_AUTHENTICATION_REQ
Definition packets_gen.h:1889
PACKET_RULESET_TRADE
@ PACKET_RULESET_TRADE
Definition packets_gen.h:2047
PACKET_EDIT_PLAYER_REMOVE
@ PACKET_EDIT_PLAYER_REMOVE
Definition packets_gen.h:2036
PACKET_CONN_INFO
@ PACKET_CONN_INFO
Definition packets_gen.h:1969
PACKET_SERVER_SETTING_BITWISE
@ PACKET_SERVER_SETTING_BITWISE
Definition packets_gen.h:2008
PACKET_EDIT_TILE_TERRAIN
@ PACKET_EDIT_TILE_TERRAIN
Definition packets_gen.h:2023
PACKET_DIPLOMACY_INIT_MEETING
@ PACKET_DIPLOMACY_INIT_MEETING
Definition packets_gen.h:1957
PACKET_RULESET_SUMMARY
@ PACKET_RULESET_SUMMARY
Definition packets_gen.h:2071
PACKET_UNIT_ACTION_QUERY
@ PACKET_UNIT_ACTION_QUERY
Definition packets_gen.h:1948
PACKET_PLAY_MUSIC
@ PACKET_PLAY_MUSIC
Definition packets_gen.h:2065
PACKET_TRADE_ROUTE_INFO
@ PACKET_TRADE_ROUTE_INFO
Definition packets_gen.h:2069
PACKET_RULESET_STYLE
@ PACKET_RULESET_STYLE
Definition packets_gen.h:2059
PACKET_RULESET_CITY
@ PACKET_RULESET_CITY
Definition packets_gen.h:1992
PACKET_CITY_NATIONALITIES
@ PACKET_CITY_NATIONALITIES
Definition packets_gen.h:1927
PACKET_EDIT_SCENARIO_DESC
@ PACKET_EDIT_SCENARIO_DESC
Definition packets_gen.h:1897
PACKET_FREEZE_CLIENT
@ PACKET_FREEZE_CLIENT
Definition packets_gen.h:1977
PACKET_VOTE_RESOLVE
@ PACKET_VOTE_RESOLVE
Definition packets_gen.h:2017
PACKET_EDIT_UNIT_CREATE
@ PACKET_EDIT_UNIT_CREATE
Definition packets_gen.h:2028
PACKET_POPUP_IMAGE
@ PACKET_POPUP_IMAGE
Definition packets_gen.h:2084
PACKET_TIMEOUT_INFO
@ PACKET_TIMEOUT_INFO
Definition packets_gen.h:2064
PACKET_RULESET_GAME
@ PACKET_RULESET_GAME
Definition packets_gen.h:1984
PACKET_UNIT_CHANGE_ACTIVITY
@ PACKET_UNIT_CHANGE_ACTIVITY
Definition packets_gen.h:2042
PACKET_EDIT_UNIT_REMOVE
@ PACKET_EDIT_UNIT_REMOVE
Definition packets_gen.h:2029
PACKET_RULESET_UNIT_FLAG
@ PACKET_RULESET_UNIT_FLAG
Definition packets_gen.h:2049
PACKET_DIPLOMACY_REMOVE_CLAUSE
@ PACKET_DIPLOMACY_REMOVE_CLAUSE
Definition packets_gen.h:1963
PACKET_TILE_INFO
@ PACKET_TILE_INFO
Definition packets_gen.h:1898
PACKET_EDIT_OBJECT_CREATED
@ PACKET_EDIT_OBJECT_CREATED
Definition packets_gen.h:2040
PACKET_CITY_SHORT_INFO
@ PACKET_CITY_SHORT_INFO
Definition packets_gen.h:1913
PACKET_CALENDAR_INFO
@ PACKET_CALENDAR_INFO
Definition packets_gen.h:2075
PACKET_SERVER_JOIN_REPLY
@ PACKET_SERVER_JOIN_REPLY
Definition packets_gen.h:1888
PACKET_SERVER_SETTING_STR
@ PACKET_SERVER_SETTING_STR
Definition packets_gen.h:2006
PACKET_VOTE_SUBMIT
@ PACKET_VOTE_SUBMIT
Definition packets_gen.h:2018
PACKET_WEB_CMA_CLEAR
@ PACKET_WEB_CMA_CLEAR
Definition packets_gen.h:2078
PACKET_EDIT_PLAYER_VISION
@ PACKET_EDIT_PLAYER_VISION
Definition packets_gen.h:2038
PACKET_SCENARIO_INFO
@ PACKET_SCENARIO_INFO
Definition packets_gen.h:2012
PACKET_EDIT_CHECK_TILES
@ PACKET_EDIT_CHECK_TILES
Definition packets_gen.h:2021
PACKET_RULESET_CHOICES
@ PACKET_RULESET_CHOICES
Definition packets_gen.h:2000
PACKET_CITY_CHANGE_SPECIALIST
@ PACKET_CITY_CHANGE_SPECIALIST
Definition packets_gen.h:1920
PACKET_RULESET_SPECIALIST
@ PACKET_RULESET_SPECIALIST
Definition packets_gen.h:1985
PACKET_CITY_REFRESH
@ PACKET_CITY_REFRESH
Definition packets_gen.h:1923
PACKET_CITY_REMOVE
@ PACKET_CITY_REMOVE
Definition packets_gen.h:1911
PACKET_UNIT_INFO
@ PACKET_UNIT_INFO
Definition packets_gen.h:1941
PACKET_RULESET_NATION_GROUPS
@ PACKET_RULESET_NATION_GROUPS
Definition packets_gen.h:1990
PACKET_CONNECT_MSG
@ PACKET_CONNECT_MSG
Definition packets_gen.h:1908
PACKET_EARLY_CHAT_MSG
@ PACKET_EARLY_CHAT_MSG
Definition packets_gen.h:1909
PACKET_RULESET_UNIT_CLASS
@ PACKET_RULESET_UNIT_CLASS
Definition packets_gen.h:1995
PACKET_PLAYER_INFO
@ PACKET_PLAYER_INFO
Definition packets_gen.h:1929
PACKET_EDIT_TILE
@ PACKET_EDIT_TILE
Definition packets_gen.h:2027
PACKET_PLAYER_READY
@ PACKET_PLAYER_READY
Definition packets_gen.h:1894
PACKET_WEB_RULESET_UNIT_ADDITION
@ PACKET_WEB_RULESET_UNIT_ADDITION
Definition packets_gen.h:2080
PACKET_SERVER_SHUTDOWN
@ PACKET_SERVER_SHUTDOWN
Definition packets_gen.h:1891
PACKET_RULESET_TERRAIN
@ PACKET_RULESET_TERRAIN
Definition packets_gen.h:1994
PACKET_RULESET_EXTRA_FLAG
@ PACKET_RULESET_EXTRA_FLAG
Definition packets_gen.h:2046
PACKET_RULESET_DESCRIPTION_PART
@ PACKET_RULESET_DESCRIPTION_PART
Definition packets_gen.h:2067
PACKET_EDIT_UNIT
@ PACKET_EDIT_UNIT
Definition packets_gen.h:2031
PACKET_RULESET_BASE
@ PACKET_RULESET_BASE
Definition packets_gen.h:1996
PACKET_SERVER_SETTING_BOOL
@ PACKET_SERVER_SETTING_BOOL
Definition packets_gen.h:2004
PACKET_RESEARCH_INFO
@ PACKET_RESEARCH_INFO
Definition packets_gen.h:1938
PACKET_CONN_PONG
@ PACKET_CONN_PONG
Definition packets_gen.h:1954
PACKET_EDIT_RECALCULATE_BORDERS
@ PACKET_EDIT_RECALCULATE_BORDERS
Definition packets_gen.h:2020
PACKET_PAGE_MSG_PART
@ PACKET_PAGE_MSG_PART
Definition packets_gen.h:2070
PACKET_EDIT_CITY
@ PACKET_EDIT_CITY
Definition packets_gen.h:2034
PACKET_RULESET_UNIT
@ PACKET_RULESET_UNIT
Definition packets_gen.h:1983
PACKET_PLAYER_TECH_GOAL
@ PACKET_PLAYER_TECH_GOAL
Definition packets_gen.h:1934
PACKET_UNIT_ACTIONS
@ PACKET_UNIT_ACTIONS
Definition packets_gen.h:1955
PACKET_INVESTIGATE_FINISHED
@ PACKET_INVESTIGATE_FINISHED
Definition packets_gen.h:1905
PACKET_RULESET_ACTION_ENABLER
@ PACKET_RULESET_ACTION_ENABLER
Definition packets_gen.h:2055
PACKET_INVESTIGATE_STARTED
@ PACKET_INVESTIGATE_STARTED
Definition packets_gen.h:1904
PACKET_CITY_RALLY_POINT
@ PACKET_CITY_RALLY_POINT
Definition packets_gen.h:1982
PACKET_RULESET_UNIT_BONUS
@ PACKET_RULESET_UNIT_BONUS
Definition packets_gen.h:2048
PACKET_RULESET_BUILDING
@ PACKET_RULESET_BUILDING
Definition packets_gen.h:1993
PACKET_RULESET_NATION
@ PACKET_RULESET_NATION
Definition packets_gen.h:1991
PACKET_UNIT_SERVER_SIDE_AGENT_SET
@ PACKET_UNIT_SERVER_SIDE_AGENT_SET
Definition packets_gen.h:1947
PACKET_SERVER_INFO
@ PACKET_SERVER_INFO
Definition packets_gen.h:1910
PACKET_RULESET_GOVERNMENT_RULER_TITLE
@ PACKET_RULESET_GOVERNMENT_RULER_TITLE
Definition packets_gen.h:1986
PACKET_SPACESHIP_LAUNCH
@ PACKET_SPACESHIP_LAUNCH
Definition packets_gen.h:1979
PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ
@ PACKET_DIPLOMACY_REMOVE_CLAUSE_REQ
Definition packets_gen.h:1962
PACKET_DIPLOMACY_ACCEPT_TREATY_REQ
@ PACKET_DIPLOMACY_ACCEPT_TREATY_REQ
Definition packets_gen.h:1964
PACKET_DIPLOMACY_CREATE_CLAUSE
@ PACKET_DIPLOMACY_CREATE_CLAUSE
Definition packets_gen.h:1961
PACKET_RULESET_GOVERNMENT
@ PACKET_RULESET_GOVERNMENT
Definition packets_gen.h:1988
PACKET_SCENARIO_DESCRIPTION
@ PACKET_SCENARIO_DESCRIPTION
Definition packets_gen.h:1896
PACKET_SERVER_SETTING_CONTROL
@ PACKET_SERVER_SETTING_CONTROL
Definition packets_gen.h:2002
PACKET_ACHIEVEMENT_INFO
@ PACKET_ACHIEVEMENT_INFO
Definition packets_gen.h:2058
PACKET_PAGE_MSG
@ PACKET_PAGE_MSG
Definition packets_gen.h:1967
PACKET_RULESET_TECH_FLAG
@ PACKET_RULESET_TECH_FLAG
Definition packets_gen.h:2054
PACKET_RULESET_RESOURCE
@ PACKET_RULESET_RESOURCE
Definition packets_gen.h:2011
PACKET_UNIT_ORDERS
@ PACKET_UNIT_ORDERS
Definition packets_gen.h:1946
PACKET_EDIT_UNIT_REMOVE_BY_ID
@ PACKET_EDIT_UNIT_REMOVE_BY_ID
Definition packets_gen.h:2030
PACKET_EDIT_STARTPOS_FULL
@ PACKET_EDIT_STARTPOS_FULL
Definition packets_gen.h:2026
PACKET_DIPLOMACY_CANCEL_PACT
@ PACKET_DIPLOMACY_CANCEL_PACT
Definition packets_gen.h:1966
PACKET_TEAM_NAME_INFO
@ PACKET_TEAM_NAME_INFO
Definition packets_gen.h:1902
PACKET_CITY_INFO
@ PACKET_CITY_INFO
Definition packets_gen.h:1912
PACKET_PLAYER_RATES
@ PACKET_PLAYER_RATES
Definition packets_gen.h:1931
PACKET_NATION_AVAILABILITY
@ PACKET_NATION_AVAILABILITY
Definition packets_gen.h:2057
PACKET_CITY_RENAME
@ PACKET_CITY_RENAME
Definition packets_gen.h:1921
PACKET_VOTE_REMOVE
@ PACKET_VOTE_REMOVE
Definition packets_gen.h:2016
PACKET_WORKER_TASK
@ PACKET_WORKER_TASK
Definition packets_gen.h:2061
parts
int parts
Definition packhand.c:132
lines
char * lines
Definition packhand.c:131
len
int len
Definition packhand.c:127
gives_shared_tiles
bool gives_shared_tiles(const struct player *me, const struct player *them)
Definition player.c:1497
gives_shared_vision
bool gives_shared_vision(const struct player *me, const struct player *them)
Definition player.c:1489
are_requirements_equal
bool are_requirements_equal(const struct requirement *req1, const struct requirement *req2)
Definition requirements.c:1472
compat
static struct compatibility compat[]
Definition savecompat.c:112
connections
static struct connection connections[MAX_NUM_CONNECTIONS]
Definition sernet.c:94
MAX_UINT16
#define MAX_UINT16
Definition shared.h:82
specialists
struct specialist specialists[SP_MAX]
Definition specialist.c:30
default_specialist
int default_specialist
Definition specialist.c:31
step
int step
Definition specpq.h:92
size
size_t size
Definition specvec.h:72
aifill
const char * aifill(int amount)
Definition srv_main.c:2505
strvec_destroy
void strvec_destroy(struct strvec *psv)
Definition string_vector.c:72
strvec_set
bool strvec_set(struct strvec *psv, size_t svindex, const char *string)
Definition string_vector.c:306
strvec_reserve
void strvec_reserve(struct strvec *psv, size_t reserve)
Definition string_vector.c:81
strvec_get
const char * strvec_get(const struct strvec *psv, size_t svindex)
Definition string_vector.c:389
strvec_copy
void strvec_copy(struct strvec *dest, const struct strvec *src)
Definition string_vector.c:238
strvec_new
struct strvec * strvec_new(void)
Definition string_vector.c:59
strvec_clear
void strvec_clear(struct strvec *psv)
Definition string_vector.c:160
strvec_size
size_t strvec_size(const struct strvec *psv)
Definition string_vector.c:344
are_strvecs_equal
bool are_strvecs_equal(const struct strvec *stv1, const struct strvec *stv2)
Definition string_vector.c:352
act_prob
Definition fc_types.h:1220
agent
Definition agents.h:40
city
Definition city.h:320
city::tile
struct tile * tile
Definition city.h:322
cm_parameter
Definition cm.h:40
connection
Definition connection.h:136
connection::capability
char capability[MAX_LEN_CAPSTR]
Definition connection.h:171
genhash
Definition genhash.c:83
government
Definition government.h:52
message
Definition messagewin_common.h:29
multiplier
Definition multipliers.h:31
music_style
Definition style.h:29
packet_achievement_info
Definition packets_gen.h:290
packet_authentication_reply
Definition packets_gen.h:66
packet_authentication_req
Definition packets_gen.h:61
packet_authentication_req::type
enum authentication_type type
Definition packets_gen.h:62
packet_begin_turn
Definition packets_gen.h:903
packet_calendar_info
Definition packets_gen.h:258
packet_chat_msg_req
Definition packets_gen.h:314
packet_chat_msg
Definition packets_gen.h:296
packet_city_buy
Definition packets_gen.h:431
packet_city_buy::city_id
int city_id
Definition packets_gen.h:432
packet_city_change_specialist
Definition packets_gen.h:456
packet_city_change_specialist::to
Specialist_type_id to
Definition packets_gen.h:459
packet_city_change_specialist::from
Specialist_type_id from
Definition packets_gen.h:458
packet_city_change_specialist::city_id
int city_id
Definition packets_gen.h:457
packet_city_change
Definition packets_gen.h:435
packet_city_change::city_id
int city_id
Definition packets_gen.h:436
packet_city_change::production_kind
int production_kind
Definition packets_gen.h:437
packet_city_change::production_value
int production_value
Definition packets_gen.h:438
packet_city_info
Definition packets_gen.h:334
packet_city_info::id
int id
Definition packets_gen.h:335
packet_city_make_specialist
Definition packets_gen.h:446
packet_city_make_specialist::tile_id
int tile_id
Definition packets_gen.h:448
packet_city_make_specialist::city_id
int city_id
Definition packets_gen.h:447
packet_city_make_worker
Definition packets_gen.h:451
packet_city_make_worker::city_id
int city_id
Definition packets_gen.h:452
packet_city_make_worker::tile_id
int tile_id
Definition packets_gen.h:453
packet_city_name_suggestion_info
Definition packets_gen.h:480
packet_city_name_suggestion_info::unit_id
int unit_id
Definition packets_gen.h:481
packet_city_name_suggestion_req
Definition packets_gen.h:476
packet_city_name_suggestion_req::unit_id
int unit_id
Definition packets_gen.h:477
packet_city_nationalities
Definition packets_gen.h:388
packet_city_nationalities::id
int id
Definition packets_gen.h:389
packet_city_options_req
Definition packets_gen.h:467
packet_city_options_req::city_id
int city_id
Definition packets_gen.h:468
packet_city_options_req::options
bv_city_options options
Definition packets_gen.h:469
packet_city_rally_point
Definition packets_gen.h:493
packet_city_refresh
Definition packets_gen.h:472
packet_city_refresh::city_id
int city_id
Definition packets_gen.h:473
packet_city_remove
Definition packets_gen.h:330
packet_city_remove::city_id
int city_id
Definition packets_gen.h:331
packet_city_rename
Definition packets_gen.h:462
packet_city_rename::city_id
int city_id
Definition packets_gen.h:463
packet_city_sabotage_list
Definition packets_gen.h:485
packet_city_sell
Definition packets_gen.h:426
packet_city_sell::build_id
int build_id
Definition packets_gen.h:428
packet_city_sell::city_id
int city_id
Definition packets_gen.h:427
packet_city_short_info
Definition packets_gen.h:401
packet_city_short_info::id
int id
Definition packets_gen.h:402
packet_city_update_counters
Definition packets_gen.h:395
packet_city_update_counters::city
int city
Definition packets_gen.h:396
packet_city_worklist
Definition packets_gen.h:441
packet_city_worklist::city_id
int city_id
Definition packets_gen.h:442
packet_client_heartbeat
Definition packets_gen.h:879
packet_client_info
Definition packets_gen.h:883
packet_conn_info
Definition packets_gen.h:853
packet_conn_info::id
int id
Definition packets_gen.h:854
packet_conn_ping_info
Definition packets_gen.h:865
packet_conn_ping
Definition packets_gen.h:871
packet_conn_pong
Definition packets_gen.h:875
packet_connect_msg
Definition packets_gen.h:318
packet_diplomacy_accept_treaty_req
Definition packets_gen.h:822
packet_diplomacy_accept_treaty_req::counterpart
int counterpart
Definition packets_gen.h:823
packet_diplomacy_accept_treaty
Definition packets_gen.h:826
packet_diplomacy_accept_treaty::I_accepted
bool I_accepted
Definition packets_gen.h:828
packet_diplomacy_accept_treaty::counterpart
int counterpart
Definition packets_gen.h:827
packet_diplomacy_accept_treaty::other_accepted
bool other_accepted
Definition packets_gen.h:829
packet_diplomacy_cancel_meeting_req
Definition packets_gen.h:785
packet_diplomacy_cancel_meeting_req::counterpart
int counterpart
Definition packets_gen.h:786
packet_diplomacy_cancel_meeting
Definition packets_gen.h:789
packet_diplomacy_cancel_meeting::counterpart
int counterpart
Definition packets_gen.h:790
packet_diplomacy_cancel_meeting::initiated_from
int initiated_from
Definition packets_gen.h:791
packet_diplomacy_cancel_pact
Definition packets_gen.h:832
packet_diplomacy_cancel_pact::other_player_id
int other_player_id
Definition packets_gen.h:833
packet_diplomacy_cancel_pact::clause
enum clause_type clause
Definition packets_gen.h:834
packet_diplomacy_create_clause_req
Definition packets_gen.h:794
packet_diplomacy_create_clause_req::value
int value
Definition packets_gen.h:798
packet_diplomacy_create_clause_req::giver
int giver
Definition packets_gen.h:796
packet_diplomacy_create_clause_req::counterpart
int counterpart
Definition packets_gen.h:795
packet_diplomacy_create_clause
Definition packets_gen.h:801
packet_diplomacy_create_clause::giver
int giver
Definition packets_gen.h:803
packet_diplomacy_create_clause::counterpart
int counterpart
Definition packets_gen.h:802
packet_diplomacy_create_clause::value
int value
Definition packets_gen.h:805
packet_diplomacy_init_meeting_req
Definition packets_gen.h:776
packet_diplomacy_init_meeting_req::counterpart
int counterpart
Definition packets_gen.h:777
packet_diplomacy_init_meeting
Definition packets_gen.h:780
packet_diplomacy_init_meeting::initiated_from
int initiated_from
Definition packets_gen.h:782
packet_diplomacy_init_meeting::counterpart
int counterpart
Definition packets_gen.h:781
packet_diplomacy_remove_clause_req
Definition packets_gen.h:808
packet_diplomacy_remove_clause_req::giver
int giver
Definition packets_gen.h:810
packet_diplomacy_remove_clause_req::counterpart
int counterpart
Definition packets_gen.h:809
packet_diplomacy_remove_clause_req::value
int value
Definition packets_gen.h:812
packet_diplomacy_remove_clause
Definition packets_gen.h:815
packet_diplomacy_remove_clause::counterpart
int counterpart
Definition packets_gen.h:816
packet_diplomacy_remove_clause::value
int value
Definition packets_gen.h:819
packet_diplomacy_remove_clause::giver
int giver
Definition packets_gen.h:817
packet_early_chat_msg
Definition packets_gen.h:305
packet_edit_check_tiles
Definition packets_gen.h:1653
packet_edit_city_create
Definition packets_gen.h:1736
packet_edit_city_create::tag
int tag
Definition packets_gen.h:1740
packet_edit_city_create::owner
int owner
Definition packets_gen.h:1737
packet_edit_city_create::tile
int tile
Definition packets_gen.h:1738
packet_edit_city_remove
Definition packets_gen.h:1743
packet_edit_city_remove::id
int id
Definition packets_gen.h:1744
packet_edit_city
Definition packets_gen.h:1747
packet_edit_city::id
int id
Definition packets_gen.h:1748
packet_edit_game
Definition packets_gen.h:1823
packet_edit_mode
Definition packets_gen.h:1645
packet_edit_mode::state
bool state
Definition packets_gen.h:1646
packet_edit_object_created
Definition packets_gen.h:1839
packet_edit_object_created::tag
int tag
Definition packets_gen.h:1840
packet_edit_player_create
Definition packets_gen.h:1779
packet_edit_player_create::tag
int tag
Definition packets_gen.h:1780
packet_edit_player_remove
Definition packets_gen.h:1783
packet_edit_player_remove::id
int id
Definition packets_gen.h:1784
packet_edit_player_vision
Definition packets_gen.h:1816
packet_edit_player_vision::tile
int tile
Definition packets_gen.h:1818
packet_edit_player_vision::known
bool known
Definition packets_gen.h:1819
packet_edit_player_vision::player
int player
Definition packets_gen.h:1817
packet_edit_player
Definition packets_gen.h:1787
packet_edit_player::id
int id
Definition packets_gen.h:1788
packet_edit_recalculate_borders
Definition packets_gen.h:1649
packet_edit_scenario_desc
Definition packets_gen.h:1835
packet_edit_startpos_full
Definition packets_gen.h:1681
packet_edit_startpos
Definition packets_gen.h:1675
packet_edit_startpos::removal
bool removal
Definition packets_gen.h:1677
packet_edit_startpos::tag
int tag
Definition packets_gen.h:1678
packet_edit_startpos::id
int id
Definition packets_gen.h:1676
packet_edit_tile_extra
Definition packets_gen.h:1667
packet_edit_tile_extra::tile
int tile
Definition packets_gen.h:1668
packet_edit_tile_extra::extra_type_id
int extra_type_id
Definition packets_gen.h:1669
packet_edit_tile_extra::removal
bool removal
Definition packets_gen.h:1670
packet_edit_tile_extra::eowner
int eowner
Definition packets_gen.h:1671
packet_edit_tile_terrain
Definition packets_gen.h:1661
packet_edit_tile_terrain::tile
int tile
Definition packets_gen.h:1662
packet_edit_tile_terrain::terrain
Terrain_type_id terrain
Definition packets_gen.h:1663
packet_edit_tile
Definition packets_gen.h:1687
packet_edit_tile::tile
int tile
Definition packets_gen.h:1688
packet_edit_toggle_fogofwar
Definition packets_gen.h:1657
packet_edit_toggle_fogofwar::player
int player
Definition packets_gen.h:1658
packet_edit_unit_create
Definition packets_gen.h:1697
packet_edit_unit_create::tag
int tag
Definition packets_gen.h:1702
packet_edit_unit_create::count
int count
Definition packets_gen.h:1701
packet_edit_unit_create::tile
int tile
Definition packets_gen.h:1699
packet_edit_unit_create::owner
int owner
Definition packets_gen.h:1698
packet_edit_unit_remove_by_id
Definition packets_gen.h:1712
packet_edit_unit_remove_by_id::id
int id
Definition packets_gen.h:1713
packet_edit_unit_remove
Definition packets_gen.h:1705
packet_edit_unit_remove::count
int count
Definition packets_gen.h:1709
packet_edit_unit_remove::tile
int tile
Definition packets_gen.h:1707
packet_edit_unit_remove::owner
int owner
Definition packets_gen.h:1706
packet_edit_unit
Definition packets_gen.h:1716
packet_edit_unit::id
int id
Definition packets_gen.h:1717
packet_end_phase
Definition packets_gen.h:889
packet_end_turn
Definition packets_gen.h:907
packet_endgame_player
Definition packets_gen.h:93
packet_endgame_report
Definition packets_gen.h:87
packet_freeze_client
Definition packets_gen.h:911
packet_game_info
Definition packets_gen.h:118
packet_game_load
Definition packets_gen.h:1495
packet_game_load::load_successful
bool load_successful
Definition packets_gen.h:1496
packet_handlers
Definition packets.h:74
packet_investigate_finished
Definition packets_gen.h:40
packet_investigate_finished::city_id
int city_id
Definition packets_gen.h:41
packet_investigate_started
Definition packets_gen.h:36
packet_investigate_started::city_id
int city_id
Definition packets_gen.h:37
packet_map_info
Definition packets_gen.h:271
packet_nation_availability
Definition packets_gen.h:1155
packet_nation_select_req
Definition packets_gen.h:74
packet_nation_select_req::nation_no
Nation_type_id nation_no
Definition packets_gen.h:76
packet_nation_select_req::player_no
int player_no
Definition packets_gen.h:75
packet_nation_select_req::is_male
bool is_male
Definition packets_gen.h:77
packet_nation_select_req::style
int style
Definition packets_gen.h:79
packet_new_year
Definition packets_gen.h:897
packet_nuke_tile_info
Definition packets_gen.h:281
packet_nuke_tile_info::tile
int tile
Definition packets_gen.h:282
packet_page_msg_part
Definition packets_gen.h:845
packet_page_msg
Definition packets_gen.h:837
packet_play_music
Definition packets_gen.h:1844
packet_player_attribute_block
Definition packets_gen.h:583
packet_player_attribute_chunk
Definition packets_gen.h:587
packet_player_attribute_chunk::offset
int offset
Definition packets_gen.h:588
packet_player_change_government
Definition packets_gen.h:574
packet_player_change_government::government
Government_type_id government
Definition packets_gen.h:575
packet_player_diplstate
Definition packets_gen.h:594
packet_player_diplstate::diplstate_id
int diplstate_id
Definition packets_gen.h:595
packet_player_info
Definition packets_gen.h:513
packet_player_info::playerno
int playerno
Definition packets_gen.h:514
packet_player_multiplier
Definition packets_gen.h:604
packet_player_phase_done
Definition packets_gen.h:564
packet_player_phase_done::turn
int turn
Definition packets_gen.h:565
packet_player_place_infra
Definition packets_gen.h:578
packet_player_place_infra::tile
int tile
Definition packets_gen.h:579
packet_player_place_infra::extra
int extra
Definition packets_gen.h:580
packet_player_rates
Definition packets_gen.h:568
packet_player_rates::science
int science
Definition packets_gen.h:571
packet_player_rates::luxury
int luxury
Definition packets_gen.h:570
packet_player_rates::tax
int tax
Definition packets_gen.h:569
packet_player_ready
Definition packets_gen.h:82
packet_player_ready::player_no
int player_no
Definition packets_gen.h:83
packet_player_ready::is_ready
bool is_ready
Definition packets_gen.h:84
packet_player_remove
Definition packets_gen.h:509
packet_player_remove::playerno
int playerno
Definition packets_gen.h:510
packet_player_research
Definition packets_gen.h:625
packet_player_research::tech
int tech
Definition packets_gen.h:626
packet_player_tech_goal
Definition packets_gen.h:629
packet_player_tech_goal::tech
int tech
Definition packets_gen.h:630
packet_popup_image
Definition packets_gen.h:1848
packet_processing_finished
Definition packets_gen.h:32
packet_processing_started
Definition packets_gen.h:28
packet_report_req
Definition packets_gen.h:849
packet_report_req::type
enum report_type type
Definition packets_gen.h:850
packet_research_info
Definition packets_gen.h:609
packet_research_info::id
int id
Definition packets_gen.h:610
packet_ruleset_achievement
Definition packets_gen.h:1351
packet_ruleset_action_auto
Definition packets_gen.h:1388
packet_ruleset_action_auto::reqs
struct requirement_vector reqs
Definition packets_gen.h:1391
packet_ruleset_action_enabler
Definition packets_gen.h:1382
packet_ruleset_action_enabler::actor_reqs
struct requirement_vector actor_reqs
Definition packets_gen.h:1384
packet_ruleset_action_enabler::target_reqs
struct requirement_vector target_reqs
Definition packets_gen.h:1385
packet_ruleset_action
Definition packets_gen.h:1367
packet_ruleset_base
Definition packets_gen.h:1306
packet_ruleset_building
Definition packets_gen.h:1177
packet_ruleset_building::helptext
struct strvec * helptext
Definition packets_gen.h:1194
packet_ruleset_building::reqs
struct requirement_vector reqs
Definition packets_gen.h:1185
packet_ruleset_building::obs_reqs
struct requirement_vector obs_reqs
Definition packets_gen.h:1186
packet_ruleset_choices
Definition packets_gen.h:1486
packet_ruleset_city
Definition packets_gen.h:1167
packet_ruleset_city::reqs
struct requirement_vector reqs
Definition packets_gen.h:1172
packet_ruleset_clause
Definition packets_gen.h:1428
packet_ruleset_clause::giver_reqs
struct requirement_vector giver_reqs
Definition packets_gen.h:1431
packet_ruleset_clause::receiver_reqs
struct requirement_vector receiver_reqs
Definition packets_gen.h:1432
packet_ruleset_clause::either_reqs
struct requirement_vector either_reqs
Definition packets_gen.h:1433
packet_ruleset_control
Definition packets_gen.h:1436
packet_ruleset_counter
Definition packets_gen.h:1396
packet_ruleset_counter::helptext
struct strvec * helptext
Definition packets_gen.h:1399
packet_ruleset_description_part
Definition packets_gen.h:1474
packet_ruleset_disaster
Definition packets_gen.h:1342
packet_ruleset_disaster::reqs
struct requirement_vector reqs
Definition packets_gen.h:1346
packet_ruleset_effect
Definition packets_gen.h:1577
packet_ruleset_effect::reqs
struct requirement_vector reqs
Definition packets_gen.h:1582
packet_ruleset_extra_flag
Definition packets_gen.h:1300
packet_ruleset_extra
Definition packets_gen.h:1260
packet_ruleset_extra::appearance_reqs
struct requirement_vector appearance_reqs
Definition packets_gen.h:1278
packet_ruleset_extra::disappearance_reqs
struct requirement_vector disappearance_reqs
Definition packets_gen.h:1280
packet_ruleset_extra::rmreqs
struct requirement_vector rmreqs
Definition packets_gen.h:1276
packet_ruleset_extra::helptext
struct strvec * helptext
Definition packets_gen.h:1297
packet_ruleset_extra::reqs
struct requirement_vector reqs
Definition packets_gen.h:1275
packet_ruleset_game
Definition packets_gen.h:1019
packet_ruleset_goods
Definition packets_gen.h:1329
packet_ruleset_goods::helptext
struct strvec * helptext
Definition packets_gen.h:1339
packet_ruleset_goods::reqs
struct requirement_vector reqs
Definition packets_gen.h:1333
packet_ruleset_government_ruler_title
Definition packets_gen.h:1047
packet_ruleset_government
Definition packets_gen.h:1083
packet_ruleset_government::reqs
struct requirement_vector reqs
Definition packets_gen.h:1085
packet_ruleset_government::helptext
struct strvec * helptext
Definition packets_gen.h:1092
packet_ruleset_impr_flag
Definition packets_gen.h:1197
packet_ruleset_multiplier
Definition packets_gen.h:1413
packet_ruleset_multiplier::reqs
struct requirement_vector reqs
Definition packets_gen.h:1424
packet_ruleset_multiplier::helptext
struct strvec * helptext
Definition packets_gen.h:1425
packet_ruleset_music
Definition packets_gen.h:1406
packet_ruleset_music::reqs
struct requirement_vector reqs
Definition packets_gen.h:1410
packet_ruleset_nation_groups
Definition packets_gen.h:1121
packet_ruleset_nation_sets
Definition packets_gen.h:1114
packet_ruleset_nation
Definition packets_gen.h:1127
packet_ruleset_nation::id
Nation_type_id id
Definition packets_gen.h:1128
packet_ruleset_resource
Definition packets_gen.h:1585
packet_ruleset_road
Definition packets_gen.h:1315
packet_ruleset_road::first_reqs
struct requirement_vector first_reqs
Definition packets_gen.h:1318
packet_ruleset_select
Definition packets_gen.h:1491
packet_ruleset_specialist
Definition packets_gen.h:1036
packet_ruleset_specialist::reqs
struct requirement_vector reqs
Definition packets_gen.h:1043
packet_ruleset_specialist::helptext
struct strvec * helptext
Definition packets_gen.h:1044
packet_ruleset_style
Definition packets_gen.h:1161
packet_ruleset_summary
Definition packets_gen.h:1470
packet_ruleset_tech_class
Definition packets_gen.h:1070
packet_ruleset_tech_flag
Definition packets_gen.h:1077
packet_ruleset_tech
Definition packets_gen.h:1054
packet_ruleset_tech::helptext
struct strvec * helptext
Definition packets_gen.h:1065
packet_ruleset_tech::research_reqs
struct requirement_vector research_reqs
Definition packets_gen.h:1057
packet_ruleset_terrain_control
Definition packets_gen.h:1095
packet_ruleset_terrain_flag
Definition packets_gen.h:1243
packet_ruleset_terrain
Definition packets_gen.h:1203
packet_ruleset_terrain::helptext
struct strvec * helptext
Definition packets_gen.h:1240
packet_ruleset_trade
Definition packets_gen.h:1360
packet_ruleset_unit_bonus
Definition packets_gen.h:999
packet_ruleset_unit_class_flag
Definition packets_gen.h:1013
packet_ruleset_unit_class
Definition packets_gen.h:1249
packet_ruleset_unit_class::helptext
struct strvec * helptext
Definition packets_gen.h:1257
packet_ruleset_unit_flag
Definition packets_gen.h:1007
packet_ruleset_unit
Definition packets_gen.h:949
packet_ruleset_unit::helptext
struct strvec * helptext
Definition packets_gen.h:993
packet_ruleset_unit::build_reqs
struct requirement_vector build_reqs
Definition packets_gen.h:966
packet_rulesets_ready
Definition packets_gen.h:1110
packet_save_scenario
Definition packets_gen.h:1611
packet_scenario_description
Definition packets_gen.h:1607
packet_scenario_info
Definition packets_gen.h:1590
packet_server_info
Definition packets_gen.h:322
packet_server_info::major_version
int major_version
Definition packets_gen.h:324
packet_server_info::version_label
char version_label[48]
Definition packets_gen.h:323
packet_server_info::patch_version
int patch_version
Definition packets_gen.h:326
packet_server_info::minor_version
int minor_version
Definition packets_gen.h:325
packet_server_info::emerg_version
int emerg_version
Definition packets_gen.h:327
packet_server_join_reply
Definition packets_gen.h:53
packet_server_join_req
Definition packets_gen.h:44
packet_server_join_req::version_label
char version_label[48]
Definition packets_gen.h:47
packet_server_join_req::capability
char capability[512]
Definition packets_gen.h:46
packet_server_join_req::minor_version
int minor_version
Definition packets_gen.h:49
packet_server_join_req::patch_version
int patch_version
Definition packets_gen.h:50
packet_server_join_req::major_version
int major_version
Definition packets_gen.h:48
packet_server_join_req::username
char username[48]
Definition packets_gen.h:45
packet_server_setting_bitwise
Definition packets_gen.h:1559
packet_server_setting_bitwise::id
int id
Definition packets_gen.h:1560
packet_server_setting_bool
Definition packets_gen.h:1514
packet_server_setting_bool::id
int id
Definition packets_gen.h:1515
packet_server_setting_const
Definition packets_gen.h:1506
packet_server_setting_const::id
int id
Definition packets_gen.h:1507
packet_server_setting_control
Definition packets_gen.h:1500
packet_server_setting_enum
Definition packets_gen.h:1546
packet_server_setting_enum::id
int id
Definition packets_gen.h:1547
packet_server_setting_int
Definition packets_gen.h:1524
packet_server_setting_int::id
int id
Definition packets_gen.h:1525
packet_server_setting_str
Definition packets_gen.h:1536
packet_server_setting_str::id
int id
Definition packets_gen.h:1537
packet_server_shutdown
Definition packets_gen.h:70
packet_set_topology
Definition packets_gen.h:1572
packet_single_want_hack_reply
Definition packets_gen.h:1482
packet_single_want_hack_reply::you_have_hack
bool you_have_hack
Definition packets_gen.h:1483
packet_single_want_hack_req
Definition packets_gen.h:1478
packet_spaceship_info
Definition packets_gen.h:928
packet_spaceship_info::player_num
int player_num
Definition packets_gen.h:929
packet_spaceship_launch
Definition packets_gen.h:919
packet_spaceship_place
Definition packets_gen.h:923
packet_spaceship_place::num
int num
Definition packets_gen.h:925
packet_spaceship_place::type
enum spaceship_place_type type
Definition packets_gen.h:924
packet_start_phase
Definition packets_gen.h:893
packet_start_phase::phase
int phase
Definition packets_gen.h:894
packet_team_name_info
Definition packets_gen.h:285
packet_team_name_info::team_id
int team_id
Definition packets_gen.h:286
packet_thaw_client
Definition packets_gen.h:915
packet_tile_info
Definition packets_gen.h:101
packet_tile_info::tile
int tile
Definition packets_gen.h:102
packet_timeout_info
Definition packets_gen.h:266
packet_trade_route_info
Definition packets_gen.h:417
packet_unit_action_answer
Definition packets_gen.h:744
packet_unit_action_answer::request_kind
int request_kind
Definition packets_gen.h:749
packet_unit_action_answer::action_type
action_id action_type
Definition packets_gen.h:748
packet_unit_action_answer::actor_id
int actor_id
Definition packets_gen.h:745
packet_unit_action_answer::target_id
int target_id
Definition packets_gen.h:746
packet_unit_action_query
Definition packets_gen.h:725
packet_unit_action_query::target_id
int target_id
Definition packets_gen.h:727
packet_unit_action_query::request_kind
int request_kind
Definition packets_gen.h:729
packet_unit_action_query::actor_id
int actor_id
Definition packets_gen.h:726
packet_unit_action_query::action_type
action_id action_type
Definition packets_gen.h:728
packet_unit_actions
Definition packets_gen.h:760
packet_unit_actions::target_unit_id
int target_unit_id
Definition packets_gen.h:762
packet_unit_actions::target_city_id
int target_city_id
Definition packets_gen.h:763
packet_unit_actions::action_probabilities
struct act_prob action_probabilities[MAX_NUM_ACTIONS]
Definition packets_gen.h:767
packet_unit_actions::request_kind
int request_kind
Definition packets_gen.h:766
packet_unit_actions::actor_unit_id
int actor_unit_id
Definition packets_gen.h:761
packet_unit_actions::target_tile_id
int target_tile_id
Definition packets_gen.h:764
packet_unit_change_activity
Definition packets_gen.h:770
packet_unit_change_activity::activity
enum unit_activity activity
Definition packets_gen.h:772
packet_unit_change_activity::unit_id
int unit_id
Definition packets_gen.h:771
packet_unit_change_activity::target
int target
Definition packets_gen.h:773
packet_unit_combat_info
Definition packets_gen.h:695
packet_unit_do_action
Definition packets_gen.h:736
packet_unit_do_action::action_type
action_id action_type
Definition packets_gen.h:741
packet_unit_do_action::sub_tgt_id
int sub_tgt_id
Definition packets_gen.h:739
packet_unit_do_action::actor_id
int actor_id
Definition packets_gen.h:737
packet_unit_do_action::target_id
int target_id
Definition packets_gen.h:738
packet_unit_get_actions
Definition packets_gen.h:752
packet_unit_get_actions::target_tile_id
int target_tile_id
Definition packets_gen.h:755
packet_unit_get_actions::actor_unit_id
int actor_unit_id
Definition packets_gen.h:753
packet_unit_get_actions::target_unit_id
int target_unit_id
Definition packets_gen.h:754
packet_unit_get_actions::request_kind
int request_kind
Definition packets_gen.h:757
packet_unit_info
Definition packets_gen.h:637
packet_unit_info::id
int id
Definition packets_gen.h:638
packet_unit_orders
Definition packets_gen.h:710
packet_unit_remove
Definition packets_gen.h:633
packet_unit_remove::unit_id
int unit_id
Definition packets_gen.h:634
packet_unit_server_side_agent_set
Definition packets_gen.h:720
packet_unit_server_side_agent_set::unit_id
int unit_id
Definition packets_gen.h:721
packet_unit_server_side_agent_set::agent
enum server_side_agent agent
Definition packets_gen.h:722
packet_unit_short_info
Definition packets_gen.h:678
packet_unit_short_info::id
int id
Definition packets_gen.h:679
packet_unit_sscs_set
Definition packets_gen.h:704
packet_unit_sscs_set::unit_id
int unit_id
Definition packets_gen.h:705
packet_unit_sscs_set::value
int value
Definition packets_gen.h:707
packet_unit_type_upgrade
Definition packets_gen.h:732
packet_unit_type_upgrade::type
Unit_type_id type
Definition packets_gen.h:733
packet_unknown_research
Definition packets_gen.h:621
packet_vote_new
Definition packets_gen.h:1615
packet_vote_remove
Definition packets_gen.h:1631
packet_vote_resolve
Definition packets_gen.h:1635
packet_vote_submit
Definition packets_gen.h:1640
packet_vote_update
Definition packets_gen.h:1623
packet_vote_update::vote_no
int vote_no
Definition packets_gen.h:1624
packet_web_city_info_addition
Definition packets_gen.h:1852
packet_web_city_info_addition::id
int id
Definition packets_gen.h:1853
packet_web_cma_clear
Definition packets_gen.h:1870
packet_web_cma_set
Definition packets_gen.h:1865
packet_web_cma_set::id
int id
Definition packets_gen.h:1866
packet_web_player_info_addition
Definition packets_gen.h:1874
packet_web_player_info_addition::playerno
int playerno
Definition packets_gen.h:1875
packet_web_ruleset_unit_addition
Definition packets_gen.h:1879
packet_web_ruleset_unit_addition::id
Unit_type_id id
Definition packets_gen.h:1880
packet_worker_task
Definition packets_gen.h:501
player
Definition player.h:249
plocation
Definition dataio_raw.h:63
requirement
Definition requirements.h:81
team
Definition team.c:40
terrain
Definition terrain.h:75
tile
Definition tile.h:50
unit_order
Definition unit.h:93
unit
Definition unit.h:140
worklist
Definition worklist.h:28
support.h
sz_strlcpy
#define sz_strlcpy(dest, src)
Definition support.h:189
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
bool
#define bool
Definition support.h:71
A_LAST
#define A_LAST
Definition tech.h:45
terrain_count
Terrain_type_id terrain_count(void)
Definition terrain.c:118
goods
static struct goods_type goods[MAX_GOODS_TYPES]
Definition traderoutes.c:43
are_unit_orders_equal
bool are_unit_orders_equal(const struct unit_order *order1, const struct unit_order *order2)
Definition unit.c:59
worklist_copy
void worklist_copy(struct worklist *dst, const struct worklist *src)
Definition worklist.c:112
are_worklists_equal
bool are_worklists_equal(const struct worklist *wlist1, const struct worklist *wlist2)
Definition worklist.c:192