1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

C-style cast cleanup II

This commit is contained in:
Nekotekina 2019-11-30 01:28:06 +03:00
parent 5b9df53c13
commit ad9c9f0183
18 changed files with 314 additions and 308 deletions

View File

@ -6,7 +6,7 @@
void generate_key(int crypto_mode, int version, unsigned char *key_final, unsigned char *iv_final, unsigned char *key, unsigned char *iv)
{
int mode = (int)(crypto_mode & 0xF0000000);
int mode = crypto_mode & 0xF0000000;
switch (mode)
{
case 0x10000000:
@ -32,7 +32,7 @@ void generate_key(int crypto_mode, int version, unsigned char *key_final, unsign
void generate_hash(int hash_mode, int version, unsigned char *hash_final, unsigned char *hash)
{
int mode = (int)(hash_mode & 0xF0000000);
int mode = hash_mode & 0xF0000000;
switch (mode)
{
case 0x10000000:
@ -81,7 +81,7 @@ bool decrypt(int hash_mode, int crypto_mode, int version, unsigned char *in, uns
LOG_ERROR(LOADER, "EDAT: Unknown crypto algorithm!");
return false;
}
if ((hash_mode & 0xFF) == 0x01) // 0x14 SHA1-HMAC
{
return hmac_hash_compare(hash_final_14, 0x14, in, length, test_hash, 0x14);
@ -122,9 +122,9 @@ std::tuple<u64, s32, s32> dec_section(unsigned char* metadata)
dec[0x0E] = (metadata[0x6] ^ metadata[0x2] ^ metadata[0x1E]);
dec[0x0F] = (metadata[0x7] ^ metadata[0x3] ^ metadata[0x1F]);
u64 offset = swap64(*(u64*)&dec[0]);
s32 length = swap32(*(s32*)&dec[8]);
s32 compression_end = swap32(*(s32*)&dec[12]);
u64 offset = swap64(*reinterpret_cast<u64*>(&dec[0]));
s32 length = swap32(*reinterpret_cast<s32*>(&dec[8]));
s32 compression_end = swap32(*reinterpret_cast<s32*>(&dec[12]));
return std::make_tuple(offset, length, compression_end);
}
@ -168,7 +168,7 @@ s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *np
// Decrypt the metadata.
if ((edat->flags & EDAT_COMPRESSED_FLAG) != 0)
{
metadata_sec_offset = metadata_offset + (unsigned long long) block_num * metadata_section_size;
metadata_sec_offset = metadata_offset + u64{block_num} * metadata_section_size;
in->seek(file_offset + metadata_sec_offset);
@ -180,9 +180,9 @@ s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *np
// NOTE: For NPD version 1 the metadata is not encrypted.
if (npd->version <= 1)
{
offset = swap64(*(unsigned long long*)&metadata[0x10]);
length = swap32(*(int*)&metadata[0x18]);
compression_end = swap32(*(int*)&metadata[0x1C]);
offset = swap64(*reinterpret_cast<u64*>(&metadata[0x10]));
length = swap32(*reinterpret_cast<s32*>(&metadata[0x18]));
compression_end = swap32(*reinterpret_cast<s32*>(&metadata[0x1C]));
}
else
{
@ -194,7 +194,7 @@ s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *np
else if ((edat->flags & EDAT_FLAG_0x20) != 0)
{
// If FLAG 0x20, the metadata precedes each data block.
metadata_sec_offset = metadata_offset + (u64) block_num * (metadata_section_size + edat->block_size);
metadata_sec_offset = metadata_offset + u64{block_num} * (metadata_section_size + edat->block_size);
in->seek(file_offset + metadata_sec_offset);
unsigned char metadata[0x20];
@ -204,30 +204,30 @@ s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *np
// If FLAG 0x20 is set, apply custom xor.
for (int j = 0; j < 0x10; j++)
hash_result[j] = (unsigned char)(metadata[j] ^ metadata[j + 0x10]);
hash_result[j] = metadata[j] ^ metadata[j + 0x10];
offset = metadata_sec_offset + 0x20;
length = edat->block_size;
if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size))
length = (int)(edat->file_size % edat->block_size);
length = static_cast<s32>(edat->file_size % edat->block_size);
}
else
{
metadata_sec_offset = metadata_offset + (u64) block_num * metadata_section_size;
metadata_sec_offset = metadata_offset + u64{block_num} * metadata_section_size;
in->seek(file_offset + metadata_sec_offset);
in->read(hash_result, 0x10);
offset = metadata_offset + (u64) block_num * edat->block_size + total_blocks * metadata_section_size;
offset = metadata_offset + u64{block_num} * edat->block_size + total_blocks * metadata_section_size;
length = edat->block_size;
if ((block_num == (total_blocks - 1)) && (edat->file_size % edat->block_size))
length = (int)(edat->file_size % edat->block_size);
length = static_cast<s32>(edat->file_size % edat->block_size);
}
// Locate the real data.
const int pad_length = length;
length = (int)((pad_length + 0xF) & 0xFFFFFFF0);
length = (pad_length + 0xF) & 0xFFFFFFF0;
// Setup buffers for decryption and read the data.
enc_data.reset(new u8[length]{ 0 });
@ -280,7 +280,7 @@ s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *np
// Call main crypto routine on this data block.
if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), enc_data.get(), dec_data.get(), length, key_result, iv, hash, hash_result))
{
LOG_ERROR(LOADER, "EDAT: Block at offset 0x%llx has invalid hash!", (u64)offset);
LOG_ERROR(LOADER, "EDAT: Block at offset 0x%llx has invalid hash!", offset);
return -1;
}
}
@ -313,8 +313,8 @@ s64 decrypt_block(const fs::file* in, u8* out, EDAT_HEADER *edat, NPD_HEADER *np
// reset file to beginning of data before calling
int decrypt_data(const fs::file* in, const fs::file* out, EDAT_HEADER *edat, NPD_HEADER *npd, unsigned char* crypt_key, bool verbose)
{
const int total_blocks = (int)((edat->file_size + edat->block_size - 1) / edat->block_size);
u64 size_left = (int)edat->file_size;
const int total_blocks = static_cast<int>((edat->file_size + edat->block_size - 1) / edat->block_size);
u64 size_left = edat->file_size;
std::unique_ptr<u8[]> data(new u8[edat->block_size]);
for (int i = 0; i < total_blocks; i++)
@ -341,7 +341,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
u8 empty_header[0xA0] = { 0 };
u8 header_hash[0x10] = { 0 };
u8 metadata_hash[0x10] = { 0 };
const u64 file_offset = f->pos();
// Check NPD version and flags.
@ -397,7 +397,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
// Setup header key and iv buffers.
unsigned char header_key[0x10] = { 0 };
unsigned char header_iv[0x10] = { 0 };
// Test the header hash (located at offset 0xA0).
if (!decrypt(hash_mode, crypto_mode, (npd->version == 4), header, empty_header, 0xA0, header_key, header_iv, key, header_hash))
{
@ -420,7 +420,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
LOG_WARNING(LOADER, "EDAT: COMPRESSED data detected!");
}
const int block_num = (int)((edat->file_size + edat->block_size - 1) / edat->block_size);
const int block_num = static_cast<int>((edat->file_size + edat->block_size - 1) / edat->block_size);
const int metadata_offset = 0x100;
const int metadata_size = metadata_section_size * block_num;
u64 metadata_section_offset = metadata_offset;
@ -465,7 +465,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
unsigned char signature_r[0x15] = { 0 };
unsigned char signature_s[0x15] = { 0 };
unsigned char zero_buf[0x15] = { 0 };
// Setup ECDSA curve and public key.
ecdsa_set_curve(VSH_CURVE_P, VSH_CURVE_A, VSH_CURVE_B, VSH_CURVE_N, VSH_CURVE_GX, VSH_CURVE_GY);
ecdsa_set_pub(VSH_PUB);
@ -498,7 +498,7 @@ int check_data(unsigned char *key, EDAT_HEADER *edat, NPD_HEADER *npd, const fs:
if (!ecdsa_verify(signature_hash, signature_r, signature_s))
{
LOG_WARNING(LOADER, "EDAT: Metadata signature is invalid!");
if (((unsigned long long)edat->block_size * block_num) > 0x100000000)
if (((edat->block_size + 0ull) * block_num) > 0x100000000)
LOG_WARNING(LOADER, "EDAT: *Due to large file size, metadata signature status may be incorrect!");
}
}
@ -576,9 +576,9 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
int title_hash_result = 0;
int dev_hash_result = 0;
const int file_name_length = (int) strlen(file_name);
const auto file_name_length = std::strlen(file_name);
std::unique_ptr<u8[]> buf(new u8[0x30 + file_name_length]);
// Build the title buffer (content_id + file_name).
memcpy(buf.get(), npd->content_id, 0x30);
memcpy(buf.get() + 0x30, file_name, file_name_length);
@ -594,7 +594,7 @@ int validate_npd_hashes(const char* file_name, const u8* klicensee, NPD_HEADER *
LOG_WARNING(LOADER, "EDAT: NPD title hash is invalid!");
}
dev_hash_result = validate_dev_klic(klicensee, npd);
return (title_hash_result && dev_hash_result);
@ -608,19 +608,19 @@ void read_npd_edat_header(const fs::file* input, NPD_HEADER& NPD, EDAT_HEADER& E
input->read(edat_header, sizeof(edat_header));
memcpy(&NPD.magic, npd_header, 4);
NPD.version = swap32(*(int*)&npd_header[4]);
NPD.license = swap32(*(int*)&npd_header[8]);
NPD.type = swap32(*(int*)&npd_header[12]);
memcpy(NPD.content_id, (unsigned char*)&npd_header[16], 0x30);
memcpy(NPD.digest, (unsigned char*)&npd_header[64], 0x10);
memcpy(NPD.title_hash, (unsigned char*)&npd_header[80], 0x10);
memcpy(NPD.dev_hash, (unsigned char*)&npd_header[96], 0x10);
NPD.unk1 = swap64(*(u64*)&npd_header[112]);
NPD.unk2 = swap64(*(u64*)&npd_header[120]);
NPD.version = swap32(*reinterpret_cast<s32*>(&npd_header[4]));
NPD.license = swap32(*reinterpret_cast<s32*>(&npd_header[8]));
NPD.type = swap32(*reinterpret_cast<s32*>(&npd_header[12]));
memcpy(NPD.content_id, &npd_header[16], 0x30);
memcpy(NPD.digest, &npd_header[64], 0x10);
memcpy(NPD.title_hash, &npd_header[80], 0x10);
memcpy(NPD.dev_hash, &npd_header[96], 0x10);
NPD.unk1 = swap64(*reinterpret_cast<u64*>(&npd_header[112]));
NPD.unk2 = swap64(*reinterpret_cast<u64*>(&npd_header[120]));
EDAT.flags = swap32(*(int*)&edat_header[0]);
EDAT.block_size = swap32(*(int*)&edat_header[4]);
EDAT.file_size = swap64(*(u64*)&edat_header[8]);
EDAT.flags = swap32(*reinterpret_cast<s32*>(&edat_header[0]));
EDAT.block_size = swap32(*reinterpret_cast<s32*>(&edat_header[4]));
EDAT.file_size = swap64(*reinterpret_cast<u64*>(&edat_header[8]));
}
bool extract_all_data(const fs::file* input, const fs::file* output, const char* input_file_name, unsigned char* devklic, unsigned char* rifkey, bool verbose)
@ -658,7 +658,7 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char*
LOG_NOTICE(LOADER, "SDAT HEADER");
LOG_NOTICE(LOADER, "SDAT flags: 0x%08X", EDAT.flags);
LOG_NOTICE(LOADER, "SDAT block size: 0x%08X", EDAT.block_size);
LOG_NOTICE(LOADER, "SDAT file size: 0x%08X", (u64)EDAT.file_size);
LOG_NOTICE(LOADER, "SDAT file size: 0x%08X", EDAT.file_size);
}
// Generate SDAT key.
@ -671,7 +671,7 @@ bool extract_all_data(const fs::file* input, const fs::file* output, const char*
LOG_NOTICE(LOADER, "EDAT HEADER");
LOG_NOTICE(LOADER, "EDAT flags: 0x%08X", EDAT.flags);
LOG_NOTICE(LOADER, "EDAT block size: 0x%08X", EDAT.block_size);
LOG_NOTICE(LOADER, "EDAT file size: 0x%08X", (u64)EDAT.file_size);
LOG_NOTICE(LOADER, "EDAT file size: 0x%08X", EDAT.file_size);
}
// Perform header validation (EDAT only).
@ -815,9 +815,9 @@ fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name,
// Set keys (RIF and DEVKLIC).
std::array<u8, 0x10> rifKey{ 0 };
unsigned char devklic[0x10] = { 0 };
// Select the EDAT key mode.
switch (mode)
switch (mode)
{
case 0:
break;
@ -842,7 +842,7 @@ fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name,
case 7:
memcpy(devklic, NP_PSP_KEY_2, 0x10);
break;
case 8:
case 8:
{
if (custom_klic != NULL)
memcpy(devklic, custom_klic, 0x10);
@ -873,7 +873,7 @@ fs::file DecryptEDAT(const fs::file& input, const std::string& input_file_name,
output.release();
return fs::file{};
}
output.seek(0);
return output;
}
@ -911,7 +911,7 @@ bool EDATADecrypter::ReadHeader()
else if ((npdHeader.license & 0x2) == 0x2) // Type 2: Use key from RAP file (RIF key).
{
dec_key = std::move(rif_key);
if (dec_key == std::array<u8, 0x10>{0})
{
LOG_WARNING(LOADER, "EDAT: Empty Dec key!");
@ -935,7 +935,7 @@ bool EDATADecrypter::ReadHeader()
}*/
file_size = edatHeader.file_size;
total_blocks = (u32)((edatHeader.file_size + edatHeader.block_size - 1) / edatHeader.block_size);
total_blocks = static_cast<u32>((edatHeader.file_size + edatHeader.block_size - 1) / edatHeader.block_size);
return true;
}
@ -948,7 +948,7 @@ u64 EDATADecrypter::ReadData(u64 pos, u8* data, u64 size)
// now we need to offset things to account for the actual 'range' requested
const u64 startOffset = pos % edatHeader.block_size;
const u32 num_blocks = static_cast<u32>(std::ceil((startOffset + size) / (double)edatHeader.block_size));
const u32 num_blocks = static_cast<u32>(std::ceil((startOffset + size) / (0. + edatHeader.block_size)));
const u64 bufSize = num_blocks*edatHeader.block_size;
if (data_buf_size < (bufSize))
{

View File

@ -98,7 +98,7 @@ public:
}
u64 read(void* buffer, u64 size) override
{
u64 bytesRead = ReadData(pos, (u8*)buffer, size);
u64 bytesRead = ReadData(pos, static_cast<u8*>(buffer), size);
pos += bytesRead;
return bytesRead;
}

View File

@ -37,13 +37,13 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
}
};
auto archive_read = [&](const void *data_ptr, const u64 num_bytes)
auto archive_read = [&](void* data_ptr, const u64 num_bytes)
{
u64 num_bytes_left = filelist[cur_file].size() - cur_file_offset;
//check if it continues in another file
if (num_bytes > num_bytes_left)
{
filelist[cur_file].read((u8 *)data_ptr, num_bytes_left);
filelist[cur_file].read(data_ptr, num_bytes_left);
if ((cur_file + 1) < filelist.size()) cur_file++;
else
{
@ -51,13 +51,13 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
cur_file_offset = filelist[cur_file].size();
return num_bytes_left;
}
u64 num_read = filelist[cur_file].read((u8 *)data_ptr + num_bytes_left, num_bytes - num_bytes_left);
u64 num_read = filelist[cur_file].read(static_cast<u8*>(data_ptr) + num_bytes_left, num_bytes - num_bytes_left);
cur_offset += (num_read + num_bytes_left);
cur_file_offset = num_read;
return (num_read+num_bytes_left);
}
u64 num_read = filelist[cur_file].read((u8 *)data_ptr, num_bytes);
u64 num_read = filelist[cur_file].read(data_ptr, num_bytes);
cur_offset += num_read;
cur_file_offset += num_read;
@ -153,7 +153,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
be_t<u32> id;
be_t<u32> size;
} packet;
archive_read(&packet, sizeof(packet));
// TODO
@ -244,7 +244,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
u8 data[20];
u128 _v128;
} hash;
sha1(reinterpret_cast<const u8*>(input), sizeof(input), hash.data);
buf[i] ^= hash._v128;

View File

@ -14,8 +14,8 @@ struct WAVHeader
RIFFHeader() = default;
RIFFHeader(u32 size)
: ID(*(u32*)"RIFF")
, WAVE(*(u32*)"WAVE")
: ID("RIFF"_u32)
, WAVE("WAVE"_u32)
, Size(size)
{
}
@ -35,7 +35,7 @@ struct WAVHeader
FMTHeader() = default;
FMTHeader(u16 ch)
: ID(*(u32*)"fmt ")
: ID("fmt "_u32)
, Size(16)
, AudioFormat(3)
, NumChannels(ch)
@ -53,7 +53,7 @@ struct WAVHeader
WAVHeader() = default;
WAVHeader(u16 ch)
: ID(*(u32*)"data")
: ID("data"_u32)
, Size(0)
, FMT(ch)
, RIFF(sizeof(RIFFHeader) + sizeof(FMTHeader))
@ -65,7 +65,7 @@ class AudioDumper
{
WAVHeader m_header;
fs::file m_output;
public:
AudioDumper(u16 ch);
~AudioDumper();

View File

@ -1019,7 +1019,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry)
continue;
}
}
if (ptr + 4 <= fend &&
ptr[0] == STD(r2, r1, 0x28) &&
(ptr[1] & 0xffff0000) == ADDIS(r2, r2, {}) &&
@ -2177,7 +2177,7 @@ void ppu_acontext::ADDI(ppu_opcode_t op)
void ppu_acontext::ADDIS(ppu_opcode_t op)
{
gpr[op.rd] = op.ra ? gpr[op.ra] + spec_gpr::fixed((u64)op.simm16 << 16) : spec_gpr::fixed((u64)op.simm16 << 16);
gpr[op.rd] = op.ra ? gpr[op.ra] + spec_gpr::fixed(op.simm16 * 65536) : spec_gpr::fixed(op.simm16 * 65536);
}
void ppu_acontext::BC(ppu_opcode_t op)
@ -2250,14 +2250,14 @@ void ppu_acontext::RLWIMI(ppu_opcode_t op)
if (op.mb32 <= op.me32)
{
// 32-bit op, including mnemonics: INSLWI, INSRWI (TODO)
min = utils::rol32((u32)min, op.sh32) & mask;
max = utils::rol32((u32)max, op.sh32) & mask;
min = utils::rol32(static_cast<u32>(min), op.sh32) & mask;
max = utils::rol32(static_cast<u32>(max), op.sh32) & mask;
}
else
{
// Full 64-bit op with duplication
min = utils::rol64((u32)min | min << 32, op.sh32) & mask;
max = utils::rol64((u32)max | max << 32, op.sh32) & mask;
min = utils::rol64(static_cast<u32>(min) | min << 32, op.sh32) & mask;
max = utils::rol64(static_cast<u32>(max) | max << 32, op.sh32) & mask;
}
if (mask != -1)
@ -2306,14 +2306,14 @@ void ppu_acontext::RLWINM(ppu_opcode_t op)
// EXTRWI and other possible mnemonics
}
min = utils::rol32((u32)min, op.sh32) & mask;
max = utils::rol32((u32)max, op.sh32) & mask;
min = utils::rol32(static_cast<u32>(min), op.sh32) & mask;
max = utils::rol32(static_cast<u32>(max), op.sh32) & mask;
}
else
{
// Full 64-bit op with duplication
min = utils::rol64((u32)min | min << 32, op.sh32) & mask;
max = utils::rol64((u32)max | max << 32, op.sh32) & mask;
min = utils::rol64(static_cast<u32>(min) | min << 32, op.sh32) & mask;
max = utils::rol64(static_cast<u32>(max) | max << 32, op.sh32) & mask;
}
gpr[op.ra] = spec_gpr::approx(min, max);

View File

@ -6,7 +6,7 @@ const ppu_decoder<PPUDisAsm> s_ppu_disasm;
u32 PPUDisAsm::disasm(u32 pc)
{
const u32 op = *(be_t<u32>*)(offset + pc);
const u32 op = *reinterpret_cast<const be_t<u32>*>(offset + pc);
(this->*(s_ppu_disasm.decode(op)))({ op });
return 4;
}

View File

@ -2526,7 +2526,7 @@ std::vector<ppu_function_t>& ppu_function_manager::access()
{
LOG_ERROR(PPU, "Unregistered function called (LR=0x%x)", ppu.lr);
ppu.gpr[3] = 0;
ppu.cia = (u32)ppu.lr & ~3;
ppu.cia = static_cast<u32>(ppu.lr) & ~3;
return false;
},
[](ppu_thread& ppu) -> bool

File diff suppressed because it is too large Load Diff

View File

@ -738,8 +738,8 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
LOG_NOTICE(LOADER, "** Segment: p_type=0x%x, p_vaddr=0x%llx, p_filesz=0x%llx, p_memsz=0x%llx, flags=0x%x", prog.p_type, prog.p_vaddr, prog.p_filesz, prog.p_memsz, prog.p_flags);
// Hash big-endian values
sha1_update(&sha, (uchar*)&prog.p_type, sizeof(prog.p_type));
sha1_update(&sha, (uchar*)&prog.p_flags, sizeof(prog.p_flags));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_type), sizeof(prog.p_type));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_flags), sizeof(prog.p_flags));
switch (const u32 p_type = prog.p_type)
{
@ -764,8 +764,8 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
LOG_WARNING(LOADER, "**** Loaded to 0x%x (size=0x%x)", addr, mem_size);
// Hash segment
sha1_update(&sha, (uchar*)&prog.p_vaddr, sizeof(prog.p_vaddr));
sha1_update(&sha, (uchar*)&prog.p_memsz, sizeof(prog.p_memsz));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_vaddr), sizeof(prog.p_vaddr));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_memsz), sizeof(prog.p_memsz));
sha1_update(&sha, prog.bin.data(), prog.bin.size());
// Initialize executable code if necessary
@ -1077,8 +1077,8 @@ void ppu_load_exec(const ppu_exec_object& elf)
_seg.filesz = ::narrow<u32>(prog.p_filesz, "p_filesz" HERE);
// Hash big-endian values
sha1_update(&sha, (uchar*)&prog.p_type, sizeof(prog.p_type));
sha1_update(&sha, (uchar*)&prog.p_flags, sizeof(prog.p_flags));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_type), sizeof(prog.p_type));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_flags), sizeof(prog.p_flags));
if (type == 0x1 /* LOAD */ && prog.p_memsz)
{
@ -1090,8 +1090,8 @@ void ppu_load_exec(const ppu_exec_object& elf)
// Copy segment data, hash it
std::memcpy(vm::base(addr), prog.bin.data(), prog.bin.size());
sha1_update(&sha, (uchar*)&prog.p_vaddr, sizeof(prog.p_vaddr));
sha1_update(&sha, (uchar*)&prog.p_memsz, sizeof(prog.p_memsz));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_vaddr), sizeof(prog.p_vaddr));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_memsz), sizeof(prog.p_memsz));
sha1_update(&sha, prog.bin.data(), prog.bin.size());
// Initialize executable code if necessary
@ -1548,8 +1548,8 @@ std::shared_ptr<lv2_overlay> ppu_load_overlay(const ppu_exec_object& elf, const
_seg.filesz = ::narrow<u32>(prog.p_filesz, "p_filesz" HERE);
// Hash big-endian values
sha1_update(&sha, (uchar*)&prog.p_type, sizeof(prog.p_type));
sha1_update(&sha, (uchar*)&prog.p_flags, sizeof(prog.p_flags));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_type), sizeof(prog.p_type));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_flags), sizeof(prog.p_flags));
if (type == 0x1 /* LOAD */ && prog.p_memsz)
{
@ -1561,8 +1561,8 @@ std::shared_ptr<lv2_overlay> ppu_load_overlay(const ppu_exec_object& elf, const
// Copy segment data, hash it
std::memcpy(vm::base(addr), prog.bin.data(), prog.bin.size());
sha1_update(&sha, (uchar*)&prog.p_vaddr, sizeof(prog.p_vaddr));
sha1_update(&sha, (uchar*)&prog.p_memsz, sizeof(prog.p_memsz));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_vaddr), sizeof(prog.p_vaddr));
sha1_update(&sha, reinterpret_cast<const uchar*>(&prog.p_memsz), sizeof(prog.p_memsz));
sha1_update(&sha, prog.bin.data(), prog.bin.size());
// Initialize executable code if necessary

View File

@ -5,7 +5,7 @@ const spu_decoder<SPUDisAsm> s_spu_disasm;
u32 SPUDisAsm::disasm(u32 pc)
{
const u32 op = *(be_t<u32>*)(offset + pc);
const u32 op = *reinterpret_cast<const be_t<u32>*>(offset + pc);
(this->*(s_spu_disasm.decode(op)))({ op });
return 4;
}

View File

@ -90,14 +90,14 @@ private:
case 0b01: return "e";
case 0b10: return "d";
//case 0b11: return "(undef)";
default: return "";
default: return "";
}
}
private:
std::string& FixOp(std::string& op)
{
op.append(std::max<int>(10 - (int)op.length(), 0),' ');
op.append(std::max<int>(10 - ::narrow<int>(op.size()), 0),' ');
return op;
}
void DisAsm(const char* op)

View File

@ -488,7 +488,7 @@ error_code sys_event_port_send(u32 eport_id, u64 data1, u64 data2, u64 data3)
{
if (const auto queue = port.queue.lock())
{
const u64 source = port.name ? port.name : ((u64)process_getpid() << 32) | (u64)eport_id;
const u64 source = port.name ? port.name : (s64{process_getpid()} << 32) | u64{eport_id};
if (queue->send(source, data1, data2, data3))
{

View File

@ -353,7 +353,7 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
#ifdef _WIN32
sock.ev_set &= ~FD_ACCEPT;
#endif
native_socket = ::accept(sock.socket, (::sockaddr*)&native_addr, &native_addrlen);
native_socket = ::accept(sock.socket, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen);
if (native_socket != -1)
{
@ -377,7 +377,7 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
#ifdef _WIN32
sock.ev_set &= ~FD_ACCEPT;
#endif
native_socket = ::accept(sock.socket, (::sockaddr*)&native_addr, &native_addrlen);
native_socket = ::accept(sock.socket, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen);
if (native_socket != -1 || (result = get_last_error(!sock.so_nbio)))
{
@ -459,8 +459,8 @@ error_code sys_net_bnet_accept(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr>
paddr->sin_len = sizeof(sys_net_sockaddr_in);
paddr->sin_family = SYS_NET_AF_INET;
paddr->sin_port = ntohs(((::sockaddr_in*)&native_addr)->sin_port);
paddr->sin_addr = ntohl(((::sockaddr_in*)&native_addr)->sin_addr.s_addr);
paddr->sin_port = ntohs(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_port);
paddr->sin_addr = ntohl(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_addr.s_addr);
paddr->sin_zero = 0;
}
@ -480,17 +480,19 @@ error_code sys_net_bnet_bind(ppu_thread& ppu, s32 s, vm::cptr<sys_net_sockaddr>
return -SYS_NET_EAFNOSUPPORT;
}
const auto psa_in = vm::_ptr<const sys_net_sockaddr_in>(addr.addr());
::sockaddr_in name{};
name.sin_family = AF_INET;
name.sin_port = htons(((sys_net_sockaddr_in*)addr.get_ptr())->sin_port);
name.sin_addr.s_addr = htonl(((sys_net_sockaddr_in*)addr.get_ptr())->sin_addr);
name.sin_port = htons(psa_in->sin_port);
name.sin_addr.s_addr = htonl(psa_in->sin_addr);
::socklen_t namelen = sizeof(name);
const auto sock = idm::check<lv2_socket>(s, [&](lv2_socket& sock) -> sys_net_error
{
std::lock_guard lock(sock.mutex);
if (::bind(sock.socket, (::sockaddr*)&name, namelen) == 0)
if (::bind(sock.socket, reinterpret_cast<struct sockaddr*>(&name), namelen) == 0)
{
return {};
}
@ -517,27 +519,29 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
sys_net.warning("sys_net_bnet_connect(s=%d, addr=*0x%x, addrlen=%u)", s, addr, addrlen);
const auto psa_in = vm::_ptr<sys_net_sockaddr_in>(addr.addr());
s32 result = 0;
::sockaddr_in name{};
name.sin_family = AF_INET;
name.sin_port = htons(((sys_net_sockaddr_in*)addr.get_ptr())->sin_port);
name.sin_addr.s_addr = htonl(((sys_net_sockaddr_in*)addr.get_ptr())->sin_addr);
name.sin_port = htons(psa_in->sin_port);
name.sin_addr.s_addr = htonl(psa_in->sin_addr);
::socklen_t namelen = sizeof(name);
const auto sock = idm::check<lv2_socket>(s, [&](lv2_socket& sock)
{
std::lock_guard lock(sock.mutex);
if (addr->sa_family == 0 && !((sys_net_sockaddr_in*)addr.get_ptr())->sin_port && !((sys_net_sockaddr_in*)addr.get_ptr())->sin_addr)
if (addr->sa_family == 0 && !psa_in->sin_port && !psa_in->sin_addr)
{
// Hack for DNS (8.8.8.8:53)
name.sin_port = htons(53);
name.sin_addr.s_addr = 0x08080808;
// Overwrite arg (probably used to validate recvfrom addr)
((sys_net_sockaddr_in*)addr.get_ptr())->sin_family = SYS_NET_AF_INET;
((sys_net_sockaddr_in*)addr.get_ptr())->sin_port = 53;
((sys_net_sockaddr_in*)addr.get_ptr())->sin_addr = 0x08080808;
psa_in->sin_family = SYS_NET_AF_INET;
psa_in->sin_port = 53;
psa_in->sin_addr = 0x08080808;
sys_net.warning("sys_net_bnet_connect(s=%d): using DNS 8.8.8.8:53...");
}
else if (addr->sa_family != SYS_NET_AF_INET)
@ -545,7 +549,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
sys_net.error("sys_net_bnet_connect(s=%d): unsupported sa_family (%d)", s, addr->sa_family);
}
if (::connect(sock.socket, (::sockaddr*)&name, namelen) == 0)
if (::connect(sock.socket, reinterpret_cast<struct sockaddr*>(&name), namelen) == 0)
{
return true;
}
@ -573,7 +577,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
#endif
int native_error;
::socklen_t size = sizeof(native_error);
if (::getsockopt(sock.socket, SOL_SOCKET, SO_ERROR, (char*)&native_error, &size) != 0 || size != sizeof(int))
if (::getsockopt(sock.socket, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&native_error), &size) != 0 || size != sizeof(int))
{
sock.so_error = 1;
}
@ -604,7 +608,7 @@ error_code sys_net_bnet_connect(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sockaddr
#endif
int native_error;
::socklen_t size = sizeof(native_error);
if (::getsockopt(sock.socket, SOL_SOCKET, SO_ERROR, (char*)&native_error, &size) != 0 || size != sizeof(int))
if (::getsockopt(sock.socket, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&native_error), &size) != 0 || size != sizeof(int))
{
result = 1;
}
@ -680,7 +684,7 @@ error_code sys_net_bnet_getpeername(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
::sockaddr_storage native_addr;
::socklen_t native_addrlen = sizeof(native_addr);
if (::getpeername(sock.socket, (::sockaddr*)&native_addr, &native_addrlen) == 0)
if (::getpeername(sock.socket, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen) == 0)
{
verify(HERE), native_addr.ss_family == AF_INET;
@ -693,8 +697,8 @@ error_code sys_net_bnet_getpeername(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
paddr->sin_len = sizeof(sys_net_sockaddr_in);
paddr->sin_family = SYS_NET_AF_INET;
paddr->sin_port = ntohs(((::sockaddr_in*)&native_addr)->sin_port);
paddr->sin_addr = ntohl(((::sockaddr_in*)&native_addr)->sin_addr.s_addr);
paddr->sin_port = ntohs(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_port);
paddr->sin_addr = ntohl(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_addr.s_addr);
paddr->sin_zero = 0;
return {};
}
@ -728,7 +732,7 @@ error_code sys_net_bnet_getsockname(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
::sockaddr_storage native_addr;
::socklen_t native_addrlen = sizeof(native_addr);
if (::getsockname(sock.socket, (::sockaddr*)&native_addr, &native_addrlen) == 0)
if (::getsockname(sock.socket, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen) == 0)
{
verify(HERE), native_addr.ss_family == AF_INET;
@ -741,8 +745,8 @@ error_code sys_net_bnet_getsockname(ppu_thread& ppu, s32 s, vm::ptr<sys_net_sock
paddr->sin_len = sizeof(sys_net_sockaddr_in);
paddr->sin_family = SYS_NET_AF_INET;
paddr->sin_port = ntohs(((::sockaddr_in*)&native_addr)->sin_port);
paddr->sin_addr = ntohl(((::sockaddr_in*)&native_addr)->sin_addr.s_addr);
paddr->sin_port = ntohs(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_port);
paddr->sin_addr = ntohl(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_addr.s_addr);
paddr->sin_zero = 0;
return {};
}
@ -799,13 +803,13 @@ error_code sys_net_bnet_getsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
case SYS_NET_SO_NBIO:
{
// Special
*(be_t<s32>*)optval.get_ptr() = sock.so_nbio;
vm::_ref<s32>(optval.addr()) = sock.so_nbio;
return {};
}
case SYS_NET_SO_ERROR:
{
// Special
*(be_t<s32>*)optval.get_ptr() = std::exchange(sock.so_error, 0);
vm::_ref<s32>(optval.addr()) = std::exchange(sock.so_error, 0);
return {};
}
case SYS_NET_SO_KEEPALIVE:
@ -841,12 +845,12 @@ error_code sys_net_bnet_getsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
#ifdef _WIN32
case SYS_NET_SO_REUSEADDR:
{
*(be_t<s32>*)optval.get_ptr() = sock.so_reuseaddr;
vm::_ref<s32>(optval.addr()) = sock.so_reuseaddr;
return {};
}
case SYS_NET_SO_REUSEPORT:
{
*(be_t<s32>*)optval.get_ptr() = sock.so_reuseport;
vm::_ref<s32>(optval.addr()) = sock.so_reuseport;
return {};
}
#else
@ -894,7 +898,7 @@ error_code sys_net_bnet_getsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
case SYS_NET_TCP_MAXSEG:
{
// Special (no effect)
*(be_t<s32>*)optval.get_ptr() = sock.so_tcp_maxseg;
vm::_ref<s32>(optval.addr()) = sock.so_tcp_maxseg;
return {};
}
case SYS_NET_TCP_NODELAY:
@ -928,20 +932,20 @@ error_code sys_net_bnet_getsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
case SYS_NET_SO_RCVTIMEO:
{
// TODO
*(sys_net_timeval*)optval.get_ptr() = { ::narrow<s64>(native_val.timeo.tv_sec), ::narrow<s64>(native_val.timeo.tv_usec) };
vm::_ref<sys_net_timeval>(optval.addr()) = { ::narrow<s64>(native_val.timeo.tv_sec), ::narrow<s64>(native_val.timeo.tv_usec) };
return {};
}
case SYS_NET_SO_LINGER:
{
// TODO
*(sys_net_linger*)optval.get_ptr() = { ::narrow<s32>(native_val.linger.l_onoff), ::narrow<s32>(native_val.linger.l_linger) };
vm::_ref<sys_net_linger>(optval.addr()) = { ::narrow<s32>(native_val.linger.l_onoff), ::narrow<s32>(native_val.linger.l_linger) };
return {};
}
}
}
// Fallback to int
*(be_t<s32>*)optval.get_ptr() = native_val._int;
vm::_ref<s32>(optval.addr()) = native_val._int;
return {};
});
@ -1025,7 +1029,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
#ifdef _WIN32
if (!(native_flags & MSG_PEEK)) sock.ev_set &= ~FD_READ;
#endif
native_result = ::recvfrom(sock.socket, (char*)buf.get_ptr(), len, native_flags, (::sockaddr*)&native_addr, &native_addrlen);
native_result = ::recvfrom(sock.socket, reinterpret_cast<char*>(buf.get_ptr()), len, native_flags, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen);
if (native_result >= 0)
{
@ -1049,7 +1053,7 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
#ifdef _WIN32
if (!(native_flags & MSG_PEEK)) sock.ev_set &= ~FD_READ;
#endif
native_result = ::recvfrom(sock.socket, (char*)buf.get_ptr(), len, native_flags, (::sockaddr*)&native_addr, &native_addrlen);
native_result = ::recvfrom(sock.socket, reinterpret_cast<char*>(buf.get_ptr()), len, native_flags, reinterpret_cast<struct sockaddr*>(&native_addr), &native_addrlen);
if (native_result >= 0 || (result = get_last_error(!sock.so_nbio && (flags & SYS_NET_MSG_DONTWAIT) == 0)))
{
@ -1123,8 +1127,8 @@ error_code sys_net_bnet_recvfrom(ppu_thread& ppu, s32 s, vm::ptr<void> buf, u32
paddr->sin_len = sizeof(sys_net_sockaddr_in);
paddr->sin_family = SYS_NET_AF_INET;
paddr->sin_port = ntohs(((::sockaddr_in*)&native_addr)->sin_port);
paddr->sin_addr = ntohl(((::sockaddr_in*)&native_addr)->sin_addr.s_addr);
paddr->sin_port = ntohs(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_port);
paddr->sin_addr = ntohl(reinterpret_cast<struct sockaddr_in*>(&native_addr)->sin_addr.s_addr);
paddr->sin_zero = 0;
}
@ -1171,6 +1175,8 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
return -SYS_NET_EAFNOSUPPORT;
}
const auto psa_in = vm::_ptr<const sys_net_sockaddr_in>(addr.addr());
int native_flags = 0;
int native_result = -1;
::sockaddr_in name{};
@ -1178,8 +1184,8 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
if (addr)
{
name.sin_family = AF_INET;
name.sin_port = htons(((sys_net_sockaddr_in*)addr.get_ptr())->sin_port);
name.sin_addr.s_addr = htonl(((sys_net_sockaddr_in*)addr.get_ptr())->sin_addr);
name.sin_port = htons(psa_in->sin_port);
name.sin_addr.s_addr = htonl(psa_in->sin_addr);
}
::socklen_t namelen = sizeof(name);
@ -1199,7 +1205,7 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
#ifdef _WIN32
sock.ev_set &= ~FD_WRITE;
#endif
native_result = ::sendto(sock.socket, (const char*)buf.get_ptr(), len, native_flags, addr ? (::sockaddr*)&name : nullptr, addr ? namelen : 0);
native_result = ::sendto(sock.socket, reinterpret_cast<const char*>(buf.get_ptr()), len, native_flags, addr ? reinterpret_cast<struct sockaddr*>(&name) : nullptr, addr ? namelen : 0);
if (native_result >= 0)
{
@ -1223,7 +1229,7 @@ error_code sys_net_bnet_sendto(ppu_thread& ppu, s32 s, vm::cptr<void> buf, u32 l
#ifdef _WIN32
sock.ev_set &= ~FD_WRITE;
#endif
native_result = ::sendto(sock.socket, (const char*)buf.get_ptr(), len, native_flags, addr ? (::sockaddr*)&name : nullptr, addr ? namelen : 0);
native_result = ::sendto(sock.socket, reinterpret_cast<const char*>(buf.get_ptr()), len, native_flags, addr ? reinterpret_cast<struct sockaddr*>(&name) : nullptr, addr ? namelen : 0);
if (native_result >= 0 || (result = get_last_error(!sock.so_nbio && (flags & SYS_NET_MSG_DONTWAIT) == 0)))
{
@ -1302,7 +1308,7 @@ error_code sys_net_bnet_setsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
if (optlen >= sizeof(int))
{
native_int = *(const be_t<s32>*)optval.get_ptr();
native_int = vm::_ref<s32>(optval.addr());
}
else
{
@ -1387,8 +1393,8 @@ error_code sys_net_bnet_setsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
native_opt = optname == SYS_NET_SO_SNDTIMEO ? SO_SNDTIMEO : SO_RCVTIMEO;
native_val = &native_timeo;
native_len = sizeof(native_timeo);
native_timeo.tv_sec = ::narrow<int>(((const sys_net_timeval*)optval.get_ptr())->tv_sec);
native_timeo.tv_usec = ::narrow<int>(((const sys_net_timeval*)optval.get_ptr())->tv_usec);
native_timeo.tv_sec = ::narrow<int>(vm::_ptr<const sys_net_timeval>(optval.addr())->tv_sec);
native_timeo.tv_usec = ::narrow<int>(vm::_ptr<const sys_net_timeval>(optval.addr())->tv_usec);
break;
}
case SYS_NET_SO_LINGER:
@ -1400,8 +1406,8 @@ error_code sys_net_bnet_setsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
native_opt = SO_LINGER;
native_val = &native_linger;
native_len = sizeof(native_linger);
native_linger.l_onoff = ((const sys_net_linger*)optval.get_ptr())->l_onoff;
native_linger.l_linger = ((const sys_net_linger*)optval.get_ptr())->l_linger;
native_linger.l_onoff = vm::_ptr<const sys_net_linger>(optval.addr())->l_onoff;
native_linger.l_linger = vm::_ptr<const sys_net_linger>(optval.addr())->l_linger;
break;
}
case SYS_NET_SO_USECRYPTO:
@ -1453,7 +1459,7 @@ error_code sys_net_bnet_setsockopt(ppu_thread& ppu, s32 s, s32 level, s32 optnam
return SYS_NET_EINVAL;
}
if (::setsockopt(sock.socket, native_level, native_opt, (const char*)native_val, native_len) == 0)
if (::setsockopt(sock.socket, native_level, native_opt, reinterpret_cast<const char*>(native_val), native_len) == 0)
{
return {};
}

View File

@ -73,7 +73,7 @@ error_code sys_overlay_load_module_by_fd(vm::ptr<u32> ovlmid, u32 fd, u64 offset
return CELL_ENOSYS;
}
if ((s64)offset < 0)
if (static_cast<s64>(offset) < 0)
{
return CELL_EINVAL;
}

View File

@ -238,7 +238,7 @@ error_code sys_timer_connect_event_queue(ppu_thread& ppu, u32 timer_id, u32 queu
// Connect event queue
timer.port = std::static_pointer_cast<lv2_event_queue>(found->second);
timer.source = name ? name : ((u64)process_getpid() << 32) | timer_id;
timer.source = name ? name : (s64{process_getpid()} << 32) | u64{timer_id};
timer.data1 = data1;
timer.data2 = data2;
return {};

View File

@ -75,7 +75,7 @@ error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadle
return CELL_EFAULT;
}
*preadlen = (u32)chars_to_read;
*preadlen = static_cast<u32>(chars_to_read);
if (chars_to_read > 0)
{

View File

@ -187,7 +187,7 @@ void gdb_thread::start_server()
unix_saddr.sun_family = AF_UNIX;
strcpy_trunc(unix_saddr.sun_path, g_cfg.misc.gdb_server.get());
if (bind(server_socket, (struct sockaddr*) &unix_saddr, sizeof(unix_saddr)) != 0)
if (bind(server_socket, reinterpret_cast<struct sockaddr*>(&unix_saddr), sizeof(unix_saddr)) != 0)
{
GDB.error("Failed to bind Unix socket '%s'.", g_cfg.misc.gdb_server.get());
return;
@ -846,7 +846,7 @@ void gdb_thread::operator()()
{
sockaddr_in client;
socklen_t client_len = sizeof(client);
client_socket = accept(server_socket, (struct sockaddr *) &client, &client_len);
client_socket = accept(server_socket, reinterpret_cast<struct sockaddr*>(&client), &client_len);
if (client_socket == -1)
{

View File

@ -160,7 +160,7 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con
{
u32 trophy_id = std::atoi(n->GetAttribute("id").c_str());
u32 trophy_grade;
switch (((const char *)n->GetAttribute("ttype").c_str())[0])
switch (n->GetAttribute("ttype")[0])
{
case 'B': trophy_grade = 4; break;
case 'S': trophy_grade = 3; break;
@ -169,8 +169,8 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con
default: trophy_grade = 0;
}
TROPUSREntry4 entry4 = { 4, u32{sizeof(TROPUSREntry4)} - 0x10, (u32)m_table4.size(), 0, trophy_id, trophy_grade, 0xFFFFFFFF };
TROPUSREntry6 entry6 = { 6, u32{sizeof(TROPUSREntry6)} - 0x10, (u32)m_table6.size(), 0, trophy_id };
TROPUSREntry4 entry4 = { 4, u32{sizeof(TROPUSREntry4)} - 0x10, ::size32(m_table4), 0, trophy_id, trophy_grade, 0xFFFFFFFF };
TROPUSREntry6 entry6 = { 6, u32{sizeof(TROPUSREntry6)} - 0x10, ::size32(m_table6), 0, trophy_id };
m_table4.push_back(entry4);
m_table6.push_back(entry6);
@ -178,9 +178,9 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con
}
u64 offset = sizeof(TROPUSRHeader) + 2 * sizeof(TROPUSRTableHeader);
TROPUSRTableHeader table4header = { 4, u32{sizeof(TROPUSREntry4)} - 0x10, 1, (u32)m_table4.size(), offset };
TROPUSRTableHeader table4header = { 4, u32{sizeof(TROPUSREntry4)} - 0x10, 1, ::size32(m_table4), offset };
offset += m_table4.size() * sizeof(TROPUSREntry4);
TROPUSRTableHeader table6header = { 6, u32{sizeof(TROPUSREntry6)} - 0x10, 1, (u32)m_table6.size(), offset };
TROPUSRTableHeader table6header = { 6, u32{sizeof(TROPUSREntry6)} - 0x10, 1, ::size32(m_table6), offset };
offset += m_table6.size() * sizeof(TROPUSREntry6);
m_tableHeaders.clear();
@ -189,7 +189,7 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con
m_header.magic = 0x818F54AD;
m_header.unk1 = 0x00010000;
m_header.tables_count = (u32)m_tableHeaders.size();
m_header.tables_count = ::size32(m_tableHeaders);
m_header.unk2 = 0;
Save(filepath);
@ -199,7 +199,7 @@ bool TROPUSRLoader::Generate(const std::string& filepath, const std::string& con
u32 TROPUSRLoader::GetTrophiesCount()
{
return (u32)m_table6.size();
return ::size32(m_table6);
}
u32 TROPUSRLoader::GetUnlockedTrophiesCount()