forked from N00byKing/APCpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Archipelago.h
252 lines (196 loc) · 6.41 KB
/
Archipelago.h
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
#pragma once
#include <string>
#include <vector>
#include <map>
#include <cstdint>
#include <set>
extern std::string ap_player_name;
void AP_Init(const char*, const char*, const char*, const char*);
void AP_Init(const char*);
bool AP_IsInit();
bool AP_IsConnected();
void AP_Start();
void AP_Stop();
struct AP_NetworkVersion {
int major;
int minor;
int build;
};
struct AP_NetworkItem {
int64_t item;
int64_t location;
int player;
int flags;
std::string itemName;
std::string locationName;
std::string playerName;
};
enum AP_ItemType {
ITEM_TYPE_FILLER,
ITEM_TYPE_PROGRESSION,
ITEM_TYPE_USEFUL,
ITEM_TYPE_TRAP
};
struct AP_NetworkPlayer {
int team;
int slot;
std::string name;
std::string alias;
std::string game;
};
// Set current client version
void AP_SetClientVersion(AP_NetworkVersion*);
/* Configuration Functions */
void AP_EnableQueueItemRecvMsgs(bool);
void AP_SetDeathLinkSupported(bool);
/* Required Callback Functions */
//Parameter Function must reset local state
void AP_SetItemClearCallback(void (*f_itemclr)());
//Parameter Function must collect item id given with parameter
//Second parameter indicates player who sent the item
//Third parameter indicates whether or not to notify player
void AP_SetItemRecvCallback(void (*f_itemrecv)(int64_t,int,bool));
//Parameter Function must mark given location id as checked
void AP_SetLocationCheckedCallback(void (*f_locrecv)(int64_t));
/* Optional Callback Functions */
//Parameter Function will be called when Death Link is received. Alternative to Pending/Clear usage
void AP_SetDeathLinkRecvCallback(void (*f_deathrecv)());
// Parameter Function receives Slotdata of respective type
void AP_RegisterSlotDataIntCallback(std::string, void (*f_slotdata)(int));
void AP_RegisterSlotDataMapIntIntCallback(std::string, void (*f_slotdata)(std::map<int,int>));
void AP_RegisterSlotDataRawCallback(std::string, void (*f_slotdata)(std::string));
int64_t AP_GetSlotDataInt(const char* key);
const char* AP_GetSlotDataString(const char* key);
bool AP_GetDataPkgReceived();
// Send LocationScouts packet
void AP_QueueLocationScout(int64_t location);
void AP_RemoveQueuedLocationScout(int64_t location);
void AP_QueueLocationScoutsAll();
void AP_SendQueuedLocationScouts(int create_as_hint);
void AP_SendLocationScoutsAll(int create_as_hint);
void AP_SendLocationScouts(std::set<int64_t> locations, int create_as_hint);
// Receive Function for LocationInfo
void AP_SetLocationInfoCallback(void (*f_locrecv)(std::vector<AP_NetworkItem>));
/* Game Management Functions */
// Sends LocationCheck for given index
void AP_SendItem(int64_t location);
void AP_SendItem(std::set<int64_t> const& locations);
// Gives all Items/Locations in current game
bool AP_GetLocationIsChecked(int64_t location_idx);
size_t AP_GetReceivedItemsSize();
int64_t AP_GetReceivedItem(size_t item_idx);
int64_t AP_GetItemAtLocation(int64_t location_id);
bool AP_GetLocationHasLocalItem(int64_t location_id);
AP_ItemType AP_GetLocationItemType(int64_t location_id);
std::string AP_GetItemName(std::string game, int64_t id);
std::string AP_GetLocationName(std::string game, int64_t id);
// Called when Story completed, sends StatusUpdate
void AP_StoryComplete();
/* Deathlink Functions */
bool AP_DeathLinkPending();
void AP_DeathLinkClear();
void AP_DeathLinkSend();
/* Message Management Types */
enum struct AP_MessageType {
Plaintext, ItemSend, ItemRecv, Hint, Countdown
};
struct AP_Message {
AP_MessageType type = AP_MessageType::Plaintext;
std::string text;
};
struct AP_ItemSendMessage : AP_Message {
std::string item;
std::string recvPlayer;
};
struct AP_ItemRecvMessage : AP_Message {
std::string item;
std::string sendPlayer;
};
struct AP_HintMessage : AP_Message {
std::string item;
std::string sendPlayer;
std::string recvPlayer;
std::string location;
bool checked;
};
struct AP_CountdownMessage : AP_Message {
int timer;
};
/* Message Management Functions */
bool AP_IsMessagePending();
AP_Message* AP_GetEarliestMessage();
AP_Message* AP_GetLatestMessage();
void AP_ClearEarliestMessage();
void AP_ClearLatestMessage();
void AP_Say(std::string);
/* Connection Information Types */
enum struct AP_ConnectionStatus {
Disconnected, Connected, Authenticated, ConnectionRefused, NotFound
};
#define AP_PERMISSION_DISABLED 0b000
#define AP_PERMISSION_ENABLED 0b001
#define AP_PERMISSION_GOAL 0b010
#define AP_PERMISSION_AUTO 0b110
struct AP_RoomInfo {
AP_NetworkVersion version;
std::vector<std::string> tags;
bool password_required;
std::map<std::string, int> permissions;
int hint_cost;
int location_check_points;
//MISSING: games
std::map<std::string, std::string> datapackage_checksums;
std::string seed_name;
double time;
};
/* Connection Information Functions */
int AP_GetRoomInfo(AP_RoomInfo*);
AP_ConnectionStatus AP_GetConnectionStatus();
uint64_t AP_GetUUID();
int AP_GetPlayerID();
/* Serverside Data Types */
enum struct AP_RequestStatus {
Pending, Done, Error
};
enum struct AP_DataType {
Raw, Int, Double
};
struct AP_GetServerDataRequest {
AP_RequestStatus status;
std::string key;
void* value;
AP_DataType type;
};
struct AP_DataStorageOperation {
std::string operation;
void* value;
};
struct AP_SetServerDataRequest {
AP_RequestStatus status;
std::string key;
std::vector<AP_DataStorageOperation> operations;
void* default_value;
AP_DataType type;
bool want_reply;
};
struct AP_SetReply {
std::string key;
void* original_value;
void* value;
};
/* Serverside Data Functions */
// Set and Receive Data
void AP_SetServerData(AP_SetServerDataRequest* request);
void AP_GetServerData(AP_GetServerDataRequest* request);
// This returns a string prefix, consistent across game connections and unique to the player slot.
// Intended to be used for getting / setting private server data
// No guarantees are made regarding the content of the prefix!
std::string AP_GetPrivateServerDataPrefix();
// Parameter Function receives all SetReply's
// ! Pointers in AP_SetReply struct only valid within function !
// If values are required beyond that a copy is needed
void AP_RegisterSetReplyCallback(void (*f_setreply)(AP_SetReply));
// Receive all SetReplys with Keys in parameter list
void AP_SetNotify(std::map<std::string,AP_DataType>);
// Single Key version of above for convenience
void AP_SetNotify(std::string, AP_DataType);