Skip to content

Commit

Permalink
Fix linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
kin4stat committed Nov 22, 2024
1 parent d33133a commit c634377
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 8 additions & 3 deletions c-api/data/discord_user.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 6 additions & 1 deletion c-api/data/vehicle_model_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ 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++)
{
modkits[i] = info.modkits[i] != 0xFFFF;
}

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();
Expand Down

0 comments on commit c634377

Please sign in to comment.