Skip to content

Commit

Permalink
Updated reunion API and implement new natives
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowsAdi committed Jul 5, 2024
1 parent e5771ba commit c8505ee
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 14 deletions.
39 changes: 32 additions & 7 deletions reapi/include/reunion_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define REUNION_API_H

#define REUNION_API_VERSION_MAJOR 1
#define REUNION_API_VERSION_MINOR 1
#define REUNION_API_VERSION_MINOR 4

enum dp_authkind_e
{
Expand All @@ -16,21 +16,46 @@ enum dp_authkind_e
DP_AUTH_SC2009 = 7,
DP_AUTH_AVSMP = 8,
DP_AUTH_SXEI = 9,
DP_AUTH_REVEMU2013 = 10,
DP_AUTH_SSE3 = 11,
DP_AUTH_REVEMU2013 = 10
};

enum reu_authkey_kind
{
REU_AK_UNKNOWN = -1,
REU_AK_STEAM,
REU_AK_VOLUMEID,
REU_AK_HDDSN,
REU_AK_FILEID,
REU_AK_SXEID,
REU_AK_OTHER,
REU_AK_MAX
};

class IReunionApi
{
public:
int version_major;
int version_minor;
enum
{
LONG_AUTHID_LEN = 16
};

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

virtual size_t GetClientAuthdata(int index, void *data, int maxlen) = 0; // get auth data as binary. index: 0-31
virtual const char *GetClientAuthdataString(int index, char *data, int maxlen) = 0; // get auth data as string. index: 0-31
/* Deprecated */virtual size_t GetClientAuthdata(int index, void *data, int maxlen) = 0; // get auth data as binary. index: 0-31
/* Deprecated */virtual const char *GetClientAuthdataString(int index, char *data, int maxlen) = 0; // get auth data as string. index: 0-31

virtual int GetMajorVersion() = 0;
virtual int GetMinorVersion() = 0;

virtual void GetLongAuthId(int index, unsigned char(&authId)[LONG_AUTHID_LEN]) = 0;
virtual reu_authkey_kind GetAuthKeyKind(int index) = 0;

// index: 0-31
virtual void SetConnectTime(int index, double time) = 0;
virtual USERID_t* GetSerializedId(int index) const = 0;
virtual USERID_t* GetStorageId(int index) const = 0;
virtual uint64 GetDisplaySteamId(int index) const = 0;
};

#endif // REUNION_API_H
14 changes: 7 additions & 7 deletions reapi/src/mods/mod_reunion_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ bool ReunionApi_Init()
if (!g_ReunionApi)
return false;

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

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

// need to notify that it is necessary to update the module.
else if (g_ReunionApi->version_major > REUNION_API_VERSION_MAJOR)
else if (g_ReunionApi->GetMajorVersion() > REUNION_API_VERSION_MAJOR)
{
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);
UTIL_ServerPrint("[%s]: Please update the %s up to a major version API >= %d\n", Plugin_info.logtag, Plugin_info.logtag, g_ReunionApi->GetMajorVersion());
}

return false;
}

if (g_ReunionApi->version_minor < REUNION_API_VERSION_MINOR)
if (g_ReunionApi->GetMinorVersion() < REUNION_API_VERSION_MINOR)
{
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);
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());
UTIL_ServerPrint("[%s]: Please update the Reunion up to a minor version API >= %d\n", Plugin_info.logtag, REUNION_API_VERSION_MINOR);
return false;
}
Expand Down
84 changes: 84 additions & 0 deletions reapi/src/natives/natives_reunion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,96 @@ cell AMX_NATIVE_CALL REU_IsRevemuWithoutAdminRights(AMX *amx, cell *params)
return TRUE;
}

cell AMX_NATIVE_CALL REU_GetAuthKeyKind(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index };

CHECK_ISPLAYER(arg_index);

return g_ReunionApi->GetAuthKeyKind(params[arg_index] - 1);
}

cell AMX_NATIVE_CALL REU_SetConnectTime(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index, arg_time };

CHECK_ISPLAYER(arg_index);

int clientId = params[arg_index] - 1;

g_ReunionApi->SetConnectTime(clientId, arg_time);

return TRUE;
}

cell AMX_NATIVE_CALL REU_GetSerializedId(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index, arg_type, arg_authid };

CHECK_ISPLAYER(arg_index);

int clientId = params[arg_index] - 1;

USERID_t *serializedId = g_ReunionApi->GetSerializedId(clientId);

if (!serializedId)
return FALSE;

*getAmxAddr(amx, params[arg_type]) = serializedId->idtype;

cell* dest = getAmxAddr(amx, params[arg_authid]);
char buffer[MAX_STEAMIDSALTLEN];
Q_memcpy(buffer, &serializedId->m_SteamID, sizeof(uint64));

setAmxString(dest, buffer, MAX_STEAMIDSALTLEN);

return TRUE;
}

cell AMX_NATIVE_CALL REU_GetStorageId(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index, arg_type, arg_authid };

CHECK_ISPLAYER(arg_index);

int clientId = params[arg_index] - 1;

USERID_t* serializedId = g_ReunionApi->GetStorageId(clientId);

if (!serializedId)
return FALSE;

*getAmxAddr(amx, params[arg_type]) = serializedId->idtype;

cell* dest = getAmxAddr(amx, params[arg_authid]);
char buffer[MAX_STEAMIDSALTLEN];
Q_memcpy(buffer, &serializedId->m_SteamID, sizeof(uint64));

setAmxString(dest, buffer, MAX_STEAMIDSALTLEN);

return TRUE;
}

cell AMX_NATIVE_CALL REU_GetDisplaySteamId(AMX* amx, cell* params)
{
enum args_e { arg_count, arg_index, arg_time };

CHECK_ISPLAYER(arg_index);

return g_ReunionApi->GetDisplaySteamId(params[arg_index] - 1);
}

AMX_NATIVE_INFO Reunion_Natives[] =
{
{ "REU_GetProtocol", REU_GetProtocol },
{ "REU_GetAuthtype", REU_GetAuthtype },
{ "REU_GetAuthKey", REU_GetAuthKey },
{ "REU_IsRevemuWithoutAdminRights", REU_IsRevemuWithoutAdminRights },
{ "REU_GetAuthKeyKind", REU_GetAuthKeyKind },
{ "REU_SetConnectTime", REU_SetConnectTime },
{ "REU_GetSerializedId", REU_GetSerializedId },
{ "REU_GetStorageId", REU_GetStorageId },
{ "REU_GetDisplaySteamId", REU_GetDisplaySteamId },

{ nullptr, nullptr }
};
Expand Down
2 changes: 2 additions & 0 deletions reapi/src/natives/natives_reunion.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#define MAX_STEAMIDSALTLEN 64

void RegisterNatives_Reunion();

0 comments on commit c8505ee

Please sign in to comment.