From c6343770c620e1c61404b19a5bca51bb69454f5f Mon Sep 17 00:00:00 2001 From: kin4stat Date: Fri, 22 Nov 2024 18:17:54 +0300 Subject: [PATCH] Fix linux build --- c-api/data/discord_user.h | 11 ++++++++--- c-api/data/vehicle_model_info.h | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/c-api/data/discord_user.h b/c-api/data/discord_user.h index 07c5591..382f77a 100644 --- a/c-api/data/discord_user.h +++ b/c-api/data/discord_user.h @@ -12,19 +12,24 @@ struct ClrDiscordUser { ClrDiscordUser() = default; ClrDiscordUser(alt::IDiscordManager* discordManager) { +#ifdef _MSC_VER + auto s_strcpy = [](char* dest, std::size_t n, const char* src) { return strcpy_s(dest, n, src); }; +#else + auto s_strcpy = [](char* dest, std::size_t n, const char* src) { return strncpy(dest, src, n); }; +#endif id = discordManager->GetUserID(); auto usernameStr = discordManager->GetUsername(); username = new char[usernameStr.length() + 1]; - strcpy_s(username, usernameStr.length() + 1, usernameStr.c_str()); + s_strcpy(username, usernameStr.length() + 1, usernameStr.c_str()); auto discriminatorStr = discordManager->GetDiscriminator(); discriminator = new char[discriminatorStr.length() + 1]; - strcpy_s(discriminator, discriminatorStr.length() + 1, discriminatorStr.c_str()); + s_strcpy(discriminator, discriminatorStr.length() + 1, discriminatorStr.c_str()); auto avatarStr = discordManager->GetAvatar(); avatar = new char[avatarStr.length() + 1]; - strcpy_s(avatar, avatarStr.length() + 1,avatarStr.c_str()); + s_strcpy(avatar, avatarStr.length() + 1,avatarStr.c_str()); } ~ClrDiscordUser() { diff --git a/c-api/data/vehicle_model_info.h b/c-api/data/vehicle_model_info.h index 3aceafe..2295eff 100644 --- a/c-api/data/vehicle_model_info.h +++ b/c-api/data/vehicle_model_info.h @@ -47,6 +47,11 @@ struct ClrVehicleModelInfo canAttachCars(info.canAttachCars), handlingNameHash(info.handlingNameHash) { +#ifdef _MSC_VER + auto s_strcpy = [](char* dest, std::size_t n, const char* src) { return strcpy_s(dest, n, src); }; +#else + auto s_strcpy = [](char* dest, std::size_t n, const char* src) { return strncpy(dest, src, n); }; +#endif size_t modkitsSize = std::size(info.modkits); for (size_t i = 0; i < modkitsSize; i++) { @@ -54,7 +59,7 @@ struct ClrVehicleModelInfo } title = new char[info.title.length() + 1]; - strcpy_s(title, info.title.length() + 1, info.title.c_str()); + s_strcpy(title, info.title.length() + 1, info.title.c_str()); const auto vehModelBones = info.bones; boneSize = vehModelBones.size();