Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
nishinji committed Aug 30, 2024
1 parent 8801e7f commit 277ec03
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion vita3k/config/include/config/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ enum ScreenshotFormat {
code(bool, "ngs-enable", true, ngs_enable) \
code(int, "sys-button", static_cast<int>(SCE_SYSTEM_PARAM_ENTER_BUTTON_CROSS), sys_button) \
code(int, "sys-lang", static_cast<int>(SCE_SYSTEM_PARAM_LANG_ENGLISH_US), sys_lang) \
code(int, "sys-date-format",static_cast<int>(SCE_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY), sys_date_format)\
code(int, "sys-date-format", static_cast<int>(SCE_SYSTEM_PARAM_DATE_FORMAT_MMDDYYYY), sys_date_format)\
code(int, "sys-time-format", static_cast<int>(SCE_SYSTEM_PARAM_TIME_FORMAT_12HOUR), sys_time_format)\
code(int, "cpu-pool-size", 10, cpu_pool_size) \
code(int, "modules-mode", static_cast<int>(ModulesMode::AUTOMATIC), modules_mode) \
Expand Down
18 changes: 9 additions & 9 deletions vita3k/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) {
large_font_config.SizePixels = 116.f;
gui.large_font = io.Fonts->AddFontFromFileTTF(fs_utils::path_to_utf8(latin_fw_font_path).c_str(), large_font_config.SizePixels, &large_font_config, large_font_chars);
} else {
LOG_WARN("Could not find firmware font file at \"{}\", install firmware fonts package to fix this.", latin_fw_font_path);
LOG_WARN("Could not find firmware font file at {}, install firmware fonts package to fix this.", latin_fw_font_path);
font_config.SizePixels = 22.f;

// Set up default font path
Expand All @@ -261,7 +261,7 @@ static void init_font(GuiState &gui, EmuEnvState &emuenv) {

LOG_INFO("Using default Vita3K font.");
} else
LOG_WARN("Could not find default Vita3K font at \"{}\", using default ImGui font.", default_font_path);
LOG_WARN("Could not find default Vita3K font at {}, using default ImGui font.", default_font_path);
}

// Build font atlas loaded and upload to GPU
Expand Down Expand Up @@ -423,18 +423,18 @@ static bool get_user_apps(GuiState &gui, EmuEnvState &emuenv) {
gui.app_selector.user_apps.clear();
// Read size of apps list
size_t size;
apps_cache.read((char *)&size, sizeof(size));
apps_cache.read(reinterpret_cast<char *>(&size), sizeof(size));

// Check version of cache
uint32_t versionInFile;
apps_cache.read((char *)&versionInFile, sizeof(uint32_t));
apps_cache.read(reinterpret_cast<char *>(&versionInFile), sizeof(uint32_t));
if (versionInFile != 1) {
LOG_WARN("Current version of cache: {}, is outdated, recreate it.", versionInFile);
return false;
}

// Read language of cache
apps_cache.read((char *)&gui.app_selector.apps_cache_lang, sizeof(uint32_t));
apps_cache.read(reinterpret_cast<char *>(&gui.app_selector.apps_cache_lang), sizeof(uint32_t));
if (gui.app_selector.apps_cache_lang != emuenv.cfg.sys_lang) {
LOG_WARN("Current lang of cache: {}, is different configuration: {}, recreate it.", get_sys_lang_name(gui.app_selector.apps_cache_lang), get_sys_lang_name(emuenv.cfg.sys_lang));
return false;
Expand All @@ -445,7 +445,7 @@ static bool get_user_apps(GuiState &gui, EmuEnvState &emuenv) {
auto read = [&apps_cache]() {
size_t size;

apps_cache.read((char *)&size, sizeof(size));
apps_cache.read(reinterpret_cast<char *>(&size), sizeof(size));

std::vector<char> buffer(size); // dont trust std::string to hold buffer enough
apps_cache.read(buffer.data(), size);
Expand Down Expand Up @@ -488,18 +488,18 @@ void save_apps_cache(GuiState &gui, EmuEnvState &emuenv) {

// Write version of cache
const uint32_t versionInFile = 1;
apps_cache.write((const char *)&versionInFile, sizeof(uint32_t));
apps_cache.write(reinterpret_cast<const char *>(&versionInFile), sizeof(uint32_t));

// Write language of cache
gui.app_selector.apps_cache_lang = emuenv.cfg.sys_lang;
apps_cache.write((char *)&gui.app_selector.apps_cache_lang, sizeof(uint32_t));
apps_cache.write(reinterpret_cast<char *>(&gui.app_selector.apps_cache_lang), sizeof(uint32_t));

// Write Apps list
for (const App &app : gui.app_selector.user_apps) {
auto write = [&apps_cache](const std::string &i) {
const auto size = i.length();

apps_cache.write((const char *)&size, sizeof(size));
apps_cache.write(reinterpret_cast<const char *>(&size), sizeof(size));
apps_cache.write(i.c_str(), size);
};

Expand Down
2 changes: 1 addition & 1 deletion vita3k/modules/SceNet/SceNet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ EXPORT(int, sceNetResolverGetError) {

EXPORT(int, sceNetResolverStartAton, int rid, const SceNetInAddr *addr, char *hostname, int len, int timeout, int retry, int flags) {
TRACY_FUNC(sceNetResolverStartAton, rid, addr, hostname, len, timeout, retry, flags);
struct hostent *resolved = gethostbyaddr((const char *)addr, len, AF_INET);
struct hostent *resolved = gethostbyaddr(reinterpret_cast<const char *>(addr), len, AF_INET);
strcpy(hostname, resolved->h_name);
return 0;
}
Expand Down
10 changes: 5 additions & 5 deletions vita3k/net/src/posixsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ int PosixSocket::get_socket_options(int level, int optname, void *optval, unsign
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_USECRYPTO, sockopt_so_usecrypto);
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_USESIGNATURE, sockopt_so_usesignature);
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_TPPOLICY, sockopt_so_tppolicy);
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_NAME, (char)0); // writes an empty string to the output buffer
CASE_GETSOCKOPT_VALUE(SCE_NET_SO_NAME, static_cast<char>(0)); // writes an empty string to the output buffer
}
} else if (level == IPPROTO_IP) {
switch (optname) {
Expand Down Expand Up @@ -346,22 +346,22 @@ int PosixSocket::get_socket_options(int level, int optname, void *optval, unsign
int PosixSocket::recv_packet(void *buf, unsigned int len, int flags, SceNetSockaddr *from, unsigned int *fromlen) {
if (from != nullptr) {
sockaddr addr;
int res = recvfrom(sock, (char *)buf, len, flags, &addr, (socklen_t *)fromlen);
int res = recvfrom(sock, static_cast<char *>(buf), len, flags, &addr, (socklen_t *)fromlen);
convertPosixSockaddrToSce(&addr, from);
*fromlen = sizeof(SceNetSockaddrIn);

return translate_return_value(res);
} else {
return translate_return_value(recv(sock, (char *)buf, len, flags));
return translate_return_value(recv(sock, static_cast<char *>(buf), len, flags));
}
}

int PosixSocket::send_packet(const void *msg, unsigned int len, int flags, const SceNetSockaddr *to, unsigned int tolen) {
if (to != nullptr) {
sockaddr addr;
convertSceSockaddrToPosix(to, &addr);
return translate_return_value(sendto(sock, (const char *)msg, len, flags, &addr, sizeof(sockaddr_in)));
return translate_return_value(sendto(sock, static_cast<const char *>(msg), len, flags, &addr, sizeof(sockaddr_in)));
} else {
return translate_return_value(send(sock, (const char *)msg, len, flags));
return translate_return_value(send(sock, static_cast<const char *>(msg), len, flags));
}
}
2 changes: 1 addition & 1 deletion vita3k/packages/src/license.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static bool open_license(const fs::path &license_path, SceNpDrmLicense &license_
memset(&license_buf, 0, sizeof(SceNpDrmLicense));
fs::ifstream license(license_path, std::ios::in | std::ios::binary);
if (license.is_open()) {
license.read((char *)&license_buf, sizeof(SceNpDrmLicense));
license.read(reinterpret_cast<char *>(&license_buf), sizeof(SceNpDrmLicense));
license.close();
return true;
}
Expand Down
8 changes: 4 additions & 4 deletions vita3k/packages/src/pkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ bool install_pkg(const fs::path &pkg_path, EmuEnvState &emuenv, std::string &p_z
for (uint32_t i = 0; i < byte_swap(pkg_header.info_count); i++) {
uint32_t block[4];
infile.seekg(info_offset);
infile.read((char *)block, sizeof(block));
infile.read(reinterpret_cast<char *>(block), sizeof(block));

auto type = byte_swap(block[0]);
auto size = byte_swap(block[1]);
Expand Down Expand Up @@ -202,7 +202,7 @@ bool install_pkg(const fs::path &pkg_path, EmuEnvState &emuenv, std::string &p_z
std::vector<uint8_t> sfo_buffer(sfo_size);
SfoFile sfo_file;
infile.seekg(sfo_offset);
infile.read((char *)&sfo_buffer[0], sfo_size);
infile.read(reinterpret_cast<char *>(&sfo_buffer[0]), sfo_size);
sfo::load(sfo_file, sfo_buffer);
sfo::get_param_info(emuenv.app_info, sfo_buffer, emuenv.cfg.sys_lang);

Expand Down Expand Up @@ -259,11 +259,11 @@ bool install_pkg(const fs::path &pkg_path, EmuEnvState &emuenv, std::string &p_z
evp_cleanup();
return false;
}
const auto file_count = (float)byte_swap(pkg_header.file_count);
const auto file_count = static_cast<float>(byte_swap(pkg_header.file_count));
progress_callback(i / file_count * 100.f * 0.6f);
std::vector<unsigned char> name(byte_swap(entry.name_size));
infile.seekg(byte_swap(pkg_header.data_offset) + byte_swap(entry.name_offset));
infile.read((char *)&name[0], byte_swap(entry.name_size));
infile.read(reinterpret_cast<char *>(&name[0]), byte_swap(entry.name_size));

decrypt_aes_ctr(byte_swap(entry.name_offset) / 16, name.data(), byte_swap(entry.name_size));

Expand Down
4 changes: 2 additions & 2 deletions vita3k/packages/src/pup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static void decrypt_segments(std::ifstream &infile, const fs::path &outdir, cons
fs::ofstream outfile(outdir / fs_utils::path_concat(filename, ".seg02"), std::ios::binary);
infile.seekg(sceseg.offset);
std::vector<unsigned char> encrypted_data(sceseg.size);
infile.read((char *)&encrypted_data[0], sceseg.size);
infile.read(reinterpret_cast<char *>(&encrypted_data[0]), sceseg.size);

std::vector<unsigned char> decrypted_data(sceseg.size);
EVP_DecryptInit_ex(cipher_ctx, cipher, nullptr, reinterpret_cast<const unsigned char *>(sceseg.key.c_str()), reinterpret_cast<const unsigned char *>(sceseg.iv.c_str()));
Expand All @@ -195,7 +195,7 @@ static void decrypt_segments(std::ifstream &infile, const fs::path &outdir, cons
const std::string decompressed_data = decompress_segments(decrypted_data, sceseg.size);
outfile.write(decompressed_data.c_str(), decompressed_data.size());
} else {
outfile.write((char *)&decrypted_data[0], sceseg.size);
outfile.write(reinterpret_cast<char *>(&decrypted_data[0]), sceseg.size);
}
outfile.close();
}
Expand Down
30 changes: 15 additions & 15 deletions vita3k/packages/src/sce_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ std::string decompress_segments(const std::vector<uint8_t> &decrypted_data, cons
return "";
}

const std::string compressed_data((char *)&decrypted_data[0], size);
const std::string compressed_data((char *)(&decrypted_data[0]), size);
stream.next_in = (const Bytef *)compressed_data.data();
stream.avail_in = compressed_data.size();

Expand Down Expand Up @@ -834,7 +834,7 @@ void self2elf(const fs::path &infile, const fs::path &outfile, KeyStore &SCE_KEY

filein.seekg(segment_infos[idx].offset);
std::vector<unsigned char> dat(segment_infos[idx].size);
filein.read((char *)&dat[0], segment_infos[idx].size);
filein.read(reinterpret_cast<char *>(&dat[0]), segment_infos[idx].size);

std::vector<unsigned char> decrypted_data(segment_infos[idx].size);
if (segment_infos[idx].plaintext == SecureBool::NO) {
Expand All @@ -850,7 +850,7 @@ void self2elf(const fs::path &infile, const fs::path &outfile, KeyStore &SCE_KEY
fileout.write(decompressed_data.c_str(), decompressed_data.length());
at += decompressed_data.length();
} else {
fileout.write((char *)&decrypted_data[0], segment_infos[idx].size);
fileout.write(reinterpret_cast<char *>(&decrypted_data[0]), segment_infos[idx].size);
at += segment_infos[idx].size;
}
}
Expand Down Expand Up @@ -936,17 +936,17 @@ void make_fself(const fs::path &input_file, const fs::path &output_file, uint64_
myhdr.e_phnum = ehdr.e_phnum;

fileout.seekp(hdr.appinfo_offset, std::ios_base::beg);
fileout.write((char *)&appinfo, sizeof(appinfo));
fileout.write(reinterpret_cast<char *>(&appinfo), sizeof(appinfo));

fileout.seekp(hdr.elf_offset, std::ios_base::beg);
fileout.write((char *)&myhdr, ElfHeader::Size);
fileout.write(reinterpret_cast<char *>(&myhdr), ElfHeader::Size);

fileout.seekp(hdr.phdr_offset, std::ios_base::beg);
for (int i = 0; i < ehdr.e_phnum; ++i) {
ElfPhdr phdr = ElfPhdr(&input[0] + ehdr.e_phoff + ehdr.e_phentsize * i);
if (phdr.p_align > 0x1000)
phdr.p_align = 0x1000;
fileout.write((char *)&phdr, sizeof(phdr));
fileout.write(reinterpret_cast<char *>(&phdr), sizeof(phdr));
}

fileout.seekp(hdr.section_info_offset, std::ios_base::beg);
Expand All @@ -957,16 +957,16 @@ void make_fself(const fs::path &input_file, const fs::path &output_file, uint64_
segment_info.length = phdr.p_filesz;
segment_info.compression = 1;
segment_info.encryption = 2;
fileout.write((char *)&segment_info, sizeof(segment_info));
fileout.write(reinterpret_cast<char *>(&segment_info), sizeof(segment_info));
}

fileout.seekp(hdr.sceversion_offset, std::ios_base::beg);
fileout.write((char *)&ver, sizeof(ver));
fileout.write(reinterpret_cast<char *>(&ver), sizeof(ver));

fileout.seekp(hdr.controlinfo_offset, std::ios_base::beg);
fileout.write((char *)&control_5, sizeof(control_5));
fileout.write((char *)&control_6, sizeof(control_6));
fileout.write((char *)&control_7, sizeof(control_7));
fileout.write(reinterpret_cast<char *>(&control_5), sizeof(control_5));
fileout.write(reinterpret_cast<char *>(&control_6), sizeof(control_6));
fileout.write(reinterpret_cast<char *>(&control_7), sizeof(control_7));

fileout.seekp(HEADER_LEN, std::ios_base::beg);
fileout.write(&input[0], file_size);
Expand All @@ -975,7 +975,7 @@ void make_fself(const fs::path &input_file, const fs::path &output_file, uint64_
hdr.self_filesize = fileout.tellp();
fileout.seekp(0, std::ios_base::beg);

fileout.write((char *)&hdr, sizeof(hdr));
fileout.write(reinterpret_cast<char *>(&hdr), sizeof(hdr));

fileout.close();
}
Expand Down Expand Up @@ -1029,7 +1029,7 @@ std::vector<SceSegment> get_segments(std::ifstream &file, const SceHeader &sce_h
EVP_DecryptUpdate(cipher_ctx, dec, &dec_len, dec_in, MetadataInfo::Size);
EVP_DecryptFinal_ex(cipher_ctx, dec + dec_len, &dec_len);

MetadataInfo metadata_info = MetadataInfo((char *)dec);
MetadataInfo metadata_info = MetadataInfo(reinterpret_cast<char *>(dec));

std::vector<unsigned char> dec1(sce_hdr.header_length - sce_hdr.metadata_offset - 48 - MetadataInfo::Size);
std::vector<unsigned char> input_data(sce_hdr.header_length - sce_hdr.metadata_offset - 48 - MetadataInfo::Size);
Expand All @@ -1041,7 +1041,7 @@ std::vector<SceSegment> get_segments(std::ifstream &file, const SceHeader &sce_h

unsigned char dec2[MetadataHeader::Size];
std::copy(&dec1[0], &dec1[MetadataHeader::Size], dec2);
MetadataHeader metadata_hdr = MetadataHeader((char *)dec2);
MetadataHeader metadata_hdr = MetadataHeader(reinterpret_cast<char *>(dec2));

std::vector<SceSegment> segs;
const auto start = MetadataHeader::Size + metadata_hdr.section_count * MetadataSection::Size;
Expand All @@ -1055,7 +1055,7 @@ std::vector<SceSegment> get_segments(std::ifstream &file, const SceHeader &sce_h
for (uint32_t i = 0; i < metadata_hdr.section_count; i++) {
std::vector<unsigned char> dec3((MetadataHeader::Size + i * MetadataSection::Size + MetadataSection::Size) - (MetadataHeader::Size + i * MetadataSection::Size));
memcpy(&dec3[0], &dec1[0] + (MetadataHeader::Size + i * MetadataSection::Size), (MetadataHeader::Size + i * MetadataSection::Size + MetadataSection::Size) - (MetadataHeader::Size + i * MetadataSection::Size));
MetadataSection metsec = MetadataSection((char *)&dec3[0]);
MetadataSection metsec = MetadataSection(reinterpret_cast<char *>(&dec3[0]));

if (metsec.encryption == EncryptionType::AES128CTR) {
segs.push_back({ metsec.offset, metsec.seg_idx, metsec.size, metsec.compression == CompressionType::DEFLATE, vault[metsec.key_idx], vault[metsec.iv_idx] });
Expand Down
2 changes: 1 addition & 1 deletion vita3k/renderer/src/gl/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static void post_process_pixels_data(GLState &renderer, std::uint32_t *pixels, s
const size_t first_pixel_offset_in_linear = (j * stride) + hori_tile * 32;

memcpy(buffer.data() + first_pixel_offset_in_tile * bytes_per_pixel,
(const char *)(pixels) + first_pixel_offset_in_linear * bytes_per_pixel, 32 * bytes_per_pixel);
reinterpret_cast<const char *>(pixels) + first_pixel_offset_in_linear * bytes_per_pixel, 32 * bytes_per_pixel);
}
}
memcpy(pixels, buffer.data(), buffer.size());
Expand Down
12 changes: 6 additions & 6 deletions vita3k/renderer/src/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ bool get_shaders_cache_hashs(State &renderer) {
renderer.shaders_cache_hashs.clear();
// Read size of hashes list
size_t size;
shaders_hashs.read((char *)&size, sizeof(size));
shaders_hashs.read(reinterpret_cast<char *>(&size), sizeof(size));

// Check version of cache and device id
uint32_t versionInFile;
shaders_hashs.read((char *)&versionInFile, sizeof(uint32_t));
shaders_hashs.read(reinterpret_cast<char *>(&versionInFile), sizeof(uint32_t));
uint32_t features_mask;
shaders_hashs.read((char *)&features_mask, sizeof(uint32_t));
shaders_hashs.read(reinterpret_cast<char *>(&features_mask), sizeof(uint32_t));
if (versionInFile != shader::CURRENT_VERSION || features_mask != renderer.get_features_mask()) {
shaders_hashs.close();
fs::remove_all(renderer.shaders_path);
Expand Down Expand Up @@ -95,13 +95,13 @@ void save_shaders_cache_hashs(State &renderer, std::vector<ShadersHash> &shaders
if (shaders_hashs.is_open()) {
// Write Size of shaders cache hashes list
const auto size = shaders_cache_hashs.size();
shaders_hashs.write((const char *)&size, sizeof(size));
shaders_hashs.write(reinterpret_cast<const char *>(&size), sizeof(size));

// Write version of cache
const uint32_t versionInFile = shader::CURRENT_VERSION;
shaders_hashs.write((const char *)&versionInFile, sizeof(uint32_t));
shaders_hashs.write(reinterpret_cast<const char *>(&versionInFile), sizeof(uint32_t));
const uint32_t features_mask = renderer.get_features_mask();
shaders_hashs.write((const char *)&features_mask, sizeof(uint32_t));
shaders_hashs.write(reinterpret_cast<const char *>(&features_mask), sizeof(uint32_t));

// Write shader hash list
for (const auto &hash : shaders_cache_hashs) {
Expand Down
8 changes: 4 additions & 4 deletions vita3k/renderer/src/vulkan/screen_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ void SinglePassScreenFilter::init() {
void SinglePassScreenFilter::render(bool is_pre_renderpass, vk::ImageView src_img, vk::ImageLayout src_layout, const Viewport &viewport) {
if (is_pre_renderpass) {
std::array<float, 4> uvs = {
viewport.offset_x / (float)viewport.texture_width,
viewport.offset_y / (float)viewport.texture_height,
(viewport.offset_x + viewport.width) / (float)(viewport.texture_width),
(viewport.offset_y + viewport.height) / (float)(viewport.texture_height)
viewport.offset_x / static_cast<float>(viewport.texture_width),
viewport.offset_y / static_cast<float>(viewport.texture_height),
(viewport.offset_x + viewport.width) / static_cast<float>(viewport.texture_width),
(viewport.offset_y + viewport.height) / static_cast<float>(viewport.texture_height)
};

// if necessary update vao (should not happen often)
Expand Down
Loading

0 comments on commit 277ec03

Please sign in to comment.