mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Clean Up
This commit is contained in:

committed by
Buddybenj

parent
e7f2a04699
commit
4f324ad742
@ -40,10 +40,8 @@ WbfsFileReader::WbfsFileReader(const std::string& filename)
|
||||
|
||||
WbfsFileReader::~WbfsFileReader()
|
||||
{
|
||||
for (u32 i = 0; i != m_files.size(); ++ i)
|
||||
{
|
||||
delete m_files[i];
|
||||
}
|
||||
for (file_entry* entry : m_files)
|
||||
delete entry;
|
||||
|
||||
delete[] m_wlba_table;
|
||||
}
|
||||
@ -58,7 +56,7 @@ bool WbfsFileReader::OpenFiles(const std::string& filename)
|
||||
|
||||
// Replace last character with index (e.g. wbfs = wbf1)
|
||||
std::string path = filename;
|
||||
if (0 != m_total_files)
|
||||
if (m_total_files != 0)
|
||||
{
|
||||
path[path.length() - 1] = '0' + m_total_files;
|
||||
}
|
||||
@ -73,7 +71,7 @@ bool WbfsFileReader::OpenFiles(const std::string& filename)
|
||||
new_entry->size = new_entry->file.GetSize();
|
||||
m_size += new_entry->size;
|
||||
|
||||
m_total_files ++;
|
||||
m_total_files++;
|
||||
m_files.push_back(new_entry);
|
||||
}
|
||||
}
|
||||
@ -90,10 +88,7 @@ bool WbfsFileReader::ReadHeader()
|
||||
m_hd_sector_size = 1ull << m_hd_sector_shift;
|
||||
|
||||
if (m_size != (m_hd_sector_count * m_hd_sector_size))
|
||||
{
|
||||
//printf("File size doesn't match expected size\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read wbfs cluster info
|
||||
m_files[0]->file.ReadBytes(&m_wbfs_sector_shift, 1);
|
||||
@ -101,10 +96,7 @@ bool WbfsFileReader::ReadHeader()
|
||||
m_wbfs_sector_count = m_size / m_wbfs_sector_size;
|
||||
|
||||
if (m_wbfs_sector_size < WII_SECTOR_SIZE)
|
||||
{
|
||||
//Setting this too low would case a very large memory allocation
|
||||
return false;
|
||||
}
|
||||
|
||||
m_blocks_per_disc = (WII_SECTOR_COUNT * WII_SECTOR_SIZE) / m_wbfs_sector_size;
|
||||
m_disc_info_size = align(WII_DISC_HEADER_SIZE + m_blocks_per_disc * 2, m_hd_sector_size);
|
||||
@ -113,11 +105,8 @@ bool WbfsFileReader::ReadHeader()
|
||||
m_files[0]->file.Seek(2, SEEK_CUR);
|
||||
m_files[0]->file.ReadBytes(m_disc_table, 500);
|
||||
|
||||
if (0 == m_disc_table[0])
|
||||
{
|
||||
//printf("Game must be in 'slot 0'\n");
|
||||
if (m_disc_table[0] == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -153,7 +142,7 @@ File::IOFile& WbfsFileReader::SeekToCluster(u64 offset, u64* available)
|
||||
u64 cluster_offset = offset & (m_wbfs_sector_size - 1);
|
||||
u64 final_address = cluster_address + cluster_offset;
|
||||
|
||||
for (u32 i = 0; i != m_total_files; i ++)
|
||||
for (u32 i = 0; i != m_total_files; i++)
|
||||
{
|
||||
if (final_address < (m_files[i]->base_address + m_files[i]->size))
|
||||
{
|
||||
|
Reference in New Issue
Block a user