diff --git a/reapi/include/reunion_api.h b/reapi/include/reunion_api.h index 0bd7b350..8ba5c363 100644 --- a/reapi/include/reunion_api.h +++ b/reapi/include/reunion_api.h @@ -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 { @@ -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 diff --git a/reapi/src/mods/mod_reunion_api.cpp b/reapi/src/mods/mod_reunion_api.cpp index 0001666f..68bed28f 100644 --- a/reapi/src/mods/mod_reunion_api.cpp +++ b/reapi/src/mods/mod_reunion_api.cpp @@ -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; } diff --git a/reapi/src/natives/natives_reunion.cpp b/reapi/src/natives/natives_reunion.cpp index 4dad5789..cf44de70 100644 --- a/reapi/src/natives/natives_reunion.cpp +++ b/reapi/src/natives/natives_reunion.cpp @@ -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 } }; diff --git a/reapi/src/natives/natives_reunion.h b/reapi/src/natives/natives_reunion.h index 2fb2b425..d38a63e9 100644 --- a/reapi/src/natives/natives_reunion.h +++ b/reapi/src/natives/natives_reunion.h @@ -1,3 +1,5 @@ #pragma once +#define MAX_STEAMIDSALTLEN 64 + void RegisterNatives_Reunion();