Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce API events & functions to work w/replays #358

Draft
wants to merge 1 commit into
base: 2.4
Choose a base branch
from

Conversation

allejo
Copy link
Member

@allejo allejo commented Sep 2, 2024

New Functions

bool bz_isReplayServer(void)

Returns true if the current BZFS process runs with the -replay flag.

bool bz_loadReplay(const char* _filename, int playerIndex = BZ_SERVERPLAYER)

The BZFS API equivalent of a player running /replay load.

bool bz_replayExists(const char* _filename)

Check to see if a given replay filename exists on the server.

bool bz_unloadReplay(int playerIndex = BZ_SERVERPLAYER)

Reset the replay server's status and unload the current replay. This is no slash-command equivalent of this (as far as I know).

New Server Events

bz_eReplayRequestedEvent

  • Dispatched from Replay::loadFile -> called from /replay load
  • This event is triggered before bz_eReplayLoadedEvent; any errors that happen in loading replays will be reported here
Property Data Type Description
playerID int The player ID that is requesting the replay to be loaded
success bool Whether the replay was able to load successfully
errorMsg const char* If there's an error in loading the replay, the details will be here
filename const char* The filename of the replay requested

bz_eReplayLoadedEvent

  • Dispatched from Replay::loadFile -> called from /replay load
  • This event is only triggered when a file is successfully loaded. If the replay fails to load, this event is never called
Property Data Type Description
filename const char* The filename of the replay that's being loaded
authorCallsign const char* The callsign of the player (or "SERVER") if who started the replay
authorMotto const char* The motto of the author who triggered the recording
protocol const char* The BZFS protocol version the replay was recorded with
serverVersion const char* The BZFS version used for the replay
seconds float The duration of this recording in seconds
start bz_Time* Timestamp of when the replay started
end bz_Time* ...and when it ended

bz_eRecordingStartedEvent

  • Dispatched when a recording starts, i.e. Record::start
    • Called during /record start
    • Called during bz_startRecBuf()
Property Data Type Description
playerID int The player ID that started the recording or 253 if the server starts it

bz_eRecordingEndedEvent

  • Dispatched when a recording ends, i.e. Record:stop
    • Called during /record stop
    • Called during bz_stopRecBuf()

Data fields are the same as bz_eRecordingStartedEvent

- Add the following new event types:
  - `bz_eReplayRequestedEvent`
  - `bz_eReplayLoadedEvent`
  - `bz_eRecordingStartedEvent`
  - `bz_eRecordingEndedEvent`
- Add the following new API functions:
  - `bz_isReplayServer()`
  - `bz_loadReplay(const char* _filename, int playerIndex)`
  - `bz_replayExists(const char* _filename)`
  - `bz_unloadReplay(int playerIndex)`
  - `bz_makeApiTime(time_t time, bz_Time* apiTime)`
@allejo allejo added this to the 2.4.28 milestone Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant