Merge branch 'master' into GUI-Work

This commit is contained in:
Megamouse 2024-12-28 18:10:18 +01:00 committed by GitHub
commit ae47a3c90b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 70 additions and 72 deletions

View file

@ -596,7 +596,7 @@ void fmt_class_string<std::source_location>::format(std::string& out, u64 arg)
}
}
func = func.substr(0, index);
func = func.substr(0, index) + "()";
break;
}

View file

@ -479,10 +479,6 @@ public:
gem_config_data(utils::serial& ar)
{
save(ar);
if (ar.is_writing())
return;
load_configs();
}

View file

@ -186,6 +186,10 @@ struct main_ppu_module : public ppu_module<T>
u32 elf_entry{};
u32 seg0_code_end{};
std::vector<u32> applied_patches;
// Disable inherited savestate ordering
void save(utils::serial&) = delete;
static constexpr double savestate_init_pos = double{};
};
// Aux

View file

@ -186,3 +186,6 @@ lv2_socket& lv2_socket::operator=(thread_state s) noexcept
return *this;
}
lv2_socket::~lv2_socket() noexcept
{
}

View file

@ -64,7 +64,7 @@ public:
lv2_socket(utils::serial&, lv2_socket_type type);
static std::function<void(void*)> load(utils::serial& ar);
void save(utils::serial&, bool save_only_this_class = false);
~lv2_socket() noexcept = default;
virtual ~lv2_socket() noexcept;
lv2_socket& operator=(thread_state s) noexcept;
std::unique_lock<shared_mutex> lock();

View file

@ -57,6 +57,11 @@ void lv2_socket_native::save(utils::serial& ar)
ar(is_socket_connected());
}
lv2_socket_native::~lv2_socket_native() noexcept
{
lv2_socket_native::close();
}
s32 lv2_socket_native::create_socket()
{
ensure(family == SYS_NET_AF_INET);

View file

@ -34,6 +34,7 @@ public:
lv2_socket_native(lv2_socket_family family, lv2_socket_type type, lv2_ip_protocol protocol);
lv2_socket_native(utils::serial& ar, lv2_socket_type type);
~lv2_socket_native() noexcept override;
void save(utils::serial& ar);
s32 create_socket();

View file

@ -33,7 +33,7 @@ std::vector<std::pair<u128, id_manager::typeinfo>>& id_manager::get_typeinfo_map
return s_map;
}
id_manager::id_key* idm::allocate_id(std::span<id_manager::id_key> keys, usz& highest_index, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, bool uses_lowest_id, std::pair<u32, u32> invl_range)
id_manager::id_key* idm::allocate_id(std::span<id_manager::id_key> keys, u32& highest_index, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, bool uses_lowest_id, std::pair<u32, u32> invl_range)
{
if (dst_id != (base ? 0 : u32{umax}))
{
@ -41,7 +41,7 @@ id_manager::id_key* idm::allocate_id(std::span<id_manager::id_key> keys, usz& hi
const u32 index = id_manager::get_index(dst_id, base, step, count, invl_range);
ensure(index < count);
highest_index = std::max<usz>(highest_index, index + 1);
highest_index = std::max(highest_index, index + 1);
if (keys[index].type() != umax)
{

View file

@ -286,7 +286,7 @@ namespace id_manager
std::array<stx::atomic_ptr<T>, T::id_count> vec_data{};
std::array<stx::shared_ptr<T>, T::id_count> private_copy{};
std::array<id_key, T::id_count> vec_keys{};
usz highest_index = 0;
u32 highest_index = 0;
shared_mutex mutex{}; // TODO: Use this instead of global mutex
@ -330,11 +330,11 @@ namespace id_manager
// Simulate construction semantics (idm::last_id() value)
g_id = id;
const usz object_index = get_index(id, info->base, info->step, info->count, info->invl_range);
const u32 object_index = get_index(id, info->base, info->step, info->count, info->invl_range);
auto& obj = ::at32(vec_data, object_index);
ensure(!obj);
highest_index = std::max<usz>(highest_index, object_index + 1);
highest_index = std::max(highest_index, object_index + 1);
vec_keys[object_index] = id_key(id, static_cast<u32>(static_cast<u64>(type_init_pos >> 64)));
info->load(ar)(&obj);
@ -383,7 +383,7 @@ namespace id_manager
reader_lock lock(g_mutex);
// Save all entries
for (usz i = 0; i < highest_index; i++)
for (u32 i = 0; i < highest_index; i++)
{
private_copy[i] = vec_data[i].load();
}
@ -489,7 +489,7 @@ class idm
}
// Prepare new ID (returns nullptr if out of resources)
static id_manager::id_key* allocate_id(std::span<id_manager::id_key> vec, usz& highest_index, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, bool uses_lowest_id, std::pair<u32, u32> invl_range);
static id_manager::id_key* allocate_id(std::span<id_manager::id_key> keys, u32& highest_index, u32 type_id, u32 dst_id, u32 base, u32 step, u32 count, bool uses_lowest_id, std::pair<u32, u32> invl_range);
// Get object by internal index if exists (additionally check type if types are not equal)
template <typename T, typename Type>

View file

@ -1749,8 +1749,7 @@ namespace vm
if (is_memory_compatible_for_copy_from_executable_optimization(addr, shm.first))
{
// Revert changes
ar.data.resize(ar.data.size() - (sizeof(u32) * 2 + sizeof(memory_page)));
ar.seek_end();
ar.trunc(sizeof(u32) * 2 + sizeof(memory_page));
vm_log.success("Removed memory block matching the memory of the executable from savestate. (addr=0x%x, size=0x%x)", addr, shm.first);
continue;
}

View file

@ -42,7 +42,7 @@ static std::array<serial_ver_t, 27> s_serial_versions;
return ::s_serial_versions[identifier].current_version;\
}
SERIALIZATION_VER(global_version, 0, 18) // For stuff not listed here
SERIALIZATION_VER(global_version, 0, 19) // For stuff not listed here
SERIALIZATION_VER(ppu, 1, 1, 2/*PPU sleep order*/, 3/*PPU FNID and module*/)
SERIALIZATION_VER(spu, 2, 1)
SERIALIZATION_VER(lv2_sync, 3, 1)
@ -393,7 +393,7 @@ namespace stx
if ((saved ^ tag) & data_mask)
{
ensure(!ar.is_writing());
fmt::throw_exception("serial_breathe_and_tag(%u): %s, object: '%s', next-object: '%s', expected/tag: 0x%x != 0x%x,", s_tls_call_count, ar, s_tls_object_name, name, tag, saved);
fmt::throw_exception("serial_breathe_and_tag(%u): %s\nobject: '%s', next-object: '%s', expected/tag: 0x%x != 0x%x,", s_tls_call_count, ar, s_tls_object_name, name, tag, saved);
}
s_tls_object_name = name;

View file

@ -13,6 +13,7 @@ enum Category
Home,
Media,
Data,
OS,
Unknown_Cat,
Others,
};
@ -50,5 +51,6 @@ namespace cat
const QStringList psp_games = { cat_psp_game, cat_psp_mini, cat_psp_rema };
const QStringList media = { cat_app_photo, cat_app_video, cat_bc_video, cat_app_music, cat_app_store, cat_app_tv, cat_web_tv };
const QStringList data = { cat_ps3_data, cat_ps2_data, cat_ps3_save, cat_psp_save };
const QStringList others = { cat_network, cat_store_fe, cat_ps3_os };
const QStringList os = { cat_ps3_os };
const QStringList others = { cat_network, cat_store_fe };
}

View file

@ -125,6 +125,7 @@ QStringList gui_settings::GetGameListCategoryFilters(bool is_list_mode) const
if (GetCategoryVisibility(Category::Home, is_list_mode)) filterList.append(cat::cat_home);
if (GetCategoryVisibility(Category::Media, is_list_mode)) filterList.append(cat::media);
if (GetCategoryVisibility(Category::Data, is_list_mode)) filterList.append(cat::data);
if (GetCategoryVisibility(Category::OS, is_list_mode)) filterList.append(cat::os);
if (GetCategoryVisibility(Category::Unknown_Cat, is_list_mode)) filterList.append(cat::cat_unknown);
if (GetCategoryVisibility(Category::Others, is_list_mode)) filterList.append(cat::others);
@ -344,6 +345,7 @@ gui_save gui_settings::GetGuiSaveForCategory(int cat, bool is_list_mode)
case Category::PSP_Game: return is_list_mode ? gui::cat_psp_game : gui::grid_cat_psp_game;
case Category::Media: return is_list_mode ? gui::cat_audio_video : gui::grid_cat_audio_video;
case Category::Data: return is_list_mode ? gui::cat_game_data : gui::grid_cat_game_data;
case Category::OS: return is_list_mode ? gui::cat_os : gui::grid_cat_os;
case Category::Unknown_Cat: return is_list_mode ? gui::cat_unknown : gui::grid_cat_unknown;
case Category::Others: return is_list_mode ? gui::cat_other : gui::grid_cat_other;
default:

View file

@ -161,6 +161,7 @@ namespace gui
const gui_save cat_home = gui_save(game_list, "categoryVisibleHome", true);
const gui_save cat_audio_video = gui_save(game_list, "categoryVisibleAudioVideo", true);
const gui_save cat_game_data = gui_save(game_list, "categoryVisibleGameData", false);
const gui_save cat_os = gui_save(game_list, "categoryVisibleOS", false);
const gui_save cat_unknown = gui_save(game_list, "categoryVisibleUnknown", true);
const gui_save cat_other = gui_save(game_list, "categoryVisibleOther", true);
@ -172,6 +173,7 @@ namespace gui
const gui_save grid_cat_home = gui_save(game_list, "gridCategoryVisibleHome", true);
const gui_save grid_cat_audio_video = gui_save(game_list, "gridCategoryVisibleAudioVideo", true);
const gui_save grid_cat_game_data = gui_save(game_list, "gridCategoryVisibleGameData", false);
const gui_save grid_cat_os = gui_save(game_list, "gridCategoryVisibleOS", false);
const gui_save grid_cat_unknown = gui_save(game_list, "gridCategoryVisibleUnknown", true);
const gui_save grid_cat_other = gui_save(game_list, "gridCategoryVisibleOther", true);

View file

@ -2391,6 +2391,7 @@ void main_window::UpdateFilterActions()
ui->showCatHomeAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Home, m_is_list_mode));
ui->showCatAudioVideoAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Media, m_is_list_mode));
ui->showCatGameDataAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Data, m_is_list_mode));
ui->showCatOSAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::OS, m_is_list_mode));
ui->showCatUnknownAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Unknown_Cat, m_is_list_mode));
ui->showCatOtherAct->setChecked(m_gui_settings->GetCategoryVisibility(Category::Others, m_is_list_mode));
}
@ -2551,6 +2552,7 @@ void main_window::CreateActions()
m_category_visible_act_group->addAction(ui->showCatHomeAct);
m_category_visible_act_group->addAction(ui->showCatAudioVideoAct);
m_category_visible_act_group->addAction(ui->showCatGameDataAct);
m_category_visible_act_group->addAction(ui->showCatOSAct);
m_category_visible_act_group->addAction(ui->showCatUnknownAct);
m_category_visible_act_group->addAction(ui->showCatOtherAct);
m_category_visible_act_group->setExclusive(false);
@ -3227,16 +3229,17 @@ void main_window::CreateConnects()
const auto get_cats = [this](QAction* act, int& id) -> QStringList
{
QStringList categories;
if (act == ui->showCatHDDGameAct) { categories += cat::cat_hdd_game; id = Category::HDD_Game; }
else if (act == ui->showCatDiscGameAct) { categories += cat::cat_disc_game; id = Category::Disc_Game; }
else if (act == ui->showCatPS1GamesAct) { categories += cat::cat_ps1_game; id = Category::PS1_Game; }
else if (act == ui->showCatPS2GamesAct) { categories += cat::ps2_games; id = Category::PS2_Game; }
else if (act == ui->showCatPSPGamesAct) { categories += cat::psp_games; id = Category::PSP_Game; }
else if (act == ui->showCatHomeAct) { categories += cat::cat_home; id = Category::Home; }
else if (act == ui->showCatAudioVideoAct) { categories += cat::media; id = Category::Media; }
else if (act == ui->showCatGameDataAct) { categories += cat::data; id = Category::Data; }
else if (act == ui->showCatUnknownAct) { categories += cat::cat_unknown; id = Category::Unknown_Cat; }
else if (act == ui->showCatOtherAct) { categories += cat::others; id = Category::Others; }
if (act == ui->showCatHDDGameAct) { categories.append(cat::cat_hdd_game); id = Category::HDD_Game; }
else if (act == ui->showCatDiscGameAct) { categories.append(cat::cat_disc_game); id = Category::Disc_Game; }
else if (act == ui->showCatPS1GamesAct) { categories.append(cat::cat_ps1_game); id = Category::PS1_Game; }
else if (act == ui->showCatPS2GamesAct) { categories.append(cat::ps2_games); id = Category::PS2_Game; }
else if (act == ui->showCatPSPGamesAct) { categories.append(cat::psp_games); id = Category::PSP_Game; }
else if (act == ui->showCatHomeAct) { categories.append(cat::cat_home); id = Category::Home; }
else if (act == ui->showCatAudioVideoAct) { categories.append(cat::media); id = Category::Media; }
else if (act == ui->showCatGameDataAct) { categories.append(cat::data); id = Category::Data; }
else if (act == ui->showCatOSAct) { categories.append(cat::os); id = Category::OS; }
else if (act == ui->showCatUnknownAct) { categories.append(cat::cat_unknown); id = Category::Unknown_Cat; }
else if (act == ui->showCatOtherAct) { categories.append(cat::others); id = Category::Others; }
else { gui_log.warning("categoryVisibleActGroup: category action not found"); }
return categories;
};
@ -3276,6 +3279,7 @@ void main_window::CreateConnects()
set_cat_count(ui->showCatHomeAct, tr("Home"));
set_cat_count(ui->showCatAudioVideoAct, tr("Audio/Video"));
set_cat_count(ui->showCatGameDataAct, tr("Game Data"));
set_cat_count(ui->showCatOSAct, tr("Operating System"));
set_cat_count(ui->showCatUnknownAct, tr("Unknown"));
set_cat_count(ui->showCatOtherAct, tr("Other"));
});

View file

@ -355,6 +355,7 @@
<addaction name="showCatHomeAct"/>
<addaction name="showCatAudioVideoAct"/>
<addaction name="showCatGameDataAct"/>
<addaction name="showCatOSAct"/>
<addaction name="showCatUnknownAct"/>
<addaction name="showCatOtherAct"/>
</widget>
@ -883,9 +884,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>HDD Games</string>
</property>
@ -894,9 +892,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Disc Games</string>
</property>
@ -905,9 +900,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>PS1 Games</string>
</property>
@ -916,9 +908,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>PS2 Games</string>
</property>
@ -927,9 +916,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>PSP Games</string>
</property>
@ -938,9 +924,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Home</string>
</property>
@ -949,9 +932,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Audio/Video</string>
</property>
@ -960,9 +940,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Game Data</string>
</property>
@ -971,9 +948,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Unknown</string>
</property>
@ -1090,9 +1064,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Other</string>
</property>
@ -1402,6 +1373,14 @@
<string>PS Move</string>
</property>
</action>
<action name="showCatOSAct">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Operating System</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>

View file

@ -108,10 +108,10 @@ public:
{
if (m_is_writing) return;
const u32 offset1 = ::offset32(first) + sizeof(first);
const u32 offset1 = ::offset32(first) + sizeof(T);
const u32 offset2 = ::offset32(second);
AUDIT(offset2 >= offset1);
AUDIT(::offset32(first) <= ::offset32(second));
if (offset2 > offset1)
{
@ -459,10 +459,16 @@ public:
m_file_handler.reset();
}
usz seek_end(usz backwards = 0)
usz seek_end()
{
ensure(data.size() + data_offset >= backwards);
pos = data.size() + data_offset - backwards;
pos = data.size() + data_offset;
return pos;
}
usz trunc(usz count)
{
data.resize(data.size() - count);
seek_end();
return pos;
}

View file

@ -451,23 +451,18 @@ namespace stx
}
}
// Converts to unique (single) ptr if reference is 1, otherwise returns null. Nullifies self.
// Converts to unique (single) ptr if reference is 1. Nullifies self on success.
template <typename U> requires PtrSame<T, U>
explicit operator single_ptr<U>() && noexcept
single_ptr<U> try_convert_to_single_ptr() noexcept
{
const auto o = d();
if (m_ptr && !--o->refs)
if (const auto o = m_ptr ? d() : nullptr; o && o->refs == 1u)
{
// Convert last reference to single_ptr instance.
o->refs.release(1);
single_ptr<T> r;
single_ptr<U> r;
r.m_ptr = static_cast<decltype(r.m_ptr)>(std::exchange(m_ptr, nullptr));
return r;
}
// Otherwise, both pointers are gone. Didn't seem right to do it in the constructor.
m_ptr = nullptr;
return {};
}