diff --git a/Utilities/StrUtil.h b/Utilities/StrUtil.h index d274cc074d..66c351d60f 100644 --- a/Utilities/StrUtil.h +++ b/Utilities/StrUtil.h @@ -13,13 +13,13 @@ std::string wchar_to_utf8(std::wstring_view src); std::string utf16_to_utf8(std::u16string_view src); std::u16string utf8_to_utf16(std::string_view src); -// Copy null-terminated string from a std::string or a char array to a char array with truncation -template +// Copy null-terminated string from a std::basic_string or a char array to a char array with truncation +template requires requires (D& d, T& t) { std::declval() = &d[0]; } inline void strcpy_trunc(D&& dst, const T& src) { const usz count = std::size(src) >= std::size(dst) ? std::max(std::size(dst), 1) - 1 : std::size(src); - std::memcpy(std::data(dst), std::data(src), count); - std::memset(std::data(dst) + count, 0, std::size(dst) - count); + std::copy_n(std::data(src), count, std::data(dst)); + std::fill_n(std::data(dst) + count, std::size(dst) - count, std::remove_cvref_t{}); } // Convert string to signed integer diff --git a/rpcs3/Emu/Cell/Modules/sceNp.h b/rpcs3/Emu/Cell/Modules/sceNp.h index 88dd2d816b..1bc0a345db 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.h +++ b/rpcs3/Emu/Cell/Modules/sceNp.h @@ -1397,9 +1397,9 @@ struct SceNpBasicMessageDetails // Presence details of an user struct SceNpBasicPresenceDetails { - s8 title[SCE_NP_BASIC_PRESENCE_TITLE_SIZE_MAX]; - s8 status[SCE_NP_BASIC_PRESENCE_STATUS_SIZE_MAX]; - s8 comment[SCE_NP_BASIC_PRESENCE_COMMENT_SIZE_MAX]; + char title[SCE_NP_BASIC_PRESENCE_TITLE_SIZE_MAX]; + char status[SCE_NP_BASIC_PRESENCE_STATUS_SIZE_MAX]; + char comment[SCE_NP_BASIC_PRESENCE_COMMENT_SIZE_MAX]; u8 data[SCE_NP_BASIC_MAX_PRESENCE_SIZE]; be_t size; be_t state; @@ -1410,9 +1410,9 @@ struct SceNpBasicPresenceDetails2 { be_t struct_size; be_t state; - s8 title[SCE_NP_BASIC_PRESENCE_TITLE_SIZE_MAX]; - s8 status[SCE_NP_BASIC_PRESENCE_EXTENDED_STATUS_SIZE_MAX]; - s8 comment[SCE_NP_BASIC_PRESENCE_COMMENT_SIZE_MAX]; + char title[SCE_NP_BASIC_PRESENCE_TITLE_SIZE_MAX]; + char status[SCE_NP_BASIC_PRESENCE_EXTENDED_STATUS_SIZE_MAX]; + char comment[SCE_NP_BASIC_PRESENCE_COMMENT_SIZE_MAX]; u8 data[SCE_NP_BASIC_MAX_PRESENCE_SIZE]; be_t size; }; @@ -1420,9 +1420,9 @@ struct SceNpBasicPresenceDetails2 // Country/region code struct SceNpCountryCode { - s8 data[2]; - s8 term; - s8 padding[1]; + char data[2]; + char term; + char padding[1]; }; // Date information @@ -1451,8 +1451,8 @@ struct SceNpScoreGameInfo // Ranking comment structure struct SceNpScoreComment { - s8 data[SCE_NP_SCORE_COMMENT_MAXLEN]; - s8 term[1]; + char data[SCE_NP_SCORE_COMMENT_MAXLEN]; + char term[1]; }; // Ranking information structure @@ -1524,15 +1524,15 @@ struct SceNpScoreNpIdPcId // Basic clan information to be used in raking struct SceNpScoreClanBasicInfo { - s8 clanName[SCE_NP_CLANS_CLAN_NAME_MAX_LENGTH + 1]; - s8 clanTag[SCE_NP_CLANS_CLAN_TAG_MAX_LENGTH + 1]; + char clanName[SCE_NP_CLANS_CLAN_NAME_MAX_LENGTH + 1]; + char clanTag[SCE_NP_CLANS_CLAN_TAG_MAX_LENGTH + 1]; u8 reserved[10]; }; // Clan member information handled in ranking struct SceNpScoreClansMemberDescription { - s8 description[SCE_NP_CLANS_CLAN_DESCRIPTION_MAX_LENGTH + 1]; + char description[SCE_NP_CLANS_CLAN_DESCRIPTION_MAX_LENGTH + 1]; }; // Clan ranking information