aboutsummaryrefslogtreecommitdiff
path: root/plugin/plugin.h
blob: bfed63d7b473febf3e99a87d82358f1b575452b2 (plain)
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
/*
 * Plugin API definition.
 */

#ifndef _PLUGIN_H
#define _PLUGIN_H

#include "common.h"
#include <stdint.h>

/* When the administrator disabled rcon. The plugin must have a way to avoid using rcon since it is non-recoverable. */
#define EPG_RCON_DISABLED	-1

/* 32-bit unsigned integer to indicate the version of the API. */
extern const uint32_t epg_version;

/* Plugin display name. */
extern const char *epg_name;

/* Current session handle. */
struct epg_handle {
	/* Unique ID. */
	int id;
	/* Send rcon command. */
	int (*rcon_send)(int, char *);
	int (*rcon_recv)(int *, char *);
};

/* Before the plugin is loaded.
 * Return a non-zero integer to indicate an error and the plugin will be unloaded immediatedly (without calling epg_unload).
 * Thread: main thread (during autoloading) or control socket (during extmcctl operations). */
int epg_load(struct epg_handle *handle);

/* Before the plugin is unloaded.
 * Return a non-zero integer to indicate an error and the plugin will not be unloaded.
 * Thread: main thread (during autoloading) or control socket (during extmcctl operations). */
int epg_unload(struct epg_handle *handle);

/*
 * When a player joins the game.
 * Thread: worker */
int epg_player_join(struct epg_handle *handle,
		char *player);

int epg_player_leave(struct epg_handle *handle,
		char *player,
		char *reason);

int epg_player_say(struct epg_handle *handle,
		char *player,
		char *content);

int epg_player_die(struct epg_handle *handle,
		char *player,
		char *source);

int epg_player_achievement(struct epg_handle *handle,
		char *player,
		char *challenge);

int epg_player_challenge(struct epg_handle *handle,
		char *player,
		char *challenge);

int epg_player_goal(struct epg_handle *handle,
		char *player,
		char *goal);

int epg_server_stopping(struct epg_handle *handle);

int epg_server_starting(struct epg_handle *handle,
		char *version);

int epg_server_started(struct epg_handle *handle,
		char *took);

#endif // _PLUGIN_H