File: bzfsAPI.h

package info (click to toggle)
bzflag 2.4.30-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 26,488 kB
  • sloc: cpp: 150,376; ansic: 3,463; sh: 2,535; makefile: 2,194; perl: 486; python: 260; objc: 246; php: 206
file content (2450 lines) | stat: -rw-r--r-- 66,645 bytes parent folder | download
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
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
/* bzflag
 * Copyright (c) 1993-2025 Tim Riker
 *
 * This package is free software;  you can redistribute it and/or
 * modify it under the terms of the license found in the file
 * named COPYING that should have accompanied this file.
 *
 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

// all the exported functions for bzfs plugins

#ifndef _BZFS_API_H_
#define _BZFS_API_H_

/* system interface headers */
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <stdint.h>


/* DO NOT INCLUDE ANY OTHER HEADERS IN THIS FILE */
/* PLUGINS NEED TO BE BUILT WITHOUT THE BZ SOURCE TREE */
/* JUST THIS ONE FILE */

#ifdef _WIN32
#pragma warning( disable : 4996 )
#ifdef INSIDE_BZ
#define BZF_API __declspec( dllexport )
#else
#define BZF_API __declspec( dllimport )
#endif
#define BZF_PLUGIN_CALL extern "C" __declspec( dllexport )
#ifndef strcasecmp
#define strcasecmp stricmp
#endif
#else
#ifdef __clang__
#define BZF_API __attribute__((visibility("default")))
#define BZF_PLUGIN_CALL extern "C" __attribute__((visibility("default")))
#else
#define BZF_API
#define BZF_PLUGIN_CALL extern "C"
#endif
#endif

/* Provide a means to deprecate API functions to discourage their use
 * in the future
 */
#ifdef __GNUC__
#  define DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
#  define DEPRECATED __declspec(deprecated)
#else
#  pragma message("WARNING: You need to implement DEPRECATED for this compiler")
#  define DEPRECATED
#endif

class bz_Plugin;

#define BZ_API_VERSION  26

#define BZ_GET_PLUGIN_VERSION BZF_PLUGIN_CALL int bz_GetMinVersion ( void ) { return BZ_API_VERSION; }

#define BZ_PLUGIN(n)\
  BZF_PLUGIN_CALL bz_Plugin* bz_GetPlugin ( void ) { return new n; }\
  BZF_PLUGIN_CALL void bz_FreePlugin ( bz_Plugin* plugin ) { delete(plugin); }\
  BZF_PLUGIN_CALL int bz_GetMinVersion ( void ) { return BZ_API_VERSION; }

/** This is so we can use gcc's "format string vs arguments"-check
 * for various printf-like functions, and still maintain compatability.
 * Not tested on other platforms yet, but should work. */
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later.  */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
#  define __attribute__(Spec) /* empty */
# endif
/* The __-protected variants of `format' and `printf' attributes
 *    are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
#  define __format__ format
#  define __printf__ printf
# endif
#endif

/** shorthand defines to make the code cleaner. */
#define _ATTRIBUTE34 __attribute__ ((__format__ (__printf__, 3, 4)))
#define _ATTRIBUTE23 __attribute__ ((__format__ (__printf__, 2, 3)))
#define _ATTRIBUTE12 __attribute__ ((__format__ (__printf__, 1, 2)))

#ifdef __cplusplus
#  ifndef DEFINED_FORCE_CAST
#    define DEFINED_FORCE_CAST
template<class To, class From>
inline To force_cast(From const & f)
{
    union
    {
        From f;
        To t;
    } fc;
    fc.f = f;
    return fc.t;
}
#  endif
#endif

typedef enum
{
    eGoodFlag = 0,
    eBadFlag,
    eLastFlagQuality
} bz_eFlagQuality;

//utility classes
class BZF_API bz_ApiString
{
public:
    bz_ApiString();
    bz_ApiString(const char* c);
    bz_ApiString(const std::string &s);
    bz_ApiString(const bz_ApiString &r);

    ~bz_ApiString();

    bz_ApiString& operator=( const bz_ApiString& r );
    bz_ApiString& operator=( const std::string& r );
    bz_ApiString& operator=( const char* r );

    bool operator==( const bz_ApiString&r );
    bool operator==( const std::string& r );
    bool operator==( const char* r );

    bool operator!=( const bz_ApiString&r );
    bool operator!=( const std::string& r );
    bool operator!=( const char* r );

    bz_ApiString& operator+=( const bz_ApiString& r );
    bz_ApiString& operator+=( const std::string& r );
    bz_ApiString& operator+=( const char* r );

    unsigned int size ( void ) const;
    bool empty ( void ) const;

    const char* c_str(void) const;

    void format(const char* fmt, ...);

    void replaceAll ( const char* target, const char* with );

    void tolower ( void );
    void toupper ( void );
    void urlEncode ( void );

protected:
    class dataBlob
    {
    public:
        std::string str;
    };

    dataBlob *data;

public:
    // Conversion/cast operator
    operator std::string() const
    {
        return this->data->str;
    }
};

class BZF_API bz_APIIntList
{
public:
    bz_APIIntList();
    bz_APIIntList(const bz_APIIntList &r);
    bz_APIIntList(const std::vector<int>  &r);

    ~bz_APIIntList();

    void push_back ( int value );
    int get ( unsigned int i );

    const int& operator[](unsigned int i) const;
    bz_APIIntList& operator=( const bz_APIIntList& r );
    bz_APIIntList& operator=( const std::vector<int>& r );

    unsigned int size ( void );
    void clear ( void );

protected:
    class dataBlob;

    dataBlob *data;
};

BZF_API bz_APIIntList* bz_newIntList ( void );
BZF_API void bz_deleteIntList( bz_APIIntList * l );

class BZF_API bz_APIFloatList
{
public:
    bz_APIFloatList();
    bz_APIFloatList(const bz_APIFloatList     &r);
    bz_APIFloatList(const std::vector<float>  &r);

    ~bz_APIFloatList();

    void push_back ( float value );
    float get ( unsigned int i );

    const float& operator[](unsigned int i) const;
    bz_APIFloatList& operator=( const bz_APIFloatList& r );
    bz_APIFloatList& operator=( const std::vector<float>& r );

    unsigned int size ( void );
    void clear ( void );

protected:
    class dataBlob;

    dataBlob *data;
};

BZF_API bz_APIFloatList* bz_newFloatList ( void );
BZF_API void bz_deleteFloatList( bz_APIFloatList * l );

class BZF_API bz_APIStringList
{
public:
    bz_APIStringList();
    bz_APIStringList(const bz_APIStringList       &r);
    bz_APIStringList(const std::vector<std::string>   &r);

    ~bz_APIStringList();

    void push_back ( const bz_ApiString &value );
    void push_back ( const std::string &value );
    bz_ApiString get ( unsigned int i ) const;

    const bz_ApiString& operator[](unsigned int i) const;
    bz_APIStringList& operator=( const bz_APIStringList& r );
    bz_APIStringList& operator=( const std::vector<std::string>& r );

    const char* join(const char* delimiter = ",");
    bool contains(const std::string &needle);

    unsigned int size ( void ) const;
    void clear ( void );

    void tokenize ( const char* in, const char* delims, int maxTokens = 0, bool useQuotes = false);
protected:
    class dataBlob;

    dataBlob *data;
};

BZF_API bz_APIStringList* bz_newStringList ( void );
BZF_API void bz_deleteStringList( bz_APIStringList * l );

// current time (leave method here, used in bz_EventData constructor)
BZF_API double bz_getCurrentTime(void);

// versioning
BZF_API int bz_APIVersion ( void );

// event stuff

typedef enum
{
    bz_eNullEvent = 0,
    bz_eCaptureEvent,
    bz_ePlayerDieEvent,
    bz_ePlayerSpawnEvent,
    bz_eZoneEntryEvent,
    bz_eZoneExitEvent,
    bz_ePlayerJoinEvent,
    bz_ePlayerPartEvent,
    bz_eRawChatMessageEvent,  // before filter
    bz_eFilteredChatMessageEvent, // after filter
    bz_eUnknownSlashCommand,
    bz_eGetPlayerSpawnPosEvent,
    bz_eGetAutoTeamEvent,
    bz_eAllowPlayer,
    bz_eTickEvent,
    bz_eGetWorldEvent,
    bz_eGetPlayerInfoEvent,
    bz_eAllowSpawn,
    bz_eListServerUpdateEvent,
    bz_eBanEvent,
    bz_eHostBanModifyEvent,
    bz_eKickEvent,
    bz_eKillEvent,
    bz_ePlayerPausedEvent,
    bz_eMessageFilteredEvent,
    bz_eGamePauseEvent,
    bz_eGameResumeEvent,
    bz_eGameStartEvent,
    bz_eGameEndEvent,
    bz_eSlashCommandEvent,
    bz_ePlayerAuthEvent,
    bz_eServerMsgEvent,
    bz_eShotFiredEvent,
    bz_ePlayerUpdateEvent,
    bz_eNetDataSendEvent,
    bz_eNetDataReceiveEvent,
    bz_eLoggingEvent,
    bz_eShotEndedEvent,
    bz_eFlagTransferredEvent,
    bz_eFlagGrabbedEvent,
    bz_eFlagDroppedEvent,
    bz_eAllowCTFCaptureEvent,
    bz_eMsgDebugEvent,
    bz_eNewNonPlayerConnection,
    bz_ePluginLoaded,
    bz_ePluginUnloaded,
    bz_ePlayerScoreChanged,
    bz_eTeamScoreChanged,
    bz_eWorldFinalized,
    bz_eReportFiledEvent,
    bz_eBZDBChange,
    bz_eGetPlayerMotto,
    bz_eAllowConnection,
    bz_eAllowFlagGrab,
    bz_eAuthenticatonComplete,
    bz_eServerAddPlayer,
    bz_eAllowPollEvent,
    bz_ePollStartEvent,
    bz_ePollVoteEvent,
    bz_ePollVetoEvent,
    bz_ePollEndEvent,
    bz_eComputeHandicapEvent,
    bz_eBeginHandicapRefreshEvent,
    bz_eEndHandicapRefreshEvent,
    bz_eAutoPilotEvent,
    bz_eMuteEvent,
    bz_eUnmuteEvent,
    bz_eServerShotFiredEvent,
    bz_ePermissionModificationEvent,
    bz_eAllowServerShotFiredEvent,
    bz_ePlayerDeathFinalizedEvent,
    bz_eLastEvent    //this is never used as an event, just show it's the last one
} bz_eEventType;

// permision #defines
#define bz_perm_actionMessage       "actionMessage"
#define bz_perm_adminMessageReceive "adminMessageReceive"
#define bz_perm_adminMessageSend    "adminMessageSend"
#define bz_perm_antiban         "antiban"
#define bz_perm_antikick        "antikick"
#define bz_perm_antikill        "antikill"
#define bz_perm_antipoll        "antipoll"
#define bz_perm_antipollban     "antipollban"
#define bz_perm_antipollkick        "antipollkick"
#define bz_perm_antipollkill        "antipollkill"
#define bz_perm_ban         "ban"
#define bz_perm_banlist         "banlist"
#define bz_perm_clientQuery     "clientQuery"
#define bz_perm_countdown       "countdown"
#define bz_perm_date            "date"
#define bz_perm_endGame         "endGame"
#define bz_perm_flagHistory     "flagHistory"
#define bz_perm_flagMod         "flagMod"
#define bz_perm_hideAdmin       "hideAdmin"
#define bz_perm_idleStats       "idleStats"
#define bz_perm_info            "info"
#define bz_perm_kick            "kick"
#define bz_perm_kill            "kill"
#define bz_perm_lagStats        "lagStats"
#define bz_perm_lagwarn         "lagwarn"
#define bz_perm_listPerms       "listPerms"
#define bz_perm_listPlugins     "listPlugins"
#define bz_perm_masterBan       "masterban"
#define bz_perm_mute            "mute"
#define bz_perm_playerList      "playerList"
#define bz_perm_plugins         "plugins"
#define bz_perm_poll            "poll"
#define bz_perm_pollBan         "pollBan"
#define bz_perm_pollKick        "pollKick"
#define bz_perm_pollKill        "pollKill"
#define bz_perm_pollSet         "pollSet"
#define bz_perm_pollFlagReset       "pollFlagReset"
#define bz_perm_privateMessage      "privateMessage"
#define bz_perm_record          "record"
#define bz_perm_rejoin          "rejoin"
#define bz_perm_removePerms     "removePerms"
#define bz_perm_replay          "replay"
#define bz_perm_report          "report"
#define bz_perm_say         "say"
#define bz_perm_sendHelp        "sendHelp"
#define bz_perm_setAll          "setAll"
#define bz_perm_setPerms        "setPerms"
#define bz_perm_setVar          "setVar"
#define bz_perm_showAdmin       "showAdmin"
#define bz_perm_showMotto       "showMotto"
#define bz_perm_showOthers      "showOthers"
#define bz_perm_shortBan        "shortBan"
#define bz_perm_shutdownServer      "shutdownServer"
#define bz_perm_spawn           "spawn"
#define bz_perm_superKill       "superKill"
#define bz_perm_talk            "talk"
#define bz_perm_unban           "unban"
#define bz_perm_unmute          "unmute"
#define bz_perm_veto            "veto"
#define bz_perm_viewReports     "viewReports"
#define bz_perm_vote            "vote"

// types of text messages
typedef enum
{
    eChatMessage,
    eActionMessage
} bz_eMessageType;

typedef enum
{
    eNoTeam = -1,
    eRogueTeam = 0,
    eRedTeam,
    eGreenTeam,
    eBlueTeam,
    ePurpleTeam,
    eRabbitTeam,
    eHunterTeam,
    eObservers,
    eAdministrators
} bz_eTeamType;

#define BZ_SERVER       -2
#define BZ_ALLUSERS     -1
#define BZ_NULLUSER     -3

#define BZ_PUBLICCHAT       254
#define BZ_ADMINCHAT        252
#define BZ_ROGUECHAT        251
#define BZ_REDCHAT      250
#define BZ_GREENCHAT        249
#define BZ_BLUECHAT     248
#define BZ_PURPLECHAT       247
#define BZ_OBSERVERCHAT     246
#define BZ_RABBITCHAT       245
#define BZ_HUNTERCHAT       244

#define BZ_SERVERPLAYER     253
#define BZ_LASTREALPLAYER   243

#define BZ_BZDBPERM_NA      0
#define BZ_BZDBPERM_USER    1
#define BZ_BZDBPERM_SERVER  2
#define BZ_BZDBPERM_CLIENT  3

typedef enum
{
    eFFAGame= 0,
    eOpenFFAGame,
    eCTFGame,
    eRabbitGame
} bz_eGameType;

// defined later but used in some event objects
class bz_BasePlayerRecord;

typedef enum
{
    eDead,        // not alive, not paused, etc.
    eAlive,       // player is alive
    ePaused,      // player is paused
    eExploding,       // currently blowing up
    eTeleporting      // teleported recently
} bz_ePlayerStatus;

typedef struct bz_PlayerUpdateState
{
    bz_ePlayerStatus  status;         // special states
    bool          falling;        // not driving on the ground or an obstacle
    bool          crossingWall;       // crossing an obstacle wall
    bool          inPhantomZone;      // zoned
    float         pos[3];         // position of tank
    float         velocity[3];        // velocity of tank
    float         rotation;       // orientation of tank
    float         angVel;         // angular velocity of tank
    int           phydrv;         // physics driver
} bz_PlayerUpdateState;


BZF_API bool bz_freePlayerRecord ( bz_BasePlayerRecord *playerRecord );

// event data types
class BZF_API bz_EventData
{
public:
    bz_EventData(bz_eEventType type =  bz_eNullEvent)
        : version(1), eventType(type), eventTime( bz_getCurrentTime() )
    {
    }
    virtual ~bz_EventData() {}
    virtual void update() {}

    int version;
    bz_eEventType eventType;
    double eventTime;
};

class BZF_API bz_CTFCaptureEventData_V1 : public bz_EventData
{
public:
    bz_CTFCaptureEventData_V1() : bz_EventData(bz_eCaptureEvent)
        , teamCapped(eNoTeam), teamCapping(eNoTeam), playerCapping(-1)
        , rot(0.0)
    {
        memset(pos,0,sizeof(float)*3);
    }

    bz_eTeamType teamCapped;
    bz_eTeamType teamCapping;
    int playerCapping;

    float pos[3];
    float rot;
};

class BZF_API bz_PlayerDieEventData_V1 : public bz_EventData
{
public:
    bz_PlayerDieEventData_V1() : bz_EventData(bz_ePlayerDieEvent)
        , playerID(-1), team(eNoTeam), killerID(-1), killerTeam(eNoTeam)
        , shotID(-1), driverID(-1), state()
    {
    }

    int playerID;
    bz_eTeamType team;
    int killerID;
    bz_eTeamType killerTeam;
    bz_ApiString flagKilledWith;
    int shotID;
    int driverID;

    bz_PlayerUpdateState state;
};

class BZF_API bz_PlayerDieEventData_V2 : public bz_PlayerDieEventData_V1
{
public:
    bz_PlayerDieEventData_V2() : bz_PlayerDieEventData_V1()
        , flagHeldWhenKilled(-1)
    {}

    int flagHeldWhenKilled;
};

class BZF_API bz_PlayerSpawnEventData_V1 : public bz_EventData
{
public:
    bz_PlayerSpawnEventData_V1() : bz_EventData(bz_ePlayerSpawnEvent)
        , playerID(-1), team(eNoTeam), state()
    {
    }

    int playerID;
    bz_eTeamType team;
    bz_PlayerUpdateState state;
};

class BZF_API bz_ChatEventData_V1 : public bz_EventData
{
public:
    bz_ChatEventData_V1() : bz_EventData(bz_eRawChatMessageEvent)
        , from(-1), to(-1), team(eNoTeam)
    {
    }

    int from;
    int to;
    bz_eTeamType team;
    bz_ApiString message;
};

class BZF_API bz_ChatEventData_V2 : public bz_ChatEventData_V1
{
public:
    bz_ChatEventData_V2() : bz_ChatEventData_V1()
        , messageType(eChatMessage)
    {
    }

    bz_eMessageType messageType;
};

class BZF_API bz_PlayerJoinPartEventData_V1 : public bz_EventData
{
public:
    bz_PlayerJoinPartEventData_V1() : bz_EventData(bz_ePlayerJoinEvent)
        , playerID(-1), record(0)
    {
    }
    ~bz_PlayerJoinPartEventData_V1()
    {
        bz_freePlayerRecord(record);
    }

    int playerID;
    bz_BasePlayerRecord* record;
    bz_ApiString reason;
};

class BZF_API bz_UnknownSlashCommandEventData_V1 : public bz_EventData
{
public:
    bz_UnknownSlashCommandEventData_V1() : bz_EventData(bz_eUnknownSlashCommand)
        , from(-1), handled(false)
    {
    }

    int from;

    bool handled;
    bz_ApiString message;
};

class BZF_API bz_GetPlayerSpawnPosEventData_V1 : public bz_EventData
{
public:
    bz_GetPlayerSpawnPosEventData_V1() : bz_EventData(bz_eGetPlayerSpawnPosEvent)
        , playerID(-1), team(eNoTeam), handled(false)
        , rot(0.0)
    {
        pos[0] = pos[1] = pos[2] = 0.0f;
    }

    int playerID;
    bz_eTeamType team;

    bool handled;

    float pos[3];
    float rot;
};

class BZF_API bz_AllowPlayerEventData_V1 : public bz_EventData
{
public:
    bz_AllowPlayerEventData_V1() : bz_EventData(bz_eAllowPlayer)
        , playerID(-1)
        , allow(true)
    {
    }

    int playerID;
    bz_ApiString callsign;
    bz_ApiString ipAddress;

    bz_ApiString reason;
    bool allow;
};

class BZF_API bz_TickEventData_V1 : public bz_EventData
{
public:
    bz_TickEventData_V1() : bz_EventData(bz_eTickEvent)
    {
    }
};

class BZF_API bz_GetWorldEventData_V1 : public bz_EventData
{
public:
    bz_GetWorldEventData_V1() : bz_EventData(bz_eGetWorldEvent)
        , generated(false)
        , ctf(false)
        , rabbit(false)
        , openFFA(false)
        , worldBlob(NULL)
    {
    }

    bool generated;
    bool ctf;
    bool rabbit;
    bool openFFA;

    bz_ApiString worldFile;
    char* worldBlob;  // if assigned, the world will be read from this NUL
    // terminated string. BZFS does not free this memory,
    // so the plugin must do so (this can be done in the
    // WorldFinalize event)
};

class BZF_API bz_GetPlayerInfoEventData_V1 : public bz_EventData
{
public:
    bz_GetPlayerInfoEventData_V1() : bz_EventData(bz_eGetPlayerInfoEvent)
        , playerID(-1), team(eNoTeam)
        , admin(false), verified(false), registered(false)
    {
    }

    int playerID;
    bz_ApiString callsign;
    bz_ApiString ipAddress;

    bz_eTeamType team;

    bool admin;
    bool verified;
    bool registered;
};

class BZF_API bz_GetAutoTeamEventData_V1 : public bz_EventData
{
public:
    bz_GetAutoTeamEventData_V1() : bz_EventData(bz_eGetAutoTeamEvent)
        , playerID(-1), team(eNoTeam)
        , handled(false)
    {
    }

    int playerID;
    bz_ApiString callsign;
    bz_eTeamType team;

    bool handled;
};

class BZF_API bz_AllowSpawnData_V1 : public bz_EventData
{
public:
    bz_AllowSpawnData_V1() : bz_EventData(bz_eAllowSpawn)
        , playerID(-1), team(eNoTeam)
        , handled(false), allow(true)
    {
    }

    int playerID;
    bz_eTeamType team;

    bool handled;
    bool allow;
};



class BZF_API bz_AllowSpawnData_V2 : public bz_AllowSpawnData_V1
{
public:
    bz_AllowSpawnData_V2() : bz_AllowSpawnData_V1()
        , kickPlayer(true), kickReason("Not allowed to spawn")
        , message("You are not allowed to spawn. Please contact an administrator.")
    {
    }

    bool kickPlayer;
    bz_ApiString kickReason;
    bz_ApiString message;
};

class BZF_API bz_ListServerUpdateEvent_V1 : public bz_EventData
{
public:
    bz_ListServerUpdateEvent_V1() : bz_EventData(bz_eListServerUpdateEvent)
        , handled(false)
    {
    }

    bz_ApiString address;
    bz_ApiString description;
    bz_ApiString groups;

    bool handled;
};

class BZF_API bz_BanEventData_V1 : public bz_EventData
{
public:
    bz_BanEventData_V1() : bz_EventData(bz_eBanEvent)
        , bannerID(-1), banneeID(-1), duration(-1)
    {
    }

    int bannerID;
    int banneeID;
    int duration;
    bz_ApiString ipAddress;
    bz_ApiString reason;
};

class BZF_API bz_HostBanEventData_V1 : public bz_EventData
{
public:
    bz_HostBanEventData_V1() : bz_EventData(bz_eHostBanModifyEvent)
        , bannerID(-1), duration(-1)
    {
    }

    int bannerID;
    int duration;
    bz_ApiString hostPattern;
    bz_ApiString reason;
};

class BZF_API bz_KickEventData_V1 : public bz_EventData
{
public:
    bz_KickEventData_V1() : bz_EventData(bz_eKickEvent)
        , kickerID(-1), kickedID(-1)
    {
    }

    int kickerID;
    int kickedID;
    bz_ApiString reason;
};

class BZF_API bz_KillEventData_V1 : public bz_EventData
{
public:
    bz_KillEventData_V1() : bz_EventData(bz_eKillEvent)
        , killerID(-1), killedID(-1)
    {
    }

    int killerID;
    int killedID;
    bz_ApiString reason;
};

class BZF_API bz_PlayerPausedEventData_V1 : public bz_EventData
{
public:
    bz_PlayerPausedEventData_V1() : bz_EventData(bz_ePlayerPausedEvent)
        , playerID(-1), pause(false)
    {
    }

    int playerID;
    bool pause;
};

class BZF_API bz_MessageFilteredEventData_V1 : public bz_EventData
{
public:
    bz_MessageFilteredEventData_V1() : bz_EventData(bz_eMessageFilteredEvent)
        , playerID(-1)
    {
    }

    int playerID;

    bz_ApiString rawMessage;
    bz_ApiString filteredMessage;
};

class BZF_API bz_GamePauseResumeEventData_V1 : public bz_EventData
{
public:
    bz_GamePauseResumeEventData_V1() : bz_EventData(bz_eGameResumeEvent)
        , actionBy("SERVER")
    {
    }

    bz_ApiString actionBy;
};

class BZF_API bz_GamePauseResumeEventData_V2 : public bz_GamePauseResumeEventData_V1
{
public:
    bz_GamePauseResumeEventData_V2() : bz_GamePauseResumeEventData_V1()
        , playerID(253)
    {
    }

    int playerID;
};

class BZF_API bz_GameStartEndEventData_V1 : public bz_EventData
{
public:
    bz_GameStartEndEventData_V1() : bz_EventData(bz_eGameStartEvent)
        , duration(0.0)
    {
    }

    double duration;
};

class BZF_API bz_GameStartEndEventData_V2 : public bz_GameStartEndEventData_V1
{
public:
    bz_GameStartEndEventData_V2() : bz_GameStartEndEventData_V1()
        , playerID(253), gameOver(false)
    {
    }

    int playerID;
    bool gameOver;
};

class BZF_API bz_SlashCommandEventData_V1 : public bz_EventData
{
public:
    bz_SlashCommandEventData_V1() : bz_EventData(bz_eSlashCommandEvent)
        , from(-1)
    {
    }

    int from;

    bz_ApiString message;
};

class BZF_API bz_SlashCommandEventData_V2 : public bz_SlashCommandEventData_V1
{
public:
    bz_SlashCommandEventData_V2() : bz_SlashCommandEventData_V1(), sourceChannel(-1)
    {
    }

    int sourceChannel;
};

class BZF_API bz_AllowPollEventData_V1 : public bz_EventData
{
public:
    bz_AllowPollEventData_V1() : bz_EventData(bz_eAllowPollEvent),
        playerID(BZ_SERVER), pollAction(""), pollTarget(""), allow(true), reason("")
    {}

    int playerID;

    // 'kick', 'kill', 'ban', 'set', 'reset', or custom value from a plug-in
    bz_ApiString pollAction;

    // If it's a 'kick', 'kill' or 'ban', this will be the victim's callsign
    // If it's a 'set', this will be e.g. '_mirror black'
    // If it's a 'reset', this will be 'flags'
    bz_ApiString pollTarget;

    bool allow;
    bz_ApiString reason;
};

class BZF_API bz_PollStartEventData_V1 : public bz_EventData
{
public:
    bz_PollStartEventData_V1() : bz_EventData(bz_ePollStartEvent),
        playerID(BZ_SERVER), pollAction(""), pollTarget("")
    {}

    int playerID;

    // See bz_AllowPollEventData_V1 for notes
    bz_ApiString pollAction;
    bz_ApiString pollTarget;
};

class BZF_API bz_PollVoteEventData_V1 : public bz_EventData
{
public:
    bz_PollVoteEventData_V1() : bz_EventData(bz_ePollVoteEvent),
        playerID(BZ_SERVER), inFavor(false), allow(true), reason("")
    {}

    int playerID;
    bool inFavor;

    bool allow;
    bz_ApiString reason;
};

class BZF_API bz_PollVetoEventData_V1 : public bz_EventData
{
public:
    bz_PollVetoEventData_V1() : bz_EventData(bz_ePollVetoEvent),
        playerID(BZ_SERVER)
    {}

    int playerID;
};

class BZF_API bz_PollEndEventData_V1 : public bz_EventData
{
public:
    bz_PollEndEventData_V1() : bz_EventData(bz_ePollEndEvent),
        successful(false), yesCount(0), noCount(0), abstentionCount(0)
    {}

    bool successful;
    int yesCount;
    int noCount;
    int abstentionCount;
};

class BZF_API bz_PlayerAuthEventData_V1 : public bz_EventData
{
public:
    bz_PlayerAuthEventData_V1() : bz_EventData(bz_ePlayerAuthEvent)
        , playerID(-1), password(false), globalAuth(false)
    {
    }

    int playerID;
    bool password;
    bool globalAuth;
};

class BZF_API bz_ServerMsgEventData_V1 : public bz_EventData
{
public:
    bz_ServerMsgEventData_V1() : bz_EventData(bz_eServerMsgEvent)
        , to(-1), team(eNoTeam)
    {
    }

    int to;
    bz_eTeamType team;
    bz_ApiString message;
};

class BZF_API bz_ShotFiredEventData_V1 : public bz_EventData
{
public:
    bz_ShotFiredEventData_V1() : bz_EventData(bz_eShotFiredEvent)
        , changed(false)
        , playerID(-1)
        , shotID(-1)
    {
        pos[0] = pos[1] = pos[2] = 0.0f;
        vel[0] = vel[1] = vel[2] = 0.0f;
    }

    bool changed;
    float pos[3];
    float vel[3];
    bz_ApiString type;
    int playerID;
    int shotID;
};

class BZF_API bz_AllowServerShotFiredEventData_V1 : public bz_EventData
{
public:
    bz_AllowServerShotFiredEventData_V1() : bz_EventData(bz_eAllowServerShotFiredEvent)
        , allow(true)
        , changed(false)
        , flagType("")
        , team(eRogueTeam)
    {
        speed = pos[0] = pos[1] = pos[2] = velocity[0] = velocity[1] = velocity[2] = 0.0f;
    }

    bool allow;
    bool changed;
    bz_ApiString flagType;
    float speed;
    float pos[3];
    float velocity[3];
    bz_eTeamType team;
};

class BZF_API bz_ServerShotFiredEventData_V1 : public bz_EventData
{
public:
    bz_ServerShotFiredEventData_V1() : bz_EventData(bz_eServerShotFiredEvent)
        , guid(0)
        , speed(0)
        , team(eRogueTeam)
    {
        pos[0] = pos[1] = pos[2] = velocity[0] = velocity[1] = velocity[2] = 0.0f;
    }

    uint32_t guid;
    bz_ApiString flagType;
    float speed;
    float pos[3];
    float velocity[3];
    bz_eTeamType team;
};

class BZF_API bz_PlayerUpdateEventData_V1 : public bz_EventData
{
public:
    bz_PlayerUpdateEventData_V1() : bz_EventData(bz_ePlayerUpdateEvent)
        , playerID(-1), state(), lastState(), stateTime(0.0)
    {
    }

    int playerID;
    bz_PlayerUpdateState state;
    bz_PlayerUpdateState lastState;
    double stateTime;
};

class BZF_API bz_ComputeHandicap_V1 : public bz_EventData
{
public:
    bz_ComputeHandicap_V1() : bz_EventData(bz_eComputeHandicapEvent)
        , playerID(-1), desiredHandicap(0)
    {
    }

    int playerID;
    int desiredHandicap;
};

class BZF_API bz_NetTransferEventData_V1 : public bz_EventData
{
public:
    bz_NetTransferEventData_V1() : bz_EventData(bz_eNetDataReceiveEvent)
        , send(false), udp(false), iSize(0), playerID(-1)
        , data(NULL)
    {
    }

    bool send;
    bool udp;
    unsigned int iSize;
    int playerID;

    // DON'T CHANGE THIS!!!
    unsigned char* data;
};

class BZF_API bz_LoggingEventData_V1 : public bz_EventData
{
public:
    bz_LoggingEventData_V1() : bz_EventData(bz_eLoggingEvent)
        , level(0)
    {
    }

    int level;
    bz_ApiString message;
};

class BZF_API bz_ShotEndedEventData_V1 : public bz_EventData
{
public:

    bz_ShotEndedEventData_V1() : bz_EventData(bz_eShotEndedEvent)
        , playerID(-1)
        , shotID(-1)
        , explode(false)
    {
    }

    int playerID;
    int shotID;
    bool explode;
};

class BZF_API bz_FlagTransferredEventData_V1 : public bz_EventData
{
public:
    enum Action
    {
        ContinueSteal = 0,
        CancelSteal = 1,
        DropThief = 2
    };

    bz_FlagTransferredEventData_V1() : bz_EventData(bz_eFlagTransferredEvent)
        , fromPlayerID(0), toPlayerID(0), flagType(NULL), action(ContinueSteal)
    {
    }

    int fromPlayerID;
    int toPlayerID;
    const char* flagType;
    enum Action action;
};

class BZF_API bz_FlagGrabbedEventData_V1 : public bz_EventData
{
public:

    bz_FlagGrabbedEventData_V1() : bz_EventData(bz_eFlagGrabbedEvent)
        , playerID(-1), flagID(-1)
        , flagType(NULL)
    {
        pos[0] = pos[1] = pos[2] = 0;
    }

    int playerID;
    int flagID;

    const char* flagType;
    float pos[3];
};

class BZF_API bz_FlagDroppedEventData_V1 : public bz_EventData
{
public:

    bz_FlagDroppedEventData_V1() : bz_EventData(bz_eFlagDroppedEvent)
        , playerID(-1), flagID(-1), flagType(NULL)
    {
        pos[0] = pos[1] = pos[2] = 0;
    }

    int playerID;
    int flagID;

    const char* flagType;
    float pos[3];
};

class BZF_API bz_AllowCTFCaptureEventData_V1 : public bz_EventData
{
public:
    bz_AllowCTFCaptureEventData_V1() : bz_EventData(bz_eAllowCTFCaptureEvent)
        , teamCapped(eNoTeam), teamCapping(eNoTeam), playerCapping(-1)
        , rot(0.0)
        , allow(false), killTeam(true)
    {
        memset (pos, 0, sizeof(float)*3);
    }

    bz_eTeamType teamCapped;
    bz_eTeamType teamCapping;
    int playerCapping;

    float pos[3];
    float rot;

    bool allow;
    bool killTeam;
};

class BZF_API bz_MsgDebugEventData_V1 : public bz_EventData
{
public:
    bz_MsgDebugEventData_V1() : bz_EventData(bz_eMsgDebugEvent)
        , len(), msg(), receive(true)
        , playerID(-1)
    {
        memset (code, 0, sizeof(char)*2);
    }

    char code[2];
    size_t len;
    unsigned char* msg;

    bool receive;
    int playerID;
};

class BZF_API bz_NewNonPlayerConnectionEventData_V1 : public bz_EventData
{
public:

    bz_NewNonPlayerConnectionEventData_V1() : bz_EventData(bz_eNewNonPlayerConnection)
        , connectionID(-1)
        , data(0), size(0)
    {
    }

    int connectionID;
    void* data;
    unsigned int size;
};

class BZF_API bz_PluginLoadUnloadEventData_V1 : public bz_EventData
{
public:

    bz_PluginLoadUnloadEventData_V1() : bz_EventData(bz_ePluginLoaded)
        , plugin(NULL)
    {
    }

    bz_Plugin* plugin;
};


typedef enum
{
    bz_eWins,
    bz_eLosses,
    bz_eTKs
} bz_eScoreElement;

class BZF_API bz_PlayerScoreChangeEventData_V1 : public bz_EventData
{
public:
    bz_PlayerScoreChangeEventData_V1( int id, bz_eScoreElement e, int lastV,
                                      int thisv) : bz_EventData(bz_ePlayerScoreChanged)
        , playerID(id), element(e), thisValue(thisv), lastValue(lastV)
    {
    }

    int playerID;
    bz_eScoreElement element;
    int thisValue;
    int lastValue;
};

class BZF_API bz_TeamScoreChangeEventData_V1 : public bz_EventData
{
public:
    bz_TeamScoreChangeEventData_V1(bz_eTeamType t, bz_eScoreElement e, int lastV,
                                   int thisv) : bz_EventData(bz_eTeamScoreChanged)
        , team(t), element(e), thisValue(thisv), lastValue(lastV)
    {
    }

    bz_eTeamType team;
    bz_eScoreElement element;
    int thisValue;
    int lastValue;
};

class BZF_API bz_ReportFiledEventData_V1 : public bz_EventData
{
public:
    bz_ReportFiledEventData_V1() : bz_EventData(bz_eReportFiledEvent) {}

    bz_ApiString from;
    bz_ApiString message;
};

class BZF_API bz_BZDBChangeData_V1 : public bz_EventData
{
public:
    bz_BZDBChangeData_V1(const std::string& _key, const std::string& _value)
        : bz_EventData(bz_eBZDBChange), key(_key), value(_value) {}

    bz_ApiString key;
    bz_ApiString value;
};

class BZF_API bz_GetPlayerMottoData_V1 : public bz_EventData
{
public:
    bz_GetPlayerMottoData_V1(const char* m)
        : bz_EventData(bz_eGetPlayerMotto)
    {
        if (m)
            motto = m;
    }

    bz_ApiString motto;
};

class BZF_API bz_GetPlayerMottoData_V2 : public bz_GetPlayerMottoData_V1
{
public:
    bz_GetPlayerMottoData_V2(const char* m)
        : bz_GetPlayerMottoData_V1(m)
    {
    }

    ~bz_GetPlayerMottoData_V2()
    {
        bz_freePlayerRecord(record);
    }

    bz_BasePlayerRecord* record;
};

class BZF_API bz_AllowConnectionData_V1 : public bz_EventData
{
public:
    bz_AllowConnectionData_V1(const char* i)
        : bz_EventData(bz_eAllowConnection)
    {
        if (i)
            ip = i;

        allow = true;
    }
    bz_ApiString ip;
    bool allow;

};

class BZF_API bz_AllowFlagGrabData_V1 : public bz_EventData
{
public:
    bz_AllowFlagGrabData_V1()
        : bz_EventData(bz_eAllowFlagGrab)
    {
        allow = true;
    }

    int playerID;
    int flagID;

    const char* flagType;

    bool allow;
};

class BZF_API bz_AuthenticationCompleteData_V1 : public bz_EventData
{
public:
    bz_AuthenticationCompleteData_V1()
        : bz_EventData(bz_eAuthenticatonComplete)
    {
    }
    ~bz_AuthenticationCompleteData_V1()
    {
        bz_freePlayerRecord(player);
    }
    bz_BasePlayerRecord *player;
};

class BZF_API bz_ServerAddPlayerData_V1 : public bz_EventData
{
public:
    bz_ServerAddPlayerData_V1()
        : bz_EventData(bz_eServerAddPlayer)
    {
        allow = true;
    }
    ~bz_ServerAddPlayerData_V1()
    {
        bz_freePlayerRecord(player);
    }
    bz_BasePlayerRecord *player;

    bool allow;
};

class BZF_API bz_AutoPilotData_V1 : public bz_EventData
{
public:
    bz_AutoPilotData_V1() : bz_EventData(bz_eAutoPilotEvent),
        playerID(-1),
        enabled(false)
    {}

    int playerID;
    bool enabled;
};

class BZF_API bz_MuteEventData_V1 : public bz_EventData
{
public:
    bz_MuteEventData_V1() : bz_EventData(bz_eMuteEvent),
        victimID(-1),
        muterID(-1)
    {}

    int victimID;
    int muterID;
};

class BZF_API bz_PermissionModificationData_V1 : public bz_EventData
{
public:
    bz_PermissionModificationData_V1() : bz_EventData(bz_ePermissionModificationEvent)
        , playerID(-1)
        , perm("")
        , granted(false)
        , customPerm(false)
    {}

    int playerID;
    const char* perm;
    bool granted;
    bool customPerm;
};

// logging
BZF_API void bz_debugMessage ( int debugLevel, const char* message );
BZF_API void bz_debugMessagef( int debugLevel, const char* fmt, ... );
BZF_API int bz_getDebugLevel ( void );
BZF_API int bz_setDebugLevel ( int debugLevel );

// plug-in registration

class BZF_API bz_Plugin
{
public:
    bz_Plugin();
    virtual ~bz_Plugin();

    virtual const char* Name () = 0;
    virtual void Init( const char* config ) = 0;
    virtual void Cleanup() {}
    virtual void Event( bz_EventData* /*eventData*/ )
    {
        return;
    }

    // used for inter plugin communication
    virtual int GeneralCallback( const char* /*name*/, void* /*data*/ )
    {
        return 0;
    }

    float MaxWaitTime;
    bool Unloadable;

protected:
    bool Register (bz_eEventType eventType);
    bool Remove (bz_eEventType eventType);
    void Flush  ();
};

BZF_API bool bz_pluginExists(const char* name);
BZF_API bz_Plugin* bz_getPlugin(const char* name);

BZF_API int bz_callPluginGenericCallback(const char* plugin, const char* name, void* data );

// non player data handlers
class bz_NonPlayerConnectionHandler
{
public:
    virtual ~bz_NonPlayerConnectionHandler() {}
    virtual void pending(int connectionID, void *data, unsigned int size) = 0;
    virtual void disconnect(int connectionID)
    {
        if (connectionID) return;
    }
};

BZF_API bool bz_registerNonPlayerConnectionHandler(int connectionID, bz_NonPlayerConnectionHandler* handler);
BZF_API bool bz_removeNonPlayerConnectionHandler(int connectionID, bz_NonPlayerConnectionHandler* handler);
BZF_API bool bz_setNonPlayerInactivityTimeout(int connectionID, double time);
BZF_API bool bz_setNonPlayerDataThrottle(int connectionID, double time);
BZF_API bool bz_setNonPlayerDisconnectOnSend(int connectionID, bool bSet);
BZF_API bool bz_sendNonPlayerData(int connectionID, const void *data, unsigned int size);
BZF_API bool bz_disconnectNonPlayerConnection(int connectionID);
BZF_API unsigned int bz_getNonPlayerConnectionOutboundPacketCount(int connectionID);

BZF_API const char* bz_getNonPlayerConnectionIP(int connectionID);
BZF_API const char* bz_getNonPlayerConnectionHost(int connectionID);


// player listing
BZF_API bz_APIIntList* bz_getPlayerIndexList(void);
BZF_API bool bz_getPlayerIndexList ( bz_APIIntList *playerList );
BZF_API bz_BasePlayerRecord *bz_getPlayerByIndex ( int index );
BZF_API bz_BasePlayerRecord *bz_getPlayerBySlotOrCallsign ( const char* name );
BZF_API bool bz_updatePlayerData ( bz_BasePlayerRecord *playerRecord );

BZF_API int bz_getPlayerCount ();

BZF_API bool bz_hasPerm ( int playerID, const char* perm );
BZF_API bool bz_grantPerm ( int playerID, const char* perm );
BZF_API bool bz_revokePerm ( int playerID, const char* perm );

BZF_API bool bz_getAdmin(int playerID);

BZF_API bool bz_validAdminPassword(const char* passwd);

BZF_API const char* bz_getPlayerFlag( int playerID );

BZF_API bool bz_isPlayerAutoPilot( int playerID );
BZF_API bool bz_isPlayerPaused( int playerID );
BZF_API double bz_getPausedTime( int playerID );
BZF_API double bz_getIdleTime( int playerID );

BZF_API bz_eTeamType bz_getPlayerTeam(int playerID);
BZF_API const char* bz_getPlayerCallsign(int playerID);
BZF_API const char* bz_getPlayerMotto(int playerID);
BZF_API const char* bz_getPlayerIPAddress(int playerID);

// player lag info
BZF_API int bz_getPlayerLag( int playerId );
BZF_API int bz_getPlayerJitter( int playerId );
BZF_API float bz_getPlayerPacketloss( int playerId );

class BZF_API bz_BasePlayerRecord
{
public:
    bz_BasePlayerRecord()
        : version(1), playerID(-1), team(eNoTeam)
        , currentFlagID(-1)
        , lastUpdateTime(0.0), lastKnownState()
        , spawned(false), verified(false), globalUser(false)
        , admin(false), op(false), canSpawn(false)
        , lag(0), jitter(0), packetLoss(0.0)
        , rank(0.0), wins(0), losses(0), teamKills(0)
    {}

    virtual ~bz_BasePlayerRecord() {}

    void update(void)
    {
        bz_updatePlayerData(this);    // call to update with current data
    }

    bool hasPerm(const char* perm)
    {
        return bz_hasPerm(playerID,perm);
    }
    bool grantPerm(const char* perm)
    {
        return bz_grantPerm(playerID,perm);
    }
    bool revokePerm(const char* perm)
    {
        return bz_revokePerm(playerID,perm);
    }

    const char *getCustomData ( const char* key);
    bool setCustomData ( const char* key, const char* data);

    int version;
    int playerID;
    bz_ApiString callsign;

    bz_eTeamType team;

    bz_ApiString ipAddress;

    int currentFlagID;
    bz_ApiString currentFlag;
    bz_APIStringList flagHistory;

    double lastUpdateTime;
    bz_PlayerUpdateState lastKnownState;

    bz_ApiString clientVersion;
    bool spawned;
    bool verified;
    bool globalUser;
    bz_ApiString bzID;
    bool admin;
    bool op;
    bool canSpawn;
    bz_APIStringList groups;

    int lag;
    int jitter;
    float packetLoss;

    float rank;
    int wins;
    int losses;
    int teamKills;

};

class BZF_API bz_PlayerRecordV2 : public bz_BasePlayerRecord
{
public:
    bz_PlayerRecordV2() : bz_BasePlayerRecord()
    {
        version = 2;
    }

    bz_ApiString motto;
};

// player info
BZF_API bool bz_getPlayerHumanity( int playerId );

BZF_API bool bz_setPlayerOperator ( int playerId );
BZF_API bool bz_setPlayerSpawnable ( int playerId, bool spawn );
BZF_API bool bz_isPlayerSpawnable ( int playerId );
BZF_API void bz_setPlayerSpawnAtBase ( int playerId, bool base );
BZF_API bool bz_getPlayerSpawnAtBase ( int playerId );

// player access control
BZF_API bool bz_addPlayerToGame (int playerID );

// team info
BZF_API unsigned int bz_getTeamPlayerLimit ( bz_eTeamType team );

// player score
BZF_API void bz_computePlayerScore( bool enabled );
BZF_API bool bz_computingPlayerScore( void );

BZF_API bool bz_setPlayerWins (int playerId, int wins);
BZF_API bool bz_setPlayerLosses (int playerId, int losses);
BZF_API bool bz_setPlayerTKs (int playerId, int tks);

BZF_API bool bz_incrementPlayerWins (int playerId, int increment);
BZF_API bool bz_incrementPlayerLosses (int playerId, int increment);
BZF_API bool bz_incrementPlayerTKs (int playerId, int increment);

BZF_API float bz_getPlayerRank(int playerId);
BZF_API int bz_getPlayerWins(int playerId);
BZF_API int bz_getPlayerLosses(int playerId);
BZF_API int bz_getPlayerTKs(int playerId);

BZF_API int bz_howManyTimesPlayerKilledBy(int playerId, int killerId);

BZF_API bool bz_resetPlayerScore(int playerId);

// player handicap
BZF_API void bz_refreshHandicaps();

// groups API
BZF_API bz_APIStringList* bz_getGroupList ( void );
BZF_API bz_APIStringList* bz_getGroupPerms ( const char* group );
BZF_API bool bz_groupAllowPerm ( const char* group, const char* perm );

// message API
BZF_API bool bz_sendTextMessage (int from, int to, bz_eMessageType type, const char* message);
BZF_API bool bz_sendTextMessage (int from, int to, const char* message);

BZF_API bool bz_sendTextMessage (int from, bz_eTeamType to, bz_eMessageType type, const char* message);
BZF_API bool bz_sendTextMessage (int from, bz_eTeamType to, const char* message);

BZF_API bool bz_sendTextMessagef(int from, int to, bz_eMessageType type, const char* fmt, ...);
BZF_API bool bz_sendTextMessagef(int from, int to, const char* fmt, ...);

BZF_API bool bz_sendTextMessagef(int from, bz_eTeamType to, bz_eMessageType type, const char* fmt, ...);
BZF_API bool bz_sendTextMessagef(int from, bz_eTeamType to, const char* fmt, ...);

BZF_API bool bz_sentFetchResMessage ( int playerID,  const char* URL );

// world weapons
// will be removed in next breaking version after 2.4.x
/*DEPRECATED*/ BZF_API bool bz_fireWorldWep ( const char* flagType, float lifetime, int fromPlayer, float *pos,
        float tilt, float direction, int shotID, float dt, bz_eTeamType shotTeam = eRogueTeam );
/*DEPRECATED*/ BZF_API bool bz_fireWorldWep( const char* flagType, float lifetime, int fromPlayer, float *pos,
        float tilt, float direction, float speed, int* shotID, float dt, bz_eTeamType shotTeam = eRogueTeam );
/*DEPRECATED*/ BZF_API bool bz_fireWorldWep( const char* flagType, float lifetime, int fromPlayer, float *pos,
        float tilt, float direction, int* shotID, float dt, bz_eTeamType shotTeam = eRogueTeam );
/*DEPRECATED*/ BZF_API int bz_fireWorldGM ( int targetPlayerID, float lifetime, float *pos, float tilt, float direction,
        float dt, bz_eTeamType shotTeam = eRogueTeam);

// new server shot API
BZF_API uint32_t bz_fireServerShot(const char* shotType, float origin[3], float vector[3],
                                   bz_eTeamType color = eRogueTeam, int targetPlayerId = -1);

// will be removed in next breaking version after 2.4.x
/*DEPRECATED*/ BZF_API uint32_t bz_getShotMetaData (int fromPlayer, int shotID, const char* name);
/*DEPRECATED*/ BZF_API void bz_setShotMetaData (int fromPlayer, int shotID, const char* name, uint32_t value);
/*DEPRECATED*/ BZF_API bool bz_shotHasMetaData (int fromPlayer, int shotID, const char* name);

// new shot metadata API
BZF_API void bz_setShotMetaData (const uint32_t shotGUID, const char* name, uint32_t value);
BZF_API void bz_setShotMetaData (const uint32_t shotGUID, const char* name, const char* value);
BZF_API bool bz_shotHasMetaData (const uint32_t shotGUID, const char* name);

BZF_API uint32_t bz_getShotMetaDataI(const uint32_t shotGUID, const char* name);
BZF_API const char* bz_getShotMetaDataS(const uint32_t shotGUID, const char* name);

BZF_API uint32_t bz_getShotGUID (int fromPlayer, int shotID);

// geometry utils
BZF_API bool bz_vectorFromPoints(const float p1[3], const float p2[3], float outVec[3]);
BZF_API bool bz_vectorFromRotations(const float tilt, const float rotation, float outVec[3]);

typedef struct
{
    int year;
    int month;
    int day;
    int hour;
    int minute;
    int second;
    int dayofweek;
    bool daylightSavings;
} bz_Time;

BZF_API void bz_getLocaltime(bz_Time *ts);
BZF_API void bz_getUTCtime(bz_Time *ts);

// BZDB API
BZF_API double bz_getBZDBDouble ( const char* variable );
BZF_API bz_ApiString bz_getBZDBString( const char* variable );
BZF_API bool bz_getBZDBBool( const char* variable );
BZF_API int bz_getBZDBInt( const char* variable );

BZF_API int bz_getBZDBItemPerms( const char* variable );
BZF_API bool bz_getBZDBItemPesistent( const char* variable );
BZF_API bool bz_BZDBItemExists( const char* variable );
BZF_API bool bz_BZDBItemHasValue( const char* variable );

BZF_API bool bz_registerCustomBZDBDouble(const char* variable, double val, int perms = 0, bool persistent = false);
BZF_API bool bz_registerCustomBZDBString(const char* variable, const char *val, int perms = 0, bool persistent = false);
BZF_API bool bz_registerCustomBZDBBool(const char* variable, bool val, int perms = 0, bool persistent = false);
BZF_API bool bz_registerCustomBZDBInt(const char* variable, int val, int perms = 0, bool persistent = false);

BZF_API bool bz_removeCustomBZDBVariable(const char* variable);

// remove in next breaking version after 2.4.x; superseded by bz_registerCustomBZDB*()
/*DEPRECATED*/ BZF_API bool bz_setBZDBDouble(const char* variable, double val, int perms = 0, bool persistent = false);
/*DEPRECATED*/ BZF_API bool bz_setBZDBString(const char* variable, const char *val, int perms = 0,
        bool persistent = false);
/*DEPRECATED*/ BZF_API bool bz_setBZDBBool(const char* variable, bool val, int perms = 0, bool persistent = false);
/*DEPRECATED*/ BZF_API bool bz_setBZDBInt(const char* variable, int val, int perms = 0, bool persistent = false);

BZF_API bool bz_setDefaultBZDBDouble(const char* variable, double val);
BZF_API bool bz_setDefaultBZDBString(const char* variable, const char* val);
BZF_API bool bz_setDefaultBZDBBool(const char* variable, bool val);
BZF_API bool bz_setDefaultBZDBInt(const char* variable, int val);

BZF_API bool bz_updateBZDBDouble(const char* variable, double val);
BZF_API bool bz_updateBZDBString(const char* variable, const char *val);
BZF_API bool bz_updateBZDBBool(const char* variable, bool val);
BZF_API bool bz_updateBZDBInt(const char* variable, int val);

BZF_API int bz_getBZDBVarList( bz_APIStringList *varList );

BZF_API void bz_resetBZDBVar( const char* variable );
BZF_API void bz_resetALLBZDBVars( void );


// admin
BZF_API bool bz_kickUser ( int playerIndex, const char* reason, bool notify );
BZF_API bool bz_IPBanUser ( int playerIndex, const char* ip, int time, const char* reason );
BZF_API bool bz_IPUnbanUser ( const char* ip );
BZF_API bool bz_HostBanUser(const char* hostmask, const char* source, int duration, const char* reason);
BZF_API bool bz_IDUnbanUser(const char* bzID);
BZF_API bool bz_HostUnbanUser(const char* hostmask);


// ban lists
typedef enum
{
    eIPList,
    eIDList,
    eHostList
} bz_eBanListType;

BZF_API unsigned int bz_getBanListSize( bz_eBanListType listType );
BZF_API const char* bz_getBanItem ( bz_eBanListType listType, unsigned int item );
BZF_API const char* bz_getBanItemReason ( bz_eBanListType listType, unsigned int item );
BZF_API const char* bz_getBanItemSource ( bz_eBanListType listType, unsigned int item );
BZF_API double bz_getBanItemDuration ( bz_eBanListType listType, unsigned int item );
BZF_API bool bz_getBanItemIsFromMaster ( bz_eBanListType listType, unsigned int item );

BZF_API  bz_APIStringList *bz_getReports( void );

// lagwarn
BZF_API int bz_getLagWarn( void );
BZF_API bool bz_setLagWarn( int lagwarn );

// timelimit
BZF_API bool bz_setTimeLimit( float timeLimit );
BZF_API float bz_getTimeLimit( void );
BZF_API bool bz_isTimeManualStart( void );

// countdown
BZF_API bool bz_isCountDownActive( void );
BZF_API bool bz_isCountDownInProgress( void );
BZF_API bool bz_isCountDownPaused( void );

// polls
BZF_API bool bz_pollActive( void );
BZF_API bool bz_pollVeto( void );

// help
BZF_API bz_APIStringList *bz_getHelpTopics( void );
BZF_API bz_APIStringList *bz_getHelpTopic( std::string name );

// custom polls

class bz_CustomPollTypeHandler
{
public:
    virtual ~bz_CustomPollTypeHandler() {};

    // Should return false to prevent the poll from starting
    virtual bool PollOpen  (bz_BasePlayerRecord *player, const char* action, const char* parameters) = 0;
    virtual void PollClose (const char* action, const char* parameters, bool success) = 0;
};

BZF_API bool bz_registerCustomPollType (const char* option, const char* parameters, bz_CustomPollTypeHandler *handler);
BZF_API bool bz_removeCustomPollType (const char* option);

// custom commands

class bz_CustomSlashCommandHandler
{
public:
    virtual ~bz_CustomSlashCommandHandler() {};
    virtual bool SlashCommand(int playerID, bz_ApiString command, bz_ApiString message, bz_APIStringList *params) = 0;
};

class bz_CustomSlashCommandHandlerV2
{
public:
    virtual ~bz_CustomSlashCommandHandlerV2() {};
    virtual bool SlashCommand ( int playerID, int sourceChannel, bz_ApiString command, bz_ApiString message,
                                bz_APIStringList *params ) = 0;
};

BZF_API bool bz_registerCustomSlashCommand ( const char* command, bz_CustomSlashCommandHandlerV2 *handler );
BZF_API bool bz_registerCustomSlashCommand (const char* command, bz_CustomSlashCommandHandler *handler);
BZF_API bool bz_removeCustomSlashCommand ( const char* command );

// spawning
BZF_API bool bz_getStandardSpawn ( int playerID, float pos[3], float *rot );

// dying
BZF_API bool bz_killPlayer ( int playerID, bool spawnOnBase, int killerID = -1, const char* flagID = NULL );

// flags
BZF_API bool bz_givePlayerFlag ( int playerID, const char* flagType, bool force );
BZF_API bool bz_removePlayerFlag ( int playerID );
BZF_API void bz_resetFlags ( bool onlyUnused, bool keepTeamFlags = false );

BZF_API unsigned int bz_getNumFlags( void );
/*DEPRECATED*/ BZF_API const bz_ApiString bz_getName( int flag );
BZF_API const bz_ApiString bz_getFlagName( int flag );
BZF_API bool bz_resetFlag ( int flag );
BZF_API bool bz_moveFlag ( int flag, float pos[3] );
BZF_API int bz_getPlayerFlagID ( int playerID );
BZF_API int bz_flagPlayer ( int flag );
BZF_API bool bz_getFlagPosition ( int flag, float* pos );
BZF_API bool bz_getNearestFlagSafetyZone(int flag, float *pos);


// world
typedef struct
{
    bool  driveThru;
    bool  shootThru;
} bz_WorldObjectOptions;

typedef struct
{
    bz_ApiString  texture;
    bool      useAlpha;
    bool      useColorOnTexture;
    bool      useSphereMap;
    int       combineMode;
} bz_MaterialTexture;

class BZF_API bzAPITextureList
{
public:
    bzAPITextureList();
    bzAPITextureList(const bzAPITextureList   &r);

    ~bzAPITextureList();

    void push_back ( bz_MaterialTexture &value );
    bz_MaterialTexture get ( unsigned int i );

    const bz_MaterialTexture& operator[](unsigned int i) const;
    bzAPITextureList& operator=( const bzAPITextureList& r );

    unsigned int size ( void );
    void clear ( void );

protected:
    class dataBlob;

    dataBlob *data;
};

typedef struct bz_MaterialInfo
{
    bz_ApiString name;
    bzAPITextureList textures;

    float     ambient[4];
    float     diffuse[4];
    float     specular[4];
    float     emisive[4];
    float     shine;

    float     alphaThresh;
    bool      culling;
    bool      sorting;
} bz_MaterialInfo;

// have bz make you a new material
bz_MaterialInfo* bz_anewMaterial ( void );
// tell bz you are done with a material
void bz_deleteMaterial ( bz_MaterialInfo *material );

BZF_API bool bz_addWorldBox ( float *pos, float rot, float* scale, bz_WorldObjectOptions options );
BZF_API bool bz_addWorldPyramid ( float *pos, float rot, float* scale, bool fliped, bz_WorldObjectOptions options );
BZF_API bool bz_addWorldBase( float *pos, float rot, float* scale, bz_eTeamType team, bz_WorldObjectOptions options );
BZF_API bool bz_addWorldTeleporter ( float *pos, float rot, float* scale, float border, bz_WorldObjectOptions options );
BZF_API bool bz_addWorldWaterLevel( float level, bz_MaterialInfo *material );
BZF_API bool bz_addWorldWeapon( const char* flagType, float *pos, float rot, float tilt, float initDelay,
                                bz_APIFloatList &delays );

BZF_API float bz_getWorldMaxHeight ( void );

BZF_API bool bz_setWorldSize( float size, float wallHeight = -1.0 );
BZF_API void bz_setClientWorldDownloadURL( const char* URL );
BZF_API const bz_ApiString bz_getClientWorldDownloadURL( void );
BZF_API bool bz_saveWorldCacheFile( const char* file );

// world
BZF_API unsigned int bz_getWorldCacheSize(void);
BZF_API unsigned int bz_getWorldCacheData(unsigned char *data);


// custom map objects

typedef struct bz_CustomMapObjectInfo
{
    bz_ApiString name;
    bz_APIStringList data;
} bz_CustomMapObjectInfo;

class bz_CustomZoneObject
{
public:
    BZF_API bz_CustomZoneObject();

    bool box;
    float xMax,xMin,yMax,yMin,zMax,zMin,radius,rotation;

    // Half height and width only for boxes
    float hh;
    float hw;

    // Center of the zone
    float cX;
    float cY;

    // Used for rotation
    float cos_val;
    float sin_val;

    BZF_API bool pointInZone(float pos[3]);
    BZF_API void handleDefaultOptions(bz_CustomMapObjectInfo *data);
};

BZF_API void bz_getRandomPoint ( bz_CustomZoneObject *obj, float *randomPos );
BZF_API bool bz_getSpawnPointWithin ( bz_CustomZoneObject *obj, float randomPos[3] );
BZF_API bool bz_isWithinWorldBoundaries ( float pos[3] );

class bz_CustomMapObjectHandler
{
public:
    virtual ~bz_CustomMapObjectHandler() {};
    virtual bool MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data ) = 0;
};

BZF_API bool bz_registerCustomMapObject ( const char* object, bz_CustomMapObjectHandler *handler );
BZF_API bool bz_removeCustomMapObject ( const char* object );


// public server info
BZF_API bool bz_getPublic( void );
BZF_API bz_ApiString bz_getPublicAddr( void );
BZF_API bz_ApiString bz_getPublicDescription( void );
BZF_API int bz_getPublicPort(void);

// plug-in management
BZF_API int bz_getLoadedPlugins(bz_APIStringList *list);
BZF_API bool bz_loadPlugin(const char* path, const char* params);
BZF_API bool bz_unloadPlugin(const char* path);

// bz_load path functions
// only valid inside the load function for a plugin
BZF_API const char* bz_pluginBinPath(void);

// custom client sounds
BZF_API bool bz_sendPlayCustomLocalSound ( int playerID, const char* soundName );

class bz_APIPluginHandler
{
public:
    virtual ~bz_APIPluginHandler() {};
    virtual bool APIPlugin ( bz_ApiString plugin, bz_ApiString param ) = 0;
};
// custom pluginHandler
BZF_API bool bz_registerCustomPluginHandler ( const char* extension, bz_APIPluginHandler * handler );
BZF_API bool bz_removeCustomPluginHandler ( const char* extension, bz_APIPluginHandler * handler );

// team info

BZF_API void bz_computeTeamScore( bool enabled );
BZF_API bool bz_computingTeamScore( void );

BZF_API int bz_getTeamCount (bz_eTeamType team );
BZF_API int bz_getTeamScore (bz_eTeamType team );
BZF_API int bz_getTeamWins (bz_eTeamType team );
BZF_API int bz_getTeamLosses (bz_eTeamType team );

BZF_API void bz_setTeamWins (bz_eTeamType team, int wins );
BZF_API void bz_setTeamLosses (bz_eTeamType team, int losses );
BZF_API void bz_incrementTeamWins (bz_eTeamType team, int increment);
BZF_API void bz_incrementTeamLosses (bz_eTeamType team, int increment);

BZF_API void bz_resetTeamScore (bz_eTeamType team );
BZF_API void bz_resetTeamScores ( void );

// list server
BZF_API void bz_updateListServer ( void );

// url API
class bz_BaseURLHandler
{
public:
    bz_BaseURLHandler()
    {
        version = 1;
    }
    virtual ~bz_BaseURLHandler() {};
    virtual void URLDone ( const char* URL, const void * data, unsigned int size, bool complete ) = 0;
    virtual void URLTimeout ( const char* /*URL*/, int /*errorCode*/ ) {};
    virtual void URLError ( const char* /*URL*/, int /*errorCode*/, const char * /*errorString*/ ) {};

    int version;
};

class bz_URLHandler_V2 : public bz_BaseURLHandler
{
public:
    bz_URLHandler_V2() : bz_BaseURLHandler()
    {
        version = 2;
        token = NULL;
    }
    void* token;
};


BZF_API bool bz_addURLJob(const char* URL, bz_BaseURLHandler* handler = NULL, const char* postData = NULL);
BZF_API bool bz_addURLJob(const char* URL, bz_URLHandler_V2* handler, void* token, const char* postData = NULL);
BZF_API bool bz_addURLJob(const char* URL, bz_URLHandler_V2* handler, void* token, const char* postData = NULL,
                          bz_APIStringList *headers = NULL);
BZF_API bool bz_removeURLJob(const char* URL);
BZF_API size_t bz_addURLJobForID(const char* URL,
                                 bz_BaseURLHandler* handler = NULL,
                                 const char* postData = NULL);
BZF_API bool bz_removeURLJobByID(size_t id);

// inter plugin communication
BZF_API bool bz_clipFieldExists ( const char *name );
BZF_API const char* bz_getclipFieldString ( const char *name );
BZF_API float bz_getclipFieldFloat ( const char *name );
BZF_API int bz_getclipFieldInt( const char *name );

BZF_API bool bz_setclipFieldString ( const char *name, const char* data );
BZF_API bool bz_setclipFieldFloat ( const char *name, float data );
BZF_API bool bz_setclipFieldInt( const char *name, int data );

class bz_ClipFieldNotifier
{
public:
    virtual ~bz_ClipFieldNotifier() {};
    virtual void fieldChange ( const char* /*field*/) = 0;
};

BZF_API bool bz_addClipFieldNotifier ( const char *name, bz_ClipFieldNotifier *cb );
BZF_API bool bz_removeClipFieldNotifier ( const char *name, bz_ClipFieldNotifier *cb );

// path checks
BZF_API bz_ApiString bz_filterPath ( const char* path );

// Record-Replay
BZF_API bool bz_saveRecBuf( const char * _filename, int seconds  = 0);
BZF_API bool bz_startRecBuf( void );
BZF_API bool bz_stopRecBuf( void );

// cheap Text Utils
BZF_API const char *bz_format(const char* fmt, ...);
BZF_API const char *bz_toupper(const char* val );
BZF_API const char *bz_tolower(const char* val );
BZF_API const char *bz_rtrim(const char* val, const char* trim = " ");
BZF_API const char *bz_ltrim(const char* val, const char* trim = " ");
BZF_API const char *bz_trim(const char* val, const char* trim = " ");
BZF_API const char *bz_join(bz_APIStringList* list, const char* delimiter = ",");
BZF_API const char *bz_urlEncode(const char* val );

// game countdown
BZF_API void bz_cancelCountdown ( int playerID );
BZF_API void bz_pauseCountdown ( int playerID );
BZF_API void bz_resumeCountdown ( int playerID );
BZF_API void bz_startCountdown ( int delay, float limit, int playerID );
BZF_API float bz_getCountdownRemaining ( void );

// @TODO deprecated game countdown commands (to be removed in 2.6.x)
BZF_API void bz_cancelCountdown ( const char *canceledBy );
BZF_API void bz_pauseCountdown ( const char *pausedBy );
BZF_API void bz_resumeCountdown ( const char *resumedBy );
BZF_API void bz_startCountdown ( int delay, float limit, const char *byWho );

// server control
BZF_API bool bz_getShotMismatch();
BZF_API void bz_setShotMismatch(bool value);
BZF_API bool bz_isAutoTeamEnabled();
BZF_API void bz_shutdown();
BZF_API void bz_superkill();
BZF_API void bz_gameOver(int playerID, bz_eTeamType team = eNoTeam);
BZF_API bool bz_restart ( void );
BZF_API const char* bz_getServerOwner();

BZF_API void bz_reloadLocalBans();
BZF_API void bz_reloadMasterBans();
BZF_API void bz_reloadGroups();
BZF_API void bz_reloadUsers();
BZF_API void bz_reloadHelp();
BZF_API void bz_reloadBadwords();

// info about the world
BZF_API bz_eTeamType bz_checkBaseAtPoint ( float pos[3] );

bz_eTeamType convertTeam ( int team );
int convertTeam( bz_eTeamType team );

// game type info
BZF_API bz_eGameType bz_getGameType ( void );
BZF_API bool bz_triggerFlagCapture(int playerID, bz_eTeamType teamCapping, bz_eTeamType teamCapped);


typedef struct
{
    int index;
    char type[2];
    int status;
    int endurance;
    int owner;
    float position[3];
    float launchPosition[3];
    float landingPosition[3];
    float flightTime;
    float flightEnd;
    float initialVelocity;
} bz_FlagUpdateRecord;

typedef struct
{
    float rank;
    int wins;
    int losses;
    int tks;
} bz_ScoreRecord;

typedef struct
{
    int id;
    int size;
    int wins;
    int losses;
} bz_TeamInfoRecord;

typedef enum
{
    eRejectBadRequest,
    eRejectBadTeam,
    eRejectBadType,
    eRejectUNUSED,
    eRejectTeamFull,
    eRejectServerFull,
    eRejectBadCallsign,
    eRejectRepeatCallsign,
    eRejectRejoinWaitTime,
    eRejectIPBanned,
    eRejectHostBanned,
    eRejectIDBanned
} bz_eRejectCodes;

typedef struct
{
    int player;
    int handicap;
} bz_HandicapUpdateRecord;

typedef enum
{
    eGotKilled,
    eGotShot,
    eGotRunOver,
    eGotCaptured,
    eGenocideEffect,
    eSelfDestruct,
    eWaterDeath,
    ePhysicsDriverDeath
} bz_ePlayerDeathReason;

class BZF_API bz_ServerSidePlayerHandler
{
public:
    bz_ServerSidePlayerHandler();
    virtual ~bz_ServerSidePlayerHandler() {}

    int getPlayerID ( void )
    {
        return playerID;
    }

    void update ( void );

    // you must call setPlayerData when this is called.
    virtual void added(int player) = 0; // it is required that the bot provide this method

    // lower level events for various things that happen in the game
    virtual void removed(void) {}

    virtual void playerAdded(int player);
    virtual void playerRemoved(int player);

    virtual void playerSpawned(int player, const float pos[3], float rot);

    virtual void textMessage(int dest, int source, const char *text);
    virtual void playerKilled(int victimIndex, int killerIndex, bz_ePlayerDeathReason reason, int shotIndex,
                              const char *flagType, int phydrv);
    virtual void scoreLimitReached(int player, bz_eTeamType team);
    virtual void flagCaptured(int player, bz_eTeamType team);

    virtual void playerStateUpdate(int player, bz_PlayerUpdateState *playerState,
                                   double timestamp); // implement when server side scoring is in
// virtual void playerScoreUpdate(int player, float rank, int wins, int losses, int TKs); // implement when server side scoring is in
    virtual void shotFired(int player, unsigned short shotID);
    virtual void shotEnded(int player, unsigned short shotID, unsigned short reason);
    virtual void playerTeleported(int player, bz_PlayerUpdateState *currentState, bz_PlayerUpdateState *lastState);

    // higher level functions for events that happen to the bot
    typedef enum
    {
        eWorldDeath,
        eServerDeath,
        eCaptureDeath,
        eOtherDeath
    } SmiteReason;

    void rejected ( bz_eRejectCodes, const char* /*reason*/) {}; // the bot was rejectd for some reason
    virtual void spawned(void); // the bot has spawned
    virtual void died ( int killer ); // the bot has died from gameplay
    virtual void smote ( SmiteReason reason = eOtherDeath ); // the bot has died from some other manner
// virtual void collide ( bz_APISolidWorldObject_V1* /*object*/, float* /*pos*/ ) {} // the bot ran into an object

    // give the bot time to do it's processing
    virtual bool think(void); // return true to kill and delete the bot;

    void setPlayerID ( int id )
    {
        playerID = id;
    }

    // actions to make
    void setPlayerData(const char *callsign,
                       const char *token, const char *clientVersion,
                       bz_eTeamType team);

    void joinGame(void);

    void respawn(void);
    void getCurrentState(bz_PlayerUpdateState *state);

    void sendServerCommand(const char* text);
    void sendChatMessage(const char* text, int targetPlayer = BZ_ALLUSERS, bz_eMessageType type = eChatMessage);
    void sendTeamChatMessage(const char *text, bz_eTeamType targetTeam, bz_eMessageType type = eChatMessage);

    void dropFlag( void );
    void setMovement(float forward, float turn);
    bool fireShot(void);
    bool jump(void);

    // state info
    bool canJump(void);
    bool canShoot(void);
    bool canMove(void);
    bool falling (void);

    void getPosition ( float *p );
    void getVelocity ( float *v );
    float getFacing ( void );

    float getMaxLinSpeed ( void );
    float getMaxRotSpeed ( void );

    // state actions
    void setAutoSpawn ( bool s = true )
    {
        autoSpawn = s;
    }

    int playerID;

private:
    float input[2];
    bool wantToJump;

    bool autoSpawn;

public:
    class BZF_API UpdateInfo
    {
    public:
        float pos[3];
        float vec[3];  // FIXME -- vel for velocity?
        float rot;     // FIXME -- radians or degrees?
        float rotVel;
        double time;

        UpdateInfo()
            : rot(0), rotVel(0), time(0)
        {
            for (int i = 0; i < 3; i++)
                pos[i] = vec[0] =0;
        }

        UpdateInfo& operator=( const UpdateInfo& u )
        {
            memcpy(pos,u.pos,sizeof(float)*3);
            memcpy(vec,u.vec,sizeof(float)*3);
            rot = u.rot;
            rotVel = u.rotVel;
            time = u.time;

            return *this;
        }
        float getDelta( const UpdateInfo & state);
    };

private:
    UpdateInfo lastUpdate;
    UpdateInfo currentState;

    int flaps;

    bool alive;
};

// *** NOTE *** support for server side players in incomplete.
//  there WILL be crashes if you add one.
// this message will be removed when the code is complete.
BZF_API int bz_addServerSidePlayer(bz_ServerSidePlayerHandler *handler);
BZF_API bool bz_removeServerSidePlayer(int playerID,
                                       bz_ServerSidePlayerHandler *handler); // you have to pass in the handler to ensure you "own" the player

// no ShotType support in 2.4 (yet?).  still accept the ShotType parameter for compatibility.
typedef int bz_eShotType;

// Note: there is NO bz_UnregisterCustomFlag, 'cause that would jack up connected clients.
// If you really need to unregister a flag, shut down the server.
BZF_API bool bz_RegisterCustomFlag(const char* abbr, const char* name,
                                   const char* helpString, bz_eShotType shotType,
                                   bz_eFlagQuality quality);


// utility
BZF_API const char* bz_MD5(const char * str);
BZF_API const char* bz_MD5(const void * data, size_t size);

BZF_API const char* bz_getServerVersion(void);
BZF_API const char* bz_getProtocolVersion(void);

BZF_API bool bz_ChatFiltered(void);
BZF_API bool bz_CallsignsFiltered(void);

BZF_API void bz_SetFiltering(bool chat, bool callsigns);
BZF_API void bz_LoadFilterDefFile(const char* fileName);
BZF_API void bz_AddFilterItem(const char* word, const char* expression = NULL);
BZF_API void bz_ClearFilter(void);

#endif //_BZFS_API_H_

// Local Variables: ***
// mode: C++ ***
// tab-width: 4 ***
// c-basic-offset: 4 ***
// indent-tabs-mode: nil ***
// End: ***
// ex: shiftwidth=4 tabstop=4