-
Notifications
You must be signed in to change notification settings - Fork 2
/
imatchext.inc
453 lines (397 loc) · 14.5 KB
/
imatchext.inc
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
#if defined _imatchext_included
#endinput
#endif
#define _imatchext_included
forward void OnMissionCacheReload();
/**
* Copies game server details information into given KeyValues at the current position.
*
* @param kvDest Handle to copy KeyValues data into.
* @param kvRequest Optional handle to extend server details with.
* @return True if data was found, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetServerGameDetails(Handle kvDest, Handle kvRequest = null);
/**
* Gets reservation cookie (lobby id).
*
* @param xuidReserve Array to store the 64bit reservation cookie in.
* @return False if internal error.
*/
native bool GetReservationCookie(int cookie[2]);
/**
* Copies missions information into given KeyValues at the current position.
*
* @param kvDest Handle to copy KeyValues data into.
* @return True if data was found, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetAllMissions(Handle kvDest);
/**
* Finds chapter and mission information by game mode, campaign name and chapter number, copies them into respective given KeyValues at their current positions.
* A KeyValues kvRequest argument must contain following structure:
* {
* "game"
* {
* "mode" "coop"
* "campaign" "L4D2C1"
* "chapter" "1"
* }
* }
*
* @param kvRequest Handle to KeyValues tree to find map info by.
* @param kvMapInfo Optional handle to copy KeyValues map info into.
* @param kvMissionInfo Optional handle to copy KeyValues mission info into.
* @return True if map was found, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetMapInfo(Handle kvRequest, Handle kvMapInfo = null, Handle kvMissionInfo = null);
/**
* Finds chapter and mission information by map file name and game mode, copies them into respective given KeyValues at their current positions.
*
* @param bspName Name of the map file name without extension.
* @param gameMode Name of game mode, or NULL_STRING to use current.
* @param kvMapInfo Optional handle to copy KeyValues map info into.
* @param kvMissionInfo Optional handle to copy KeyValues mission info into.
* @return True if map was found, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetMapInfoByBspName(const char[] bspName, const char[] gameMode = NULL_STRING, Handle kvMapInfo = null, Handle kvMissionInfo = null);
/**
* (Left 4 Dead 2 only) Copies all game modes information into given KeyValues at the current position.
*
* @param kvDest Handle to copy KeyValues data into.
* @return True if data was found, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetAllModes(Handle kvDest);
/**
* (Left 4 Dead 2 only) Copies game mode information into given KeyValues at the current position.
*
* @param kvDest Optional handle to copy KeyValues data into.
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if game mode was found, false otherwise.
* @error Invalid or corrupt Handle.
*/
native bool GetGameModeInfo(Handle kvDest = null, const char[] name = NULL_STRING);
/**
* Returns if game mode is using single chapters.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if game mode uses single chapters, false otherwise.
*/
native bool IsSingleChapterMode(const char[] name = NULL_STRING);
/**
* Returns if game mode is based on coop.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if coop game mode used as base, false otherwise.
*/
native bool IsCoopMode(const char[] name = NULL_STRING);
/**
* Returns if game mode is based on realism.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if realism game mode used as base, false otherwise.
*/
native bool IsRealismMode(const char[] name = NULL_STRING);
/**
* Returns if game mode is based on versus.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if versus game mode used as base, false otherwise.
*/
native bool IsVersusMode(const char[] name = NULL_STRING);
/**
* Returns if game mode is based on survival.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if survival game mode used as base, false otherwise.
*/
native bool IsSurvivalMode(const char[] name = NULL_STRING);
/**
* Returns if game mode is based on scavenge.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if scavenge game mode used as base, false otherwise.
*/
native bool IsScavengeMode(const char[] name = NULL_STRING);
/**
* Returns if game mode has player controlled zombies.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if game mode has player controlled zombies, false otherwise.
*/
native bool HasPlayerControlledZombies(const char[] name = NULL_STRING);
/**
* Returns if game mode has configurable difficulty setting.
*
* @param name Name of game mode, or NULL_STRING to use current.
* @return True if game mode has configurable difficulty setting, false otherwise.
*/
native bool HasConfigurableDifficultySetting(const char[] name = NULL_STRING);
/**
* Returns if current map is first in mission scenario.
*
* @return True if current map is first in mission scenario, false otherwise.
*/
native bool IsFirstMapInScenario();
/**
* Returns if current map is last in mission scenario.
*
* @return True if current map is last in mission scenario, false otherwise.
*/
native bool IsMissionFinalMap();
// Helpers
enum SurvivorSet
{
SurvivorSet_L4D2 = 2, /**< Left 4 Dead 2 and Left 4 Dead 1 characters */
SurvivorSet_L4D1 = 1, /**< Left 4 Dead 1 characters */
};
enum MissionSymbol
{
MissionSymbol_Invalid = -1,
};
methodmap MissionSymbol
{
/**
* Returns true if mission is soft disabled.
*
* @return True if mission is soft disabled, false otherwise.
*/
property bool IsDisabled
{
public native get();
}
property bool IsAddon
{
public native get();
}
property bool AllowCola
{
public native get();
}
property bool NoFemaleBoomers
{
public native get();
}
property bool NoCSWeapons
{
public native get();
}
property SurvivorSet SurvivorSet
{
public native get();
}
/**
* Retrieves short identifier of mission, e.g. (L4D2) "L4D2C1", "L4D2C13", (L4D1) "Hospital".
*
* @param buffer Buffer to store name in.
* @param maxlength Maximum length of the value buffer.
* @return Number of bytes written.
*/
public native int GetName(char[] buffer, int maxlength);
/**
* Retrieves a string value for a given mission subkey.
*
* @param key Name of the key.
* @param buffer Buffer to store key value in.
* @param maxlength Maximum length of the value buffer.
* @param defvalue Optional default value to use if the key is not found.
* @return Number of bytes written.
*/
public native int GetString(const char[] key, char[] buffer, int maxlength, const char[] defvalue = NULL_STRING);
/**
* Copies mission data into given KeyValues at the current position.
*
* @param kvDest Handle to copy KeyValues data into.
*/
public native void Export(KeyValues kvDest);
/**
* Obtain first mission symbol for iteration.
*
* @return First MissionSymbol.
*/
public static native MissionSymbol First();
/**
* Next mission symbol for iteration.
*
* @return Next MissionSymbol.
*/
public native MissionSymbol Next();
/**
* Checks whether given MissionSymbol is valid (corresponding mission exists).
*
* @param key MissionSymbol to check existence of.
* @return True if mission is valid, false otherwise.
*/
public static native bool IsValid(MissionSymbol mission);
};
/**
* Retrieve MissionSymbol from given game mode name.
*
* @param name Mission name to look for.
* @return MissionSymbol value, or MissionSymbol_Invalid if mission was not found.
*/
native MissionSymbol GetMissionSymbol(const char[] name);
enum ModeSymbol
{
ModeSymbol_Invalid = -1,
};
methodmap ModeSymbol
{
/**
* Returns true if mode is soft disabled.
*
* @return True if mode is soft disabled, false otherwise.
*/
property bool IsDisabled
{
public native get();
}
property ModeSymbol Base
{
public native get();
}
property bool IsAddon
{
public native get();
}
property int MaxPlayers
{
public native get();
}
property bool HasPlayerControlledZombies
{
public native get();
}
property bool HasConfigurableDifficultySetting
{
public native get();
}
property bool IsSingleChapterMode
{
public native get();
}
/**
* Retrieves short identifier of game mode, e.g. "coop", "survival", "versus".
*
* @param buffer Buffer to store name in.
* @param maxlength Maximum length of the value buffer.
* @return Number of bytes written.
*/
public native int GetName(char[] buffer, int maxlength);
/**
* Retrieves a string value for a given mode subkey.
*
* @param key Name of the key.
* @param buffer Buffer to store key value in.
* @param maxlength Maximum length of the value buffer.
* @param defvalue Optional default value to use if the key is not found.
* @return Number of bytes written.
*/
public native int GetString(const char[] key, char[] buffer, int maxlength, const char[] defvalue = NULL_STRING);
/**
* Copies mission data into given KeyValues at the current position.
*
* @param kvDest Handle to copy KeyValues data into.
*/
public native void Export(KeyValues kvDest);
public native int GetNumChapters(MissionSymbol mission);
public native bool ExportChapter(MissionSymbol mission, int chapter, KeyValues kvDest = null);
public native bool ExportChapterByFile(const char[] bspName, MissionSymbol &mission = MissionSymbol_Invalid, int &chapter = 0, KeyValues kvDest = null);
/**
* Obtain first mode symbol for iteration.
*
* @return First ModeSymbol.
*/
public static native ModeSymbol First();
/**
* Next mode symbol for iteration.
*
* @return Next ModeSymbol.
*/
public native ModeSymbol Next();
/**
* Checks whether given ModeSymbol is valid (corresponding game mode exists).
*
* @param key ModeSymbol to check existence of.
* @return True if mode is valid, false otherwise.
*/
public static native bool IsValid(ModeSymbol mode);
};
/**
* Retrieve ModeSymbol from given game mode name.
*
* @param name Game mode name to look for.
* @return ModeSymbol value, or ModeSymbol_Invalid if game mode was not found.
*/
native ModeSymbol GetModeSymbol(const char[] name);
/** @var ModeSymbol Current mode symbol, or ModeSymbol_Invalid on internal error. */
public const ModeSymbol CurrentMode;
/** @var MissionSymbol Current mission symbol, or MissionSymbol_Invalid if not found. */
public const MissionSymbol CurrentMission;
public Extension __ext_imatchext =
{
name = "[L4D/2] Matchmaking Extension Interface",
file = "imatchext.ext",
#if defined AUTOLOAD_EXTENSIONS
autoload = 1,
#else
autoload = 0,
#endif
required = 0,
};
public void __ext_imatchext_SetNTVOptional()
{
#if !defined REQUIRE_EXTENSIONS
MarkNativeAsOptional("GetServerGameDetails");
MarkNativeAsOptional("GetAllMissions");
MarkNativeAsOptional("GetMapInfo");
MarkNativeAsOptional("GetMapInfoByBspName");
MarkNativeAsOptional("IsSingleChapterMode");
MarkNativeAsOptional("IsCoopMode");
MarkNativeAsOptional("IsRealismMode");
MarkNativeAsOptional("IsVersusMode");
MarkNativeAsOptional("IsSurvivalMode");
MarkNativeAsOptional("IsScavengeMode");
MarkNativeAsOptional("HasPlayerControlledZombies");
MarkNativeAsOptional("HasConfigurableDifficultySetting");
MarkNativeAsOptional("IsFirstMapInScenario");
MarkNativeAsOptional("IsMissionFinalMap");
#endif
MarkNativeAsOptional("GetAllModes");
MarkNativeAsOptional("GetGameModeInfo");
#if !defined REQUIRE_EXTENSIONS
MarkNativeAsOptional("MissionSymbol.GetName");
MarkNativeAsOptional("MissionSymbol.GetString");
MarkNativeAsOptional("MissionSymbol.Export");
MarkNativeAsOptional("MissionSymbol.IsDisabled.get");
MarkNativeAsOptional("MissionSymbol.IsAddon.get");
MarkNativeAsOptional("MissionSymbol.AllowCola.get");
MarkNativeAsOptional("MissionSymbol.NoFemaleBoomers.get");
MarkNativeAsOptional("MissionSymbol.NoCSWeapons.get");
MarkNativeAsOptional("MissionSymbol.SurvivorSet.get");
MarkNativeAsOptional("MissionSymbol.Next");
MarkNativeAsOptional("MissionSymbol.First");
MarkNativeAsOptional("MissionSymbol.IsValid");
MarkNativeAsOptional("GetMissionSymbol");
#endif
MarkNativeAsOptional("ModeSymbol.GetName");
MarkNativeAsOptional("ModeSymbol.GetString");
MarkNativeAsOptional("ModeSymbol.Export");
MarkNativeAsOptional("ModeSymbol.IsDisabled.get");
MarkNativeAsOptional("ModeSymbol.Base.get");
MarkNativeAsOptional("ModeSymbol.IsAddon.get");
MarkNativeAsOptional("ModeSymbol.MaxPlayers.get");
MarkNativeAsOptional("ModeSymbol.HasPlayerControlledZombies.get");
MarkNativeAsOptional("ModeSymbol.HasConfigurableDifficultySetting.get");
MarkNativeAsOptional("ModeSymbol.IsSingleChapterMode.get");
MarkNativeAsOptional("ModeSymbol.GetNumChapters");
MarkNativeAsOptional("ModeSymbol.GetChapter");
MarkNativeAsOptional("ModeSymbol.GetChapterByFile");
MarkNativeAsOptional("ModeSymbol.Next");
MarkNativeAsOptional("ModeSymbol.First");
MarkNativeAsOptional("ModeSymbol.IsValid");
MarkNativeAsOptional("GetModeSymbol");
}