mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 15:49:25 +01:00
Merge pull request #4982 from leoetlino/copy
ESFormats: Fix GetRawTicketView
This commit is contained in:
commit
e375c96693
@ -234,14 +234,17 @@ const std::vector<u8>& TicketReader::GetRawTicket() const
|
|||||||
std::vector<u8> TicketReader::GetRawTicketView(u32 ticket_num) const
|
std::vector<u8> TicketReader::GetRawTicketView(u32 ticket_num) const
|
||||||
{
|
{
|
||||||
// A ticket view is composed of a view ID + part of a ticket starting from the ticket_id field.
|
// A ticket view is composed of a view ID + part of a ticket starting from the ticket_id field.
|
||||||
std::vector<u8> view{sizeof(TicketView)};
|
const auto ticket_start = m_bytes.cbegin() + (GetOffset() + sizeof(Ticket)) * ticket_num;
|
||||||
|
const auto view_start = ticket_start + offsetof(Ticket, ticket_id);
|
||||||
|
|
||||||
u32 view_id = Common::swap32(ticket_num);
|
// Copy the view ID to the buffer.
|
||||||
|
std::vector<u8> view(sizeof(TicketView::view));
|
||||||
|
const u32 view_id = Common::swap32(ticket_num);
|
||||||
std::memcpy(view.data(), &view_id, sizeof(view_id));
|
std::memcpy(view.data(), &view_id, sizeof(view_id));
|
||||||
|
|
||||||
const size_t ticket_start = (GetOffset() + sizeof(Ticket)) * ticket_num;
|
// Copy the rest of the ticket view structure from the ticket.
|
||||||
const size_t view_start = ticket_start + offsetof(Ticket, ticket_id);
|
view.insert(view.end(), view_start, view_start + sizeof(TicketView) - sizeof(view_id));
|
||||||
std::memcpy(view.data() + sizeof(view_id), &m_bytes[view_start], sizeof(view) - sizeof(view_id));
|
_assert_(view.size() == sizeof(TicketView));
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user