mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-31 11:55:37 +00:00
GameList: Fix uninitialized fields of PSF/EXE
This commit is contained in:
parent
8ad0f78ef7
commit
2985c395df
|
@ -59,27 +59,16 @@ float File::GetTagFloat(const char* tag_name, float default_value) const
|
|||
|
||||
bool File::Load(const char* path)
|
||||
{
|
||||
auto fp = FileSystem::OpenManagedCFile(path, "rb");
|
||||
if (!fp)
|
||||
std::optional<std::vector<u8>> file_data(FileSystem::ReadBinaryFile(path));
|
||||
if (!file_data.has_value() || file_data->empty())
|
||||
{
|
||||
Log_ErrorPrintf("Failed to open PSF file '%s'", path);
|
||||
Log_ErrorPrintf("Failed to open/read PSF file '%s'", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
// we could mmap this instead
|
||||
std::fseek(fp.get(), 0, SEEK_END);
|
||||
const u32 file_size = static_cast<u32>(std::ftell(fp.get()));
|
||||
std::fseek(fp.get(), 0, SEEK_SET);
|
||||
|
||||
std::vector<u8> file_data(file_size);
|
||||
if (std::fread(file_data.data(), 1, file_size, fp.get()) != file_size)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read data from PSF '%s'", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
const u8* file_pointer = file_data.data();
|
||||
const u8* file_pointer_end = file_data.data() + file_data.size();
|
||||
const u8* file_pointer = file_data->data();
|
||||
const u8* file_pointer_end = file_data->data() + file_data->size();
|
||||
const u32 file_size = static_cast<u32>(file_data->size());
|
||||
|
||||
PSFHeader header;
|
||||
std::memcpy(&header, file_pointer, sizeof(header));
|
||||
|
|
|
@ -122,7 +122,7 @@ bool GameList::GetPsfListEntry(const char* path, GameListEntry* entry)
|
|||
entry->code.clear();
|
||||
entry->path = path;
|
||||
entry->region = file.GetRegion();
|
||||
entry->total_size = ffd.Size;
|
||||
entry->total_size = static_cast<u32>(file.GetProgramData().size());
|
||||
entry->last_modified_time = ffd.ModificationTime.AsUnixTimestamp();
|
||||
entry->type = GameListEntryType::PSF;
|
||||
entry->compatibility_rating = GameListCompatibilityRating::Unknown;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
#include "core/types.h"
|
||||
#include "game_settings.h"
|
||||
#include "game_database.h"
|
||||
#include "game_settings.h"
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
@ -37,8 +37,8 @@ enum class GameListCompatibilityRating
|
|||
|
||||
struct GameListEntry
|
||||
{
|
||||
GameListEntryType type;
|
||||
DiscRegion region;
|
||||
GameListEntryType type = GameListEntryType::Disc;
|
||||
DiscRegion region = DiscRegion::Other;
|
||||
|
||||
std::string path;
|
||||
std::string code;
|
||||
|
@ -46,17 +46,17 @@ struct GameListEntry
|
|||
std::string genre;
|
||||
std::string publisher;
|
||||
std::string developer;
|
||||
u64 total_size;
|
||||
u64 last_modified_time;
|
||||
u64 total_size = 0;
|
||||
u64 last_modified_time = 0;
|
||||
|
||||
u64 release_date;
|
||||
u32 supported_controllers;
|
||||
u8 min_players;
|
||||
u8 max_players;
|
||||
u8 min_blocks;
|
||||
u8 max_blocks;
|
||||
u64 release_date = 0;
|
||||
u32 supported_controllers = ~static_cast<u32>(0);
|
||||
u8 min_players = 1;
|
||||
u8 max_players = 1;
|
||||
u8 min_blocks = 0;
|
||||
u8 max_blocks = 0;
|
||||
|
||||
GameListCompatibilityRating compatibility_rating;
|
||||
GameListCompatibilityRating compatibility_rating = GameListCompatibilityRating::Unknown;
|
||||
GameSettings::Entry settings;
|
||||
|
||||
size_t GetReleaseDateString(char* buffer, size_t buffer_size) const;
|
||||
|
@ -69,8 +69,8 @@ struct GameListCompatibilityEntry
|
|||
std::string version_tested;
|
||||
std::string upscaling_issues;
|
||||
std::string comments;
|
||||
DiscRegion region;
|
||||
GameListCompatibilityRating compatibility_rating;
|
||||
DiscRegion region = DiscRegion::Other;
|
||||
GameListCompatibilityRating compatibility_rating = GameListCompatibilityRating::Unknown;
|
||||
};
|
||||
|
||||
class GameList
|
||||
|
|
Loading…
Reference in a new issue