Replace some utils::bless usages

This commit is contained in:
Eladash 2023-08-19 12:20:06 +03:00 committed by Elad Ashkenazi
parent 373e502501
commit 9635417ae5
5 changed files with 22 additions and 22 deletions

View file

@ -292,8 +292,8 @@ namespace rpcn
{ {
if (msg.size() == 6) if (msg.size() == 6)
{ {
addr_sig = *utils::bless<le_t<u32>>(&msg[0]); addr_sig = read_from_ptr<le_t<u32>>(&msg[0]);
port_sig = *utils::bless<be_t<u16>>(&msg[4]); port_sig = read_from_ptr<be_t<u16>>(&msg[4]);
last_pong_time = now; last_pong_time = now;
} }
@ -308,8 +308,8 @@ namespace rpcn
{ {
std::vector<u8> ping(13); std::vector<u8> ping(13);
ping[0] = 1; ping[0] = 1;
*utils::bless<le_t<s64, 1>>(&ping[1]) = user_id; write_to_ptr<le_t<s64>>(ping, 1, user_id);
*utils::bless<be_t<u32, 1>>(&ping[9]) = local_addr_sig; write_to_ptr<be_t<u32>>(ping, 9, +local_addr_sig);
if (send_packet_from_p2p_port(ping, addr_rpcn_udp) == -1) if (send_packet_from_p2p_port(ping, addr_rpcn_udp) == -1)
{ {
rpcn_log.error("Failed to send ping to RPCN!"); rpcn_log.error("Failed to send ping to RPCN!");
@ -354,9 +354,9 @@ namespace rpcn
} }
const u8 packet_type = header[0]; const u8 packet_type = header[0];
const u16 command = *utils::bless<le_t<u16>>(&header[1]); const u16 command = read_from_ptr<le_t<u16>>(&header[1]);
const u32 packet_size = *utils::bless<le_t<u32>>(&header[3]); const u32 packet_size = read_from_ptr<le_t<u32>>(&header[3]);
const u64 packet_id = *utils::bless<le_t<u64>>(&header[7]); const u64 packet_id = read_from_ptr<le_t<u64>>(&header[7]);
if (packet_size < RPCN_HEADER_SIZE) if (packet_size < RPCN_HEADER_SIZE)
return error_and_disconnect("Invalid packet size"); return error_and_disconnect("Invalid packet size");
@ -1707,7 +1707,7 @@ namespace rpcn
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u64)); std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u64));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE);
*utils::bless<le_t<u64>>(&data[COMMUNICATION_ID_SIZE]) = room_id; write_to_ptr<le_t<u64>>(data, COMMUNICATION_ID_SIZE, room_id);
return forge_send(CommandType::PingRoomOwner, req_id, data); return forge_send(CommandType::PingRoomOwner, req_id, data);
} }
@ -1811,7 +1811,7 @@ namespace rpcn
{ {
std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u32)); std::vector<u8> data(COMMUNICATION_ID_SIZE + sizeof(u32));
memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE); memcpy(data.data(), communication_id.data, COMMUNICATION_ID_SIZE);
*utils::bless<le_t<u32>>(&data[COMMUNICATION_ID_SIZE]) = board_id; write_to_ptr<le_t<u32>>(data, COMMUNICATION_ID_SIZE, board_id);
return forge_send(CommandType::GetBoardInfos, req_id, data); return forge_send(CommandType::GetBoardInfos, req_id, data);
} }

View file

@ -59,7 +59,7 @@ public:
error = true; error = true;
return 0; return 0;
} }
T res = *utils::bless<le_t<T, 1>>(&vec[i]); T res = read_from_ptr<le_t<T>>(&vec[i]);
i += sizeof(T); i += sizeof(T);
return res; return res;
} }

View file

@ -195,7 +195,7 @@ namespace rsx
} }
} }
const auto ret = utils::bless<const be_t<u32>>(&m_cache)[(addr - m_cache_addr) >> 2]; const auto ret = read_from_ptr<be_t<u32>>(+m_cache[0], addr - m_cache_addr);
return {true, ret}; return {true, ret};
} }

View file

@ -426,12 +426,12 @@ namespace
{ {
case rsx::surface_color_format::b8: case rsx::surface_color_format::b8:
{ {
const u8 value = utils::bless<const u8>(orig_buffer)[idx]; const u8 value = read_from_ptr<u8>(orig_buffer, idx);
return{ value, value, value }; return{ value, value, value };
} }
case rsx::surface_color_format::x32: case rsx::surface_color_format::x32:
{ {
const be_t<u32> stored_val = utils::bless<const be_t<u32>>(orig_buffer)[idx]; const be_t<u32> stored_val = read_from_ptr<be_t<u32>>(orig_buffer, idx);
const u32 swapped_val = stored_val; const u32 swapped_val = stored_val;
const f32 float_val = std::bit_cast<f32>(swapped_val); const f32 float_val = std::bit_cast<f32>(swapped_val);
const u8 val = float_val * 255.f; const u8 val = float_val * 255.f;
@ -441,14 +441,14 @@ namespace
case rsx::surface_color_format::x8b8g8r8_o8b8g8r8: case rsx::surface_color_format::x8b8g8r8_o8b8g8r8:
case rsx::surface_color_format::x8b8g8r8_z8b8g8r8: case rsx::surface_color_format::x8b8g8r8_z8b8g8r8:
{ {
const auto ptr = utils::bless<const u8>(orig_buffer); const auto ptr = reinterpret_cast<const u8*>(orig_buffer.data());
return{ ptr[1 + idx * 4], ptr[2 + idx * 4], ptr[3 + idx * 4] }; return{ ptr[1 + idx * 4], ptr[2 + idx * 4], ptr[3 + idx * 4] };
} }
case rsx::surface_color_format::a8r8g8b8: case rsx::surface_color_format::a8r8g8b8:
case rsx::surface_color_format::x8r8g8b8_o8r8g8b8: case rsx::surface_color_format::x8r8g8b8_o8r8g8b8:
case rsx::surface_color_format::x8r8g8b8_z8r8g8b8: case rsx::surface_color_format::x8r8g8b8_z8r8g8b8:
{ {
const auto ptr = utils::bless<const u8>(orig_buffer); const auto ptr = reinterpret_cast<const u8*>(orig_buffer.data());
return{ ptr[3 + idx * 4], ptr[2 + idx * 4], ptr[1 + idx * 4] }; return{ ptr[3 + idx * 4], ptr[2 + idx * 4], ptr[1 + idx * 4] };
} }
case rsx::surface_color_format::w16z16y16x16: case rsx::surface_color_format::w16z16y16x16:
@ -581,7 +581,7 @@ void rsx_debugger::OnClickDrawCalls()
{ {
for (u32 col = 0; col < width; col++) for (u32 col = 0; col < width; col++)
{ {
const u8 stencil_val = utils::bless<const u8>(orig_buffer)[row * width + col]; const u8 stencil_val = reinterpret_cast<const u8*>(orig_buffer.data())[row * width + col];
buffer[4 * col + 0 + width * row * 4] = stencil_val; buffer[4 * col + 0 + width * row * 4] = stencil_val;
buffer[4 * col + 1 + width * row * 4] = stencil_val; buffer[4 * col + 1 + width * row * 4] = stencil_val;
buffer[4 * col + 2 + width * row * 4] = stencil_val; buffer[4 * col + 2 + width * row * 4] = stencil_val;

View file

@ -643,17 +643,17 @@ skylander_creator_dialog::skylander_creator_dialog(QWidget* parent)
std::array<u8, 0x40 * 0x10> buf{}; std::array<u8, 0x40 * 0x10> buf{};
const auto data = buf.data(); const auto data = buf.data();
// Set the block permissions // Set the block permissions
*utils::bless<le_t<u32>>(&data[0x36]) = 0x690F0F0F; write_to_ptr<le_t<u32>>(data, 0x36, 0x690F0F0F);
for (u32 index = 1; index < 0x10; index++) for (u32 index = 1; index < 0x10; index++)
{ {
*utils::bless<le_t<u32>>(&data[(index * 0x40) + 0x36]) = 0x69080F7F; write_to_ptr<le_t<u32>>(data, (index * 0x40) + 0x36, 0x69080F7F);
} }
// Set the skylander infos // Set the skylander infos
*utils::bless<le_t<u16>>(&data[0]) = (sky_id | sky_var) + 1; write_to_ptr<le_t<u16>>(data, (sky_id | sky_var) + 1);
*utils::bless<le_t<u16>>(&data[0x10]) = sky_id; write_to_ptr<le_t<u16>>(data, 0x10, sky_id);
*utils::bless<le_t<u16>>(&data[0x1C]) = sky_var; write_to_ptr<le_t<u16>>(data, 0x1C, sky_var);
// Set checksum // Set checksum
*utils::bless<le_t<u16>>(&data[0x1E]) = skylander_crc16(0xFFFF, data, 0x1E); write_to_ptr<le_t<u16>>(data, 0x1E, skylander_crc16(0xFFFF, data, 0x1E));
sky_file.write(buf.data(), buf.size()); sky_file.write(buf.data(), buf.size());
sky_file.close(); sky_file.close();