1 /* bzflag
2 * Copyright (c) 1993-2021 Tim Riker
3 *
4 * This package is free software; you can redistribute it and/or
5 * modify it under the terms of the license found in the file
6 * named COPYING that should have accompanied this file.
7 *
8 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
9 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 */
12
13 // all the exported functions for bzfs plugins
14
15 #ifndef _BZFS_API_H_
16 #define _BZFS_API_H_
17
18 /* system interface headers */
19 #include <string>
20 #include <cstring>
21 #include <vector>
22 #include <cstdlib>
23 #include <stdint.h>
24
25
26 /* DO NOT INCLUDE ANY OTHER HEADERS IN THIS FILE */
27 /* PLUGINS NEED TO BE BUILT WITHOUT THE BZ SOURCE TREE */
28 /* JUST THIS ONE FILE */
29
30 #ifdef _WIN32
31 #pragma warning( disable : 4996 )
32 #ifdef INSIDE_BZ
33 #define BZF_API __declspec( dllexport )
34 #else
35 #define BZF_API __declspec( dllimport )
36 #endif
37 #define BZF_PLUGIN_CALL extern "C" __declspec( dllexport )
38 #ifndef strcasecmp
39 #define strcasecmp stricmp
40 #endif
41 #else
42 #ifdef __clang__
43 #define BZF_API __attribute__((visibility("default")))
44 #define BZF_PLUGIN_CALL extern "C" __attribute__((visibility("default")))
45 #else
46 #define BZF_API
47 #define BZF_PLUGIN_CALL extern "C"
48 #endif
49 #endif
50
51 /* Provide a means to deprecate API functions to discourage their use
52 * in the future
53 */
54 #ifdef __GNUC__
55 # define DEPRECATED __attribute__((deprecated))
56 #elif defined(_MSC_VER)
57 # define DEPRECATED __declspec(deprecated)
58 #else
59 # pragma message("WARNING: You need to implement DEPRECATED for this compiler")
60 # define DEPRECATED
61 #endif
62
63 class bz_Plugin;
64
65 #define BZ_API_VERSION 26
66
67 #define BZ_GET_PLUGIN_VERSION BZF_PLUGIN_CALL int bz_GetMinVersion ( void ) { return BZ_API_VERSION; }
68
69 #define BZ_PLUGIN(n)\
70 BZF_PLUGIN_CALL bz_Plugin* bz_GetPlugin ( void ) { return new n; }\
71 BZF_PLUGIN_CALL void bz_FreePlugin ( bz_Plugin* plugin ) { delete(plugin); }\
72 BZF_PLUGIN_CALL int bz_GetMinVersion ( void ) { return BZ_API_VERSION; }
73
74 /** This is so we can use gcc's "format string vs arguments"-check
75 * for various printf-like functions, and still maintain compatability.
76 * Not tested on other platforms yet, but should work. */
77 #ifndef __attribute__
78 /* This feature is available in gcc versions 2.5 and later. */
79 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
80 # define __attribute__(Spec) /* empty */
81 # endif
82 /* The __-protected variants of `format' and `printf' attributes
83 * are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
84 # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
85 # define __format__ format
86 # define __printf__ printf
87 # endif
88 #endif
89
90 /** shorthand defines to make the code cleaner. */
91 #define _ATTRIBUTE34 __attribute__ ((__format__ (__printf__, 3, 4)))
92 #define _ATTRIBUTE23 __attribute__ ((__format__ (__printf__, 2, 3)))
93 #define _ATTRIBUTE12 __attribute__ ((__format__ (__printf__, 1, 2)))
94
95 #ifdef __cplusplus
96 # ifndef DEFINED_FORCE_CAST
97 # define DEFINED_FORCE_CAST
98 template<class To, class From>
force_cast(From const & f)99 inline To force_cast(From const & f)
100 {
101 union
102 {
103 From f;
104 To t;
105 } fc;
106 fc.f = f;
107 return fc.t;
108 }
109 # endif
110 #endif
111
112 typedef enum
113 {
114 eGoodFlag = 0,
115 eBadFlag,
116 eLastFlagQuality
117 } bz_eFlagQuality;
118
119 //utility classes
120 class BZF_API bz_ApiString
121 {
122 public:
123 bz_ApiString();
124 bz_ApiString(const char* c);
125 bz_ApiString(const std::string &s);
126 bz_ApiString(const bz_ApiString &r);
127
128 ~bz_ApiString();
129
130 bz_ApiString& operator=( const bz_ApiString& r );
131 bz_ApiString& operator=( const std::string& r );
132 bz_ApiString& operator=( const char* r );
133
134 bool operator==( const bz_ApiString&r );
135 bool operator==( const std::string& r );
136 bool operator==( const char* r );
137
138 bool operator!=( const bz_ApiString&r );
139 bool operator!=( const std::string& r );
140 bool operator!=( const char* r );
141
142 bz_ApiString& operator+=( const bz_ApiString& r );
143 bz_ApiString& operator+=( const std::string& r );
144 bz_ApiString& operator+=( const char* r );
145
146 unsigned int size ( void ) const;
147 bool empty ( void ) const;
148
149 const char* c_str(void) const;
150
151 void format(const char* fmt, ...);
152
153 void replaceAll ( const char* target, const char* with );
154
155 void tolower ( void );
156 void toupper ( void );
157 void urlEncode ( void );
158
159 protected:
160 class dataBlob
161 {
162 public:
163 std::string str;
164 };
165
166 dataBlob *data;
167
168 public:
169 // Conversion/cast operator
string()170 operator std::string() const
171 {
172 return this->data->str;
173 }
174 };
175
176 class BZF_API bz_APIIntList
177 {
178 public:
179 bz_APIIntList();
180 bz_APIIntList(const bz_APIIntList &r);
181 bz_APIIntList(const std::vector<int> &r);
182
183 ~bz_APIIntList();
184
185 void push_back ( int value );
186 int get ( unsigned int i );
187
188 const int& operator[](unsigned int i) const;
189 bz_APIIntList& operator=( const bz_APIIntList& r );
190 bz_APIIntList& operator=( const std::vector<int>& r );
191
192 unsigned int size ( void );
193 void clear ( void );
194
195 protected:
196 class dataBlob;
197
198 dataBlob *data;
199 };
200
201 BZF_API bz_APIIntList* bz_newIntList ( void );
202 BZF_API void bz_deleteIntList( bz_APIIntList * l );
203
204 class BZF_API bz_APIFloatList
205 {
206 public:
207 bz_APIFloatList();
208 bz_APIFloatList(const bz_APIFloatList &r);
209 bz_APIFloatList(const std::vector<float> &r);
210
211 ~bz_APIFloatList();
212
213 void push_back ( float value );
214 float get ( unsigned int i );
215
216 const float& operator[](unsigned int i) const;
217 bz_APIFloatList& operator=( const bz_APIFloatList& r );
218 bz_APIFloatList& operator=( const std::vector<float>& r );
219
220 unsigned int size ( void );
221 void clear ( void );
222
223 protected:
224 class dataBlob;
225
226 dataBlob *data;
227 };
228
229 BZF_API bz_APIFloatList* bz_newFloatList ( void );
230 BZF_API void bz_deleteFloatList( bz_APIFloatList * l );
231
232 class BZF_API bz_APIStringList
233 {
234 public:
235 bz_APIStringList();
236 bz_APIStringList(const bz_APIStringList &r);
237 bz_APIStringList(const std::vector<std::string> &r);
238
239 ~bz_APIStringList();
240
241 void push_back ( const bz_ApiString &value );
242 void push_back ( const std::string &value );
243 bz_ApiString get ( unsigned int i ) const;
244
245 const bz_ApiString& operator[](unsigned int i) const;
246 bz_APIStringList& operator=( const bz_APIStringList& r );
247 bz_APIStringList& operator=( const std::vector<std::string>& r );
248
249 const char* join(const char* delimiter = ",");
250 bool contains(const std::string &needle);
251
252 unsigned int size ( void ) const;
253 void clear ( void );
254
255 void tokenize ( const char* in, const char* delims, int maxTokens = 0, bool useQuotes = false);
256 protected:
257 class dataBlob;
258
259 dataBlob *data;
260 };
261
262 BZF_API bz_APIStringList* bz_newStringList ( void );
263 BZF_API void bz_deleteStringList( bz_APIStringList * l );
264
265 // current time (leave method here, used in bz_EventData constructor)
266 BZF_API double bz_getCurrentTime(void);
267
268 // versioning
269 BZF_API int bz_APIVersion ( void );
270
271 // event stuff
272
273 typedef enum
274 {
275 bz_eNullEvent = 0,
276 bz_eCaptureEvent,
277 bz_ePlayerDieEvent,
278 bz_ePlayerSpawnEvent,
279 bz_eZoneEntryEvent,
280 bz_eZoneExitEvent,
281 bz_ePlayerJoinEvent,
282 bz_ePlayerPartEvent,
283 bz_eRawChatMessageEvent, // before filter
284 bz_eFilteredChatMessageEvent, // after filter
285 bz_eUnknownSlashCommand,
286 bz_eGetPlayerSpawnPosEvent,
287 bz_eGetAutoTeamEvent,
288 bz_eAllowPlayer,
289 bz_eTickEvent,
290 bz_eGetWorldEvent,
291 bz_eGetPlayerInfoEvent,
292 bz_eAllowSpawn,
293 bz_eListServerUpdateEvent,
294 bz_eBanEvent,
295 bz_eHostBanModifyEvent,
296 bz_eKickEvent,
297 bz_eKillEvent,
298 bz_ePlayerPausedEvent,
299 bz_eMessageFilteredEvent,
300 bz_eGamePauseEvent,
301 bz_eGameResumeEvent,
302 bz_eGameStartEvent,
303 bz_eGameEndEvent,
304 bz_eSlashCommandEvent,
305 bz_ePlayerAuthEvent,
306 bz_eServerMsgEvent,
307 bz_eShotFiredEvent,
308 bz_ePlayerUpdateEvent,
309 bz_eNetDataSendEvent,
310 bz_eNetDataReceiveEvent,
311 bz_eLoggingEvent,
312 bz_eShotEndedEvent,
313 bz_eFlagTransferredEvent,
314 bz_eFlagGrabbedEvent,
315 bz_eFlagDroppedEvent,
316 bz_eAllowCTFCaptureEvent,
317 bz_eMsgDebugEvent,
318 bz_eNewNonPlayerConnection,
319 bz_ePluginLoaded,
320 bz_ePluginUnloaded,
321 bz_ePlayerScoreChanged,
322 bz_eTeamScoreChanged,
323 bz_eWorldFinalized,
324 bz_eReportFiledEvent,
325 bz_eBZDBChange,
326 bz_eGetPlayerMotto,
327 bz_eAllowConnection,
328 bz_eAllowFlagGrab,
329 bz_eAuthenticatonComplete,
330 bz_eServerAddPlayer,
331 bz_eAllowPollEvent,
332 bz_ePollStartEvent,
333 bz_ePollVoteEvent,
334 bz_ePollVetoEvent,
335 bz_ePollEndEvent,
336 bz_eComputeHandicapEvent,
337 bz_eBeginHandicapRefreshEvent,
338 bz_eEndHandicapRefreshEvent,
339 bz_eAutoPilotEvent,
340 bz_eMuteEvent,
341 bz_eUnmuteEvent,
342 bz_eServerShotFiredEvent,
343 bz_ePermissionModificationEvent,
344 bz_eAllowServerShotFiredEvent,
345 bz_ePlayerDeathFinalizedEvent,
346 bz_eLastEvent //this is never used as an event, just show it's the last one
347 } bz_eEventType;
348
349 // permision #defines
350 #define bz_perm_actionMessage "actionMessage"
351 #define bz_perm_adminMessageReceive "adminMessageReceive"
352 #define bz_perm_adminMessageSend "adminMessageSend"
353 #define bz_perm_antiban "antiban"
354 #define bz_perm_antikick "antikick"
355 #define bz_perm_antikill "antikill"
356 #define bz_perm_antipoll "antipoll"
357 #define bz_perm_antipollban "antipollban"
358 #define bz_perm_antipollkick "antipollkick"
359 #define bz_perm_antipollkill "antipollkill"
360 #define bz_perm_ban "ban"
361 #define bz_perm_banlist "banlist"
362 #define bz_perm_clientQuery "clientQuery"
363 #define bz_perm_countdown "countdown"
364 #define bz_perm_date "date"
365 #define bz_perm_endGame "endGame"
366 #define bz_perm_flagHistory "flagHistory"
367 #define bz_perm_flagMod "flagMod"
368 #define bz_perm_hideAdmin "hideAdmin"
369 #define bz_perm_idleStats "idleStats"
370 #define bz_perm_info "info"
371 #define bz_perm_kick "kick"
372 #define bz_perm_kill "kill"
373 #define bz_perm_lagStats "lagStats"
374 #define bz_perm_lagwarn "lagwarn"
375 #define bz_perm_listPerms "listPerms"
376 #define bz_perm_listPlugins "listPlugins"
377 #define bz_perm_masterBan "masterban"
378 #define bz_perm_mute "mute"
379 #define bz_perm_playerList "playerList"
380 #define bz_perm_plugins "plugins"
381 #define bz_perm_poll "poll"
382 #define bz_perm_pollBan "pollBan"
383 #define bz_perm_pollKick "pollKick"
384 #define bz_perm_pollKill "pollKill"
385 #define bz_perm_pollSet "pollSet"
386 #define bz_perm_pollFlagReset "pollFlagReset"
387 #define bz_perm_privateMessage "privateMessage"
388 #define bz_perm_record "record"
389 #define bz_perm_rejoin "rejoin"
390 #define bz_perm_removePerms "removePerms"
391 #define bz_perm_replay "replay"
392 #define bz_perm_report "report"
393 #define bz_perm_say "say"
394 #define bz_perm_sendHelp "sendHelp"
395 #define bz_perm_setAll "setAll"
396 #define bz_perm_setPerms "setPerms"
397 #define bz_perm_setVar "setVar"
398 #define bz_perm_showAdmin "showAdmin"
399 #define bz_perm_showMotto "showMotto"
400 #define bz_perm_showOthers "showOthers"
401 #define bz_perm_shortBan "shortBan"
402 #define bz_perm_shutdownServer "shutdownServer"
403 #define bz_perm_spawn "spawn"
404 #define bz_perm_superKill "superKill"
405 #define bz_perm_talk "talk"
406 #define bz_perm_unban "unban"
407 #define bz_perm_unmute "unmute"
408 #define bz_perm_veto "veto"
409 #define bz_perm_viewReports "viewReports"
410 #define bz_perm_vote "vote"
411
412 // types of text messages
413 typedef enum
414 {
415 eChatMessage,
416 eActionMessage
417 } bz_eMessageType;
418
419 typedef enum
420 {
421 eNoTeam = -1,
422 eRogueTeam = 0,
423 eRedTeam,
424 eGreenTeam,
425 eBlueTeam,
426 ePurpleTeam,
427 eRabbitTeam,
428 eHunterTeam,
429 eObservers,
430 eAdministrators
431 } bz_eTeamType;
432
433 #define BZ_SERVER -2
434 #define BZ_ALLUSERS -1
435 #define BZ_NULLUSER -3
436
437 #define BZ_PUBLICCHAT 254
438 #define BZ_ADMINCHAT 252
439 #define BZ_ROGUECHAT 251
440 #define BZ_REDCHAT 250
441 #define BZ_GREENCHAT 249
442 #define BZ_BLUECHAT 248
443 #define BZ_PURPLECHAT 247
444 #define BZ_OBSERVERCHAT 246
445 #define BZ_RABBITCHAT 245
446 #define BZ_HUNTERCHAT 244
447
448 #define BZ_SERVERPLAYER 253
449 #define BZ_LASTREALPLAYER 243
450
451 #define BZ_BZDBPERM_NA 0
452 #define BZ_BZDBPERM_USER 1
453 #define BZ_BZDBPERM_SERVER 2
454 #define BZ_BZDBPERM_CLIENT 3
455
456 typedef enum
457 {
458 eFFAGame= 0,
459 eOpenFFAGame,
460 eCTFGame,
461 eRabbitGame
462 } bz_eGameType;
463
464 // defined later but used in some event objects
465 class bz_BasePlayerRecord;
466
467 typedef enum
468 {
469 eDead, // not alive, not paused, etc.
470 eAlive, // player is alive
471 ePaused, // player is paused
472 eExploding, // currently blowing up
473 eTeleporting // teleported recently
474 } bz_ePlayerStatus;
475
476 typedef struct bz_PlayerUpdateState
477 {
478 bz_ePlayerStatus status; // special states
479 bool falling; // not driving on the ground or an obstacle
480 bool crossingWall; // crossing an obstacle wall
481 bool inPhantomZone; // zoned
482 float pos[3]; // position of tank
483 float velocity[3]; // velocity of tank
484 float rotation; // orientation of tank
485 float angVel; // angular velocity of tank
486 int phydrv; // physics driver
487 } bz_PlayerUpdateState;
488
489
490 BZF_API bool bz_freePlayerRecord ( bz_BasePlayerRecord *playerRecord );
491
492 // event data types
493 class BZF_API bz_EventData
494 {
495 public:
496 bz_EventData(bz_eEventType type = bz_eNullEvent)
497 : version(1), eventType(type), eventTime( bz_getCurrentTime() )
498 {
499 }
~bz_EventData()500 virtual ~bz_EventData() {}
update()501 virtual void update() {}
502
503 int version;
504 bz_eEventType eventType;
505 double eventTime;
506 };
507
508 class BZF_API bz_CTFCaptureEventData_V1 : public bz_EventData
509 {
510 public:
bz_CTFCaptureEventData_V1()511 bz_CTFCaptureEventData_V1() : bz_EventData(bz_eCaptureEvent)
512 , teamCapped(eNoTeam), teamCapping(eNoTeam), playerCapping(-1)
513 , rot(0.0)
514 {
515 memset(pos,0,sizeof(float)*3);
516 }
517
518 bz_eTeamType teamCapped;
519 bz_eTeamType teamCapping;
520 int playerCapping;
521
522 float pos[3];
523 float rot;
524 };
525
526 class BZF_API bz_PlayerDieEventData_V1 : public bz_EventData
527 {
528 public:
bz_PlayerDieEventData_V1()529 bz_PlayerDieEventData_V1() : bz_EventData(bz_ePlayerDieEvent)
530 , playerID(-1), team(eNoTeam), killerID(-1), killerTeam(eNoTeam)
531 , shotID(-1), driverID(-1), state()
532 {
533 }
534
535 int playerID;
536 bz_eTeamType team;
537 int killerID;
538 bz_eTeamType killerTeam;
539 bz_ApiString flagKilledWith;
540 int shotID;
541 int driverID;
542
543 bz_PlayerUpdateState state;
544 };
545
546 class BZF_API bz_PlayerDieEventData_V2 : public bz_PlayerDieEventData_V1
547 {
548 public:
bz_PlayerDieEventData_V2()549 bz_PlayerDieEventData_V2() : bz_PlayerDieEventData_V1()
550 , flagHeldWhenKilled(-1)
551 {}
552
553 int flagHeldWhenKilled;
554 };
555
556 class BZF_API bz_PlayerSpawnEventData_V1 : public bz_EventData
557 {
558 public:
bz_PlayerSpawnEventData_V1()559 bz_PlayerSpawnEventData_V1() : bz_EventData(bz_ePlayerSpawnEvent)
560 , playerID(-1), team(eNoTeam), state()
561 {
562 }
563
564 int playerID;
565 bz_eTeamType team;
566 bz_PlayerUpdateState state;
567 };
568
569 class BZF_API bz_ChatEventData_V1 : public bz_EventData
570 {
571 public:
bz_ChatEventData_V1()572 bz_ChatEventData_V1() : bz_EventData(bz_eRawChatMessageEvent)
573 , from(-1), to(-1), team(eNoTeam)
574 {
575 }
576
577 int from;
578 int to;
579 bz_eTeamType team;
580 bz_ApiString message;
581 };
582
583 class BZF_API bz_ChatEventData_V2 : public bz_ChatEventData_V1
584 {
585 public:
bz_ChatEventData_V2()586 bz_ChatEventData_V2() : bz_ChatEventData_V1()
587 , messageType(eChatMessage)
588 {
589 }
590
591 bz_eMessageType messageType;
592 };
593
594 class BZF_API bz_PlayerJoinPartEventData_V1 : public bz_EventData
595 {
596 public:
bz_PlayerJoinPartEventData_V1()597 bz_PlayerJoinPartEventData_V1() : bz_EventData(bz_ePlayerJoinEvent)
598 , playerID(-1), record(0)
599 {
600 }
~bz_PlayerJoinPartEventData_V1()601 ~bz_PlayerJoinPartEventData_V1()
602 {
603 bz_freePlayerRecord(record);
604 }
605
606 int playerID;
607 bz_BasePlayerRecord* record;
608 bz_ApiString reason;
609 };
610
611 class BZF_API bz_UnknownSlashCommandEventData_V1 : public bz_EventData
612 {
613 public:
bz_UnknownSlashCommandEventData_V1()614 bz_UnknownSlashCommandEventData_V1() : bz_EventData(bz_eUnknownSlashCommand)
615 , from(-1), handled(false)
616 {
617 }
618
619 int from;
620
621 bool handled;
622 bz_ApiString message;
623 };
624
625 class BZF_API bz_GetPlayerSpawnPosEventData_V1 : public bz_EventData
626 {
627 public:
bz_GetPlayerSpawnPosEventData_V1()628 bz_GetPlayerSpawnPosEventData_V1() : bz_EventData(bz_eGetPlayerSpawnPosEvent)
629 , playerID(-1), team(eNoTeam), handled(false)
630 , rot(0.0)
631 {
632 pos[0] = pos[1] = pos[2] = 0.0f;
633 }
634
635 int playerID;
636 bz_eTeamType team;
637
638 bool handled;
639
640 float pos[3];
641 float rot;
642 };
643
644 class BZF_API bz_AllowPlayerEventData_V1 : public bz_EventData
645 {
646 public:
bz_AllowPlayerEventData_V1()647 bz_AllowPlayerEventData_V1() : bz_EventData(bz_eAllowPlayer)
648 , playerID(-1)
649 , allow(true)
650 {
651 }
652
653 int playerID;
654 bz_ApiString callsign;
655 bz_ApiString ipAddress;
656
657 bz_ApiString reason;
658 bool allow;
659 };
660
661 class BZF_API bz_TickEventData_V1 : public bz_EventData
662 {
663 public:
bz_TickEventData_V1()664 bz_TickEventData_V1() : bz_EventData(bz_eTickEvent)
665 {
666 }
667 };
668
669 class BZF_API bz_GetWorldEventData_V1 : public bz_EventData
670 {
671 public:
bz_GetWorldEventData_V1()672 bz_GetWorldEventData_V1() : bz_EventData(bz_eGetWorldEvent)
673 , generated(false)
674 , ctf(false)
675 , rabbit(false)
676 , openFFA(false)
677 , worldBlob(NULL)
678 {
679 }
680
681 bool generated;
682 bool ctf;
683 bool rabbit;
684 bool openFFA;
685
686 bz_ApiString worldFile;
687 char* worldBlob; // if assigned, the world will be read from this NUL
688 // terminated string. BZFS does not free this memory,
689 // so the plugin must do so (this can be done in the
690 // WorldFinalize event)
691 };
692
693 class BZF_API bz_GetPlayerInfoEventData_V1 : public bz_EventData
694 {
695 public:
bz_GetPlayerInfoEventData_V1()696 bz_GetPlayerInfoEventData_V1() : bz_EventData(bz_eGetPlayerInfoEvent)
697 , playerID(-1), team(eNoTeam)
698 , admin(false), verified(false), registered(false)
699 {
700 }
701
702 int playerID;
703 bz_ApiString callsign;
704 bz_ApiString ipAddress;
705
706 bz_eTeamType team;
707
708 bool admin;
709 bool verified;
710 bool registered;
711 };
712
713 class BZF_API bz_GetAutoTeamEventData_V1 : public bz_EventData
714 {
715 public:
bz_GetAutoTeamEventData_V1()716 bz_GetAutoTeamEventData_V1() : bz_EventData(bz_eGetAutoTeamEvent)
717 , playerID(-1), team(eNoTeam)
718 , handled(false)
719 {
720 }
721
722 int playerID;
723 bz_ApiString callsign;
724 bz_eTeamType team;
725
726 bool handled;
727 };
728
729 class BZF_API bz_AllowSpawnData_V1 : public bz_EventData
730 {
731 public:
bz_AllowSpawnData_V1()732 bz_AllowSpawnData_V1() : bz_EventData(bz_eAllowSpawn)
733 , playerID(-1), team(eNoTeam)
734 , handled(false), allow(true)
735 {
736 }
737
738 int playerID;
739 bz_eTeamType team;
740
741 bool handled;
742 bool allow;
743 };
744
745
746
747 class BZF_API bz_AllowSpawnData_V2 : public bz_AllowSpawnData_V1
748 {
749 public:
bz_AllowSpawnData_V2()750 bz_AllowSpawnData_V2() : bz_AllowSpawnData_V1()
751 , kickPlayer(true), kickReason("Not allowed to spawn")
752 , message("You are not allowed to spawn. Please contact an administrator.")
753 {
754 }
755
756 bool kickPlayer;
757 bz_ApiString kickReason;
758 bz_ApiString message;
759 };
760
761 class BZF_API bz_ListServerUpdateEvent_V1 : public bz_EventData
762 {
763 public:
bz_ListServerUpdateEvent_V1()764 bz_ListServerUpdateEvent_V1() : bz_EventData(bz_eListServerUpdateEvent)
765 , handled(false)
766 {
767 }
768
769 bz_ApiString address;
770 bz_ApiString description;
771 bz_ApiString groups;
772
773 bool handled;
774 };
775
776 class BZF_API bz_BanEventData_V1 : public bz_EventData
777 {
778 public:
bz_BanEventData_V1()779 bz_BanEventData_V1() : bz_EventData(bz_eBanEvent)
780 , bannerID(-1), banneeID(-1), duration(-1)
781 {
782 }
783
784 int bannerID;
785 int banneeID;
786 int duration;
787 bz_ApiString ipAddress;
788 bz_ApiString reason;
789 };
790
791 class BZF_API bz_HostBanEventData_V1 : public bz_EventData
792 {
793 public:
bz_HostBanEventData_V1()794 bz_HostBanEventData_V1() : bz_EventData(bz_eHostBanModifyEvent)
795 , bannerID(-1), duration(-1)
796 {
797 }
798
799 int bannerID;
800 int duration;
801 bz_ApiString hostPattern;
802 bz_ApiString reason;
803 };
804
805 class BZF_API bz_KickEventData_V1 : public bz_EventData
806 {
807 public:
bz_KickEventData_V1()808 bz_KickEventData_V1() : bz_EventData(bz_eKickEvent)
809 , kickerID(-1), kickedID(-1)
810 {
811 }
812
813 int kickerID;
814 int kickedID;
815 bz_ApiString reason;
816 };
817
818 class BZF_API bz_KillEventData_V1 : public bz_EventData
819 {
820 public:
bz_KillEventData_V1()821 bz_KillEventData_V1() : bz_EventData(bz_eKillEvent)
822 , killerID(-1), killedID(-1)
823 {
824 }
825
826 int killerID;
827 int killedID;
828 bz_ApiString reason;
829 };
830
831 class BZF_API bz_PlayerPausedEventData_V1 : public bz_EventData
832 {
833 public:
bz_PlayerPausedEventData_V1()834 bz_PlayerPausedEventData_V1() : bz_EventData(bz_ePlayerPausedEvent)
835 , playerID(-1), pause(false)
836 {
837 }
838
839 int playerID;
840 bool pause;
841 };
842
843 class BZF_API bz_MessageFilteredEventData_V1 : public bz_EventData
844 {
845 public:
bz_MessageFilteredEventData_V1()846 bz_MessageFilteredEventData_V1() : bz_EventData(bz_eMessageFilteredEvent)
847 , playerID(-1)
848 {
849 }
850
851 int playerID;
852
853 bz_ApiString rawMessage;
854 bz_ApiString filteredMessage;
855 };
856
857 class BZF_API bz_GamePauseResumeEventData_V1 : public bz_EventData
858 {
859 public:
bz_GamePauseResumeEventData_V1()860 bz_GamePauseResumeEventData_V1() : bz_EventData(bz_eGameResumeEvent)
861 , actionBy("SERVER")
862 {
863 }
864
865 bz_ApiString actionBy;
866 };
867
868 class BZF_API bz_GamePauseResumeEventData_V2 : public bz_GamePauseResumeEventData_V1
869 {
870 public:
bz_GamePauseResumeEventData_V2()871 bz_GamePauseResumeEventData_V2() : bz_GamePauseResumeEventData_V1()
872 , playerID(253)
873 {
874 }
875
876 int playerID;
877 };
878
879 class BZF_API bz_GameStartEndEventData_V1 : public bz_EventData
880 {
881 public:
bz_GameStartEndEventData_V1()882 bz_GameStartEndEventData_V1() : bz_EventData(bz_eGameStartEvent)
883 , duration(0.0)
884 {
885 }
886
887 double duration;
888 };
889
890 class BZF_API bz_GameStartEndEventData_V2 : public bz_GameStartEndEventData_V1
891 {
892 public:
bz_GameStartEndEventData_V2()893 bz_GameStartEndEventData_V2() : bz_GameStartEndEventData_V1()
894 , playerID(253), gameOver(false)
895 {
896 }
897
898 int playerID;
899 bool gameOver;
900 };
901
902 class BZF_API bz_SlashCommandEventData_V1 : public bz_EventData
903 {
904 public:
bz_SlashCommandEventData_V1()905 bz_SlashCommandEventData_V1() : bz_EventData(bz_eSlashCommandEvent)
906 , from(-1)
907 {
908 }
909
910 int from;
911
912 bz_ApiString message;
913 };
914
915 class BZF_API bz_SlashCommandEventData_V2 : public bz_SlashCommandEventData_V1
916 {
917 public:
bz_SlashCommandEventData_V2()918 bz_SlashCommandEventData_V2() : bz_SlashCommandEventData_V1(), sourceChannel(-1)
919 {
920 }
921
922 int sourceChannel;
923 };
924
925 class BZF_API bz_AllowPollEventData_V1 : public bz_EventData
926 {
927 public:
bz_AllowPollEventData_V1()928 bz_AllowPollEventData_V1() : bz_EventData(bz_eAllowPollEvent),
929 playerID(BZ_SERVER), pollAction(""), pollTarget(""), allow(true), reason("")
930 {}
931
932 int playerID;
933
934 // 'kick', 'kill', 'ban', 'set', 'reset', or custom value from a plug-in
935 bz_ApiString pollAction;
936
937 // If it's a 'kick', 'kill' or 'ban', this will be the victim's callsign
938 // If it's a 'set', this will be e.g. '_mirror black'
939 // If it's a 'reset', this will be 'flags'
940 bz_ApiString pollTarget;
941
942 bool allow;
943 bz_ApiString reason;
944 };
945
946 class BZF_API bz_PollStartEventData_V1 : public bz_EventData
947 {
948 public:
bz_PollStartEventData_V1()949 bz_PollStartEventData_V1() : bz_EventData(bz_ePollStartEvent),
950 playerID(BZ_SERVER), pollAction(""), pollTarget("")
951 {}
952
953 int playerID;
954
955 // See bz_AllowPollEventData_V1 for notes
956 bz_ApiString pollAction;
957 bz_ApiString pollTarget;
958 };
959
960 class BZF_API bz_PollVoteEventData_V1 : public bz_EventData
961 {
962 public:
bz_PollVoteEventData_V1()963 bz_PollVoteEventData_V1() : bz_EventData(bz_ePollVoteEvent),
964 playerID(BZ_SERVER), inFavor(false), allow(true), reason("")
965 {}
966
967 int playerID;
968 bool inFavor;
969
970 bool allow;
971 bz_ApiString reason;
972 };
973
974 class BZF_API bz_PollVetoEventData_V1 : public bz_EventData
975 {
976 public:
bz_PollVetoEventData_V1()977 bz_PollVetoEventData_V1() : bz_EventData(bz_ePollVetoEvent),
978 playerID(BZ_SERVER)
979 {}
980
981 int playerID;
982 };
983
984 class BZF_API bz_PollEndEventData_V1 : public bz_EventData
985 {
986 public:
bz_PollEndEventData_V1()987 bz_PollEndEventData_V1() : bz_EventData(bz_ePollEndEvent),
988 successful(false), yesCount(0), noCount(0), abstentionCount(0)
989 {}
990
991 bool successful;
992 int yesCount;
993 int noCount;
994 int abstentionCount;
995 };
996
997 class BZF_API bz_PlayerAuthEventData_V1 : public bz_EventData
998 {
999 public:
bz_PlayerAuthEventData_V1()1000 bz_PlayerAuthEventData_V1() : bz_EventData(bz_ePlayerAuthEvent)
1001 , playerID(-1), password(false), globalAuth(false)
1002 {
1003 }
1004
1005 int playerID;
1006 bool password;
1007 bool globalAuth;
1008 };
1009
1010 class BZF_API bz_ServerMsgEventData_V1 : public bz_EventData
1011 {
1012 public:
bz_ServerMsgEventData_V1()1013 bz_ServerMsgEventData_V1() : bz_EventData(bz_eServerMsgEvent)
1014 , to(-1), team(eNoTeam)
1015 {
1016 }
1017
1018 int to;
1019 bz_eTeamType team;
1020 bz_ApiString message;
1021 };
1022
1023 class BZF_API bz_ShotFiredEventData_V1 : public bz_EventData
1024 {
1025 public:
bz_ShotFiredEventData_V1()1026 bz_ShotFiredEventData_V1() : bz_EventData(bz_eShotFiredEvent)
1027 , changed(false)
1028 , playerID(-1)
1029 , shotID(-1)
1030 {
1031 pos[0] = pos[1] = pos[2] = 0.0f;
1032 vel[0] = vel[1] = vel[2] = 0.0f;
1033 }
1034
1035 bool changed;
1036 float pos[3];
1037 float vel[3];
1038 bz_ApiString type;
1039 int playerID;
1040 int shotID;
1041 };
1042
1043 class BZF_API bz_AllowServerShotFiredEventData_V1 : public bz_EventData
1044 {
1045 public:
bz_AllowServerShotFiredEventData_V1()1046 bz_AllowServerShotFiredEventData_V1() : bz_EventData(bz_eAllowServerShotFiredEvent)
1047 , allow(true)
1048 , changed(false)
1049 , flagType("")
1050 , team(eRogueTeam)
1051 {
1052 speed = pos[0] = pos[1] = pos[2] = velocity[0] = velocity[1] = velocity[2] = 0.0f;
1053 }
1054
1055 bool allow;
1056 bool changed;
1057 bz_ApiString flagType;
1058 float speed;
1059 float pos[3];
1060 float velocity[3];
1061 bz_eTeamType team;
1062 };
1063
1064 class BZF_API bz_ServerShotFiredEventData_V1 : public bz_EventData
1065 {
1066 public:
bz_ServerShotFiredEventData_V1()1067 bz_ServerShotFiredEventData_V1() : bz_EventData(bz_eServerShotFiredEvent)
1068 , guid(0)
1069 , speed(0)
1070 , team(eRogueTeam)
1071 {
1072 pos[0] = pos[1] = pos[2] = velocity[0] = velocity[1] = velocity[2] = 0.0f;
1073 }
1074
1075 uint32_t guid;
1076 bz_ApiString flagType;
1077 float speed;
1078 float pos[3];
1079 float velocity[3];
1080 bz_eTeamType team;
1081 };
1082
1083 class BZF_API bz_PlayerUpdateEventData_V1 : public bz_EventData
1084 {
1085 public:
bz_PlayerUpdateEventData_V1()1086 bz_PlayerUpdateEventData_V1() : bz_EventData(bz_ePlayerUpdateEvent)
1087 , playerID(-1), state(), lastState(), stateTime(0.0)
1088 {
1089 }
1090
1091 int playerID;
1092 bz_PlayerUpdateState state;
1093 bz_PlayerUpdateState lastState;
1094 double stateTime;
1095 };
1096
1097 class BZF_API bz_ComputeHandicap_V1 : public bz_EventData
1098 {
1099 public:
bz_ComputeHandicap_V1()1100 bz_ComputeHandicap_V1() : bz_EventData(bz_eComputeHandicapEvent)
1101 , playerID(-1), desiredHandicap(0)
1102 {
1103 }
1104
1105 int playerID;
1106 int desiredHandicap;
1107 };
1108
1109 class BZF_API bz_NetTransferEventData_V1 : public bz_EventData
1110 {
1111 public:
bz_NetTransferEventData_V1()1112 bz_NetTransferEventData_V1() : bz_EventData(bz_eNetDataReceiveEvent)
1113 , send(false), udp(false), iSize(0), playerID(-1)
1114 , data(NULL)
1115 {
1116 }
1117
1118 bool send;
1119 bool udp;
1120 unsigned int iSize;
1121 int playerID;
1122
1123 // DON'T CHANGE THIS!!!
1124 unsigned char* data;
1125 };
1126
1127 class BZF_API bz_LoggingEventData_V1 : public bz_EventData
1128 {
1129 public:
bz_LoggingEventData_V1()1130 bz_LoggingEventData_V1() : bz_EventData(bz_eLoggingEvent)
1131 , level(0)
1132 {
1133 }
1134
1135 int level;
1136 bz_ApiString message;
1137 };
1138
1139 class BZF_API bz_ShotEndedEventData_V1 : public bz_EventData
1140 {
1141 public:
1142
bz_ShotEndedEventData_V1()1143 bz_ShotEndedEventData_V1() : bz_EventData(bz_eShotEndedEvent)
1144 , playerID(-1)
1145 , shotID(-1)
1146 , explode(false)
1147 {
1148 }
1149
1150 int playerID;
1151 int shotID;
1152 bool explode;
1153 };
1154
1155 class BZF_API bz_FlagTransferredEventData_V1 : public bz_EventData
1156 {
1157 public:
1158 enum Action
1159 {
1160 ContinueSteal = 0,
1161 CancelSteal = 1,
1162 DropThief = 2
1163 };
1164
bz_FlagTransferredEventData_V1()1165 bz_FlagTransferredEventData_V1() : bz_EventData(bz_eFlagTransferredEvent)
1166 , fromPlayerID(0), toPlayerID(0), flagType(NULL), action(ContinueSteal)
1167 {
1168 }
1169
1170 int fromPlayerID;
1171 int toPlayerID;
1172 const char* flagType;
1173 enum Action action;
1174 };
1175
1176 class BZF_API bz_FlagGrabbedEventData_V1 : public bz_EventData
1177 {
1178 public:
1179
bz_FlagGrabbedEventData_V1()1180 bz_FlagGrabbedEventData_V1() : bz_EventData(bz_eFlagGrabbedEvent)
1181 , playerID(-1), flagID(-1)
1182 , flagType(NULL)
1183 {
1184 pos[0] = pos[1] = pos[2] = 0;
1185 }
1186
1187 int playerID;
1188 int flagID;
1189
1190 const char* flagType;
1191 float pos[3];
1192 };
1193
1194 class BZF_API bz_FlagDroppedEventData_V1 : public bz_EventData
1195 {
1196 public:
1197
bz_FlagDroppedEventData_V1()1198 bz_FlagDroppedEventData_V1() : bz_EventData(bz_eFlagDroppedEvent)
1199 , playerID(-1), flagID(-1), flagType(NULL)
1200 {
1201 pos[0] = pos[1] = pos[2] = 0;
1202 }
1203
1204 int playerID;
1205 int flagID;
1206
1207 const char* flagType;
1208 float pos[3];
1209 };
1210
1211 class BZF_API bz_AllowCTFCaptureEventData_V1 : public bz_EventData
1212 {
1213 public:
bz_AllowCTFCaptureEventData_V1()1214 bz_AllowCTFCaptureEventData_V1() : bz_EventData(bz_eAllowCTFCaptureEvent)
1215 , teamCapped(eNoTeam), teamCapping(eNoTeam), playerCapping(-1)
1216 , rot(0.0)
1217 , allow(false), killTeam(true)
1218 {
1219 memset (pos, 0, sizeof(float)*3);
1220 }
1221
1222 bz_eTeamType teamCapped;
1223 bz_eTeamType teamCapping;
1224 int playerCapping;
1225
1226 float pos[3];
1227 float rot;
1228
1229 bool allow;
1230 bool killTeam;
1231 };
1232
1233 class BZF_API bz_MsgDebugEventData_V1 : public bz_EventData
1234 {
1235 public:
bz_MsgDebugEventData_V1()1236 bz_MsgDebugEventData_V1() : bz_EventData(bz_eMsgDebugEvent)
1237 , len(), msg(), receive(true)
1238 , playerID(-1)
1239 {
1240 memset (code, 0, sizeof(char)*2);
1241 }
1242
1243 char code[2];
1244 size_t len;
1245 unsigned char* msg;
1246
1247 bool receive;
1248 int playerID;
1249 };
1250
1251 class BZF_API bz_NewNonPlayerConnectionEventData_V1 : public bz_EventData
1252 {
1253 public:
1254
bz_NewNonPlayerConnectionEventData_V1()1255 bz_NewNonPlayerConnectionEventData_V1() : bz_EventData(bz_eNewNonPlayerConnection)
1256 , connectionID(-1)
1257 , data(0), size(0)
1258 {
1259 }
1260
1261 int connectionID;
1262 void* data;
1263 unsigned int size;
1264 };
1265
1266 class BZF_API bz_PluginLoadUnloadEventData_V1 : public bz_EventData
1267 {
1268 public:
1269
bz_PluginLoadUnloadEventData_V1()1270 bz_PluginLoadUnloadEventData_V1() : bz_EventData(bz_ePluginLoaded)
1271 , plugin(NULL)
1272 {
1273 }
1274
1275 bz_Plugin* plugin;
1276 };
1277
1278
1279 typedef enum
1280 {
1281 bz_eWins,
1282 bz_eLosses,
1283 bz_eTKs
1284 } bz_eScoreElement;
1285
1286 class BZF_API bz_PlayerScoreChangeEventData_V1 : public bz_EventData
1287 {
1288 public:
bz_PlayerScoreChangeEventData_V1(int id,bz_eScoreElement e,int lastV,int thisv)1289 bz_PlayerScoreChangeEventData_V1( int id, bz_eScoreElement e, int lastV,
1290 int thisv) : bz_EventData(bz_ePlayerScoreChanged)
1291 , playerID(id), element(e), thisValue(thisv), lastValue(lastV)
1292 {
1293 }
1294
1295 int playerID;
1296 bz_eScoreElement element;
1297 int thisValue;
1298 int lastValue;
1299 };
1300
1301 class BZF_API bz_TeamScoreChangeEventData_V1 : public bz_EventData
1302 {
1303 public:
bz_TeamScoreChangeEventData_V1(bz_eTeamType t,bz_eScoreElement e,int lastV,int thisv)1304 bz_TeamScoreChangeEventData_V1(bz_eTeamType t, bz_eScoreElement e, int lastV,
1305 int thisv) : bz_EventData(bz_eTeamScoreChanged)
1306 , team(t), element(e), thisValue(thisv), lastValue(lastV)
1307 {
1308 }
1309
1310 bz_eTeamType team;
1311 bz_eScoreElement element;
1312 int thisValue;
1313 int lastValue;
1314 };
1315
1316 class BZF_API bz_ReportFiledEventData_V1 : public bz_EventData
1317 {
1318 public:
bz_ReportFiledEventData_V1()1319 bz_ReportFiledEventData_V1() : bz_EventData(bz_eReportFiledEvent) {}
1320
1321 bz_ApiString from;
1322 bz_ApiString message;
1323 };
1324
1325 class BZF_API bz_BZDBChangeData_V1 : public bz_EventData
1326 {
1327 public:
bz_BZDBChangeData_V1(const std::string & _key,const std::string & _value)1328 bz_BZDBChangeData_V1(const std::string& _key, const std::string& _value)
1329 : bz_EventData(bz_eBZDBChange), key(_key), value(_value) {}
1330
1331 bz_ApiString key;
1332 bz_ApiString value;
1333 };
1334
1335 class BZF_API bz_GetPlayerMottoData_V1 : public bz_EventData
1336 {
1337 public:
bz_GetPlayerMottoData_V1(const char * m)1338 bz_GetPlayerMottoData_V1(const char* m)
1339 : bz_EventData(bz_eGetPlayerMotto)
1340 {
1341 if (m)
1342 motto = m;
1343 }
1344
1345 bz_ApiString motto;
1346 };
1347
1348 class BZF_API bz_GetPlayerMottoData_V2 : public bz_GetPlayerMottoData_V1
1349 {
1350 public:
bz_GetPlayerMottoData_V2(const char * m)1351 bz_GetPlayerMottoData_V2(const char* m)
1352 : bz_GetPlayerMottoData_V1(m)
1353 {
1354 }
1355
~bz_GetPlayerMottoData_V2()1356 ~bz_GetPlayerMottoData_V2()
1357 {
1358 bz_freePlayerRecord(record);
1359 }
1360
1361 bz_BasePlayerRecord* record;
1362 };
1363
1364 class BZF_API bz_AllowConnectionData_V1 : public bz_EventData
1365 {
1366 public:
bz_AllowConnectionData_V1(const char * i)1367 bz_AllowConnectionData_V1(const char* i)
1368 : bz_EventData(bz_eAllowConnection)
1369 {
1370 if (i)
1371 ip = i;
1372
1373 allow = true;
1374 }
1375 bz_ApiString ip;
1376 bool allow;
1377
1378 };
1379
1380 class BZF_API bz_AllowFlagGrabData_V1 : public bz_EventData
1381 {
1382 public:
bz_AllowFlagGrabData_V1()1383 bz_AllowFlagGrabData_V1()
1384 : bz_EventData(bz_eAllowFlagGrab)
1385 {
1386 allow = true;
1387 }
1388
1389 int playerID;
1390 int flagID;
1391
1392 const char* flagType;
1393
1394 bool allow;
1395 };
1396
1397 class BZF_API bz_AuthenticationCompleteData_V1 : public bz_EventData
1398 {
1399 public:
bz_AuthenticationCompleteData_V1()1400 bz_AuthenticationCompleteData_V1()
1401 : bz_EventData(bz_eAuthenticatonComplete)
1402 {
1403 }
~bz_AuthenticationCompleteData_V1()1404 ~bz_AuthenticationCompleteData_V1()
1405 {
1406 bz_freePlayerRecord(player);
1407 }
1408 bz_BasePlayerRecord *player;
1409 };
1410
1411 class BZF_API bz_ServerAddPlayerData_V1 : public bz_EventData
1412 {
1413 public:
bz_ServerAddPlayerData_V1()1414 bz_ServerAddPlayerData_V1()
1415 : bz_EventData(bz_eServerAddPlayer)
1416 {
1417 allow = true;
1418 }
~bz_ServerAddPlayerData_V1()1419 ~bz_ServerAddPlayerData_V1()
1420 {
1421 bz_freePlayerRecord(player);
1422 }
1423 bz_BasePlayerRecord *player;
1424
1425 bool allow;
1426 };
1427
1428 class BZF_API bz_AutoPilotData_V1 : public bz_EventData
1429 {
1430 public:
bz_AutoPilotData_V1()1431 bz_AutoPilotData_V1() : bz_EventData(bz_eAutoPilotEvent),
1432 playerID(-1),
1433 enabled(false)
1434 {}
1435
1436 int playerID;
1437 bool enabled;
1438 };
1439
1440 class BZF_API bz_MuteEventData_V1 : public bz_EventData
1441 {
1442 public:
bz_MuteEventData_V1()1443 bz_MuteEventData_V1() : bz_EventData(bz_eMuteEvent),
1444 victimID(-1),
1445 muterID(-1)
1446 {}
1447
1448 int victimID;
1449 int muterID;
1450 };
1451
1452 class BZF_API bz_PermissionModificationData_V1 : public bz_EventData
1453 {
1454 public:
bz_PermissionModificationData_V1()1455 bz_PermissionModificationData_V1() : bz_EventData(bz_ePermissionModificationEvent)
1456 , playerID(-1)
1457 , perm("")
1458 , granted(false)
1459 , customPerm(false)
1460 {}
1461
1462 int playerID;
1463 const char* perm;
1464 bool granted;
1465 bool customPerm;
1466 };
1467
1468 // logging
1469 BZF_API void bz_debugMessage ( int debugLevel, const char* message );
1470 BZF_API void bz_debugMessagef( int debugLevel, const char* fmt, ... );
1471 BZF_API int bz_getDebugLevel ( void );
1472 BZF_API int bz_setDebugLevel ( int debugLevel );
1473
1474 // plug-in registration
1475
1476 class BZF_API bz_Plugin
1477 {
1478 public:
1479 bz_Plugin();
1480 virtual ~bz_Plugin();
1481
1482 virtual const char* Name () = 0;
1483 virtual void Init( const char* config ) = 0;
Cleanup()1484 virtual void Cleanup() {}
Event(bz_EventData *)1485 virtual void Event( bz_EventData* /*eventData*/ )
1486 {
1487 return;
1488 }
1489
1490 // used for inter plugin communication
GeneralCallback(const char *,void *)1491 virtual int GeneralCallback( const char* /*name*/, void* /*data*/ )
1492 {
1493 return 0;
1494 }
1495
1496 float MaxWaitTime;
1497 bool Unloadable;
1498
1499 protected:
1500 bool Register (bz_eEventType eventType);
1501 bool Remove (bz_eEventType eventType);
1502 void Flush ();
1503 };
1504
1505 BZF_API bool bz_pluginExists(const char* name);
1506 BZF_API bz_Plugin* bz_getPlugin(const char* name);
1507
1508 BZF_API int bz_callPluginGenericCallback(const char* plugin, const char* name, void* data );
1509
1510 // non player data handlers
1511 class bz_NonPlayerConnectionHandler
1512 {
1513 public:
~bz_NonPlayerConnectionHandler()1514 virtual ~bz_NonPlayerConnectionHandler() {}
1515 virtual void pending(int connectionID, void *data, unsigned int size) = 0;
disconnect(int connectionID)1516 virtual void disconnect(int connectionID)
1517 {
1518 if (connectionID) return;
1519 }
1520 };
1521
1522 BZF_API bool bz_registerNonPlayerConnectionHandler(int connectionID, bz_NonPlayerConnectionHandler* handler);
1523 BZF_API bool bz_removeNonPlayerConnectionHandler(int connectionID, bz_NonPlayerConnectionHandler* handler);
1524 BZF_API bool bz_setNonPlayerInactivityTimeout(int connectionID, double time);
1525 BZF_API bool bz_setNonPlayerDataThrottle(int connectionID, double time);
1526 BZF_API bool bz_setNonPlayerDisconnectOnSend(int connectionID, bool bSet);
1527 BZF_API bool bz_sendNonPlayerData(int connectionID, const void *data, unsigned int size);
1528 BZF_API bool bz_disconnectNonPlayerConnection(int connectionID);
1529 BZF_API unsigned int bz_getNonPlayerConnectionOutboundPacketCount(int connectionID);
1530
1531 BZF_API const char* bz_getNonPlayerConnectionIP(int connectionID);
1532 BZF_API const char* bz_getNonPlayerConnectionHost(int connectionID);
1533
1534
1535 // player listing
1536 BZF_API bz_APIIntList* bz_getPlayerIndexList(void);
1537 BZF_API bool bz_getPlayerIndexList ( bz_APIIntList *playerList );
1538 BZF_API bz_BasePlayerRecord *bz_getPlayerByIndex ( int index );
1539 BZF_API bz_BasePlayerRecord *bz_getPlayerBySlotOrCallsign ( const char* name );
1540 BZF_API bool bz_updatePlayerData ( bz_BasePlayerRecord *playerRecord );
1541
1542 BZF_API int bz_getPlayerCount ();
1543
1544 BZF_API bool bz_hasPerm ( int playerID, const char* perm );
1545 BZF_API bool bz_grantPerm ( int playerID, const char* perm );
1546 BZF_API bool bz_revokePerm ( int playerID, const char* perm );
1547
1548 BZF_API bool bz_getAdmin(int playerID);
1549
1550 BZF_API bool bz_validAdminPassword(const char* passwd);
1551
1552 BZF_API const char* bz_getPlayerFlag( int playerID );
1553
1554 BZF_API bool bz_isPlayerAutoPilot( int playerID );
1555 BZF_API bool bz_isPlayerPaused( int playerID );
1556 BZF_API double bz_getPausedTime( int playerID );
1557 BZF_API double bz_getIdleTime( int playerID );
1558
1559 BZF_API bz_eTeamType bz_getPlayerTeam(int playerID);
1560 BZF_API const char* bz_getPlayerCallsign(int playerID);
1561 BZF_API const char* bz_getPlayerMotto(int playerID);
1562 BZF_API const char* bz_getPlayerIPAddress(int playerID);
1563
1564 // player lag info
1565 BZF_API int bz_getPlayerLag( int playerId );
1566 BZF_API int bz_getPlayerJitter( int playerId );
1567 BZF_API float bz_getPlayerPacketloss( int playerId );
1568
1569 class BZF_API bz_BasePlayerRecord
1570 {
1571 public:
bz_BasePlayerRecord()1572 bz_BasePlayerRecord()
1573 : version(1), playerID(-1), team(eNoTeam)
1574 , currentFlagID(-1)
1575 , lastUpdateTime(0.0), lastKnownState()
1576 , spawned(false), verified(false), globalUser(false)
1577 , admin(false), op(false), canSpawn(false)
1578 , lag(0), jitter(0), packetLoss(0.0)
1579 , rank(0.0), wins(0), losses(0), teamKills(0)
1580 {}
1581
~bz_BasePlayerRecord()1582 virtual ~bz_BasePlayerRecord() {}
1583
update(void)1584 void update(void)
1585 {
1586 bz_updatePlayerData(this); // call to update with current data
1587 }
1588
hasPerm(const char * perm)1589 bool hasPerm(const char* perm)
1590 {
1591 return bz_hasPerm(playerID,perm);
1592 }
grantPerm(const char * perm)1593 bool grantPerm(const char* perm)
1594 {
1595 return bz_grantPerm(playerID,perm);
1596 }
revokePerm(const char * perm)1597 bool revokePerm(const char* perm)
1598 {
1599 return bz_revokePerm(playerID,perm);
1600 }
1601
1602 const char *getCustomData ( const char* key);
1603 bool setCustomData ( const char* key, const char* data);
1604
1605 int version;
1606 int playerID;
1607 bz_ApiString callsign;
1608
1609 bz_eTeamType team;
1610
1611 bz_ApiString ipAddress;
1612
1613 int currentFlagID;
1614 bz_ApiString currentFlag;
1615 bz_APIStringList flagHistory;
1616
1617 double lastUpdateTime;
1618 bz_PlayerUpdateState lastKnownState;
1619
1620 bz_ApiString clientVersion;
1621 bool spawned;
1622 bool verified;
1623 bool globalUser;
1624 bz_ApiString bzID;
1625 bool admin;
1626 bool op;
1627 bool canSpawn;
1628 bz_APIStringList groups;
1629
1630 int lag;
1631 int jitter;
1632 float packetLoss;
1633
1634 float rank;
1635 int wins;
1636 int losses;
1637 int teamKills;
1638
1639 };
1640
1641 class BZF_API bz_PlayerRecordV2 : public bz_BasePlayerRecord
1642 {
1643 public:
bz_PlayerRecordV2()1644 bz_PlayerRecordV2() : bz_BasePlayerRecord()
1645 {
1646 version = 2;
1647 }
1648
1649 bz_ApiString motto;
1650 };
1651
1652 // player info
1653 BZF_API bool bz_getPlayerHumanity( int playerId );
1654
1655 BZF_API bool bz_setPlayerOperator ( int playerId );
1656 BZF_API bool bz_setPlayerSpawnable ( int playerId, bool spawn );
1657 BZF_API bool bz_isPlayerSpawnable ( int playerId );
1658 BZF_API void bz_setPlayerSpawnAtBase ( int playerId, bool base );
1659 BZF_API bool bz_getPlayerSpawnAtBase ( int playerId );
1660
1661 // player access control
1662 BZF_API bool bz_addPlayerToGame (int playerID );
1663
1664 // team info
1665 BZF_API unsigned int bz_getTeamPlayerLimit ( bz_eTeamType team );
1666
1667 // player score
1668 BZF_API void bz_computePlayerScore( bool enabled );
1669 BZF_API bool bz_computingPlayerScore( void );
1670
1671 BZF_API bool bz_setPlayerWins (int playerId, int wins);
1672 BZF_API bool bz_setPlayerLosses (int playerId, int losses);
1673 BZF_API bool bz_setPlayerTKs (int playerId, int tks);
1674
1675 BZF_API bool bz_incrementPlayerWins (int playerId, int increment);
1676 BZF_API bool bz_incrementPlayerLosses (int playerId, int increment);
1677 BZF_API bool bz_incrementPlayerTKs (int playerId, int increment);
1678
1679 BZF_API float bz_getPlayerRank(int playerId);
1680 BZF_API int bz_getPlayerWins(int playerId);
1681 BZF_API int bz_getPlayerLosses(int playerId);
1682 BZF_API int bz_getPlayerTKs(int playerId);
1683
1684 BZF_API int bz_howManyTimesPlayerKilledBy(int playerId, int killerId);
1685
1686 BZF_API bool bz_resetPlayerScore(int playerId);
1687
1688 // player handicap
1689 BZF_API void bz_refreshHandicaps();
1690
1691 // groups API
1692 BZF_API bz_APIStringList* bz_getGroupList ( void );
1693 BZF_API bz_APIStringList* bz_getGroupPerms ( const char* group );
1694 BZF_API bool bz_groupAllowPerm ( const char* group, const char* perm );
1695
1696 // message API
1697 BZF_API bool bz_sendTextMessage (int from, int to, bz_eMessageType type, const char* message);
1698 BZF_API bool bz_sendTextMessage (int from, int to, const char* message);
1699
1700 BZF_API bool bz_sendTextMessage (int from, bz_eTeamType to, bz_eMessageType type, const char* message);
1701 BZF_API bool bz_sendTextMessage (int from, bz_eTeamType to, const char* message);
1702
1703 BZF_API bool bz_sendTextMessagef(int from, int to, bz_eMessageType type, const char* fmt, ...);
1704 BZF_API bool bz_sendTextMessagef(int from, int to, const char* fmt, ...);
1705
1706 BZF_API bool bz_sendTextMessagef(int from, bz_eTeamType to, bz_eMessageType type, const char* fmt, ...);
1707 BZF_API bool bz_sendTextMessagef(int from, bz_eTeamType to, const char* fmt, ...);
1708
1709 BZF_API bool bz_sentFetchResMessage ( int playerID, const char* URL );
1710
1711 // world weapons
1712 // will be removed in next breaking version after 2.4.x
1713 /*DEPRECATED*/ BZF_API bool bz_fireWorldWep ( const char* flagType, float lifetime, int fromPlayer, float *pos,
1714 float tilt, float direction, int shotID, float dt, bz_eTeamType shotTeam = eRogueTeam );
1715 /*DEPRECATED*/ BZF_API bool bz_fireWorldWep( const char* flagType, float lifetime, int fromPlayer, float *pos,
1716 float tilt, float direction, float speed, int* shotID, float dt, bz_eTeamType shotTeam = eRogueTeam );
1717 /*DEPRECATED*/ BZF_API bool bz_fireWorldWep( const char* flagType, float lifetime, int fromPlayer, float *pos,
1718 float tilt, float direction, int* shotID, float dt, bz_eTeamType shotTeam = eRogueTeam );
1719 /*DEPRECATED*/ BZF_API int bz_fireWorldGM ( int targetPlayerID, float lifetime, float *pos, float tilt, float direction,
1720 float dt, bz_eTeamType shotTeam = eRogueTeam);
1721
1722 // new server shot API
1723 BZF_API uint32_t bz_fireServerShot(const char* shotType, float origin[3], float vector[3],
1724 bz_eTeamType color = eRogueTeam, int targetPlayerId = -1);
1725
1726 // will be removed in next breaking version after 2.4.x
1727 /*DEPRECATED*/ BZF_API uint32_t bz_getShotMetaData (int fromPlayer, int shotID, const char* name);
1728 /*DEPRECATED*/ BZF_API void bz_setShotMetaData (int fromPlayer, int shotID, const char* name, uint32_t value);
1729 /*DEPRECATED*/ BZF_API bool bz_shotHasMetaData (int fromPlayer, int shotID, const char* name);
1730
1731 // new shot metadata API
1732 BZF_API void bz_setShotMetaData (const uint32_t shotGUID, const char* name, uint32_t value);
1733 BZF_API void bz_setShotMetaData (const uint32_t shotGUID, const char* name, const char* value);
1734 BZF_API bool bz_shotHasMetaData (const uint32_t shotGUID, const char* name);
1735
1736 BZF_API uint32_t bz_getShotMetaDataI(const uint32_t shotGUID, const char* name);
1737 BZF_API const char* bz_getShotMetaDataS(const uint32_t shotGUID, const char* name);
1738
1739 BZF_API uint32_t bz_getShotGUID (int fromPlayer, int shotID);
1740
1741 // geometry utils
1742 BZF_API bool bz_vectorFromPoints(const float p1[3], const float p2[3], float outVec[3]);
1743 BZF_API bool bz_vectorFromRotations(const float tilt, const float rotation, float outVec[3]);
1744
1745 typedef struct
1746 {
1747 int year;
1748 int month;
1749 int day;
1750 int hour;
1751 int minute;
1752 int second;
1753 int dayofweek;
1754 bool daylightSavings;
1755 } bz_Time;
1756
1757 BZF_API void bz_getLocaltime(bz_Time *ts);
1758 BZF_API void bz_getUTCtime(bz_Time *ts);
1759
1760 // BZDB API
1761 BZF_API double bz_getBZDBDouble ( const char* variable );
1762 BZF_API bz_ApiString bz_getBZDBString( const char* variable );
1763 BZF_API bool bz_getBZDBBool( const char* variable );
1764 BZF_API int bz_getBZDBInt( const char* variable );
1765
1766 BZF_API int bz_getBZDBItemPerms( const char* variable );
1767 BZF_API bool bz_getBZDBItemPesistent( const char* variable );
1768 BZF_API bool bz_BZDBItemExists( const char* variable );
1769 BZF_API bool bz_BZDBItemHasValue( const char* variable );
1770
1771 BZF_API bool bz_registerCustomBZDBDouble(const char* variable, double val, int perms = 0, bool persistent = false);
1772 BZF_API bool bz_registerCustomBZDBString(const char* variable, const char *val, int perms = 0, bool persistent = false);
1773 BZF_API bool bz_registerCustomBZDBBool(const char* variable, bool val, int perms = 0, bool persistent = false);
1774 BZF_API bool bz_registerCustomBZDBInt(const char* variable, int val, int perms = 0, bool persistent = false);
1775
1776 BZF_API bool bz_removeCustomBZDBVariable(const char* variable);
1777
1778 // remove in next breaking version after 2.4.x; superseded by bz_registerCustomBZDB*()
1779 /*DEPRECATED*/ BZF_API bool bz_setBZDBDouble(const char* variable, double val, int perms = 0, bool persistent = false);
1780 /*DEPRECATED*/ BZF_API bool bz_setBZDBString(const char* variable, const char *val, int perms = 0,
1781 bool persistent = false);
1782 /*DEPRECATED*/ BZF_API bool bz_setBZDBBool(const char* variable, bool val, int perms = 0, bool persistent = false);
1783 /*DEPRECATED*/ BZF_API bool bz_setBZDBInt(const char* variable, int val, int perms = 0, bool persistent = false);
1784
1785 BZF_API bool bz_setDefaultBZDBDouble(const char* variable, double val);
1786 BZF_API bool bz_setDefaultBZDBString(const char* variable, const char* val);
1787 BZF_API bool bz_setDefaultBZDBBool(const char* variable, bool val);
1788 BZF_API bool bz_setDefaultBZDBInt(const char* variable, int val);
1789
1790 BZF_API bool bz_updateBZDBDouble(const char* variable, double val);
1791 BZF_API bool bz_updateBZDBString(const char* variable, const char *val);
1792 BZF_API bool bz_updateBZDBBool(const char* variable, bool val);
1793 BZF_API bool bz_updateBZDBInt(const char* variable, int val);
1794
1795 BZF_API int bz_getBZDBVarList( bz_APIStringList *varList );
1796
1797 BZF_API void bz_resetBZDBVar( const char* variable );
1798 BZF_API void bz_resetALLBZDBVars( void );
1799
1800
1801 // admin
1802 BZF_API bool bz_kickUser ( int playerIndex, const char* reason, bool notify );
1803 BZF_API bool bz_IPBanUser ( int playerIndex, const char* ip, int time, const char* reason );
1804 BZF_API bool bz_IPUnbanUser ( const char* ip );
1805 BZF_API bool bz_HostBanUser(const char* hostmask, const char* source, int duration, const char* reason);
1806 BZF_API bool bz_IDUnbanUser(const char* bzID);
1807 BZF_API bool bz_HostUnbanUser(const char* hostmask);
1808
1809
1810 // ban lists
1811 typedef enum
1812 {
1813 eIPList,
1814 eIDList,
1815 eHostList
1816 } bz_eBanListType;
1817
1818 BZF_API unsigned int bz_getBanListSize( bz_eBanListType listType );
1819 BZF_API const char* bz_getBanItem ( bz_eBanListType listType, unsigned int item );
1820 BZF_API const char* bz_getBanItemReason ( bz_eBanListType listType, unsigned int item );
1821 BZF_API const char* bz_getBanItemSource ( bz_eBanListType listType, unsigned int item );
1822 BZF_API double bz_getBanItemDuration ( bz_eBanListType listType, unsigned int item );
1823 BZF_API bool bz_getBanItemIsFromMaster ( bz_eBanListType listType, unsigned int item );
1824
1825 BZF_API bz_APIStringList *bz_getReports( void );
1826
1827 // lagwarn
1828 BZF_API int bz_getLagWarn( void );
1829 BZF_API bool bz_setLagWarn( int lagwarn );
1830
1831 // timelimit
1832 BZF_API bool bz_setTimeLimit( float timeLimit );
1833 BZF_API float bz_getTimeLimit( void );
1834 BZF_API bool bz_isTimeManualStart( void );
1835
1836 // countdown
1837 BZF_API bool bz_isCountDownActive( void );
1838 BZF_API bool bz_isCountDownInProgress( void );
1839 BZF_API bool bz_isCountDownPaused( void );
1840
1841 // polls
1842 BZF_API bool bz_pollActive( void );
1843 BZF_API bool bz_pollVeto( void );
1844
1845 // help
1846 BZF_API bz_APIStringList *bz_getHelpTopics( void );
1847 BZF_API bz_APIStringList *bz_getHelpTopic( std::string name );
1848
1849 // custom polls
1850
1851 class bz_CustomPollTypeHandler
1852 {
1853 public:
~bz_CustomPollTypeHandler()1854 virtual ~bz_CustomPollTypeHandler() {};
1855
1856 // Should return false to prevent the poll from starting
1857 virtual bool PollOpen (bz_BasePlayerRecord *player, const char* action, const char* parameters) = 0;
1858 virtual void PollClose (const char* action, const char* parameters, bool success) = 0;
1859 };
1860
1861 BZF_API bool bz_registerCustomPollType (const char* option, const char* parameters, bz_CustomPollTypeHandler *handler);
1862 BZF_API bool bz_removeCustomPollType (const char* option);
1863
1864 // custom commands
1865
1866 class bz_CustomSlashCommandHandler
1867 {
1868 public:
~bz_CustomSlashCommandHandler()1869 virtual ~bz_CustomSlashCommandHandler() {};
1870 virtual bool SlashCommand(int playerID, bz_ApiString command, bz_ApiString message, bz_APIStringList *params) = 0;
1871 };
1872
1873 class bz_CustomSlashCommandHandlerV2
1874 {
1875 public:
~bz_CustomSlashCommandHandlerV2()1876 virtual ~bz_CustomSlashCommandHandlerV2() {};
1877 virtual bool SlashCommand ( int playerID, int sourceChannel, bz_ApiString command, bz_ApiString message,
1878 bz_APIStringList *params ) = 0;
1879 };
1880
1881 BZF_API bool bz_registerCustomSlashCommand ( const char* command, bz_CustomSlashCommandHandlerV2 *handler );
1882 BZF_API bool bz_registerCustomSlashCommand (const char* command, bz_CustomSlashCommandHandler *handler);
1883 BZF_API bool bz_removeCustomSlashCommand ( const char* command );
1884
1885 // spawning
1886 BZF_API bool bz_getStandardSpawn ( int playerID, float pos[3], float *rot );
1887
1888 // dying
1889 BZF_API bool bz_killPlayer ( int playerID, bool spawnOnBase, int killerID = -1, const char* flagID = NULL );
1890
1891 // flags
1892 BZF_API bool bz_givePlayerFlag ( int playerID, const char* flagType, bool force );
1893 BZF_API bool bz_removePlayerFlag ( int playerID );
1894 BZF_API void bz_resetFlags ( bool onlyUnused, bool keepTeamFlags = false );
1895
1896 BZF_API unsigned int bz_getNumFlags( void );
1897 /*DEPRECATED*/ BZF_API const bz_ApiString bz_getName( int flag );
1898 BZF_API const bz_ApiString bz_getFlagName( int flag );
1899 BZF_API bool bz_resetFlag ( int flag );
1900 BZF_API bool bz_moveFlag ( int flag, float pos[3] );
1901 BZF_API int bz_getPlayerFlagID ( int playerID );
1902 BZF_API int bz_flagPlayer ( int flag );
1903 BZF_API bool bz_getFlagPosition ( int flag, float* pos );
1904 BZF_API bool bz_getNearestFlagSafetyZone(int flag, float *pos);
1905
1906
1907 // world
1908 typedef struct
1909 {
1910 bool driveThru;
1911 bool shootThru;
1912 } bz_WorldObjectOptions;
1913
1914 typedef struct
1915 {
1916 bz_ApiString texture;
1917 bool useAlpha;
1918 bool useColorOnTexture;
1919 bool useSphereMap;
1920 int combineMode;
1921 } bz_MaterialTexture;
1922
1923 class BZF_API bzAPITextureList
1924 {
1925 public:
1926 bzAPITextureList();
1927 bzAPITextureList(const bzAPITextureList &r);
1928
1929 ~bzAPITextureList();
1930
1931 void push_back ( bz_MaterialTexture &value );
1932 bz_MaterialTexture get ( unsigned int i );
1933
1934 const bz_MaterialTexture& operator[](unsigned int i) const;
1935 bzAPITextureList& operator=( const bzAPITextureList& r );
1936
1937 unsigned int size ( void );
1938 void clear ( void );
1939
1940 protected:
1941 class dataBlob;
1942
1943 dataBlob *data;
1944 };
1945
1946 typedef struct bz_MaterialInfo
1947 {
1948 bz_ApiString name;
1949 bzAPITextureList textures;
1950
1951 float ambient[4];
1952 float diffuse[4];
1953 float specular[4];
1954 float emisive[4];
1955 float shine;
1956
1957 float alphaThresh;
1958 bool culling;
1959 bool sorting;
1960 } bz_MaterialInfo;
1961
1962 // have bz make you a new material
1963 bz_MaterialInfo* bz_anewMaterial ( void );
1964 // tell bz you are done with a material
1965 void bz_deleteMaterial ( bz_MaterialInfo *material );
1966
1967 BZF_API bool bz_addWorldBox ( float *pos, float rot, float* scale, bz_WorldObjectOptions options );
1968 BZF_API bool bz_addWorldPyramid ( float *pos, float rot, float* scale, bool fliped, bz_WorldObjectOptions options );
1969 BZF_API bool bz_addWorldBase( float *pos, float rot, float* scale, bz_eTeamType team, bz_WorldObjectOptions options );
1970 BZF_API bool bz_addWorldTeleporter ( float *pos, float rot, float* scale, float border, bz_WorldObjectOptions options );
1971 BZF_API bool bz_addWorldWaterLevel( float level, bz_MaterialInfo *material );
1972 BZF_API bool bz_addWorldWeapon( const char* flagType, float *pos, float rot, float tilt, float initDelay,
1973 bz_APIFloatList &delays );
1974
1975 BZF_API float bz_getWorldMaxHeight ( void );
1976
1977 BZF_API bool bz_setWorldSize( float size, float wallHeight = -1.0 );
1978 BZF_API void bz_setClientWorldDownloadURL( const char* URL );
1979 BZF_API const bz_ApiString bz_getClientWorldDownloadURL( void );
1980 BZF_API bool bz_saveWorldCacheFile( const char* file );
1981
1982 // world
1983 BZF_API unsigned int bz_getWorldCacheSize(void);
1984 BZF_API unsigned int bz_getWorldCacheData(unsigned char *data);
1985
1986
1987 // custom map objects
1988
1989 typedef struct bz_CustomMapObjectInfo
1990 {
1991 bz_ApiString name;
1992 bz_APIStringList data;
1993 } bz_CustomMapObjectInfo;
1994
1995 class bz_CustomZoneObject
1996 {
1997 public:
1998 BZF_API bz_CustomZoneObject();
1999
2000 bool box;
2001 float xMax,xMin,yMax,yMin,zMax,zMin,radius,rotation;
2002
2003 BZF_API bool pointInZone(float pos[3]);
2004 BZF_API void handleDefaultOptions(bz_CustomMapObjectInfo *data);
2005
2006 private:
2007 float calculateTriangleSum(float x1, float x2, float x3, float y1, float y2, float y3);
2008 };
2009
2010 BZF_API void bz_getRandomPoint ( bz_CustomZoneObject *obj, float *randomPos );
2011 BZF_API bool bz_getSpawnPointWithin ( bz_CustomZoneObject *obj, float randomPos[3] );
2012 BZF_API bool bz_isWithinWorldBoundaries ( float pos[3] );
2013
2014 class bz_CustomMapObjectHandler
2015 {
2016 public:
~bz_CustomMapObjectHandler()2017 virtual ~bz_CustomMapObjectHandler() {};
2018 virtual bool MapObject ( bz_ApiString object, bz_CustomMapObjectInfo *data ) = 0;
2019 };
2020
2021 BZF_API bool bz_registerCustomMapObject ( const char* object, bz_CustomMapObjectHandler *handler );
2022 BZF_API bool bz_removeCustomMapObject ( const char* object );
2023
2024
2025 // public server info
2026 BZF_API bool bz_getPublic( void );
2027 BZF_API bz_ApiString bz_getPublicAddr( void );
2028 BZF_API bz_ApiString bz_getPublicDescription( void );
2029 BZF_API int bz_getPublicPort(void);
2030
2031 // plug-in management
2032 BZF_API int bz_getLoadedPlugins(bz_APIStringList *list);
2033 BZF_API bool bz_loadPlugin(const char* path, const char* params);
2034 BZF_API bool bz_unloadPlugin(const char* path);
2035
2036 // bz_load path functions
2037 // only valid inside the load function for a plugin
2038 BZF_API const char* bz_pluginBinPath(void);
2039
2040 // custom client sounds
2041 BZF_API bool bz_sendPlayCustomLocalSound ( int playerID, const char* soundName );
2042
2043 class bz_APIPluginHandler
2044 {
2045 public:
~bz_APIPluginHandler()2046 virtual ~bz_APIPluginHandler() {};
2047 virtual bool APIPlugin ( bz_ApiString plugin, bz_ApiString param ) = 0;
2048 };
2049 // custom pluginHandler
2050 BZF_API bool bz_registerCustomPluginHandler ( const char* extension, bz_APIPluginHandler * handler );
2051 BZF_API bool bz_removeCustomPluginHandler ( const char* extension, bz_APIPluginHandler * handler );
2052
2053 // team info
2054
2055 BZF_API void bz_computeTeamScore( bool enabled );
2056 BZF_API bool bz_computingTeamScore( void );
2057
2058 BZF_API int bz_getTeamCount (bz_eTeamType team );
2059 BZF_API int bz_getTeamScore (bz_eTeamType team );
2060 BZF_API int bz_getTeamWins (bz_eTeamType team );
2061 BZF_API int bz_getTeamLosses (bz_eTeamType team );
2062
2063 BZF_API void bz_setTeamWins (bz_eTeamType team, int wins );
2064 BZF_API void bz_setTeamLosses (bz_eTeamType team, int losses );
2065 BZF_API void bz_incrementTeamWins (bz_eTeamType team, int increment);
2066 BZF_API void bz_incrementTeamLosses (bz_eTeamType team, int increment);
2067
2068 BZF_API void bz_resetTeamScore (bz_eTeamType team );
2069 BZF_API void bz_resetTeamScores ( void );
2070
2071 // list server
2072 BZF_API void bz_updateListServer ( void );
2073
2074 // url API
2075 class bz_BaseURLHandler
2076 {
2077 public:
bz_BaseURLHandler()2078 bz_BaseURLHandler()
2079 {
2080 version = 1;
2081 }
~bz_BaseURLHandler()2082 virtual ~bz_BaseURLHandler() {};
2083 virtual void URLDone ( const char* URL, const void * data, unsigned int size, bool complete ) = 0;
URLTimeout(const char *,int)2084 virtual void URLTimeout ( const char* /*URL*/, int /*errorCode*/ ) {};
URLError(const char *,int,const char *)2085 virtual void URLError ( const char* /*URL*/, int /*errorCode*/, const char * /*errorString*/ ) {};
2086
2087 int version;
2088 };
2089
2090 class bz_URLHandler_V2 : public bz_BaseURLHandler
2091 {
2092 public:
bz_URLHandler_V2()2093 bz_URLHandler_V2() : bz_BaseURLHandler()
2094 {
2095 version = 2;
2096 token = NULL;
2097 }
2098 void* token;
2099 };
2100
2101
2102 BZF_API bool bz_addURLJob(const char* URL, bz_BaseURLHandler* handler = NULL, const char* postData = NULL);
2103 BZF_API bool bz_addURLJob(const char* URL, bz_URLHandler_V2* handler, void* token, const char* postData = NULL);
2104 BZF_API bool bz_addURLJob(const char* URL, bz_URLHandler_V2* handler, void* token, const char* postData = NULL,
2105 bz_APIStringList *headers = NULL);
2106 BZF_API bool bz_removeURLJob(const char* URL);
2107 BZF_API size_t bz_addURLJobForID(const char* URL,
2108 bz_BaseURLHandler* handler = NULL,
2109 const char* postData = NULL);
2110 BZF_API bool bz_removeURLJobByID(size_t id);
2111
2112 // inter plugin communication
2113 BZF_API bool bz_clipFieldExists ( const char *name );
2114 BZF_API const char* bz_getclipFieldString ( const char *name );
2115 BZF_API float bz_getclipFieldFloat ( const char *name );
2116 BZF_API int bz_getclipFieldInt( const char *name );
2117
2118 BZF_API bool bz_setclipFieldString ( const char *name, const char* data );
2119 BZF_API bool bz_setclipFieldFloat ( const char *name, float data );
2120 BZF_API bool bz_setclipFieldInt( const char *name, int data );
2121
2122 class bz_ClipFieldNotifier
2123 {
2124 public:
~bz_ClipFieldNotifier()2125 virtual ~bz_ClipFieldNotifier() {};
2126 virtual void fieldChange ( const char* /*field*/) = 0;
2127 };
2128
2129 BZF_API bool bz_addClipFieldNotifier ( const char *name, bz_ClipFieldNotifier *cb );
2130 BZF_API bool bz_removeClipFieldNotifier ( const char *name, bz_ClipFieldNotifier *cb );
2131
2132 // path checks
2133 BZF_API bz_ApiString bz_filterPath ( const char* path );
2134
2135 // Record-Replay
2136 BZF_API bool bz_saveRecBuf( const char * _filename, int seconds = 0);
2137 BZF_API bool bz_startRecBuf( void );
2138 BZF_API bool bz_stopRecBuf( void );
2139
2140 // cheap Text Utils
2141 BZF_API const char *bz_format(const char* fmt, ...);
2142 BZF_API const char *bz_toupper(const char* val );
2143 BZF_API const char *bz_tolower(const char* val );
2144 BZF_API const char *bz_rtrim(const char* val, const char* trim = " ");
2145 BZF_API const char *bz_ltrim(const char* val, const char* trim = " ");
2146 BZF_API const char *bz_trim(const char* val, const char* trim = " ");
2147 BZF_API const char *bz_join(bz_APIStringList* list, const char* delimiter = ",");
2148 BZF_API const char *bz_urlEncode(const char* val );
2149
2150 // game countdown
2151 BZF_API void bz_cancelCountdown ( int playerID );
2152 BZF_API void bz_pauseCountdown ( int playerID );
2153 BZF_API void bz_resumeCountdown ( int playerID );
2154 BZF_API void bz_startCountdown ( int delay, float limit, int playerID );
2155 BZF_API float bz_getCountdownRemaining ( void );
2156
2157 // @TODO deprecated game countdown commands (to be removed in 2.6.x)
2158 BZF_API void bz_cancelCountdown ( const char *canceledBy );
2159 BZF_API void bz_pauseCountdown ( const char *pausedBy );
2160 BZF_API void bz_resumeCountdown ( const char *resumedBy );
2161 BZF_API void bz_startCountdown ( int delay, float limit, const char *byWho );
2162
2163 // server control
2164 BZF_API bool bz_getShotMismatch();
2165 BZF_API void bz_setShotMismatch(bool value);
2166 BZF_API bool bz_isAutoTeamEnabled();
2167 BZF_API void bz_shutdown();
2168 BZF_API void bz_superkill();
2169 BZF_API void bz_gameOver(int playerID, bz_eTeamType team = eNoTeam);
2170 BZF_API bool bz_restart ( void );
2171 BZF_API const char* bz_getServerOwner();
2172
2173 BZF_API void bz_reloadLocalBans();
2174 BZF_API void bz_reloadMasterBans();
2175 BZF_API void bz_reloadGroups();
2176 BZF_API void bz_reloadUsers();
2177 BZF_API void bz_reloadHelp();
2178 BZF_API void bz_reloadBadwords();
2179
2180 // info about the world
2181 BZF_API bz_eTeamType bz_checkBaseAtPoint ( float pos[3] );
2182
2183 bz_eTeamType convertTeam ( int team );
2184 int convertTeam( bz_eTeamType team );
2185
2186 // game type info
2187 BZF_API bz_eGameType bz_getGameType ( void );
2188 BZF_API bool bz_triggerFlagCapture(int playerID, bz_eTeamType teamCapping, bz_eTeamType teamCapped);
2189
2190
2191 typedef struct
2192 {
2193 int index;
2194 char type[2];
2195 int status;
2196 int endurance;
2197 int owner;
2198 float position[3];
2199 float launchPosition[3];
2200 float landingPosition[3];
2201 float flightTime;
2202 float flightEnd;
2203 float initialVelocity;
2204 } bz_FlagUpdateRecord;
2205
2206 typedef struct
2207 {
2208 float rank;
2209 int wins;
2210 int losses;
2211 int tks;
2212 } bz_ScoreRecord;
2213
2214 typedef struct
2215 {
2216 int id;
2217 int size;
2218 int wins;
2219 int losses;
2220 } bz_TeamInfoRecord;
2221
2222 typedef enum
2223 {
2224 eRejectBadRequest,
2225 eRejectBadTeam,
2226 eRejectBadType,
2227 eRejectUNUSED,
2228 eRejectTeamFull,
2229 eRejectServerFull,
2230 eRejectBadCallsign,
2231 eRejectRepeatCallsign,
2232 eRejectRejoinWaitTime,
2233 eRejectIPBanned,
2234 eRejectHostBanned,
2235 eRejectIDBanned
2236 } bz_eRejectCodes;
2237
2238 typedef struct
2239 {
2240 int player;
2241 int handicap;
2242 } bz_HandicapUpdateRecord;
2243
2244 typedef enum
2245 {
2246 eGotKilled,
2247 eGotShot,
2248 eGotRunOver,
2249 eGotCaptured,
2250 eGenocideEffect,
2251 eSelfDestruct,
2252 eWaterDeath,
2253 ePhysicsDriverDeath
2254 } bz_ePlayerDeathReason;
2255
2256 class BZF_API bz_ServerSidePlayerHandler
2257 {
2258 public:
2259 bz_ServerSidePlayerHandler();
~bz_ServerSidePlayerHandler()2260 virtual ~bz_ServerSidePlayerHandler() {}
2261
getPlayerID(void)2262 int getPlayerID ( void )
2263 {
2264 return playerID;
2265 }
2266
2267 void update ( void );
2268
2269 // you must call setPlayerData when this is called.
2270 virtual void added(int player) = 0; // it is required that the bot provide this method
2271
2272 // lower level events for various things that happen in the game
removed(void)2273 virtual void removed(void) {}
2274
2275 virtual void playerAdded(int player);
2276 virtual void playerRemoved(int player);
2277
2278 virtual void playerSpawned(int player, const float pos[3], float rot);
2279
2280 virtual void textMessage(int dest, int source, const char *text);
2281 virtual void playerKilled(int victimIndex, int killerIndex, bz_ePlayerDeathReason reason, int shotIndex,
2282 const char *flagType, int phydrv);
2283 virtual void scoreLimitReached(int player, bz_eTeamType team);
2284 virtual void flagCaptured(int player, bz_eTeamType team);
2285
2286 virtual void playerStateUpdate(int player, bz_PlayerUpdateState *playerState,
2287 double timestamp); // implement when server side scoring is in
2288 // virtual void playerScoreUpdate(int player, float rank, int wins, int losses, int TKs); // implement when server side scoring is in
2289 virtual void shotFired(int player, unsigned short shotID);
2290 virtual void shotEnded(int player, unsigned short shotID, unsigned short reason);
2291 virtual void playerTeleported(int player, bz_PlayerUpdateState *currentState, bz_PlayerUpdateState *lastState);
2292
2293 // higher level functions for events that happen to the bot
2294 typedef enum
2295 {
2296 eWorldDeath,
2297 eServerDeath,
2298 eCaptureDeath,
2299 eOtherDeath
2300 } SmiteReason;
2301
rejected(bz_eRejectCodes,const char *)2302 void rejected ( bz_eRejectCodes, const char* /*reason*/) {}; // the bot was rejectd for some reason
2303 virtual void spawned(void); // the bot has spawned
2304 virtual void died ( int killer ); // the bot has died from gameplay
2305 virtual void smote ( SmiteReason reason = eOtherDeath ); // the bot has died from some other manner
2306 // virtual void collide ( bz_APISolidWorldObject_V1* /*object*/, float* /*pos*/ ) {} // the bot ran into an object
2307
2308 // give the bot time to do it's processing
2309 virtual bool think(void); // return true to kill and delete the bot;
2310
setPlayerID(int id)2311 void setPlayerID ( int id )
2312 {
2313 playerID = id;
2314 }
2315
2316 // actions to make
2317 void setPlayerData(const char *callsign,
2318 const char *token, const char *clientVersion,
2319 bz_eTeamType team);
2320
2321 void joinGame(void);
2322
2323 void respawn(void);
2324 void getCurrentState(bz_PlayerUpdateState *state);
2325
2326 void sendServerCommand(const char* text);
2327 void sendChatMessage(const char* text, int targetPlayer = BZ_ALLUSERS, bz_eMessageType type = eChatMessage);
2328 void sendTeamChatMessage(const char *text, bz_eTeamType targetTeam, bz_eMessageType type = eChatMessage);
2329
2330 void dropFlag( void );
2331 void setMovement(float forward, float turn);
2332 bool fireShot(void);
2333 bool jump(void);
2334
2335 // state info
2336 bool canJump(void);
2337 bool canShoot(void);
2338 bool canMove(void);
2339 bool falling (void);
2340
2341 void getPosition ( float *p );
2342 void getVelocity ( float *v );
2343 float getFacing ( void );
2344
2345 float getMaxLinSpeed ( void );
2346 float getMaxRotSpeed ( void );
2347
2348 // state actions
2349 void setAutoSpawn ( bool s = true )
2350 {
2351 autoSpawn = s;
2352 }
2353
2354 int playerID;
2355
2356 private:
2357 float input[2];
2358 bool wantToJump;
2359
2360 bool autoSpawn;
2361
2362 public:
2363 class BZF_API UpdateInfo
2364 {
2365 public:
2366 float pos[3];
2367 float vec[3]; // FIXME -- vel for velocity?
2368 float rot; // FIXME -- radians or degrees?
2369 float rotVel;
2370 double time;
2371
UpdateInfo()2372 UpdateInfo()
2373 : rot(0), rotVel(0), time(0)
2374 {
2375 for (int i = 0; i < 3; i++)
2376 pos[i] = vec[0] =0;
2377 }
2378
2379 UpdateInfo& operator=( const UpdateInfo& u )
2380 {
2381 memcpy(pos,u.pos,sizeof(float)*3);
2382 memcpy(vec,u.vec,sizeof(float)*3);
2383 rot = u.rot;
2384 rotVel = u.rotVel;
2385 time = u.time;
2386
2387 return *this;
2388 }
2389 float getDelta( const UpdateInfo & state);
2390 };
2391
2392 private:
2393 UpdateInfo lastUpdate;
2394 UpdateInfo currentState;
2395
2396 int flaps;
2397
2398 bool alive;
2399 };
2400
2401 // *** NOTE *** support for server side players in incomplete.
2402 // there WILL be crashes if you add one.
2403 // this message will be removed when the code is complete.
2404 BZF_API int bz_addServerSidePlayer(bz_ServerSidePlayerHandler *handler);
2405 BZF_API bool bz_removeServerSidePlayer(int playerID,
2406 bz_ServerSidePlayerHandler *handler); // you have to pass in the handler to ensure you "own" the player
2407
2408 // no ShotType support in 2.4 (yet?). still accept the ShotType parameter for compatibility.
2409 typedef int bz_eShotType;
2410
2411 // Note: there is NO bz_UnregisterCustomFlag, 'cause that would jack up connected clients.
2412 // If you really need to unregister a flag, shut down the server.
2413 BZF_API bool bz_RegisterCustomFlag(const char* abbr, const char* name,
2414 const char* helpString, bz_eShotType shotType,
2415 bz_eFlagQuality quality);
2416
2417
2418 // utility
2419 BZF_API const char* bz_MD5(const char * str);
2420 BZF_API const char* bz_MD5(const void * data, size_t size);
2421
2422 BZF_API const char* bz_getServerVersion(void);
2423 BZF_API const char* bz_getProtocolVersion(void);
2424
2425 BZF_API bool bz_ChatFiltered(void);
2426 BZF_API bool bz_CallsignsFiltered(void);
2427
2428 BZF_API void bz_SetFiltering(bool chat, bool callsigns);
2429 BZF_API void bz_LoadFilterDefFile(const char* fileName);
2430 BZF_API void bz_AddFilterItem(const char* word, const char* expression = NULL);
2431 BZF_API void bz_ClearFilter(void);
2432
2433 #endif //_BZFS_API_H_
2434
2435 // Local Variables: ***
2436 // mode: C++ ***
2437 // tab-width: 4 ***
2438 // c-basic-offset: 4 ***
2439 // indent-tabs-mode: nil ***
2440 // End: ***
2441 // ex: shiftwidth=4 tabstop=4
2442