summaryrefslogtreecommitdiff
path: root/src/proto2/types.hpp
blob: 516889a0719ac8c3c43838e2372192a1796f093a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
#pragma once
//    proto2/types.hpp - Forward declarations of packet component types
//
//    Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com>
//
//    This file is part of The Mana World (Athena server)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Affero General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU Affero General Public License for more details.
//
//    You should have received a copy of the GNU Affero General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include "fwd.hpp"

#include "../generic/array.hpp"
#include "../mmo/consts.hpp"

//TODO split the includes
#include <cstdint>
#include "../ints/little.hpp"
#include "../strings/vstring.hpp"
#include "../net/ip.hpp"
#include "../net/timer.t.hpp"
#include "../mmo/consts.hpp"
#include "../mmo/enums.hpp"
#include "../mmo/human_time_diff.hpp"
#include "../mmo/ids.hpp"
#include "../mmo/strs.hpp"
#include "../mmo/utils.hpp"
#include "../mmo/version.hpp"
#include "../login/login.t.hpp"
#include "../map/clif.t.hpp"
#include "../map/skill.t.hpp"

namespace tmwa
{
template<class T>
bool native_to_network(T *network, T native)
{
    *network = native;
    return true;
}
template<class T>
bool network_to_native(T *native, T network)
{
    *native = network;
    return true;
}
template<class T, size_t N>
struct NetArray
{
    T data[N];
};
template<class T, class U, class I>
bool native_to_network(NetArray<T, I::alloc_size> *network, GenericArray<U, I> native)
{
    for (size_t i = 0; i < I::alloc_size; ++i)
    {
        if (!native_to_network(&(*network).data[i], native[I::offset_to_index(i)]))
            return false;
    }
    return true;
}
template<class T, class U, class I>
bool network_to_native(GenericArray<U, I> *native, NetArray<T, I::alloc_size> network)
{
    for (size_t i = 0; i < I::alloc_size; ++i)
    {
        if (!network_to_native(&(*native)[I::offset_to_index(i)], network.data[i]))
            return false;
    }
    return true;
}

template<size_t N>
struct NetString
{
    char data[N];
};
template<size_t N>
bool native_to_network(NetString<N> *network, VString<N-1> native)
{
    // basically WBUF_STRING
    char *const begin = network->data;
    char *const end = begin + N;
    char *const mid = std::copy(native.begin(), native.end(), begin);
    std::fill(mid, end, '\0');
    return true;
}
template<size_t N>
bool network_to_native(VString<N-1> *native, NetString<N> network)
{
    // basically RBUF_STRING
    const char *const begin = network.data;
    const char *const end = begin + N;
    const char *const mid = std::find(begin, end, '\0');
    *native = XString(begin, mid, nullptr);
    return true;
}

inline
bool native_to_network(NetString<24> *network, CharName native)
{
    VString<23> tmp = native.to__actual();
    bool rv = native_to_network(network, tmp);
    return rv;
}
inline
bool network_to_native(CharName *native, NetString<24> network)
{
    VString<23> tmp;
    bool rv = network_to_native(&tmp, network);
    *native = stringish<CharName>(tmp);
    return rv;
}

inline
bool native_to_network(NetString<16> *network, MapName native)
{
    XString tmp = native;
    bool rv = native_to_network(network, VString<15>(tmp));
    return rv;
}
inline
bool network_to_native(MapName *native, NetString<16> network)
{
    VString<15> tmp;
    bool rv = network_to_native(&tmp, network);
    *native = stringish<MapName>(tmp);
    return rv;
}

template<class T, size_t N>
struct SkewedLength
{
    T data;
};
template<class T, size_t N, class U>
bool native_to_network(SkewedLength<T, N> *network, U native)
{
    native -= N;
    return native_to_network(&network->data, native);
}
template<class T, size_t N, class U>
bool network_to_native(U *native, SkewedLength<T, N> network)
{
    bool rv = network_to_native(native, network.data);
    *native += N;
    return rv;
}

inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, DIR native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(DIR *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<DIR>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, BeingRemoveWhy native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(BeingRemoveWhy *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<BeingRemoveWhy>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, Opt1 native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Opt1 *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<Opt1>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, Opt2 native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Opt2 *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<Opt2>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, Opt3 native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Opt3 *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<Opt3>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, ItemType native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(ItemType *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<ItemType>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, PickupFail native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(PickupFail *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<PickupFail>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, DamageType native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(DamageType *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<DamageType>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, SP native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(SP *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<SP>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, LOOK native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(LOOK *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<LOOK>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, SkillID native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(SkillID *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<SkillID>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, StatusChange native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(StatusChange *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<StatusChange>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, SkillFlags native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(SkillFlags *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<SkillFlags>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, SEX native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(SEX *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<SEX>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, Option native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Option *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<Option>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, EPOS native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(EPOS *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<EPOS>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, ItemLook native)
{
    bool rv = true;
    uint16_t tmp = static_cast<uint16_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(ItemLook *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<ItemLook>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, Species native)
{
    bool rv = true;
    uint16_t tmp = unwrap<Species>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Species *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<Species>(tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little32 *network, AccountId native)
{
    bool rv = true;
    uint32_t tmp = unwrap<AccountId>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(AccountId *native, Little32 network)
{
    bool rv = true;
    uint32_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<AccountId>(tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little32 *network, CharId native)
{
    bool rv = true;
    uint32_t tmp = unwrap<CharId>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(CharId *native, Little32 network)
{
    bool rv = true;
    uint32_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<CharId>(tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little32 *network, PartyId native)
{
    bool rv = true;
    uint32_t tmp = unwrap<PartyId>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(PartyId *native, Little32 network)
{
    bool rv = true;
    uint32_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<PartyId>(tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little16 *network, ItemNameId native)
{
    bool rv = true;
    uint16_t tmp = unwrap<ItemNameId>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(ItemNameId *native, Little16 network)
{
    bool rv = true;
    uint16_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<ItemNameId>(tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little32 *network, ItemNameId native)
{
    bool rv = true;
    uint32_t tmp = unwrap<ItemNameId>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(ItemNameId *native, Little32 network)
{
    bool rv = true;
    uint32_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<ItemNameId>(tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool native_to_network(Little32 *network, BlockId native)
{
    bool rv = true;
    uint32_t tmp = unwrap<BlockId>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(BlockId *native, Little32 network)
{
    bool rv = true;
    uint32_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = wrap<BlockId>(tmp);
    return rv;
}
struct NetHumanTimeDiff
{
    Little16 year;
    Little16 month;
    Little16 day;
    Little16 hour;
    Little16 minute;
    Little16 second;
};
inline __attribute__((warn_unused_result))
bool native_to_network(NetHumanTimeDiff *network, HumanTimeDiff native)
{
    bool rv = true;
    int16_t year = native.year; rv &= native_to_network(&network->year, year);
    int16_t month = native.month; rv &= native_to_network(&network->month, month);
    int16_t day = native.day; rv &= native_to_network(&network->day, day);
    int16_t hour = native.hour; rv &= native_to_network(&network->hour, hour);
    int16_t minute = native.minute; rv &= native_to_network(&network->minute, minute);
    int16_t second = native.second; rv &= native_to_network(&network->second, second);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(HumanTimeDiff *native, NetHumanTimeDiff network)
{
    bool rv = true;
    int16_t year; rv &= network_to_native(&year, network.year); native->year = year;
    int16_t month; rv &= network_to_native(&month, network.month); native->month = month;
    int16_t day; rv &= network_to_native(&day, network.day); native->day = day;
    int16_t hour; rv &= network_to_native(&hour, network.hour); native->hour = hour;
    int16_t minute; rv &= network_to_native(&minute, network.minute); native->minute = minute;
    int16_t second; rv &= network_to_native(&second, network.second); native->second = second;
    return rv;
}

struct NetVersion
{
    Byte major;
    Byte minor;
    Byte patch;
    Byte devel;
    Byte flags;
    Byte which;
    Little16 vend;
};
inline __attribute__((warn_unused_result))
bool native_to_network(NetVersion *network, Version native)
{
    bool rv = true;
    uint8_t major = native.major; rv &= native_to_network(&network->major, major);
    uint8_t minor = native.minor; rv &= native_to_network(&network->minor, minor);
    uint8_t patch = native.patch; rv &= native_to_network(&network->patch, patch);
    uint8_t devel = native.devel; rv &= native_to_network(&network->devel, devel);
    uint8_t flags = native.flags; rv &= native_to_network(&network->flags, flags);
    uint8_t which = native.which; rv &= native_to_network(&network->which, which);
    uint16_t vend = native.vend; rv &= native_to_network(&network->vend, vend);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Version *native, NetVersion network)
{
    bool rv = true;
    uint8_t major; rv &= network_to_native(&major, network.major); native->major = major;
    uint8_t minor; rv &= network_to_native(&minor, network.minor); native->minor = minor;
    uint8_t patch; rv &= network_to_native(&patch, network.patch); native->patch = patch;
    uint8_t devel; rv &= network_to_native(&devel, network.devel); native->devel = devel;
    uint8_t flags; rv &= network_to_native(&flags, network.flags); native->flags = flags;
    uint8_t which; rv &= network_to_native(&which, network.which); native->which = which;
    uint16_t vend; rv &= network_to_native(&vend, network.vend); native->vend = vend;
    return rv;
}

inline __attribute__((warn_unused_result))
bool native_to_network(Byte *network, VERSION_2 native)
{
    bool rv = true;
    uint8_t tmp = static_cast<uint8_t>(native);
    rv &= native_to_network(network, tmp);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(VERSION_2 *native, Byte network)
{
    bool rv = true;
    uint8_t tmp;
    rv &= network_to_native(&tmp, network);
    *native = static_cast<VERSION_2>(tmp);
    // TODO this is what really should be doing a checked cast
    return rv;
}
struct Stats6
{
    uint8_t str = {};
    uint8_t agi = {};
    uint8_t vit = {};
    uint8_t int_ = {};
    uint8_t dex = {};
    uint8_t luk = {};
};
struct NetStats6
{
    Byte str;
    Byte agi;
    Byte vit;
    Byte int_;
    Byte dex;
    Byte luk;
};
static_assert(offsetof(NetStats6, str) == 0, "offsetof(NetStats6, str) == 0");
static_assert(offsetof(NetStats6, agi) == 1, "offsetof(NetStats6, agi) == 1");
static_assert(offsetof(NetStats6, vit) == 2, "offsetof(NetStats6, vit) == 2");
static_assert(offsetof(NetStats6, int_) == 3, "offsetof(NetStats6, int_) == 3");
static_assert(offsetof(NetStats6, dex) == 4, "offsetof(NetStats6, dex) == 4");
static_assert(offsetof(NetStats6, luk) == 5, "offsetof(NetStats6, luk) == 5");
static_assert(sizeof(NetStats6) == 6, "sizeof(NetStats6) == 6");
static_assert(alignof(NetStats6) == 1, "alignof(NetStats6) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetStats6 *network, Stats6 native)
{
    bool rv = true;
    rv &= native_to_network(&network->str, native.str);
    rv &= native_to_network(&network->agi, native.agi);
    rv &= native_to_network(&network->vit, native.vit);
    rv &= native_to_network(&network->int_, native.int_);
    rv &= native_to_network(&network->dex, native.dex);
    rv &= native_to_network(&network->luk, native.luk);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Stats6 *native, NetStats6 network)
{
    bool rv = true;
    rv &= network_to_native(&native->str, network.str);
    rv &= network_to_native(&native->agi, network.agi);
    rv &= network_to_native(&native->vit, network.vit);
    rv &= network_to_native(&native->int_, network.int_);
    rv &= network_to_native(&native->dex, network.dex);
    rv &= network_to_native(&native->luk, network.luk);
    return rv;
}

struct CharSelect
{
    CharId char_id = {};
    uint32_t base_exp = {};
    uint32_t zeny = {};
    uint32_t job_exp = {};
    uint32_t job_level = {};
    ItemNameId shoes = {};
    ItemNameId gloves = {};
    ItemNameId cape = {};
    ItemNameId misc1 = {};
    Option option = {};
    uint16_t unused = {};
    uint32_t karma = {};
    uint32_t manner = {};
    uint16_t status_point = {};
    uint16_t hp = {};
    uint16_t max_hp = {};
    uint16_t sp = {};
    uint16_t max_sp = {};
    uint16_t speed = {};
    Species species = {};
    uint16_t hair_style = {};
    uint16_t weapon = {};
    uint16_t base_level = {};
    uint16_t skill_point = {};
    ItemNameId head_bottom = {};
    ItemNameId shield = {};
    ItemNameId head_top = {};
    ItemNameId head_mid = {};
    uint16_t hair_color = {};
    ItemNameId misc2 = {};
    CharName char_name = {};
    Stats6 stats = {};
    uint8_t char_num = {};
    uint8_t unused2 = {};
};
struct NetCharSelect
{
    Little32 char_id;
    Little32 base_exp;
    Little32 zeny;
    Little32 job_exp;
    Little32 job_level;
    Little16 shoes;
    Little16 gloves;
    Little16 cape;
    Little16 misc1;
    Little16 option;
    Little16 unused;
    Little32 karma;
    Little32 manner;
    Little16 status_point;
    Little16 hp;
    Little16 max_hp;
    Little16 sp;
    Little16 max_sp;
    Little16 speed;
    Little16 species;
    Little16 hair_style;
    Little16 weapon;
    Little16 base_level;
    Little16 skill_point;
    Little16 head_bottom;
    Little16 shield;
    Little16 head_top;
    Little16 head_mid;
    Little16 hair_color;
    Little16 misc2;
    NetString<sizeof(CharName)> char_name;
    NetStats6 stats;
    Byte char_num;
    Byte unused2;
};
static_assert(offsetof(NetCharSelect, char_id) == 0, "offsetof(NetCharSelect, char_id) == 0");
static_assert(offsetof(NetCharSelect, base_exp) == 4, "offsetof(NetCharSelect, base_exp) == 4");
static_assert(offsetof(NetCharSelect, zeny) == 8, "offsetof(NetCharSelect, zeny) == 8");
static_assert(offsetof(NetCharSelect, job_exp) == 12, "offsetof(NetCharSelect, job_exp) == 12");
static_assert(offsetof(NetCharSelect, job_level) == 16, "offsetof(NetCharSelect, job_level) == 16");
static_assert(offsetof(NetCharSelect, shoes) == 20, "offsetof(NetCharSelect, shoes) == 20");
static_assert(offsetof(NetCharSelect, gloves) == 22, "offsetof(NetCharSelect, gloves) == 22");
static_assert(offsetof(NetCharSelect, cape) == 24, "offsetof(NetCharSelect, cape) == 24");
static_assert(offsetof(NetCharSelect, misc1) == 26, "offsetof(NetCharSelect, misc1) == 26");
static_assert(offsetof(NetCharSelect, option) == 28, "offsetof(NetCharSelect, option) == 28");
static_assert(offsetof(NetCharSelect, unused) == 30, "offsetof(NetCharSelect, unused) == 30");
static_assert(offsetof(NetCharSelect, karma) == 32, "offsetof(NetCharSelect, karma) == 32");
static_assert(offsetof(NetCharSelect, manner) == 36, "offsetof(NetCharSelect, manner) == 36");
static_assert(offsetof(NetCharSelect, status_point) == 40, "offsetof(NetCharSelect, status_point) == 40");
static_assert(offsetof(NetCharSelect, hp) == 42, "offsetof(NetCharSelect, hp) == 42");
static_assert(offsetof(NetCharSelect, max_hp) == 44, "offsetof(NetCharSelect, max_hp) == 44");
static_assert(offsetof(NetCharSelect, sp) == 46, "offsetof(NetCharSelect, sp) == 46");
static_assert(offsetof(NetCharSelect, max_sp) == 48, "offsetof(NetCharSelect, max_sp) == 48");
static_assert(offsetof(NetCharSelect, speed) == 50, "offsetof(NetCharSelect, speed) == 50");
static_assert(offsetof(NetCharSelect, species) == 52, "offsetof(NetCharSelect, species) == 52");
static_assert(offsetof(NetCharSelect, hair_style) == 54, "offsetof(NetCharSelect, hair_style) == 54");
static_assert(offsetof(NetCharSelect, weapon) == 56, "offsetof(NetCharSelect, weapon) == 56");
static_assert(offsetof(NetCharSelect, base_level) == 58, "offsetof(NetCharSelect, base_level) == 58");
static_assert(offsetof(NetCharSelect, skill_point) == 60, "offsetof(NetCharSelect, skill_point) == 60");
static_assert(offsetof(NetCharSelect, head_bottom) == 62, "offsetof(NetCharSelect, head_bottom) == 62");
static_assert(offsetof(NetCharSelect, shield) == 64, "offsetof(NetCharSelect, shield) == 64");
static_assert(offsetof(NetCharSelect, head_top) == 66, "offsetof(NetCharSelect, head_top) == 66");
static_assert(offsetof(NetCharSelect, head_mid) == 68, "offsetof(NetCharSelect, head_mid) == 68");
static_assert(offsetof(NetCharSelect, hair_color) == 70, "offsetof(NetCharSelect, hair_color) == 70");
static_assert(offsetof(NetCharSelect, misc2) == 72, "offsetof(NetCharSelect, misc2) == 72");
static_assert(offsetof(NetCharSelect, char_name) == 74, "offsetof(NetCharSelect, char_name) == 74");
static_assert(offsetof(NetCharSelect, stats) == 98, "offsetof(NetCharSelect, stats) == 98");
static_assert(offsetof(NetCharSelect, char_num) == 104, "offsetof(NetCharSelect, char_num) == 104");
static_assert(offsetof(NetCharSelect, unused2) == 105, "offsetof(NetCharSelect, unused2) == 105");
static_assert(sizeof(NetCharSelect) == 106, "sizeof(NetCharSelect) == 106");
static_assert(alignof(NetCharSelect) == 1, "alignof(NetCharSelect) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetCharSelect *network, CharSelect native)
{
    bool rv = true;
    rv &= native_to_network(&network->char_id, native.char_id);
    rv &= native_to_network(&network->base_exp, native.base_exp);
    rv &= native_to_network(&network->zeny, native.zeny);
    rv &= native_to_network(&network->job_exp, native.job_exp);
    rv &= native_to_network(&network->job_level, native.job_level);
    rv &= native_to_network(&network->shoes, native.shoes);
    rv &= native_to_network(&network->gloves, native.gloves);
    rv &= native_to_network(&network->cape, native.cape);
    rv &= native_to_network(&network->misc1, native.misc1);
    rv &= native_to_network(&network->option, native.option);
    rv &= native_to_network(&network->unused, native.unused);
    rv &= native_to_network(&network->karma, native.karma);
    rv &= native_to_network(&network->manner, native.manner);
    rv &= native_to_network(&network->status_point, native.status_point);
    rv &= native_to_network(&network->hp, native.hp);
    rv &= native_to_network(&network->max_hp, native.max_hp);
    rv &= native_to_network(&network->sp, native.sp);
    rv &= native_to_network(&network->max_sp, native.max_sp);
    rv &= native_to_network(&network->speed, native.speed);
    rv &= native_to_network(&network->species, native.species);
    rv &= native_to_network(&network->hair_style, native.hair_style);
    rv &= native_to_network(&network->weapon, native.weapon);
    rv &= native_to_network(&network->base_level, native.base_level);
    rv &= native_to_network(&network->skill_point, native.skill_point);
    rv &= native_to_network(&network->head_bottom, native.head_bottom);
    rv &= native_to_network(&network->shield, native.shield);
    rv &= native_to_network(&network->head_top, native.head_top);
    rv &= native_to_network(&network->head_mid, native.head_mid);
    rv &= native_to_network(&network->hair_color, native.hair_color);
    rv &= native_to_network(&network->misc2, native.misc2);
    rv &= native_to_network(&network->char_name, native.char_name);
    rv &= native_to_network(&network->stats, native.stats);
    rv &= native_to_network(&network->char_num, native.char_num);
    rv &= native_to_network(&network->unused2, native.unused2);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(CharSelect *native, NetCharSelect network)
{
    bool rv = true;
    rv &= network_to_native(&native->char_id, network.char_id);
    rv &= network_to_native(&native->base_exp, network.base_exp);
    rv &= network_to_native(&native->zeny, network.zeny);
    rv &= network_to_native(&native->job_exp, network.job_exp);
    rv &= network_to_native(&native->job_level, network.job_level);
    rv &= network_to_native(&native->shoes, network.shoes);
    rv &= network_to_native(&native->gloves, network.gloves);
    rv &= network_to_native(&native->cape, network.cape);
    rv &= network_to_native(&native->misc1, network.misc1);
    rv &= network_to_native(&native->option, network.option);
    rv &= network_to_native(&native->unused, network.unused);
    rv &= network_to_native(&native->karma, network.karma);
    rv &= network_to_native(&native->manner, network.manner);
    rv &= network_to_native(&native->status_point, network.status_point);
    rv &= network_to_native(&native->hp, network.hp);
    rv &= network_to_native(&native->max_hp, network.max_hp);
    rv &= network_to_native(&native->sp, network.sp);
    rv &= network_to_native(&native->max_sp, network.max_sp);
    rv &= network_to_native(&native->speed, network.speed);
    rv &= network_to_native(&native->species, network.species);
    rv &= network_to_native(&native->hair_style, network.hair_style);
    rv &= network_to_native(&native->weapon, network.weapon);
    rv &= network_to_native(&native->base_level, network.base_level);
    rv &= network_to_native(&native->skill_point, network.skill_point);
    rv &= network_to_native(&native->head_bottom, network.head_bottom);
    rv &= network_to_native(&native->shield, network.shield);
    rv &= network_to_native(&native->head_top, network.head_top);
    rv &= network_to_native(&native->head_mid, network.head_mid);
    rv &= network_to_native(&native->hair_color, network.hair_color);
    rv &= network_to_native(&native->misc2, network.misc2);
    rv &= network_to_native(&native->char_name, network.char_name);
    rv &= network_to_native(&native->stats, network.stats);
    rv &= network_to_native(&native->char_num, network.char_num);
    rv &= network_to_native(&native->unused2, network.unused2);
    return rv;
}

struct SkillInfo
{
    SkillID skill_id = {};
    uint16_t type_or_inf = {};
    SkillFlags flags = {};
    uint16_t level = {};
    uint16_t sp = {};
    uint16_t range = {};
    VString<23> unused = {};
    uint8_t can_raise = {};
};
struct NetSkillInfo
{
    Little16 skill_id;
    Little16 type_or_inf;
    Little16 flags;
    Little16 level;
    Little16 sp;
    Little16 range;
    NetString<sizeof(VString<23>)> unused;
    Byte can_raise;
};
static_assert(offsetof(NetSkillInfo, skill_id) == 0, "offsetof(NetSkillInfo, skill_id) == 0");
static_assert(offsetof(NetSkillInfo, type_or_inf) == 2, "offsetof(NetSkillInfo, type_or_inf) == 2");
static_assert(offsetof(NetSkillInfo, flags) == 4, "offsetof(NetSkillInfo, flags) == 4");
static_assert(offsetof(NetSkillInfo, level) == 6, "offsetof(NetSkillInfo, level) == 6");
static_assert(offsetof(NetSkillInfo, sp) == 8, "offsetof(NetSkillInfo, sp) == 8");
static_assert(offsetof(NetSkillInfo, range) == 10, "offsetof(NetSkillInfo, range) == 10");
static_assert(offsetof(NetSkillInfo, unused) == 12, "offsetof(NetSkillInfo, unused) == 12");
static_assert(offsetof(NetSkillInfo, can_raise) == 36, "offsetof(NetSkillInfo, can_raise) == 36");
static_assert(sizeof(NetSkillInfo) == 37, "sizeof(NetSkillInfo) == 37");
static_assert(alignof(NetSkillInfo) == 1, "alignof(NetSkillInfo) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetSkillInfo *network, SkillInfo native)
{
    bool rv = true;
    rv &= native_to_network(&network->skill_id, native.skill_id);
    rv &= native_to_network(&network->type_or_inf, native.type_or_inf);
    rv &= native_to_network(&network->flags, native.flags);
    rv &= native_to_network(&network->level, native.level);
    rv &= native_to_network(&network->sp, native.sp);
    rv &= native_to_network(&network->range, native.range);
    rv &= native_to_network(&network->unused, native.unused);
    rv &= native_to_network(&network->can_raise, native.can_raise);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(SkillInfo *native, NetSkillInfo network)
{
    bool rv = true;
    rv &= network_to_native(&native->skill_id, network.skill_id);
    rv &= network_to_native(&native->type_or_inf, network.type_or_inf);
    rv &= network_to_native(&native->flags, network.flags);
    rv &= network_to_native(&native->level, network.level);
    rv &= network_to_native(&native->sp, network.sp);
    rv &= network_to_native(&native->range, network.range);
    rv &= network_to_native(&native->unused, network.unused);
    rv &= network_to_native(&native->can_raise, network.can_raise);
    return rv;
}

struct Item
{
    ItemNameId nameid = {};
    int16_t amount = {};
    EPOS equip = {};
};
struct NetItem
{
    Little16 nameid;
    Little16 amount;
    Little16 equip;
};
static_assert(alignof(NetItem) == 1, "alignof(NetItem) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetItem *network, Item native)
{
    bool rv = true;
    rv &= native_to_network(&network->nameid, native.nameid);
    rv &= native_to_network(&network->amount, native.amount);
    rv &= native_to_network(&network->equip, native.equip);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Item *native, NetItem network)
{
    bool rv = true;
    rv &= network_to_native(&native->nameid, network.nameid);
    rv &= network_to_native(&native->amount, network.amount);
    rv &= network_to_native(&native->equip, network.equip);
    return rv;
}

struct Point
{
    MapName map_ = {};
    int16_t x = {};
    int16_t y = {};
    Point() = default;
    Point(MapName _map_, int16_t _x, int16_t _y) : map_(_map_), x(_x), y(_y) {}
};
struct NetPoint
{
    NetString<sizeof(MapName)> map_;
    Little16 x;
    Little16 y;
};
static_assert(alignof(NetPoint) == 1, "alignof(NetPoint) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetPoint *network, Point native)
{
    bool rv = true;
    rv &= native_to_network(&network->map_, native.map_);
    rv &= native_to_network(&network->x, native.x);
    rv &= native_to_network(&network->y, native.y);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Point *native, NetPoint network)
{
    bool rv = true;
    rv &= network_to_native(&native->map_, network.map_);
    rv &= network_to_native(&native->x, network.x);
    rv &= network_to_native(&native->y, network.y);
    return rv;
}

struct SkillValue
{
    uint16_t lv = {};
    SkillFlags flags = {};
};
struct NetSkillValue
{
    Little16 lv;
    Little16 flags;
};
static_assert(alignof(NetSkillValue) == 1, "alignof(NetSkillValue) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetSkillValue *network, SkillValue native)
{
    bool rv = true;
    rv &= native_to_network(&network->lv, native.lv);
    rv &= native_to_network(&network->flags, native.flags);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(SkillValue *native, NetSkillValue network)
{
    bool rv = true;
    rv &= network_to_native(&native->lv, network.lv);
    rv &= network_to_native(&native->flags, network.flags);
    return rv;
}

struct GlobalReg
{
    VarName str = {};
    int32_t value = {};
};
struct NetGlobalReg
{
    NetString<sizeof(VarName)> str;
    Little32 value;
};
static_assert(alignof(NetGlobalReg) == 1, "alignof(NetGlobalReg) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetGlobalReg *network, GlobalReg native)
{
    bool rv = true;
    rv &= native_to_network(&network->str, native.str);
    rv &= native_to_network(&network->value, native.value);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(GlobalReg *native, NetGlobalReg network)
{
    bool rv = true;
    rv &= network_to_native(&native->str, network.str);
    rv &= network_to_native(&native->value, network.value);
    return rv;
}

struct CharKey
{
    CharName name = {};
    AccountId account_id = {};
    CharId char_id = {};
    uint8_t char_num = {};
};
struct NetCharKey
{
    NetString<sizeof(CharName)> name;
    Little32 account_id;
    Little32 char_id;
    Byte char_num;
};
static_assert(alignof(NetCharKey) == 1, "alignof(NetCharKey) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetCharKey *network, CharKey native)
{
    bool rv = true;
    rv &= native_to_network(&network->name, native.name);
    rv &= native_to_network(&network->account_id, native.account_id);
    rv &= native_to_network(&network->char_id, native.char_id);
    rv &= native_to_network(&network->char_num, native.char_num);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(CharKey *native, NetCharKey network)
{
    bool rv = true;
    rv &= network_to_native(&native->name, network.name);
    rv &= network_to_native(&native->account_id, network.account_id);
    rv &= network_to_native(&native->char_id, network.char_id);
    rv &= network_to_native(&native->char_num, network.char_num);
    return rv;
}

struct CharData
{
    CharId partner_id = {};
    int32_t base_exp = {};
    int32_t job_exp = {};
    int32_t zeny = {};
    Species species = {};
    int16_t status_point = {};
    int16_t skill_point = {};
    int32_t hp = {};
    int32_t max_hp = {};
    int32_t sp = {};
    int32_t max_sp = {};
    Option option = {};
    int16_t karma = {};
    int16_t manner = {};
    int16_t hair = {};
    int16_t hair_color = {};
    int16_t clothes_color = {};
    PartyId party_id = {};
    ItemLook weapon = {};
    ItemNameId shield = {};
    ItemNameId head_top = {};
    ItemNameId head_mid = {};
    ItemNameId head_bottom = {};
    uint8_t base_level = {};
    uint8_t job_level = {};
    earray<int16_t, ATTR, ATTR::COUNT> attrs = {};
    SEX sex = {};
    IP4Address mapip = {};
    uint16_t mapport = {};
    Point last_point = {};
    Point save_point = {};
    GenericArray<Item, InventoryIndexing<IOff0, MAX_INVENTORY>> inventory = {};
    earray<SkillValue, SkillID, MAX_SKILL> skill = {};
    int32_t global_reg_num = {};
    Array<GlobalReg, GLOBAL_REG_NUM> global_reg = {};
    int32_t account_reg_num = {};
    Array<GlobalReg, ACCOUNT_REG_NUM> account_reg = {};
    int32_t account_reg2_num = {};
    Array<GlobalReg, ACCOUNT_REG2_NUM> account_reg2 = {};
};
struct NetCharData
{
    Little32 partner_id;
    Little32 base_exp;
    Little32 job_exp;
    Little32 zeny;
    Little16 species;
    Little16 status_point;
    Little16 skill_point;
    Little32 hp;
    Little32 max_hp;
    Little32 sp;
    Little32 max_sp;
    Little16 option;
    Little16 karma;
    Little16 manner;
    Little16 hair;
    Little16 hair_color;
    Little16 clothes_color;
    Little32 party_id;
    Little16 weapon;
    Little16 shield;
    Little16 head_top;
    Little16 head_mid;
    Little16 head_bottom;
    Byte base_level;
    Byte job_level;
    NetArray<Little16, static_cast<size_t>(ATTR::COUNT)> attrs;
    Byte sex;
    IP4Address mapip;
    Little16 mapport;
    NetPoint last_point;
    NetPoint save_point;
    NetArray<NetItem, MAX_INVENTORY> inventory;
    NetArray<NetSkillValue, static_cast<size_t>(MAX_SKILL)> skill;
    Little32 global_reg_num;
    NetArray<NetGlobalReg, GLOBAL_REG_NUM> global_reg;
    Little32 account_reg_num;
    NetArray<NetGlobalReg, ACCOUNT_REG_NUM> account_reg;
    Little32 account_reg2_num;
    NetArray<NetGlobalReg, ACCOUNT_REG2_NUM> account_reg2;
};
static_assert(alignof(NetCharData) == 1, "alignof(NetCharData) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetCharData *network, CharData native)
{
    bool rv = true;
    rv &= native_to_network(&network->partner_id, native.partner_id);
    rv &= native_to_network(&network->base_exp, native.base_exp);
    rv &= native_to_network(&network->job_exp, native.job_exp);
    rv &= native_to_network(&network->zeny, native.zeny);
    rv &= native_to_network(&network->species, native.species);
    rv &= native_to_network(&network->status_point, native.status_point);
    rv &= native_to_network(&network->skill_point, native.skill_point);
    rv &= native_to_network(&network->hp, native.hp);
    rv &= native_to_network(&network->max_hp, native.max_hp);
    rv &= native_to_network(&network->sp, native.sp);
    rv &= native_to_network(&network->max_sp, native.max_sp);
    rv &= native_to_network(&network->option, native.option);
    rv &= native_to_network(&network->karma, native.karma);
    rv &= native_to_network(&network->manner, native.manner);
    rv &= native_to_network(&network->hair, native.hair);
    rv &= native_to_network(&network->hair_color, native.hair_color);
    rv &= native_to_network(&network->clothes_color, native.clothes_color);
    rv &= native_to_network(&network->party_id, native.party_id);
    rv &= native_to_network(&network->weapon, native.weapon);
    rv &= native_to_network(&network->shield, native.shield);
    rv &= native_to_network(&network->head_top, native.head_top);
    rv &= native_to_network(&network->head_mid, native.head_mid);
    rv &= native_to_network(&network->head_bottom, native.head_bottom);
    rv &= native_to_network(&network->base_level, native.base_level);
    rv &= native_to_network(&network->job_level, native.job_level);
    rv &= native_to_network(&network->attrs, native.attrs);
    rv &= native_to_network(&network->sex, native.sex);
    rv &= native_to_network(&network->mapip, native.mapip);
    rv &= native_to_network(&network->mapport, native.mapport);
    rv &= native_to_network(&network->last_point, native.last_point);
    rv &= native_to_network(&network->save_point, native.save_point);
    rv &= native_to_network(&network->inventory, native.inventory);
    rv &= native_to_network(&network->skill, native.skill);
    rv &= native_to_network(&network->global_reg_num, native.global_reg_num);
    rv &= native_to_network(&network->global_reg, native.global_reg);
    rv &= native_to_network(&network->account_reg_num, native.account_reg_num);
    rv &= native_to_network(&network->account_reg, native.account_reg);
    rv &= native_to_network(&network->account_reg2_num, native.account_reg2_num);
    rv &= native_to_network(&network->account_reg2, native.account_reg2);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(CharData *native, NetCharData network)
{
    bool rv = true;
    rv &= network_to_native(&native->partner_id, network.partner_id);
    rv &= network_to_native(&native->base_exp, network.base_exp);
    rv &= network_to_native(&native->job_exp, network.job_exp);
    rv &= network_to_native(&native->zeny, network.zeny);
    rv &= network_to_native(&native->species, network.species);
    rv &= network_to_native(&native->status_point, network.status_point);
    rv &= network_to_native(&native->skill_point, network.skill_point);
    rv &= network_to_native(&native->hp, network.hp);
    rv &= network_to_native(&native->max_hp, network.max_hp);
    rv &= network_to_native(&native->sp, network.sp);
    rv &= network_to_native(&native->max_sp, network.max_sp);
    rv &= network_to_native(&native->option, network.option);
    rv &= network_to_native(&native->karma, network.karma);
    rv &= network_to_native(&native->manner, network.manner);
    rv &= network_to_native(&native->hair, network.hair);
    rv &= network_to_native(&native->hair_color, network.hair_color);
    rv &= network_to_native(&native->clothes_color, network.clothes_color);
    rv &= network_to_native(&native->party_id, network.party_id);
    rv &= network_to_native(&native->weapon, network.weapon);
    rv &= network_to_native(&native->shield, network.shield);
    rv &= network_to_native(&native->head_top, network.head_top);
    rv &= network_to_native(&native->head_mid, network.head_mid);
    rv &= network_to_native(&native->head_bottom, network.head_bottom);
    rv &= network_to_native(&native->base_level, network.base_level);
    rv &= network_to_native(&native->job_level, network.job_level);
    rv &= network_to_native(&native->attrs, network.attrs);
    rv &= network_to_native(&native->sex, network.sex);
    rv &= network_to_native(&native->mapip, network.mapip);
    rv &= network_to_native(&native->mapport, network.mapport);
    rv &= network_to_native(&native->last_point, network.last_point);
    rv &= network_to_native(&native->save_point, network.save_point);
    rv &= network_to_native(&native->inventory, network.inventory);
    rv &= network_to_native(&native->skill, network.skill);
    rv &= network_to_native(&native->global_reg_num, network.global_reg_num);
    rv &= network_to_native(&native->global_reg, network.global_reg);
    rv &= network_to_native(&native->account_reg_num, network.account_reg_num);
    rv &= network_to_native(&native->account_reg, network.account_reg);
    rv &= network_to_native(&native->account_reg2_num, network.account_reg2_num);
    rv &= network_to_native(&native->account_reg2, network.account_reg2);
    return rv;
}

struct NetPartyMember
{
    Little32 account_id;
    NetString<sizeof(CharName)> name;
    NetString<sizeof(MapName)> map;
    Little32 leader;
    Little32 online;
    Little32 lv;
};
inline __attribute__((warn_unused_result))
bool native_to_network(NetPartyMember *network, PartyMember native)
{
    bool rv = true;
    AccountId account_id = native.account_id; rv &= native_to_network(&network->account_id, account_id);
    CharName name = native.name; rv &= native_to_network(&network->name, name);
    MapName map = native.map; rv &= native_to_network(&network->map, map);
    int32_t leader = native.leader; rv &= native_to_network(&network->leader, leader);
    int32_t online = native.online; rv &= native_to_network(&network->online, online);
    int32_t lv = native.lv; rv &= native_to_network(&network->lv, lv);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(PartyMember *native, NetPartyMember network)
{
    bool rv = true;
    AccountId account_id; rv &= network_to_native(&account_id, network.account_id); native->account_id = account_id;
    CharName name; rv &= network_to_native(&name, network.name); native->name = name;
    MapName map; rv &= network_to_native(&map, network.map); native->map = map;
    int32_t leader; rv &= network_to_native(&leader, network.leader); native->leader = leader;
    int32_t online; rv &= network_to_native(&online, network.online); native->online = online;
    int32_t lv; rv &= network_to_native(&lv, network.lv); native->lv = lv;
    return rv;
}

struct PartyMost
{
    PartyName name = {};
    int32_t exp = {};
    int32_t item = {};
    Array<PartyMember, MAX_PARTY> member = {};
};
struct NetPartyMost
{
    NetString<sizeof(PartyName)> name;
    Little32 exp;
    Little32 item;
    NetArray<NetPartyMember, MAX_PARTY> member;
};
static_assert(alignof(NetPartyMost) == 1, "alignof(NetPartyMost) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetPartyMost *network, PartyMost native)
{
    bool rv = true;
    rv &= native_to_network(&network->name, native.name);
    rv &= native_to_network(&network->exp, native.exp);
    rv &= native_to_network(&network->item, native.item);
    rv &= native_to_network(&network->member, native.member);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(PartyMost *native, NetPartyMost network)
{
    bool rv = true;
    rv &= network_to_native(&native->name, network.name);
    rv &= network_to_native(&native->exp, network.exp);
    rv &= network_to_native(&native->item, network.item);
    rv &= network_to_native(&native->member, network.member);
    return rv;
}

struct Storage
{
    bool dirty = {};
    AccountId account_id = {};
    int16_t storage_status = {};
    int16_t storage_amount = {};
    GenericArray<Item, InventoryIndexing<SOff0, MAX_STORAGE>> storage_ = {};
};
struct NetStorage
{
    bool dirty;
    Little32 account_id;
    Little16 storage_status;
    Little16 storage_amount;
    NetArray<NetItem, MAX_STORAGE> storage_;
};
static_assert(alignof(NetStorage) == 1, "alignof(NetStorage) == 1");
inline __attribute__((warn_unused_result))
bool native_to_network(NetStorage *network, Storage native)
{
    bool rv = true;
    rv &= native_to_network(&network->dirty, native.dirty);
    rv &= native_to_network(&network->account_id, native.account_id);
    rv &= native_to_network(&network->storage_status, native.storage_status);
    rv &= native_to_network(&network->storage_amount, native.storage_amount);
    rv &= native_to_network(&network->storage_, native.storage_);
    return rv;
}
inline __attribute__((warn_unused_result))
bool network_to_native(Storage *native, NetStorage network)
{
    bool rv = true;
    rv &= network_to_native(&native->dirty, network.dirty);
    rv &= network_to_native(&native->account_id, network.account_id);
    rv &= network_to_native(&native->storage_status, network.storage_status);
    rv &= network_to_native(&native->storage_amount, network.storage_amount);
    rv &= network_to_native(&native->storage_, network.storage_);
    return rv;
}

} // namespace tmwa