更改ACE_SDK位置

This commit is contained in:
2025-12-06 17:59:24 +08:00
parent baf547c71d
commit ae5479b583
31 changed files with 2 additions and 2 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+92
View File
@@ -0,0 +1,92 @@
#ifndef __ACE_SDK_ACCOUNT_H__
#define __ACE_SDK_ACCOUNT_H__
#include "ace_sdk_common.h"
#pragma pack(push, 1)
#ifndef ACE_SDK_ACCOUNT_TYPE_ENUM
#define ACE_SDK_ACCOUNT_TYPE_ENUM
typedef enum
{
ACE_SDK_ACCOUNT_TYPE_QQ = 1, // QQ Number
ACE_SDK_ACCOUNT_TYPE_WECHAT = 2, // WeChat Openid
ACE_SDK_ACCOUNT_TYPE_BAIDU = 3, // Baidu Account
ACE_SDK_ACCOUNT_TYPE_QQ_OPENID = 4, // QQ Openid
ACE_SDK_ACCOUNT_TYPE_VISITOR = 7, // Visitor
ACE_SDK_ACCOUNT_TYPE_GOPENID = 8, // Gopenid
ACE_SDK_ACCOUNT_TYPE_GOOGLE = 101, // Google Mail
ACE_SDK_ACCOUNT_TYPE_WEGAME_MAIL = 102, // Wegame Mail
ACE_SDK_ACCOUNT_TYPE_4399 = 201, // 4399
ACE_SDK_ACCOUNT_TYPE_GARENA = 202, // Garena
ACE_SDK_ACCOUNT_TYPE_GIANT_NETWORK = 203, // Giant Network
ACE_SDK_ACCOUNT_TYPE_WEGAME = 301, // WeGame Rail ID
ACE_SDK_ACCOUNT_TYPE_STEAM = 302, // Steam
ACE_SDK_ACCOUNT_TYPE_WEGAME_COMMON_ID = 308, // WeGame Common ID
ACE_SDK_ACCOUNT_TYPE_WOODUAN = 312, // WOODUAN
ACE_SDK_ACCOUNT_TYPE_VK = 314, // VK
ACE_SDK_ACCOUNT_TYPE_COMMON_ID = 601, // Common Account
ACE_SDK_ACCOUNT_TYPE_FACEBOOK = 1001, // Facebook
ACE_SDK_ACCOUNT_TYPE_SUPERCELL = 1002, // Supercell
ACE_SDK_ACCOUNT_TYPE_TCOMMIC = 1005, // Tcommic
ACE_SDK_ACCOUNT_TYPE_UPLAY = 1006, // Uplay
ACE_SDK_ACCOUNT_TYPE_PHONE_OPENID = 1014, // Telephone Openid
ACE_SDK_ACCOUNT_TYPE_LINE = 1019, // Line
ACE_SDK_ACCOUNT_TYPE_APPLE = 1020, // Apple
} AceSdkAccountType;
#endif
#ifndef ACE_SDK_ACCOUNT_PLAT_ENUM
#define ACE_SDK_ACCOUNT_PLAT_ENUM
typedef enum
{
ACE_SDK_PLAT_ID_IOS = 0, // IOS
ACE_SDK_PLAT_ID_ANDROID = 1, // Android
ACE_SDK_PLAT_ID_PC_CLIENT = 3, // PC
ACE_SDK_PLAT_ID_LINUX = 4, // Linux
ACE_SDK_PLAT_ID_SWITCH = 6, // Switch client
ACE_SDK_PLAT_ID_MAC = 7, // Mac
ACE_SDK_PLAT_ID_PS_CLIENT = 8, // PS client
ACE_SDK_PLAT_ID_XBOX_CLIENT = 9, // XBOX client
ACE_SDK_PLAT_ID_PC_EMULATOR_CLIENT = 11, // PC Emulator
ACE_SDK_PLAT_ID_HARMONY_MOBILE = 12, // Harmony Mobile
ACE_SDK_PLAT_ID_HARMONY_PC = 13, // Harmony PC
ACE_SDK_PLAT_ID_UNKNOWN = 99,
} AceSdkAccountPlatID;
#endif
#ifndef ACE_SDK_MAX_ACCOUNT_LEN
#define ACE_SDK_MAX_ACCOUNT_LEN 65
#endif
/**
* 1. Some fields below also require filling in on the client side, their consistency between client and server needs to be ensured.
*/
typedef struct
{
/**
* Player's account is a C-style string composed only of printable ascii characters(except spaces) and '\0' terminator.
* Player's account must be unique for the same 'game_id_'.
*/
char account_[ACE_SDK_MAX_ACCOUNT_LEN];
/**
* If it is not defined in 'AceSdkAccountType', fill it with 'AceSdkAccountType::ACE_SDK_ACCOUNT_TYPE_COMMON_ID'.
*/
AceSdkAccountType account_type_;
// Plat ID of player's client.
AceSdkAccountPlatID plat_id_;
// Contact ACE to obtain your game ID.
uint32_t game_id_;
/**
* For games with separate zones, please fill in the zone ID to uniquely identify a zone; for games without separate zones, please fill in 0.
*/
uint32_t world_id_;
} AceSdkAccount;
#pragma pack(pop)
#endif // __ACE_SDK_ACCOUNT_H__
+21
View File
@@ -0,0 +1,21 @@
#ifndef __ACE_SDK_CLIENT_H__
#define __ACE_SDK_CLIENT_H__
#include <stdint.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
#include "ace_sdk_client_impl.h"
/**
* Initializes the ACE Client SDK.
* This function should be called before any other functions in the ACE Client SDK.
*/
AceSdkResult ace_sdk_client_init();
/**
* Should be called when the game process is exiting.
*/
AceSdkResult ace_sdk_client_deinit();
#endif
@@ -0,0 +1,52 @@
#ifndef __ACE_SDK_CLIENT_ANTI_CHEAT_CORE_H__
#define __ACE_SDK_CLIENT_ANTI_CHEAT_CORE_H__
#include <stdint.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
#include "ace_sdk_client_impl.h"
/**
* This function should be called when the user logs in succesfully.
* @param account_id The GLOBALLY UNIQUE account ID. Its length must be less than or equal to 64 characters, and each must be printable ASCII characters except space.
* @param account_type Find the account type in AceSdkAccountType, or set to ACE_SDK_ACCOUNT_TYPE_COMMON_ID.
* @param world_id For games with multiple zones, set to the unique zone id, or set to 0.
* @param login_ticket The login ticket. A C-style string which is transfered from the game server by ace_sdk_server_get_ticket() of the ACE server sdk.
* @note For each player, the first 3 parameters must be the same as the fields with same name in the server sdk.
*/
AceSdkResult ace_sdk_client_log_in(const char* account_id, AceSdkAccountType account_type, uint32_t world_id, const char* login_ticket);
/**
* Should be called when the user succesfully logs out from the server.
*/
AceSdkResult ace_sdk_client_log_out();
/** The packet buffer */
typedef struct __AceSdkClientPacket {
/** packer buffer */
uint8_t buffer[2048];
/** packet len */
uint32_t len;
} AceSdkClientPacket;
/**
* Should be called every 100ms once the game connects to the game server, and the packet should be sent through the relay channel.
* @param packet The packet buffer.
* @return ACE_SDK_RESULT_OK if there is a packet that need to be sent, and ACE_SDK_RESULT_NO_PACKET_NEED_SENDING if no packets need to be sent.
* @note This function is thread-safe.
*/
AceSdkResult ace_sdk_client_get_packet(AceSdkClientPacket* out_packet);
/**
* Should be called when game received a packet from the relay channel.
* @param packet Pointer to the packet buffer.
* @param len The length of the packet.
* @note This function is NOT thread-safe. Please call this function from a single thread, or ensure that the calls to this function are sequential and do not overlap.
*/
AceSdkResult ace_sdk_client_on_packet_received(const uint8_t* packet_buffer, uint32_t packet_len);
#endif
@@ -0,0 +1,166 @@
#ifndef __ACE_SDK_CLIENT_IMPL_H__
#define __ACE_SDK_CLIENT_IMPL_H__
#ifndef _WIN32
#error ACE Client SDK is only compatible with Windows programs now.
#endif
#include <stdint.h>
#include <string.h>
#include <windows.h>
#define STRSAFE_NO_DEPRECATE
#include <strsafe.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
struct __AceSdkClientPacket;
struct __AceSdkClientLightFeaturePacket;
struct __AceSdkClientLightFeature;
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientLogInRoutine)(void*, const char*, uint32_t, uint32_t, const char*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientLogOutRoutine)(void*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientDeinitRoutine)(void*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientGetPacketRoutine)(void*, struct __AceSdkClientPacket* out_packet);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientOnPacketReceivedRoutine)(void*, const uint8_t*, uint32_t);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientGetLightFeaturePacketRoutine)(void*, struct __AceSdkClientLightFeaturePacket*);
typedef AceSdkResult(ACE_SDK_CALL* __AceSdkClientOnLightFeatureReceivedRoutine)(void*, const struct __AceSdkClientLightFeature*);
typedef struct {
void* handle_;
void* deprecated1_;
__AceSdkClientLogOutRoutine log_out_;
__AceSdkClientDeinitRoutine deinit_;
__AceSdkClientGetPacketRoutine get_packet_;
__AceSdkClientOnPacketReceivedRoutine on_packet_received_;
__AceSdkClientLogInRoutine log_in_;
__AceSdkClientGetLightFeaturePacketRoutine get_light_feature_packet_;
__AceSdkClientOnLightFeatureReceivedRoutine on_light_feature_received_;
}__AceSdkClientObject;
typedef struct {
const ACE_CHAR* config_path_;
}__AceSdkClientInitParams;
#ifdef _MSC_VER
__declspec(selectany) __AceSdkClientObject* __ace_sdk_client_object = NULL;
#else
__attribute__((weak)) __AceSdkClientObject* __ace_sdk_client_object = NULL;
#endif
#define __ACE_SDK_CLIENT_VERSION 9
inline int32_t __ace_sdk_get_exe_mod_path(ACE_CHAR* path, uint32_t len)
{
uint32_t ret = GetModuleFileNameW(NULL, path, len);
if (ret == 0 || ret == len)
{
return -1;
}
ACE_CHAR* pos = wcsrchr(path, L'\\');
if (pos == NULL)
{
return -1;
}
*pos = L'\0';
return 0;
}
inline AceSdkResult ace_sdk_client_init()
{
ACE_CHAR full_path[1024];
if (__ace_sdk_get_exe_mod_path(full_path, ARRAYSIZE(full_path)) != 0)
{
return ACE_SDK_RESULT_CALC_PATH_FAILED;
}
#ifdef _WIN64
const ACE_CHAR* dll_path = L"\\AntiCheatExpert\\ACE-Base64.dll";
#else
const ACE_CHAR* dll_path = L"\\AntiCheatExpert\\x86\\ACE-Base32.dll";
#endif
if (FAILED(StringCchCatW(full_path, ARRAYSIZE(full_path), dll_path)))
{
return ACE_SDK_RESULT_CALC_PATH_FAILED;
}
int32_t ret = __ace_sdk_load_library(full_path);
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
typedef AceSdkResult(*InitRoutine)(uint32_t, const __AceSdkClientInitParams*, __AceSdkClientObject**);
InitRoutine init = (InitRoutine)__ace_sdk_get_symbol("InitAceClient5");
if (init == NULL)
{
__ace_sdk_unload_library();
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
}
return init(__ACE_SDK_CLIENT_VERSION, NULL, &__ace_sdk_client_object);
}
inline AceSdkResult ace_sdk_client_log_in(const char* account_id, AceSdkAccountType account_type, uint32_t world_id, const char* login_token)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->log_in_(__ace_sdk_client_object->handle_, account_id, (uint32_t)account_type, world_id, login_token);
}
inline AceSdkResult ace_sdk_client_log_out()
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->log_out_(__ace_sdk_client_object->handle_);
}
inline AceSdkResult ace_sdk_client_deinit()
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
AceSdkResult ret = __ace_sdk_client_object->deinit_(__ace_sdk_client_object->handle_);
__ace_sdk_client_object = NULL;
return ret;
}
inline AceSdkResult ace_sdk_client_get_packet(struct __AceSdkClientPacket* out_packet)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->get_packet_(__ace_sdk_client_object->handle_, out_packet);
}
inline AceSdkResult ace_sdk_client_on_packet_received(const uint8_t* packet, uint32_t len)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->on_packet_received_(__ace_sdk_client_object->handle_, packet, len);
}
inline AceSdkResult ace_sdk_client_get_light_feature_packet(struct __AceSdkClientLightFeaturePacket* out_packet)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->get_light_feature_packet_(__ace_sdk_client_object->handle_, out_packet);
}
inline AceSdkResult ace_sdk_client_on_light_feature_received(const struct __AceSdkClientLightFeature* light_feature)
{
if (__ace_sdk_client_object == NULL)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
return __ace_sdk_client_object->on_light_feature_received_(__ace_sdk_client_object->handle_, light_feature);
}
#endif
@@ -0,0 +1,41 @@
#ifndef __ACE_SDK_CLIENT_LIGHT_FEATURE_H__
#define __ACE_SDK_CLIENT_LIGHT_FEATURE_H__
#include <stdint.h>
#include "ace_sdk_common.h"
#include "ace_sdk_account.h"
#include "ace_sdk_client_impl.h"
/** The light feature packet buffer */
typedef struct __AceSdkClientLightFeaturePacket {
/** packer buffer */
uint8_t buffer[1024];
/** packet len */
uint32_t len;
} AceSdkClientLightFeaturePacket;
/* The light feature info. All fields are transfered from the game server.
* See AceSdkLightFeatureResponse in ace_sdk_server_light_feature.h */
typedef struct __AceSdkClientLightFeature {
const char* name;
const uint8_t* data;
uint32_t data_len;
uint32_t crc;
} AceSdkClientLightFeature;
/**
* Should be called every time the client tries to send a packet to the game server.
* @param out_packet packet that should be bind to a game protocol to send to the game server.
*/
AceSdkResult ace_sdk_client_get_light_feature_packet(AceSdkClientLightFeaturePacket* out_packet);
/**
* Should be called when game received the light feature from the game server.
* @param data date received from the game server
*/
AceSdkResult ace_sdk_client_on_light_feature_received(const AceSdkClientLightFeature* data);
#endif
+234
View File
@@ -0,0 +1,234 @@
#ifndef __ACE_SDK_COMMON_H__
#define __ACE_SDK_COMMON_H__
#include <stdint.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <dlfcn.h>
#endif
#ifdef __cplusplus
#define ACE_EXTERN_C extern "C"
#else
#define ACE_EXTERN_C
#endif
#if defined(_WIN32) && !defined(_WIN64)
#define ACE_SDK_CALL __cdecl
#else
#define ACE_SDK_CALL
#endif
#ifdef _WIN32
typedef wchar_t ACE_CHAR;
#else
typedef char ACE_CHAR;
#endif
typedef enum
{
ACE_SDK_RESULT_OK = 0,
ACE_SDK_RESULT_NOT_SUPPORTED = 1,
ACE_SDK_RESULT_INVALID_PARAMETER = 2,
ACE_SDK_RESULT_CALC_PATH_FAILED = 3,
ACE_SDK_RESULT_LOAD_LIBRARY_FAILED = 4,
ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED = 5,
ACE_SDK_RESULT_SYMBOL_NOT_FOUND = 6,
ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED = 7,
ACE_SDK_RESULT_INTERNAL_ERROR = 8,
ACE_SDK_RESULT_ACCOUNT_TOO_LONG = 9,
ACE_SDK_RESULT_ACCOUNT_ILLEGAL_CHARACTER = 10,
ACE_SDK_RESULT_NO_PACKET_NEED_SENDING = 100,
ACE_SDK_RESULT_ILLEGAL_LOG_IN = 101,
ACE_SDK_RESULT_COMMON_END = 1000,
ACE_SDK_RESULT_DEVELOP_LANGUAGE_BEGIN = 10000,
ACE_SDK_RESULT_PACK_STRUCT_1BYTE_ERROR = 10001,
ACE_SDK_RESULT_UNPACK_STRUCT_1BYTE_ERROR = 10002,
ACE_SDK_RESULT_PACK_STRUCT_1BYTE_LEN_ERROR = 10003,
ACE_SDK_RESLUT_JAVA_JNI_BEGIN = 20001,
ACE_SDK_RESLUT_JAVA_JNI_ENV_NULL = 20002,
ACE_SDK_RESLUT_JAVA_JNI_JVM_NULL = 20003,
ACE_SDK_RESLUT_JAVA_JNI_JOBJECT_NULL = 20004,
ACE_SDK_RESLUT_JAVA_JNI_CLASS_NULL = 20005,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_DATA_FAILED = 20006,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_OFFSET_FAILED = 20007,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_CAPACITY_FAILED = 20008,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_LENGTH_ERROR = 20009,
// Array field must use the pre-defined length
ACE_SDK_RESLUT_JAVA_ARRAY_LENTGH_ERROR = 20010,
ACE_SDK_RESLUT_JAVA_JNI_END = 20100,
ACE_SDK_RESULT_DEVELOP_LANGUAGE_END = 99999,
ACE_SDK_RESULT_BUSI_INTERFACE_BEGIN = 100000,
ACE_SDK_RESLUT_LIGHT_FEATURE_BEGIN = 100001,
ACE_SDK_RESLUT_LIGHT_FEATURE_NOT_OPENED = 100002,
ACE_SDK_RESLUT_LIGHT_FEATURE_END = 100100,
ACE_SDK_RESLUT_UIC_BEGIN = 100101,
ACE_SDK_RESULT_UIC_TEXT_INTERF_CALL_FAILED = 100102,
ACE_SDK_RESULT_UIC_TEXT_CALLBACK_HAS_NOT_SET = 100103,
ACE_SDK_RESULT_UIC_PIC_INTERF_CALL_FAILED = 100104,
ACE_SDK_RESULT_UIC_PIC_CALLBACK_HAS_NOT_SET = 100105,
ACE_SDK_RESLUT_UIC_END = 100200,
ACE_SDK_RESULT_SAFEMODE_BEGIN = 100201,
ACE_SDK_RESULT_SAFEMODE_CALLBACK_HAS_NOT_SET = 100202,
ACE_SDK_RESULT_SAFEMODE_INTERF_CALL_FAILED = 100203,
ACE_SDK_RESULT_SAFEMODE_END = 100300,
ACE_SDK_RESULT_GAME_SESSION_BEGIN = 100301,
ACE_SDK_RESULT_GAME_SESSION_INTERF_CALL_FAILED = 100302,
ACE_SDK_RESULT_GAME_SESSION_END = 100400,
ACE_SDK_RESULT_BUSI_INTERFACE_END = 999999,
ACE_SDK_RESULT_MAX_INT32 = 0x7fffffff,
} AceSdkResult;
// ----------------------------------------------------
// Internal definitions and functions
// ----------------------------------------------------
#ifdef _WIN32
typedef HMODULE __ACE_SDK_MODULE;
#else
typedef void* __ACE_SDK_MODULE;
#endif
#if defined(ACE_CGO)
extern __ACE_SDK_MODULE __ace_sdk_global_module;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) __ACE_SDK_MODULE __ace_sdk_global_module;
#else
__attribute__((weak)) __ACE_SDK_MODULE __ace_sdk_global_module;
#endif
#ifdef _WIN32
inline int32_t __ace_sdk_load_library_win(const ACE_CHAR* path)
{
if (__ace_sdk_global_module != NULL)
{
return ACE_SDK_RESULT_OK;
}
__ace_sdk_global_module = LoadLibraryW(path);
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
inline void* __ace_sdk_get_symbol_win(const char* symbol_name)
{
if (__ace_sdk_global_module == NULL)
{
return NULL;
}
void* func = (void*)GetProcAddress(__ace_sdk_global_module, symbol_name);
return func;
}
inline int32_t __ace_sdk_unload_library_win()
{
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_OK;
}
BOOL ret = FreeLibrary(__ace_sdk_global_module);
__ace_sdk_global_module = NULL;
return ret == TRUE ? ACE_SDK_RESULT_OK : ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED;
}
#else
inline int32_t __ace_sdk_load_library_linux(const ACE_CHAR* path)
{
char* error = NULL;
if (__ace_sdk_global_module != NULL)
{
return ACE_SDK_RESULT_OK;
}
__ace_sdk_global_module = dlopen(path, RTLD_NOW);
error = dlerror();
if (error)
{
fprintf(stderr, "Open shared library %s failed, %s.\n", path, error);
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
inline void* __ace_sdk_get_symbol_linux(const char* symbol_name)
{
void *func = NULL;
char *error = NULL;
if (__ace_sdk_global_module == NULL)
{
return NULL;
}
func = dlsym(__ace_sdk_global_module, symbol_name);
error = dlerror();
if (error)
{
fprintf(stderr, "dlsym failed, %s.\n", error);
return NULL;
}
return func;
}
inline int32_t __ace_sdk_unload_library_linux()
{
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_OK;
}
int32_t ret = dlclose(__ace_sdk_global_module);
__ace_sdk_global_module = NULL;
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
#endif
inline int32_t __ace_sdk_load_library(const ACE_CHAR* path)
{
#ifdef _WIN32
return __ace_sdk_load_library_win(path);
#else
return __ace_sdk_load_library_linux(path);
#endif
}
inline void* __ace_sdk_get_symbol(const char* symbol_name)
{
#ifdef _WIN32
return __ace_sdk_get_symbol_win(symbol_name);
#else
return __ace_sdk_get_symbol_linux(symbol_name);
#endif
}
inline int32_t __ace_sdk_unload_library()
{
#if defined(_WIN32)
return __ace_sdk_unload_library_win();
#else
return __ace_sdk_unload_library_linux();
#endif
}
#endif
@@ -0,0 +1,47 @@
#ifndef __ACE_SDK_PROTOCOL_BINDING_H__
#define __ACE_SDK_PROTOCOL_BINDING_H__
#include <stdint.h>
#include <stdio.h>
#define INIT_FUNC_KEY (0xaa55abca)
namespace AceProtocolBindingSDK
{
#pragma pack(push, 1)
struct AceSdkAntiDataInfo
{
unsigned int anti_data_len_; /* [in] length of anti data */
const unsigned char *anti_data_; /* [in] anti data buffer */
};
#pragma pack(pop)
typedef struct
{
uint64_t xor_key;
uint64_t get_report_data3_ptr;
uint64_t del_report_data_ptr;
uint64_t on_receive_signature;
}SharedMemInfo,*PSharedMemInfo;
typedef struct
{
uint64_t xor_key;
uint64_t report_data_encrypt_ptr;
uint64_t get_encrypt_key_ptr;
}EncryptSharedMemInfo, *PEncryptSharedMemInfo;
//游戏启动时调用该函数初始化共享内存数据
uint32_t __ace_sdk_protocol_binding_init();
//在发送协议时通过该指针调获取安全需要上报的数据
extern void (*g__ace_sdk_get_report_data3)(AceSdkAntiDataInfo*);
//上报完成后调用该函数删除数据
extern void(*g__ace_sdk_del_report_data)(AceSdkAntiDataInfo*);
//下行收到服务端下发的夹带数据调用该函数
extern void(*g__ace_sdk_on_receive_signature)(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc);
}
#endif
#include "ace_sdk_protocol_binding_impl.h"
@@ -0,0 +1,125 @@
#undef BUILD_WITH_UE
#ifdef BUILD_WITH_UE
#include "Windows/AllowWindowsPlatformTypes.h"
#include "Windows/PreWindowsApi.h"
#include <windows.h>
#include "Windows/PostWindowsApi.h"
#include "Windows/HideWindowsPlatformTypes.h"
#else
#include <windows.h>
#endif
#include <strsafe.h>
//#include "ace_sdk_protocol_binding.h"
#define XOR_CHAR(x) (x^(0x2A))
#define SHARED_MEM_SIZE (255)
#define XOR_KEY_SALT (0x255)
namespace AceProtocolBindingSDK
{
enum
{
PROTOCOL_BINDING_ERROR_SUCCESS = 0,
PROTOCOL_BINDING_ERROR_EXE_PATH = 1,
PROTOCOL_BINDING_ERROR_FULL_PATH = 2,
PROTOCOL_BINDING_ERROR_HANDLE_NULL = 3,
PROTOCOL_BINDING_ERROR_CALL_FUNC = 4,
PROTOCOL_BINDING_ERROR_GET_FUNC = 5,
};
void __ace_sdk_get_report_data3(AceSdkAntiDataInfo* report_data);
void __ace_sdk_del_report_data(AceSdkAntiDataInfo* del_data);
void __ace_sdk_on_receive_signature(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc);
void(*g__ace_sdk_get_report_data3)(AceSdkAntiDataInfo*) = __ace_sdk_get_report_data3;
void(*g__ace_sdk_del_report_data)(AceSdkAntiDataInfo*) = __ace_sdk_del_report_data;
void(*g__ace_sdk_on_receive_signature)(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc) = __ace_sdk_on_receive_signature;
inline int32_t __ace_sdk_get_exe_mod_path(wchar_t* path, uint32_t len)
{
uint32_t ret = GetModuleFileNameW(NULL, path, len);
if (ret == 0 || ret == len)
{
return -1;
}
wchar_t* pos = wcsrchr(path, L'\\');
if (pos == NULL)
{
return -1;
}
*pos = L'\0';
return 0;
}
uint32_t __ace_sdk_protocol_binding_init()
{
static bool init_successful = false;
if (init_successful == true)
{
return PROTOCOL_BINDING_ERROR_SUCCESS;
}
auto now_time = GetTickCount64();
uint64_t mem_xor_key = (now_time << 32) | now_time;
SharedMemInfo info;
info.xor_key = mem_xor_key;
info.get_report_data3_ptr = reinterpret_cast<uint64_t>(&g__ace_sdk_get_report_data3) ^ (info.xor_key + XOR_KEY_SALT);
info.del_report_data_ptr = reinterpret_cast<uint64_t>(&g__ace_sdk_del_report_data) ^ (info.xor_key + XOR_KEY_SALT);
info.on_receive_signature = reinterpret_cast<uint64_t>(&g__ace_sdk_on_receive_signature) ^ (info.xor_key + XOR_KEY_SALT);
wchar_t full_path[1024] = { 0 };
if (__ace_sdk_get_exe_mod_path(full_path, ARRAYSIZE(full_path)) != 0)
{
return PROTOCOL_BINDING_ERROR_EXE_PATH;
}
const wchar_t dll_path[] = { L'\\', L'A', L'n', L't', L'i', L'C', L'h', L'e', L'a', L't', L'E', L'x', L'p', L'e', L'r', L't', L'\\', L'A', L'C', L'E', L'-', L'P', L'B', L'C', L'-', L'G', L'a', L'm', L'e', L'6', L'4', L'.', L'd', L'l', L'l', L'\0' };;
if (FAILED(StringCchCatW(full_path, ARRAYSIZE(full_path), dll_path)))
{
return PROTOCOL_BINDING_ERROR_FULL_PATH;
}
auto handle = GetModuleHandleW(full_path);
if (handle == NULL)
{
handle = LoadLibraryW(full_path);
}
if (handle == NULL)
{
return PROTOCOL_BINDING_ERROR_HANDLE_NULL;
}
typedef bool(*InitRoutine)(SharedMemInfo*, uint32_t key);
InitRoutine func = (InitRoutine)GetProcAddress(handle, MAKEINTRESOURCEA(7));
if (func == NULL)
{
return PROTOCOL_BINDING_ERROR_GET_FUNC;
}
bool init_result = func(&info, INIT_FUNC_KEY);
if (init_result == true)
{
init_successful = true;
return PROTOCOL_BINDING_ERROR_SUCCESS;
}
return PROTOCOL_BINDING_ERROR_CALL_FUNC;
}
void __ace_sdk_get_report_data3(AceSdkAntiDataInfo* report_data)
{
}
void __ace_sdk_del_report_data(AceSdkAntiDataInfo* del_data)
{
}
void __ace_sdk_on_receive_signature(const char* name, const unsigned char *buf, uint32_t buf_len, uint32_t crc)
{
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+92
View File
@@ -0,0 +1,92 @@
#ifndef __ACE_SDK_ACCOUNT_H__
#define __ACE_SDK_ACCOUNT_H__
#include "ace_sdk_common.h"
#pragma pack(push, 1)
#ifndef ACE_SDK_ACCOUNT_TYPE_ENUM
#define ACE_SDK_ACCOUNT_TYPE_ENUM
typedef enum
{
ACE_SDK_ACCOUNT_TYPE_QQ = 1, // QQ Number
ACE_SDK_ACCOUNT_TYPE_WECHAT = 2, // WeChat Openid
ACE_SDK_ACCOUNT_TYPE_BAIDU = 3, // Baidu Account
ACE_SDK_ACCOUNT_TYPE_QQ_OPENID = 4, // QQ Openid
ACE_SDK_ACCOUNT_TYPE_VISITOR = 7, // Visitor
ACE_SDK_ACCOUNT_TYPE_GOPENID = 8, // Gopenid
ACE_SDK_ACCOUNT_TYPE_GOOGLE = 101, // Google Mail
ACE_SDK_ACCOUNT_TYPE_WEGAME_MAIL = 102, // Wegame Mail
ACE_SDK_ACCOUNT_TYPE_4399 = 201, // 4399
ACE_SDK_ACCOUNT_TYPE_GARENA = 202, // Garena
ACE_SDK_ACCOUNT_TYPE_GIANT_NETWORK = 203, // Giant Network
ACE_SDK_ACCOUNT_TYPE_WEGAME = 301, // WeGame Rail ID
ACE_SDK_ACCOUNT_TYPE_STEAM = 302, // Steam
ACE_SDK_ACCOUNT_TYPE_WEGAME_COMMON_ID = 308, // WeGame Common ID
ACE_SDK_ACCOUNT_TYPE_WOODUAN = 312, // WOODUAN
ACE_SDK_ACCOUNT_TYPE_VK = 314, // VK
ACE_SDK_ACCOUNT_TYPE_COMMON_ID = 601, // Common Account
ACE_SDK_ACCOUNT_TYPE_FACEBOOK = 1001, // Facebook
ACE_SDK_ACCOUNT_TYPE_SUPERCELL = 1002, // Supercell
ACE_SDK_ACCOUNT_TYPE_TCOMMIC = 1005, // Tcommic
ACE_SDK_ACCOUNT_TYPE_UPLAY = 1006, // Uplay
ACE_SDK_ACCOUNT_TYPE_PHONE_OPENID = 1014, // Telephone Openid
ACE_SDK_ACCOUNT_TYPE_LINE = 1019, // Line
ACE_SDK_ACCOUNT_TYPE_APPLE = 1020, // Apple
} AceSdkAccountType;
#endif
#ifndef ACE_SDK_ACCOUNT_PLAT_ENUM
#define ACE_SDK_ACCOUNT_PLAT_ENUM
typedef enum
{
ACE_SDK_PLAT_ID_IOS = 0, // IOS
ACE_SDK_PLAT_ID_ANDROID = 1, // Android
ACE_SDK_PLAT_ID_PC_CLIENT = 3, // PC
ACE_SDK_PLAT_ID_LINUX = 4, // Linux
ACE_SDK_PLAT_ID_SWITCH = 6, // Switch client
ACE_SDK_PLAT_ID_MAC = 7, // Mac
ACE_SDK_PLAT_ID_PS_CLIENT = 8, // PS client
ACE_SDK_PLAT_ID_XBOX_CLIENT = 9, // XBOX client
ACE_SDK_PLAT_ID_PC_EMULATOR_CLIENT = 11, // PC Emulator
ACE_SDK_PLAT_ID_HARMONY_MOBILE = 12, // Harmony Mobile
ACE_SDK_PLAT_ID_HARMONY_PC = 13, // Harmony PC
ACE_SDK_PLAT_ID_UNKNOWN = 99,
} AceSdkAccountPlatID;
#endif
#ifndef ACE_SDK_MAX_ACCOUNT_LEN
#define ACE_SDK_MAX_ACCOUNT_LEN 65
#endif
/**
* 1. Some fields below also require filling in on the client side, their consistency between client and server needs to be ensured.
*/
typedef struct
{
/**
* Player's account is a C-style string composed only of printable ascii characters(except spaces) and '\0' terminator.
* Player's account must be unique for the same 'game_id_'.
*/
char account_[ACE_SDK_MAX_ACCOUNT_LEN];
/**
* If it is not defined in 'AceSdkAccountType', fill it with 'AceSdkAccountType::ACE_SDK_ACCOUNT_TYPE_COMMON_ID'.
*/
AceSdkAccountType account_type_;
// Plat ID of player's client.
AceSdkAccountPlatID plat_id_;
// Contact ACE to obtain your game ID.
uint32_t game_id_;
/**
* For games with separate zones, please fill in the zone ID to uniquely identify a zone; for games without separate zones, please fill in 0.
*/
uint32_t world_id_;
} AceSdkAccount;
#pragma pack(pop)
#endif // __ACE_SDK_ACCOUNT_H__
+234
View File
@@ -0,0 +1,234 @@
#ifndef __ACE_SDK_COMMON_H__
#define __ACE_SDK_COMMON_H__
#include <stdint.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <dlfcn.h>
#endif
#ifdef __cplusplus
#define ACE_EXTERN_C extern "C"
#else
#define ACE_EXTERN_C
#endif
#if defined(_WIN32) && !defined(_WIN64)
#define ACE_SDK_CALL __cdecl
#else
#define ACE_SDK_CALL
#endif
#ifdef _WIN32
typedef wchar_t ACE_CHAR;
#else
typedef char ACE_CHAR;
#endif
typedef enum
{
ACE_SDK_RESULT_OK = 0,
ACE_SDK_RESULT_NOT_SUPPORTED = 1,
ACE_SDK_RESULT_INVALID_PARAMETER = 2,
ACE_SDK_RESULT_CALC_PATH_FAILED = 3,
ACE_SDK_RESULT_LOAD_LIBRARY_FAILED = 4,
ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED = 5,
ACE_SDK_RESULT_SYMBOL_NOT_FOUND = 6,
ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED = 7,
ACE_SDK_RESULT_INTERNAL_ERROR = 8,
ACE_SDK_RESULT_ACCOUNT_TOO_LONG = 9,
ACE_SDK_RESULT_ACCOUNT_ILLEGAL_CHARACTER = 10,
ACE_SDK_RESULT_NO_PACKET_NEED_SENDING = 100,
ACE_SDK_RESULT_ILLEGAL_LOG_IN = 101,
ACE_SDK_RESULT_COMMON_END = 1000,
ACE_SDK_RESULT_DEVELOP_LANGUAGE_BEGIN = 10000,
ACE_SDK_RESULT_PACK_STRUCT_1BYTE_ERROR = 10001,
ACE_SDK_RESULT_UNPACK_STRUCT_1BYTE_ERROR = 10002,
ACE_SDK_RESULT_PACK_STRUCT_1BYTE_LEN_ERROR = 10003,
ACE_SDK_RESLUT_JAVA_JNI_BEGIN = 20001,
ACE_SDK_RESLUT_JAVA_JNI_ENV_NULL = 20002,
ACE_SDK_RESLUT_JAVA_JNI_JVM_NULL = 20003,
ACE_SDK_RESLUT_JAVA_JNI_JOBJECT_NULL = 20004,
ACE_SDK_RESLUT_JAVA_JNI_CLASS_NULL = 20005,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_DATA_FAILED = 20006,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_OFFSET_FAILED = 20007,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_CAPACITY_FAILED = 20008,
ACE_SDK_RESLUT_JAVA_JNI_REFLECT_BS_LENGTH_ERROR = 20009,
// Array field must use the pre-defined length
ACE_SDK_RESLUT_JAVA_ARRAY_LENTGH_ERROR = 20010,
ACE_SDK_RESLUT_JAVA_JNI_END = 20100,
ACE_SDK_RESULT_DEVELOP_LANGUAGE_END = 99999,
ACE_SDK_RESULT_BUSI_INTERFACE_BEGIN = 100000,
ACE_SDK_RESLUT_LIGHT_FEATURE_BEGIN = 100001,
ACE_SDK_RESLUT_LIGHT_FEATURE_NOT_OPENED = 100002,
ACE_SDK_RESLUT_LIGHT_FEATURE_END = 100100,
ACE_SDK_RESLUT_UIC_BEGIN = 100101,
ACE_SDK_RESULT_UIC_TEXT_INTERF_CALL_FAILED = 100102,
ACE_SDK_RESULT_UIC_TEXT_CALLBACK_HAS_NOT_SET = 100103,
ACE_SDK_RESULT_UIC_PIC_INTERF_CALL_FAILED = 100104,
ACE_SDK_RESULT_UIC_PIC_CALLBACK_HAS_NOT_SET = 100105,
ACE_SDK_RESLUT_UIC_END = 100200,
ACE_SDK_RESULT_SAFEMODE_BEGIN = 100201,
ACE_SDK_RESULT_SAFEMODE_CALLBACK_HAS_NOT_SET = 100202,
ACE_SDK_RESULT_SAFEMODE_INTERF_CALL_FAILED = 100203,
ACE_SDK_RESULT_SAFEMODE_END = 100300,
ACE_SDK_RESULT_GAME_SESSION_BEGIN = 100301,
ACE_SDK_RESULT_GAME_SESSION_INTERF_CALL_FAILED = 100302,
ACE_SDK_RESULT_GAME_SESSION_END = 100400,
ACE_SDK_RESULT_BUSI_INTERFACE_END = 999999,
ACE_SDK_RESULT_MAX_INT32 = 0x7fffffff,
} AceSdkResult;
// ----------------------------------------------------
// Internal definitions and functions
// ----------------------------------------------------
#ifdef _WIN32
typedef HMODULE __ACE_SDK_MODULE;
#else
typedef void* __ACE_SDK_MODULE;
#endif
#if defined(ACE_CGO)
extern __ACE_SDK_MODULE __ace_sdk_global_module;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) __ACE_SDK_MODULE __ace_sdk_global_module;
#else
__attribute__((weak)) __ACE_SDK_MODULE __ace_sdk_global_module;
#endif
#ifdef _WIN32
inline int32_t __ace_sdk_load_library_win(const ACE_CHAR* path)
{
if (__ace_sdk_global_module != NULL)
{
return ACE_SDK_RESULT_OK;
}
__ace_sdk_global_module = LoadLibraryW(path);
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
inline void* __ace_sdk_get_symbol_win(const char* symbol_name)
{
if (__ace_sdk_global_module == NULL)
{
return NULL;
}
void* func = (void*)GetProcAddress(__ace_sdk_global_module, symbol_name);
return func;
}
inline int32_t __ace_sdk_unload_library_win()
{
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_OK;
}
BOOL ret = FreeLibrary(__ace_sdk_global_module);
__ace_sdk_global_module = NULL;
return ret == TRUE ? ACE_SDK_RESULT_OK : ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED;
}
#else
inline int32_t __ace_sdk_load_library_linux(const ACE_CHAR* path)
{
char* error = NULL;
if (__ace_sdk_global_module != NULL)
{
return ACE_SDK_RESULT_OK;
}
__ace_sdk_global_module = dlopen(path, RTLD_NOW);
error = dlerror();
if (error)
{
fprintf(stderr, "Open shared library %s failed, %s.\n", path, error);
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
inline void* __ace_sdk_get_symbol_linux(const char* symbol_name)
{
void *func = NULL;
char *error = NULL;
if (__ace_sdk_global_module == NULL)
{
return NULL;
}
func = dlsym(__ace_sdk_global_module, symbol_name);
error = dlerror();
if (error)
{
fprintf(stderr, "dlsym failed, %s.\n", error);
return NULL;
}
return func;
}
inline int32_t __ace_sdk_unload_library_linux()
{
if (__ace_sdk_global_module == NULL)
{
return ACE_SDK_RESULT_OK;
}
int32_t ret = dlclose(__ace_sdk_global_module);
__ace_sdk_global_module = NULL;
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
#endif
inline int32_t __ace_sdk_load_library(const ACE_CHAR* path)
{
#ifdef _WIN32
return __ace_sdk_load_library_win(path);
#else
return __ace_sdk_load_library_linux(path);
#endif
}
inline void* __ace_sdk_get_symbol(const char* symbol_name)
{
#ifdef _WIN32
return __ace_sdk_get_symbol_win(symbol_name);
#else
return __ace_sdk_get_symbol_linux(symbol_name);
#endif
}
inline int32_t __ace_sdk_unload_library()
{
#if defined(_WIN32)
return __ace_sdk_unload_library_win();
#else
return __ace_sdk_unload_library_linux();
#endif
}
#endif
+124
View File
@@ -0,0 +1,124 @@
#ifndef __ACE_SDK_SERVER_H__
#define __ACE_SDK_SERVER_H__
#include "ace_sdk_common.h"
#pragma pack(push, 1)
#define ACE_SDK_MAX_LIBRARY_DIR_LENGTH 1024
#define ACE_SDK_MAX_TOKEN_LENGTH 128
/**
AceSdkServerLibraryInfo
*/
typedef struct __AceSdkServerLibraryInfo
{
/**
* Need to end with 0
* Directory of libace_sdk.so(linux) or ace_sdk.dll(windows)
*/
ACE_CHAR library_dir_[ACE_SDK_MAX_LIBRARY_DIR_LENGTH];
} AceSdkServerLibraryInfo;
/**
AceSdkServerAuthInfo
*/
typedef struct __AceSdkServerAuthInfo
{
uint32_t game_id_;
/**
* Need to end with 0
* Contact ACE to obtain your token
*/
char auth_token_[ACE_SDK_MAX_TOKEN_LENGTH];
} AceSdkServerAuthInfo;
/**
AceSdkServerRegion
*/
typedef enum __AceSdkServerRegion
{
/**
* Mainland, China, excluding Hong Kong, Macao and Taiwan..
*/
ACE_SDK_REGION_CHINA_MAINLAND = 101,
/**
* Hong Kong, China
*/
ACE_SDK_REGION_CHINA_HONGKONG = 102,
/**
* Macao, China
*/
ACE_SDK_REGION_CHINA_MACAO = 103,
/**
* Taiwan, China
*/
ACE_SDK_REGION_CHINA_TAIWAN = 104,
/**
* All regions of the Asia except for those defined accurately in this enumeration.
*/
ACE_SDK_REGION_ASIA = 200,
/**
* All regions of the Europe except for those defined accurately in this enumeration.
*/
ACE_SDK_REGION_EUROPE = 300,
/**
* All regions of the America except for those defined accurately in this enumeration.
*/
ACE_SDK_REGION_AMERICA = 400,
} AceSdkServerRegion;
/**
AceSdkGameDistributor
*/
typedef enum __AceSdkGameDistributor
{
/**
* This option usually means:
* 1. the game servers are deployed on Tencent’s intranet (mainland China), or
* 2. the game servers are deployed on Tencent Cloud (Oversea). In this case, you need remember to enable the server to access the public network through the TCP protocol.
*/
ACE_SDK_GAME_DISTRIBUTOR_TENCENT = 1,
/**
* If use this option, you need remember to enable the server to access the public network through the TCP protocol.
*/
ACE_SDK_GAME_DISTRIBUTOR_COMMON = 1000,
} AceSdkGameDistributor;
/**
AceSdkServerDeploymentInfo
*/
typedef struct __AceSdkServerDeploymentInfo
{
/**
It indicates where the game server reports data. So it is necessary to fill it with the most suitable value in the enumeration.
If the game server is deployed in mutiple regions,
case 1: Game servers in different regions are assigned different game ids(they generally are), it is necessary to fill it according to gameid.
case 2: Game servers in different regions are assigned same game id, it is necessary to fill it as ACE_SDK_REGION_ASIA and contact ACE to confirm it.
*/
AceSdkServerRegion region_;
/**
Game distributor
*/
AceSdkGameDistributor distributor_;
} AceSdkServerDeploymentInfo;
#pragma pack(pop)
/**
@brief Init ACE SDK of server side. It must be called before using any other interfaces.
@param library It indicates where the libace_sdk.so/ace_sdk.dll is located.
@param auth_info Authentication info which is provided by ACE.
@param deployment_info Deployment info of the game server.
*/
AceSdkResult ace_sdk_server_init(const AceSdkServerLibraryInfo* library_info, const AceSdkServerAuthInfo* auth_info, const AceSdkServerDeploymentInfo* deployment_info);
/**
@brief Deinit ACE SDK of server side. It could be called before process is ready to exist.
*/
AceSdkResult ace_sdk_server_deinit();
#include "ace_sdk_server_impl.h"
#endif // __ACE_SDK_SERVER_H__
@@ -0,0 +1,81 @@
#ifndef __ACE_SDK_SERVER_ANTI_CHEAT_CORE_H__
#define __ACE_SDK_SERVER_ANTI_CHEAT_CORE_H__
#include "ace_sdk_account.h"
#include "ace_sdk_server_anti_cheat_core_impl.h"
#pragma pack(push, 1)
#ifndef ACE_SDK_MAX_PLAYER_ROLE_NAME
#define ACE_SDK_MAX_PLAYER_ROLE_NAME 1024
#endif
#ifndef ACE_SDK_MAX_PACKET_SIZE
#define ACE_SDK_MAX_PACKET_SIZE (2 * 1024)
#endif
#ifndef ACE_SDK_MAX_PACKET_NUM
#define ACE_SDK_MAX_PACKET_NUM 100
#endif
typedef struct __AceSdkPlayerAddInfo
{
char role_name_[ACE_SDK_MAX_PLAYER_ROLE_NAME];
} AceSdkPlayerAddInfo;
typedef struct __AceSdkServerPacket
{
/**
* It indicates the account to which the packet belongs.
*/
AceSdkAccount account_;
/**
* It represents the actual length of 'packet_buffer_'.
*/
uint32_t packet_len_;
uint8_t packet_buffer_[ACE_SDK_MAX_PACKET_SIZE];
} AceSdkServerPacket;
typedef struct __AceSdkServerPacketList
{
/**
* if 'packet_num_' is 0, it means that there is no data to send to the ACE client currently.
*/
uint32_t packet_num_;
AceSdkServerPacket packets_[ACE_SDK_MAX_PACKET_NUM];
} AceSdkServerPacketList;
#pragma pack(pop)
/**
* @brief It must be called after player logins the game immediately.
* @brief If player's client reconnects to game server successfully after calling 'del_player_', it also should be called.
* @param account Account for player.
* @param info Additional Information for Player.
*/
AceSdkResult ace_sdk_server_add_player(const AceSdkAccount* account, const AceSdkPlayerAddInfo* info);
/**
* @brief It must be called every 60 seconds between calling 'add_player_' and 'del_player_'.
* @brief It should not be called before calling 'add_player_' or after calling 'del_player_'.
* @param account Account for player.
*/
AceSdkResult ace_sdk_server_keep_alive_player(const AceSdkAccount* account);
/**
* @brief It must be called after player logouts the game immediately.
* @brief If game server losts the connection of player's client, it also should be called.
* @param account Account for player.
*/
AceSdkResult ace_sdk_server_delete_player(const AceSdkAccount* account);
/**
* @brief It must be called when receive anti cheat packet from client
* @param packet Packet that received from ACE client and need to be sent to ACE backend.
*/
AceSdkResult ace_sdk_server_on_packet_received(const AceSdkServerPacket* packet);
/**
* @brief must be called more than 1000 times per second.The faster and more uniform the frequency, the better.
*/
AceSdkResult ace_sdk_server_get_packet(AceSdkServerPacketList* packets);
#endif // __ACE_SDK_SERVER_ANTI_CHEAT_CORE_H__
@@ -0,0 +1,115 @@
#ifndef __ACE_SDK_SERVER_ANTI_CHEAT_CORE_IMPL_H__
#define __ACE_SDK_SERVER_ANTI_CHEAT_CORE_IMPL_H__
#include "ace_sdk_server.h"
struct __AceSdkPlayerAddInfo;
struct __AceSdkServerPacket;
struct __AceSdkServerPacketList;
/***
* Internal functions' implementation
*/
#pragma pack(push, 1)
typedef int32_t(ACE_SDK_CALL* __AceSdkServerAddPlayer)(const AceSdkAccount*, const struct __AceSdkPlayerAddInfo*);
typedef int32_t(ACE_SDK_CALL* __AceSdkServerKeepAlivePlayer)(const AceSdkAccount*);
typedef int32_t(ACE_SDK_CALL* __AceSdkServerDeletePlayer)(const AceSdkAccount*);
typedef int32_t(ACE_SDK_CALL* __AceSdkServerOnPacketReceived)(const struct __AceSdkServerPacket*);
typedef int32_t(ACE_SDK_CALL* __AceSdkServerGetPacket)(struct __AceSdkServerPacketList*);
typedef struct
{
__AceSdkServerAddPlayer add_player_;
__AceSdkServerKeepAlivePlayer keep_alive_player_;
__AceSdkServerDeletePlayer del_player_;
__AceSdkServerOnPacketReceived on_packet_received_;
__AceSdkServerGetPacket get_packet_;
} __AceSdkServerAntiCheatCoreObject;
#pragma pack(pop)
#if defined(ACE_CGO)
extern __AceSdkServerAntiCheatCoreObject* __ace_sdk_server_anti_cheat_core_object;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) __AceSdkServerAntiCheatCoreObject* __ace_sdk_server_anti_cheat_core_object = NULL;
#else
__attribute__((weak)) __AceSdkServerAntiCheatCoreObject* __ace_sdk_server_anti_cheat_core_object = NULL;
#endif
inline int32_t __ace_sdk_server_anti_cheat_core_init()
{
if (__ace_sdk_init_succ == 0)
{
return -1;
}
if (__ace_sdk_server_anti_cheat_core_object != NULL)
{
return 0;
}
typedef __AceSdkServerAntiCheatCoreObject* (ACE_SDK_CALL*__AceSdkServerGetAntiCheatCoreObject)();
__AceSdkServerGetAntiCheatCoreObject func = (__AceSdkServerGetAntiCheatCoreObject)__ace_sdk_get_symbol("__ace_sdk_server_get_anti_cheat_core_object");
if (func == NULL)
{
return -1;
}
__ace_sdk_server_anti_cheat_core_object = func();
if (__ace_sdk_server_anti_cheat_core_object == NULL)
{
return -1;
}
return 0;
}
inline AceSdkResult ace_sdk_server_add_player(const AceSdkAccount* account, const struct __AceSdkPlayerAddInfo* info)
{
if (__ace_sdk_server_anti_cheat_core_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
__ace_sdk_server_anti_cheat_core_object->add_player_(account, info);
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_keep_alive_player(const AceSdkAccount* account)
{
if (__ace_sdk_server_anti_cheat_core_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
__ace_sdk_server_anti_cheat_core_object->keep_alive_player_(account);
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_delete_player(const AceSdkAccount* account)
{
if (__ace_sdk_server_anti_cheat_core_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
__ace_sdk_server_anti_cheat_core_object->del_player_(account);
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_on_packet_received(const struct __AceSdkServerPacket* packet)
{
if (__ace_sdk_server_anti_cheat_core_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
__ace_sdk_server_anti_cheat_core_object->on_packet_received_(packet);
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_get_packet(struct __AceSdkServerPacketList* packets)
{
if (__ace_sdk_server_anti_cheat_core_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
__ace_sdk_server_anti_cheat_core_object->get_packet_(packets);
return ACE_SDK_RESULT_OK;
}
#endif // __ACE_SDK_SERVER_ANTI_CHEAT_CORE_IMPL_H__
@@ -0,0 +1,211 @@
#ifndef __ACE_SDK_SERVER_IMPL_H__
#define __ACE_SDK_SERVER_IMPL_H__
#include "ace_sdk_common.h"
struct __AceSdkServerLibraryInfo;
struct __AceSdkServerAuthInfo;
struct __AceSdkServerDeploymentInfo;
#define ACE_SDK_SERVER_MAX_GAME_DEV_LANGUAGE_LEN 64
#pragma pack(push, 1)
typedef struct
{
char library_path_[ACE_SDK_MAX_LIBRARY_DIR_LENGTH * 2];
char game_dev_language_[ACE_SDK_SERVER_MAX_GAME_DEV_LANGUAGE_LEN];
} AceSdkServerExtendInfo;
#pragma pack(pop)
#if defined(ACE_CGO)
extern int __ace_sdk_init_succ;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) int __ace_sdk_init_succ = 0;
#else
__attribute__((weak)) int __ace_sdk_init_succ = 0;
#endif
/***
* Internal functions' implementation
*/
inline AceSdkResult ace_sdk_server_report_extend_info(const AceSdkServerExtendInfo* extend_info)
{
if (extend_info == NULL)
{
return ACE_SDK_RESULT_OK;
}
typedef int(ACE_SDK_CALL* AceSdkServerExtendInfoReport)(const AceSdkServerExtendInfo* info);
AceSdkServerExtendInfoReport func_extend_info = (AceSdkServerExtendInfoReport)__ace_sdk_get_symbol("__ace_sdk_server_extend_info");
if (func_extend_info != NULL)
{
func_extend_info(extend_info);
}
return ACE_SDK_RESULT_OK;
}
/**
* Initialize the SDK using the specified interface.
*/
inline AceSdkResult ace_sdk_server_init_specified(const struct __AceSdkServerLibraryInfo* library_info, const struct __AceSdkServerAuthInfo* auth_info, const struct __AceSdkServerDeploymentInfo* deployment_info, const char* name)
{
int32_t ret = ACE_SDK_RESULT_OK;
if (library_info == NULL || auth_info == NULL || deployment_info == NULL || name == NULL)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
ACE_CHAR library_path[ACE_SDK_MAX_LIBRARY_DIR_LENGTH * 2] = {0};
#ifdef _WIN32
_snwprintf_s(library_path, sizeof(library_path)/sizeof(library_path[0]), _TRUNCATE, L"%s/%s", library_info->library_dir_, L"ace_sdk.dll");
#else
snprintf(library_path, sizeof(library_path), "%s/%s", library_info->library_dir_, "libace_sdk.so");
#endif
ret = __ace_sdk_load_library(library_path);
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
typedef int(ACE_SDK_CALL* AceSdkServerInit)(const struct __AceSdkServerAuthInfo*, const struct __AceSdkServerDeploymentInfo*);
AceSdkServerInit func = (AceSdkServerInit)__ace_sdk_get_symbol(name);
if (func == NULL)
{
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
}
ret = func(auth_info, deployment_info);
if (ret != 0)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
__ace_sdk_init_succ = 1;
// report extend info
AceSdkServerExtendInfo extend_info;
#ifdef _WIN32
char library_path_utf8[ACE_SDK_MAX_LIBRARY_DIR_LENGTH] = {0};
int library_path_utf8_len = WideCharToMultiByte(CP_UTF8, 0, library_info->library_dir_, -1, library_path_utf8, sizeof(library_path_utf8)-1, NULL, NULL);
if (library_path_utf8_len <= 0)
{
return ACE_SDK_RESULT_OK;
}
library_path_utf8[library_path_utf8_len] = 0;
snprintf(extend_info.library_path_, sizeof(extend_info.library_path_), "%s/%s", library_path_utf8, "ace_sdk.dll");
#else
snprintf(extend_info.library_path_, sizeof(extend_info.library_path_), "%s/%s", library_info->library_dir_, "libace_sdk.so");
#endif
snprintf(extend_info.game_dev_language_, sizeof(extend_info.game_dev_language_), "C/C++");
ace_sdk_server_report_extend_info(&extend_info);
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_init(const struct __AceSdkServerLibraryInfo* library_info, const struct __AceSdkServerAuthInfo* auth_info, const struct __AceSdkServerDeploymentInfo* deployment_info)
{
return ace_sdk_server_init_specified(library_info, auth_info, deployment_info, "__ace_sdk_server_init");
}
inline AceSdkResult ace_sdk_server_init_without_proc(const struct __AceSdkServerLibraryInfo* library_info, const struct __AceSdkServerAuthInfo* auth_info, const struct __AceSdkServerDeploymentInfo* deployment_info)
{
return ace_sdk_server_init_specified(library_info, auth_info, deployment_info, "__ace_sdk_server_init_without_proc");
}
inline AceSdkResult ace_sdk_server_proc()
{
if (!__ace_sdk_init_succ)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
typedef int(ACE_SDK_CALL* ace_sdk_server_proc)();
ace_sdk_server_proc func = (ace_sdk_server_proc)__ace_sdk_get_symbol("__ace_sdk_server_proc");
if (func != NULL)
{
func();
}
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_deinit()
{
int32_t ret = ACE_SDK_RESULT_OK;
__ace_sdk_init_succ = 0;
typedef int(ACE_SDK_CALL* AceSdkServerDeinit)();
AceSdkServerDeinit func = (AceSdkServerDeinit)__ace_sdk_get_symbol("__ace_sdk_server_deinit");
if (func != NULL)
{
func();
}
ret = __ace_sdk_unload_library();
if (ret != 0)
{
return ACE_SDK_RESULT_UNLOAD_LIBRARY_FAILED;
}
return ACE_SDK_RESULT_OK;
}
/***
* Internal functions' implementation for special usage
*/
#pragma pack(push, 1)
/**
AceSdkServerEnvType
*/
typedef enum
{
ACE_SDK_SERVER_TEST = 101,
ACE_SDK_SERVER_PRODUCT = 1001
} AceSdkServerEnvType;
/**
AceSdkServerNetworkType
*/
typedef enum
{
ACE_SDK_SERVER_INTRA_NET = 0,
ACE_SDK_SERVER_PUBLIC_NET = 1,
} AceSdkServerNetType;
/**
AceSdkServerAccessInfo
*/
#define ACE_SDK_SERVER_MAX_DOMAIN_LEN 1024
typedef struct
{
char product_data_proxy_[ACE_SDK_SERVER_MAX_DOMAIN_LEN];
char product_busi_proxy_[ACE_SDK_SERVER_MAX_DOMAIN_LEN];
char test_data_proxy_[ACE_SDK_SERVER_MAX_DOMAIN_LEN];
char test_busi_proxy_[ACE_SDK_SERVER_MAX_DOMAIN_LEN];
AceSdkServerEnvType env_type_;
AceSdkServerNetType net_type_;
} AceSdkServerAccessInfo;
#pragma pack(pop)
inline AceSdkResult ace_sdk_server_customized_init(const struct __AceSdkServerLibraryInfo* library_info, const struct __AceSdkServerAuthInfo* auth_info, const AceSdkServerAccessInfo* access_info)
{
int32_t ret = ACE_SDK_RESULT_OK;
ACE_CHAR library_path[ACE_SDK_MAX_LIBRARY_DIR_LENGTH * 2] = {0};
#ifdef _WIN32
_snwprintf_s(library_path, sizeof(library_path)/sizeof(library_path[0]), _TRUNCATE, L"%s/%s", library_info->library_dir_, L"ace_sdk.dll");
#else
snprintf(library_path, sizeof(library_path), "%s/%s", library_info->library_dir_, "libace_sdk.so");
#endif
ret = __ace_sdk_load_library(library_path);
if (ret != 0)
{
return ACE_SDK_RESULT_LOAD_LIBRARY_FAILED;
}
typedef int(ACE_SDK_CALL* AceSdkServerInit)(const struct __AceSdkServerAuthInfo*, const AceSdkServerAccessInfo*);
AceSdkServerInit func = (AceSdkServerInit)__ace_sdk_get_symbol("__ace_sdk_server_customized_init");
if (func == NULL)
{
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
}
ret = func(auth_info, access_info);
if (ret != 0)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
__ace_sdk_init_succ = 1;
return ACE_SDK_RESULT_OK;
}
#endif // __ACE_SDK_SERVER_IMPL_H__
@@ -0,0 +1,62 @@
#ifndef __ACE_SDK_SERVER_LIGHT_FEATURE_H__
#define __ACE_SDK_SERVER_LIGHT_FEATURE_H__
#include "ace_sdk_account.h"
#include "ace_sdk_server_light_feature_impl.h"
#pragma pack(push, 1)
#define ACE_SDK_MAX_CLIENT_VERSION_LEN 256
#define ACE_SDK_MAX_LIGHT_FEATURE_NAME_LEN 256
#define ACE_SDK_MAX_LIGHT_FEATURE_DATA_LEN (128 * 1024)
/**
* TssSdkGetFeatureUserInfo
*/
typedef struct __AceSdkLightFeatureRequest
{
/**
* Version of the client: string separated by '.'
*/
char client_version_[ACE_SDK_MAX_CLIENT_VERSION_LEN];
} AceSdkLightFeatureRequest;
/**
* AceSdkLightFeatureResponse
*/
typedef struct __AceSdkLightFeatureResponse
{
/**
* Actual length of the light feature. 0 means that no light features are matched.
*/
int32_t data_len_;
/**
* Binary content of the light feature.
*/
char data_[ACE_SDK_MAX_LIGHT_FEATURE_DATA_LEN];
/**
* Name of the light feature(C-style string). It is recommended to log it along with the account for trouble shooting.
*/
char name_[ACE_SDK_MAX_LIGHT_FEATURE_NAME_LEN];
/**
* CRC32 of the light feature data. It is recommended to log it along with the account for trouble shooting.
*/
uint32_t data_crc_;
} AceSdkLightFeatureResponse;
#pragma pack(pop)
/**
* @brief It must be called after player logins the game as soon as possible.
* @param account Account of player.
* @param request Information for matching light feature.
* @param response Information of light feature.
* @returns Non-0 : Contact ACE to handle it.
* 0 : If 'data_len_' is not 0, send light feature data('data_') to ACE client with the actual length('data_len_') and guarante success.
* If 'data_len_' is 0, do nothing.
* @note If light feature is matched but not sent to ACE client successfully and immediately, players may be punished wrongly by ACE.
*/
AceSdkResult ace_sdk_server_get_light_feature(const AceSdkAccount* account, const AceSdkLightFeatureRequest* request, AceSdkLightFeatureResponse* response);
#endif // __ACE_SDK_SERVER_LIGHT_FEATURE_H__
@@ -0,0 +1,63 @@
#ifndef __ACE_SDK_SERVER_LIGHT_FEATURE_IMPL_H__
#define __ACE_SDK_SERVER_LIGHT_FEATURE_IMPL_H__
#include "ace_sdk_server.h"
struct __AceSdkLightFeatureRequest;
struct __AceSdkLightFeatureResponse;
#if defined(ACE_CGO)
extern int __ace_sdk_light_feature_init_succ;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) int __ace_sdk_light_feature_init_succ = 0;
#else
__attribute__((weak)) int __ace_sdk_light_feature_init_succ = 0;
#endif
inline int ace_sdk_server_init_light_feature() {
int ret = 0;
if (!__ace_sdk_init_succ)
{
return -1;
}
if (__ace_sdk_light_feature_init_succ)
{
return ret;
}
typedef int32_t(ACE_SDK_CALL* __AceSdkServerInitLightFeature)();
__AceSdkServerInitLightFeature func = (__AceSdkServerInitLightFeature)__ace_sdk_get_symbol("__ace_sdk_server_init_light_feature");
if (func == NULL)
{
return -1;
}
ret = func();
if (ret == 0)
{
__ace_sdk_light_feature_init_succ = 1;
}
return ret;
}
inline AceSdkResult ace_sdk_server_get_light_feature(const AceSdkAccount* account, const struct __AceSdkLightFeatureRequest* request, struct __AceSdkLightFeatureResponse* response)
{
if (ace_sdk_server_init_light_feature() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
if (account == NULL || request == NULL || response == NULL)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
typedef int32_t(ACE_SDK_CALL* __AceSdkServerGetLightFeature)(const AceSdkAccount*, const struct __AceSdkLightFeatureRequest*, struct __AceSdkLightFeatureResponse*);
__AceSdkServerGetLightFeature func = (__AceSdkServerGetLightFeature)__ace_sdk_get_symbol("__ace_sdk_server_get_light_feature");
if (func == NULL)
{
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
}
func(account, request, response);
return ACE_SDK_RESULT_OK;
}
#endif // ACE_SDK_SERVER_LIGHT_FEATURE_IMPL_H
@@ -0,0 +1,238 @@
#ifndef __ACE_SDK_SERVER_TEXT_CHECK_H__
#define __ACE_SDK_SERVER_TEXT_CHECK_H__
#include "ace_sdk_account.h"
#include "ace_sdk_server_uic.h"
#include "ace_sdk_server_text_check_impl.h"
#pragma pack(push, 1)
#define ACE_SDK_UIC_MAX_MESSAGE_LEN 15000
#define ACE_SDK_UIC_MAX_TITLE_LEN 300
#define ACE_SDK_UIC_MAX_INTRODUCTION_LEN 1000
#define ACE_SDK_UIC_MAX_BATCH_MULTI_TEXT_LEN 10
#define ACE_SDK_UIC_MAX_EXTRA_DATA_LEN 4095
typedef enum
{
ACE_LANGUAGE_NON = 0, // No language distinction
ACE_LANGUAGE_EN = 1, // English
ACE_LANGUAGE_CHT = 2, // Traditional Chinese
ACE_LANGUAGE_VN = 3, // Vietnamese
ACE_LANGUAGE_CHS = 4, // Simplified Chinese
ACE_LANGUAGE_TH = 5, // Thai
ACE_LANGUAGE_KO = 6, // Korean
ACE_LANGUAGE_FR = 7, // French
ACE_LANGUAGE_DE = 8, // German
ACE_LANGUAGE_RU = 9, // Russian
ACE_LANGUAGE_TR = 10, // Turkish
ACE_LANGUAGE_PTEU = 11, // Portugal (Europe)
ACE_LANGUAGE_PTLT = 12, // Portugal (Latin America)
ACE_LANGUAGE_ESEU = 13, // Spain (Europe)
ACE_LANGUAGE_ESLT = 14, // Spain (Latin America)
ACE_LANGUAGE_IT = 15, // Italy
ACE_LANGUAGE_NL = 16, // Dutch
ACE_LANGUAGE_MY = 17, // Malay
ACE_LANGUAGE_ID = 18, // Indonesian
ACE_LANGUAGE_AR = 19, // Arabic
ACE_LANGUAGE_INDIA = 20, // Hindi
ACE_LANGUAGE_JP = 21, // Japanese
ACE_LANGUAGE_MAX_DEFINE = 100
} AceSdkTextMsglanguage;
typedef struct
{
/**
* It represents the text usage scene id, segmentation principle refer to AceSdkUicMsgCategory
* For specific values, refer to the registration scenario on the ACE official website
* Required
*/
uint32_t scene_id_;
/**
* It represents message content, maximum length is ACE_SDK_UIC_MAX_MESSAGE_LEN
* Required
*/
char text_[ACE_SDK_UIC_MAX_MESSAGE_LEN];
/**
* It represents title of message content, maximum length is ACE_SDK_UIC_MAX_TITLE_LEN
* Optional, if no need, recommend clear it
*/
char title_[ACE_SDK_UIC_MAX_TITLE_LEN];
/**
* It represents introduction of message content, maximum length is ACE_SDK_UIC_MAX_INTRODUCTION_LEN
* Optional, if no need, recommend clear it
*/
char introduction_[ACE_SDK_UIC_MAX_INTRODUCTION_LEN];
/**
* It represents language of message content, refer to AceSdkTextMsglanguage
* By default, fill in ACE_LANGUAGE_NON(0) to indicate no language distinction
* Required
*/
int32_t local_language_;
/**
* Reserved for extended content, generally in json format, maximum length is ACE_SDK_UIC_MAX_EXTRA_DATA_LEN
* Optional, if no need, recommend clear it
*/
char extra_data_[ACE_SDK_UIC_MAX_EXTRA_DATA_LEN];
} AceSdkMultiTextInputInfo;
typedef struct __AceSdkBatchMultiTextInputInfo
{
/**
* It indicates the account to which the input belongs
* Required
*/
AceSdkAccount account_info_;
/**
* It represents the area id of the account, refer to AceSdkUicAreaID
* Required
*/
uint32_t area_id_;
/**
* It represents the role id of the account
* Required
*/
uint32_t role_id_;
/**
* It represents the role level of the account
* Required
*/
uint32_t role_level_;
/**
* It represents the role name of the account
* Required
*/
char role_name_[ACE_SDK_UIC_MAX_ROLE_NAME_LEN];
/**
* It represents the url of user avatar, maximum length is ACE_SDK_UIC_MAX_HEAD_PIC_URL_LEN
* Optional, if no need, recommend clear it
*/
char head_pic_url_[ACE_SDK_UIC_MAX_HEAD_PIC_URL_LEN];
/**
* It represents the length of 'multi_text_array_', maximum length is ACE_SDK_UIC_MAX_BATCH_MULTI_TEXT_LEN
* Required
*/
int32_t multi_text_cnt_;
/**
* It contains several sets of input text
* Required
*/
AceSdkMultiTextInputInfo multi_text_array_[ACE_SDK_UIC_MAX_BATCH_MULTI_TEXT_LEN];
/**
* callback_len_ is the length of 'callback_data_', maximum length is ACE_SDK_UIC_MAX_CALLBACK_DATA_LEN
* When the asynchronous interface is called back, the 'callback_data_' is returned as it is
* Optional, if none fill in Zero and NULL
*/
int32_t callback_len_;
uint8_t callback_data_[ACE_SDK_UIC_MAX_CALLBACK_DATA_LEN];
} AceSdkBatchMultiTextInputInfo;
typedef enum
{
/**
* Legal text
*/
ACE_SDK_MSG_NORMAL_FLAG = 0,
/**
* Illegal text contains malicious words
* 1. user profile scenarios such as naming: failed to name
* 2. instant messaging scenarios: only the sender self can see it, and the visible content is the filtered text
*/
ACE_SDK_MSG_EVIL_FLAG = 1,
/**
* Illegal text contains sensitive words
* 1. user profile scenarios such as naming: failed to name
* 2. instant messaging scenarios: both the receiver and sender can see it, and the visible content is the filtered text
*/
ACE_SDK_MSG_DIRTY_FLAG = 2,
} AceSdkUicMsgResultFlag;
typedef struct
{
/**
* Return the scene id entered before
*/
uint32_t scene_id_;
/**
* The judgment result of the user input text from ACE Backend
* Please display the user input text as required in AceSdkUicMsgResultFlag
*/
uint32_t check_result_;
/**
* Label of the user input text from ACE Backend
*/
uint32_t lable_;
/**
* Judgement Description of the user input text from ACE Backend
*/
char check_desc_[ACE_SDK_UIC_MAX_CHECK_DESC_LEN];
/**
* Filtered text of the user input replaced by ACE Backend
*/
char filtered_text_[ACE_SDK_UIC_MAX_MESSAGE_LEN];
} AceSdkUicJudegeResultInfoMultiText;
typedef struct __AceSdkUicJudgeResultInfoBatchMultiText
{
/**
* Return the account entered before
*/
AceSdkAccount account_info_;
/**
* Zero represents judgement of ACE Backend success
* Not Zero represents judgement of ACE Backend fail
*/
uint32_t err_code_;
/**
* Error Description of ACE Backend judgement
*/
char err_msg_[ACE_SDK_UIC_MAX_ERR_MSG_LEN];
/**
* It represents the length of 'multi_text_array_', maximum length is ACE_SDK_UIC_MAX_BATCH_MULTI_TEXT_LEN
* If err_code_ == 0, it is the same as entered before
*/
int32_t multext_result_cnt_;
/**
* It contains several sets of judgement result from ACE Backend
*/
AceSdkUicJudegeResultInfoMultiText multext_result_array_[ACE_SDK_UIC_MAX_BATCH_MULTI_TEXT_LEN];
/**
* callback_len_ is the length of 'callback_data_', maximum length is ACE_SDK_UIC_MAX_CALLBACK_DATA_LEN
* It is the same as entered before
*/
int32_t callback_len_;
uint8_t callback_data_[ACE_SDK_UIC_MAX_CALLBACK_DATA_LEN];
} AceSdkUicJudgeResultInfoBatchMultiText;
/**
* @brief Callback function of gamesvr to receive the judgement result of user input texts
* @param result_info The judgement result from ACE SDK
* @return 0 Processing Successfully
* @return other value Processing Failed
*/
typedef int(*OnRecvAceSdkUicJudgeResultInfoBatchMultiText)(const AceSdkUicJudgeResultInfoBatchMultiText* result_info);
#pragma pack(pop)
/**
* @brief Set the callback function to receive the judgement result of user input texts
* @brief The callback function must be set firstly before call 'ace_sdk_server_judge_batch_multi_text' in order to get judgement result
* @brief A single autonomous thread propelling the callback interface within the SDK is distinct from the game server thread invoking 'ace_sdk_server_judge_batch_multi_text'. Please pay attention to potential thread safety concerns.
* The callback function should be designed to be lightweight. It is recommended to transfer time-consuming operations to the business layer working thread for processing to avoid blocking the callback thread inside the SDK.
* @brief After the SDK executes the callback function, it will immediately reclaim the data returned to the callback function.
* It is recommended that the game copy the returned data to the business layer memory space within the callback function to avoid memory security issues such as out-of-bounds access.
* @param on_result_func The callback function pointer
*/
AceSdkResult ace_sdk_server_set_recv_batch_multi_text_result_callback(OnRecvAceSdkUicJudgeResultInfoBatchMultiText on_result_func);
/**
* @brief Asynchronous interface to review batch multi-text of an account
* @brief Before calling this function, you must first set 'OnRecvAceSdkUicJudgeResultInfoBatchMultiText'
* @brief All texts will be sent to ACE Backend for review, and even if the backend review times out(500 ms), ACE SDK has local policies to cover it
* @param input_info A group of texts to review
*/
AceSdkResult ace_sdk_server_judge_batch_multi_text(const AceSdkBatchMultiTextInputInfo* input_info);
#endif // __ACE_SDK_SERVER_TEXT_CHECK_H__
@@ -0,0 +1,103 @@
#ifndef __ACE_SDK_SERVER_TEXT_CHECK_IMPL_H__
#define __ACE_SDK_SERVER_TEXT_CHECK_IMPL_H__
#include "ace_sdk_server.h"
struct __AceSdkUicJudgeResultInfoBatchMultiText;
struct __AceSdkBatchMultiTextInputInfo;
typedef int(*__OnRecvAceSdkUicJudgeResultInfoBatchMultiText)(const struct __AceSdkUicJudgeResultInfoBatchMultiText* result_info);
/***
* Internal functions' implementation
*/
#pragma pack(push, 1)
typedef int32_t (ACE_SDK_CALL*__AceSdkServerSetOnRecvResultBatchMultiText)(__OnRecvAceSdkUicJudgeResultInfoBatchMultiText);
typedef int32_t (ACE_SDK_CALL*__AceSdkServerJudgeBatchMultiText)(const struct __AceSdkBatchMultiTextInputInfo*);
typedef struct
{
__AceSdkServerSetOnRecvResultBatchMultiText set_on_recv_judge_result_;
__AceSdkServerJudgeBatchMultiText judge_batch_multi_text_;
} __AceSdkServerUicBatchMultiTextObject;
#pragma pack(pop)
#if defined(ACE_CGO)
extern __AceSdkServerUicBatchMultiTextObject* __ace_sdk_server_uic_batch_multi_text_object;
extern int __is_set_ace_sdk_server_recv_batch_multi_text_callback;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) __AceSdkServerUicBatchMultiTextObject* __ace_sdk_server_uic_batch_multi_text_object = NULL;
__declspec(selectany) int __is_set_ace_sdk_server_recv_batch_multi_text_callback = 0;
#else
__attribute__((weak)) __AceSdkServerUicBatchMultiTextObject* __ace_sdk_server_uic_batch_multi_text_object = NULL;
__attribute__((weak)) int __is_set_ace_sdk_server_recv_batch_multi_text_callback = 0;
#endif
inline int32_t __ace_sdk_server_uic_batch_multi_text_init()
{
if (__ace_sdk_init_succ == 0)
{
return -1;
}
if (__ace_sdk_server_uic_batch_multi_text_object != NULL)
{
return 0;
}
typedef __AceSdkServerUicBatchMultiTextObject* (ACE_SDK_CALL*__AceSdkServerGetUicBatchMultiTextObject)();
__AceSdkServerGetUicBatchMultiTextObject func = (__AceSdkServerGetUicBatchMultiTextObject)__ace_sdk_get_symbol("__ace_sdk_server_get_uic_batch_multi_text_object");
if (func == NULL)
{
return -1;
}
__ace_sdk_server_uic_batch_multi_text_object = func();
if (__ace_sdk_server_uic_batch_multi_text_object == NULL)
{
return -1;
}
return 0;
}
inline AceSdkResult ace_sdk_server_set_recv_batch_multi_text_result_callback(__OnRecvAceSdkUicJudgeResultInfoBatchMultiText on_result_func)
{
if (on_result_func == NULL)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
if (__ace_sdk_server_uic_batch_multi_text_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
__ace_sdk_server_uic_batch_multi_text_object->set_on_recv_judge_result_(on_result_func);
__is_set_ace_sdk_server_recv_batch_multi_text_callback = 1;
return ACE_SDK_RESULT_OK;
}
inline AceSdkResult ace_sdk_server_judge_batch_multi_text(const struct __AceSdkBatchMultiTextInputInfo* input_info)
{
if (input_info == NULL)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
if (__ace_sdk_server_uic_batch_multi_text_init() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
if (!__is_set_ace_sdk_server_recv_batch_multi_text_callback)
{
return ACE_SDK_RESULT_UIC_TEXT_CALLBACK_HAS_NOT_SET;
}
// not allow input_info->multi_text_cnt_ <= 0 || input_info->multi_text_cnt_ > 10
if (__ace_sdk_server_uic_batch_multi_text_object->judge_batch_multi_text_(input_info) != 0)
{
return ACE_SDK_RESULT_UIC_TEXT_INTERF_CALL_FAILED;
}
return ACE_SDK_RESULT_OK;
}
#endif // __ACE_SDK_SERVER_TEXT_CHECK_IMPL_H__
@@ -0,0 +1,33 @@
#ifndef __ACE_SDK_SERVER_TICKET_H__
#define __ACE_SDK_SERVER_TICKET_H__
#include "ace_sdk_account.h"
#include "ace_sdk_server_ticket_impl.h"
#pragma pack(push, 1)
#define ACE_SDK_MAX_TICKET_LENGTH 1024
typedef struct __AceSdkTicket
{
/**
* It represents the actual length of 'ticket_'.
*/
uint32_t ticket_len_;
/**
* Is a C-style string generaged locally by ACE SDK.
*/
char ticket_[ACE_SDK_MAX_TICKET_LENGTH];
} AceSdkTicket;
#pragma pack(pop)
/**
* @brief It must be called when a player tries to enter the game.
* @brief If the obtained ticket is not sent to the client ACE SDK, the player must be prohibited from entering the game.
* @param account Account for player.
* @param ticket Ticket used to verify players for ACE.
*/
AceSdkResult ace_sdk_server_get_ticket(const AceSdkAccount* account, AceSdkTicket* ticket);
#endif // __ACE_SDK_SERVER_TICKET_H__
@@ -0,0 +1,62 @@
#ifndef __ACE_SDK_SERVER_TICKET_IMPL_H__
#define __ACE_SDK_SERVER_TICKET_IMPL_H__
#include "ace_sdk_server.h"
struct __AceSdkTicket;
#if defined(ACE_CGO)
extern int __ace_sdk_ticket_init_succ;
#elif defined(_WIN32) && defined(_MSC_VER)
__declspec(selectany) int __ace_sdk_ticket_init_succ = 0;
#else
__attribute__((weak)) int __ace_sdk_ticket_init_succ = 0;
#endif
inline int ace_sdk_server_init_ticket() {
int ret = 0;
if (!__ace_sdk_init_succ)
{
return -1;
}
if (__ace_sdk_ticket_init_succ)
{
return ret;
}
typedef int32_t(ACE_SDK_CALL* __AceSdkServerInitTicket)();
__AceSdkServerInitTicket func = (__AceSdkServerInitTicket)__ace_sdk_get_symbol("__ace_sdk_server_init_ticket");
if (func == NULL)
{
return -1;
}
ret = func();
if (ret == 0)
{
__ace_sdk_ticket_init_succ = 1;
}
return ret;
}
inline AceSdkResult ace_sdk_server_get_ticket(const AceSdkAccount* account, struct __AceSdkTicket* ticket)
{
if (ace_sdk_server_init_ticket() != 0)
{
return ACE_SDK_RESULT_INIT_NOT_CALLED_OR_FAILED;
}
if (account == NULL || ticket == NULL)
{
return ACE_SDK_RESULT_INVALID_PARAMETER;
}
typedef int32_t(ACE_SDK_CALL* __AceSdkServerGetTicket)(const AceSdkAccount*, struct __AceSdkTicket*);
__AceSdkServerGetTicket func = (__AceSdkServerGetTicket)__ace_sdk_get_symbol("__ace_sdk_server_get_ticket");
if (func == NULL)
{
return ACE_SDK_RESULT_SYMBOL_NOT_FOUND;
}
func(account, ticket);
return ACE_SDK_RESULT_OK;
}
#endif // __ACE_SDK_SERVER_TICKET_IMPL_H__
@@ -0,0 +1,33 @@
#ifndef __ACE_SDK_SERVER_UIC_H__
#define __ACE_SDK_SERVER_UIC_H__
#pragma pack(push, 1)
#define ACE_SDK_UIC_MAX_CALLBACK_DATA_LEN 1024
#define ACE_SDK_UIC_MAX_ROLE_NAME_LEN 1024
#define ACE_SDK_UIC_MAX_HEAD_PIC_URL_LEN 1024
#define ACE_SDK_UIC_MAX_CHECK_DESC_LEN 512
#define ACE_SDK_UIC_MAX_ERR_MSG_LEN 128
typedef enum
{
ACE_SDK_CONTENT_CATEGORY_METERIRAL = 100, // user profile [100-999]
ACE_SDK_CONTENT_CATEGORY_MESSAGE = 1000, // instant message [1000-1899]
ACE_SDK_CONTENT_CATEGORY_PRIVATE_CHAT = 1900, // private chat [1900-1999]
ACE_SDK_CONTENT_CATEGORY_SOCIAL = 2000, // social operation [2000-2999]
ACE_SDK_CONTENT_CATEGORY_FORUM = 3000, // user space or forum [3000-3999]
ACE_SDK_CONTENT_CATEGORY_SEARCH = 4000, // user search [4000-4999]
} AceSdkUicMsgCategory;
typedef enum
{
ACE_SDK_AREA_ID_WECHAT = 1, // WeChat
ACE_SDK_AREA_ID_QQ = 2, // QQ
ACE_SDK_AREA_ID_GUEST = 3, // GUEST
ACE_SDK_AREA_ID_COMMON = 999, // Temporarily used when WeChat and QQ do not exist
} AceSdkUicAreaID;
#pragma pack(pop)
#endif // __ACE_SDK_SERVER_UIC_H__