Skip to content

Commit f08c8b7

Browse files
authored
Updated reunion API and implement new natives (#318)
1 parent 54aa276 commit f08c8b7

File tree

4 files changed

+125
-14
lines changed

4 files changed

+125
-14
lines changed

reapi/include/reunion_api.h

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define REUNION_API_H
33

44
#define REUNION_API_VERSION_MAJOR 1
5-
#define REUNION_API_VERSION_MINOR 1
5+
#define REUNION_API_VERSION_MINOR 4
66

77
enum dp_authkind_e
88
{
@@ -16,21 +16,46 @@ enum dp_authkind_e
1616
DP_AUTH_SC2009 = 7,
1717
DP_AUTH_AVSMP = 8,
1818
DP_AUTH_SXEI = 9,
19-
DP_AUTH_REVEMU2013 = 10,
20-
DP_AUTH_SSE3 = 11,
19+
DP_AUTH_REVEMU2013 = 10
20+
};
21+
22+
enum reu_authkey_kind
23+
{
24+
REU_AK_UNKNOWN = -1,
25+
REU_AK_STEAM,
26+
REU_AK_VOLUMEID,
27+
REU_AK_HDDSN,
28+
REU_AK_FILEID,
29+
REU_AK_SXEID,
30+
REU_AK_OTHER,
31+
REU_AK_MAX
2132
};
2233

2334
class IReunionApi
2435
{
2536
public:
26-
int version_major;
27-
int version_minor;
37+
enum
38+
{
39+
LONG_AUTHID_LEN = 16
40+
};
2841

2942
virtual int GetClientProtocol(int index) = 0; // index: 0-31
3043
virtual dp_authkind_e GetClientAuthtype(int index) = 0; // index: 0-31
3144

32-
virtual size_t GetClientAuthdata(int index, void *data, int maxlen) = 0; // get auth data as binary. index: 0-31
33-
virtual const char *GetClientAuthdataString(int index, char *data, int maxlen) = 0; // get auth data as string. index: 0-31
45+
/* Deprecated */virtual size_t GetClientAuthdata(int index, void *data, int maxlen) = 0; // get auth data as binary. index: 0-31
46+
/* Deprecated */virtual const char *GetClientAuthdataString(int index, char *data, int maxlen) = 0; // get auth data as string. index: 0-31
47+
48+
virtual int GetMajorVersion() = 0;
49+
virtual int GetMinorVersion() = 0;
50+
51+
virtual void GetLongAuthId(int index, unsigned char(&authId)[LONG_AUTHID_LEN]) = 0;
52+
virtual reu_authkey_kind GetAuthKeyKind(int index) = 0;
53+
54+
// index: 0-31
55+
virtual void SetConnectTime(int index, double time) = 0;
56+
virtual USERID_t* GetSerializedId(int index) const = 0;
57+
virtual USERID_t* GetStorageId(int index) const = 0;
58+
virtual uint64 GetDisplaySteamId(int index) const = 0;
3459
};
3560

3661
#endif // REUNION_API_H

reapi/src/mods/mod_reunion_api.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ bool ReunionApi_Init()
1212
if (!g_ReunionApi)
1313
return false;
1414

15-
if (g_ReunionApi->version_major != REUNION_API_VERSION_MAJOR)
15+
if (g_ReunionApi->GetMajorVersion() != REUNION_API_VERSION_MAJOR)
1616
{
17-
UTIL_ServerPrint("[%s]: Reunion API major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MAJOR, g_ReunionApi->version_major);
17+
UTIL_ServerPrint("[%s]: Reunion API major version mismatch; expected %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MAJOR, g_ReunionApi->GetMajorVersion());
1818

1919
// need to notify that it is necessary to update the Reunion.
20-
if (g_ReunionApi->version_major < REUNION_API_VERSION_MAJOR)
20+
if (g_ReunionApi->GetMajorVersion() < REUNION_API_VERSION_MAJOR)
2121
{
2222
UTIL_ServerPrint("[%s]: Please update the Reunion up to a major version API >= %d\n", Plugin_info.logtag, REUNION_API_VERSION_MAJOR);
2323
}
2424

2525
// need to notify that it is necessary to update the module.
26-
else if (g_ReunionApi->version_major > REUNION_API_VERSION_MAJOR)
26+
else if (g_ReunionApi->GetMajorVersion() > REUNION_API_VERSION_MAJOR)
2727
{
28-
UTIL_ServerPrint("[%s]: Please update the %s up to a major version API >= %d\n", Plugin_info.logtag, Plugin_info.logtag, g_ReunionApi->version_major);
28+
UTIL_ServerPrint("[%s]: Please update the %s up to a major version API >= %d\n", Plugin_info.logtag, Plugin_info.logtag, g_ReunionApi->GetMajorVersion());
2929
}
3030

3131
return false;
3232
}
3333

34-
if (g_ReunionApi->version_minor < REUNION_API_VERSION_MINOR)
34+
if (g_ReunionApi->GetMinorVersion() < REUNION_API_VERSION_MINOR)
3535
{
36-
UTIL_ServerPrint("[%s]: Reunion API minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MINOR, g_ReunionApi->version_minor);
36+
UTIL_ServerPrint("[%s]: Reunion API minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, REUNION_API_VERSION_MINOR, g_ReunionApi->GetMinorVersion());
3737
UTIL_ServerPrint("[%s]: Please update the Reunion up to a minor version API >= %d\n", Plugin_info.logtag, REUNION_API_VERSION_MINOR);
3838
return false;
3939
}

reapi/src/natives/natives_reunion.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,96 @@ cell AMX_NATIVE_CALL REU_IsRevemuWithoutAdminRights(AMX *amx, cell *params)
9696
return TRUE;
9797
}
9898

99+
cell AMX_NATIVE_CALL REU_GetAuthKeyKind(AMX* amx, cell* params)
100+
{
101+
enum args_e { arg_count, arg_index };
102+
103+
CHECK_ISPLAYER(arg_index);
104+
105+
return g_ReunionApi->GetAuthKeyKind(params[arg_index] - 1);
106+
}
107+
108+
cell AMX_NATIVE_CALL REU_SetConnectTime(AMX* amx, cell* params)
109+
{
110+
enum args_e { arg_count, arg_index, arg_time };
111+
112+
CHECK_ISPLAYER(arg_index);
113+
114+
int clientId = params[arg_index] - 1;
115+
116+
g_ReunionApi->SetConnectTime(clientId, arg_time);
117+
118+
return TRUE;
119+
}
120+
121+
cell AMX_NATIVE_CALL REU_GetSerializedId(AMX* amx, cell* params)
122+
{
123+
enum args_e { arg_count, arg_index, arg_type, arg_authid };
124+
125+
CHECK_ISPLAYER(arg_index);
126+
127+
int clientId = params[arg_index] - 1;
128+
129+
USERID_t *serializedId = g_ReunionApi->GetSerializedId(clientId);
130+
131+
if (!serializedId)
132+
return FALSE;
133+
134+
*getAmxAddr(amx, params[arg_type]) = serializedId->idtype;
135+
136+
cell* dest = getAmxAddr(amx, params[arg_authid]);
137+
char buffer[MAX_STEAMIDSALTLEN];
138+
Q_memcpy(buffer, &serializedId->m_SteamID, sizeof(uint64));
139+
140+
setAmxString(dest, buffer, MAX_STEAMIDSALTLEN);
141+
142+
return TRUE;
143+
}
144+
145+
cell AMX_NATIVE_CALL REU_GetStorageId(AMX* amx, cell* params)
146+
{
147+
enum args_e { arg_count, arg_index, arg_type, arg_authid };
148+
149+
CHECK_ISPLAYER(arg_index);
150+
151+
int clientId = params[arg_index] - 1;
152+
153+
USERID_t* serializedId = g_ReunionApi->GetStorageId(clientId);
154+
155+
if (!serializedId)
156+
return FALSE;
157+
158+
*getAmxAddr(amx, params[arg_type]) = serializedId->idtype;
159+
160+
cell* dest = getAmxAddr(amx, params[arg_authid]);
161+
char buffer[MAX_STEAMIDSALTLEN];
162+
Q_memcpy(buffer, &serializedId->m_SteamID, sizeof(uint64));
163+
164+
setAmxString(dest, buffer, MAX_STEAMIDSALTLEN);
165+
166+
return TRUE;
167+
}
168+
169+
cell AMX_NATIVE_CALL REU_GetDisplaySteamId(AMX* amx, cell* params)
170+
{
171+
enum args_e { arg_count, arg_index, arg_time };
172+
173+
CHECK_ISPLAYER(arg_index);
174+
175+
return g_ReunionApi->GetDisplaySteamId(params[arg_index] - 1);
176+
}
177+
99178
AMX_NATIVE_INFO Reunion_Natives[] =
100179
{
101180
{ "REU_GetProtocol", REU_GetProtocol },
102181
{ "REU_GetAuthtype", REU_GetAuthtype },
103182
{ "REU_GetAuthKey", REU_GetAuthKey },
104183
{ "REU_IsRevemuWithoutAdminRights", REU_IsRevemuWithoutAdminRights },
184+
{ "REU_GetAuthKeyKind", REU_GetAuthKeyKind },
185+
{ "REU_SetConnectTime", REU_SetConnectTime },
186+
{ "REU_GetSerializedId", REU_GetSerializedId },
187+
{ "REU_GetStorageId", REU_GetStorageId },
188+
{ "REU_GetDisplaySteamId", REU_GetDisplaySteamId },
105189

106190
{ nullptr, nullptr }
107191
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#pragma once
22

3+
#define MAX_STEAMIDSALTLEN 64
4+
35
void RegisterNatives_Reunion();

0 commit comments

Comments
 (0)