Merge f2392e4048
into 4d0cf1315e
This commit is contained in:
commit
4d6bceb815
|
@ -356,14 +356,13 @@ void GekkoIRPlugin::OnCloseParen(ParenType type)
|
|||
void GekkoIRPlugin::OnLabelDecl(std::string_view name)
|
||||
{
|
||||
const std::string name_str(name);
|
||||
if (m_symset.contains(name_str))
|
||||
if (const bool inserted = m_symset.insert(name_str).second; !inserted)
|
||||
{
|
||||
m_owner->EmitErrorHere(fmt::format("Label/Constant {} is already defined", name));
|
||||
return;
|
||||
}
|
||||
|
||||
m_labels[name_str] = m_active_block->BlockEndAddress();
|
||||
m_symset.insert(name_str);
|
||||
}
|
||||
|
||||
void GekkoIRPlugin::OnNumericLabelDecl(std::string_view, u32 num)
|
||||
|
@ -374,14 +373,13 @@ void GekkoIRPlugin::OnNumericLabelDecl(std::string_view, u32 num)
|
|||
void GekkoIRPlugin::OnVarDecl(std::string_view name)
|
||||
{
|
||||
const std::string name_str(name);
|
||||
if (m_symset.contains(name_str))
|
||||
if (const bool inserted = m_symset.insert(name_str).second; !inserted)
|
||||
{
|
||||
m_owner->EmitErrorHere(fmt::format("Label/Constant {} is already defined", name));
|
||||
return;
|
||||
}
|
||||
|
||||
m_active_var = &m_constants[name_str];
|
||||
m_symset.insert(name_str);
|
||||
}
|
||||
|
||||
void GekkoIRPlugin::PostParseAction()
|
||||
|
|
|
@ -192,8 +192,8 @@ void AchievementManager::LoadGame(const DiscIO::Volume* volume)
|
|||
std::lock_guard lg{m_lock};
|
||||
#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION
|
||||
const auto& names = volume->GetLongNames();
|
||||
if (names.contains(DiscIO::Language::English))
|
||||
m_title_estimate = names.at(DiscIO::Language::English);
|
||||
if (const auto it = names.find(DiscIO::Language::English); it != names.end())
|
||||
m_title_estimate = it->second;
|
||||
else if (!names.empty())
|
||||
m_title_estimate = names.begin()->second;
|
||||
else
|
||||
|
|
|
@ -964,8 +964,9 @@ s32 WiiSockMan::NewSocket(s32 af, s32 type, s32 protocol)
|
|||
|
||||
s32 WiiSockMan::GetHostSocket(s32 wii_fd) const
|
||||
{
|
||||
if (WiiSockets.contains(wii_fd))
|
||||
return WiiSockets.at(wii_fd).fd;
|
||||
auto socket_entry = WiiSockets.find(wii_fd);
|
||||
if (socket_entry != WiiSockets.end())
|
||||
return socket_entry->second.fd;
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
|
|
|
@ -186,9 +186,10 @@ FigureData SkylanderFigure::GetData() const
|
|||
|
||||
auto filter = std::make_pair(figure_data.figure_id, figure_data.variant_id);
|
||||
Type type = Type::Item;
|
||||
if (IOS::HLE::USB::list_skylanders.contains(filter))
|
||||
if (const auto it = IOS::HLE::USB::list_skylanders.find(filter);
|
||||
it != IOS::HLE::USB::list_skylanders.end())
|
||||
{
|
||||
auto found = IOS::HLE::USB::list_skylanders.at(filter);
|
||||
auto found = it->second;
|
||||
type = found.type;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,9 +176,9 @@ std::optional<IPCReply> OH0::RegisterRemovalHook(const u64 device_id, const IOCt
|
|||
{
|
||||
std::lock_guard lock{m_hooks_mutex};
|
||||
// IOS only allows a single device removal hook.
|
||||
if (m_removal_hooks.contains(device_id))
|
||||
const bool inserted = m_removal_hooks.try_emplace(device_id, request.address).second;
|
||||
if (!inserted)
|
||||
return IPCReply(IPC_EEXIST);
|
||||
m_removal_hooks.insert({device_id, request.address});
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,16 +171,20 @@ void USB_HIDv4::OnDeviceChange(ChangeEvent event, std::shared_ptr<USB::Device> d
|
|||
std::lock_guard id_map_lock{m_id_map_mutex};
|
||||
if (event == ChangeEvent::Inserted)
|
||||
{
|
||||
const auto id = device->GetId();
|
||||
s32 new_id = 0;
|
||||
while (m_ios_ids.contains(new_id))
|
||||
while (!m_ios_ids.emplace(new_id, id).second)
|
||||
++new_id;
|
||||
m_ios_ids[new_id] = device->GetId();
|
||||
m_device_ids[device->GetId()] = new_id;
|
||||
|
||||
m_device_ids[id] = new_id;
|
||||
}
|
||||
else if (event == ChangeEvent::Removed && m_device_ids.contains(device->GetId()))
|
||||
else if (event == ChangeEvent::Removed)
|
||||
{
|
||||
m_ios_ids.erase(m_device_ids.at(device->GetId()));
|
||||
m_device_ids.erase(device->GetId());
|
||||
if (const auto it = m_device_ids.find(device->GetId()); it != m_device_ids.end())
|
||||
{
|
||||
m_ios_ids.erase(it->second);
|
||||
m_device_ids.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2392,8 +2392,8 @@ void NetPlayClient::RequestGolfControl()
|
|||
std::string NetPlayClient::GetCurrentGolfer()
|
||||
{
|
||||
std::lock_guard lkp(m_crit.players);
|
||||
if (m_players.contains(m_current_golfer))
|
||||
return m_players[m_current_golfer].name;
|
||||
if (const auto it = m_players.find(m_current_golfer); it != m_players.end())
|
||||
return it->second.name;
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -290,8 +290,8 @@ void NetPlayServer::ThreadFunc()
|
|||
auto& e = m_async_queue.Front();
|
||||
if (e.target_mode == TargetMode::Only)
|
||||
{
|
||||
if (m_players.contains(e.target_pid))
|
||||
Send(m_players.at(e.target_pid).socket, e.packet, e.channel_id);
|
||||
if (const auto it = m_players.find(e.target_pid); it != m_players.end())
|
||||
Send(it->second.socket, e.packet, e.channel_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -794,9 +794,10 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
u32 cid;
|
||||
packet >> cid;
|
||||
|
||||
if (m_chunked_data_complete_count.contains(cid))
|
||||
if (const auto it = m_chunked_data_complete_count.find(cid);
|
||||
it != m_chunked_data_complete_count.end())
|
||||
{
|
||||
m_chunked_data_complete_count[cid]++;
|
||||
it->second++;
|
||||
m_chunked_data_complete_event.Set();
|
||||
}
|
||||
}
|
||||
|
@ -839,8 +840,11 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
|
|||
if (m_host_input_authority)
|
||||
{
|
||||
// Prevent crash before game stop if the golfer disconnects
|
||||
if (m_current_golfer != 0 && m_players.contains(m_current_golfer))
|
||||
Send(m_players.at(m_current_golfer).socket, spac);
|
||||
if (m_current_golfer != 0)
|
||||
{
|
||||
if (const auto it = m_players.find(m_current_golfer); it != m_players.end())
|
||||
Send(it->second.socket, spac);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -40,9 +40,10 @@ const void* ConstantPool::GetConstant(const void* value, size_t element_size, si
|
|||
size_t index)
|
||||
{
|
||||
const size_t value_size = element_size * num_elements;
|
||||
auto iter = m_const_info.find(value);
|
||||
const auto [iter, inserted] = m_const_info.emplace(value, ConstantInfo{});
|
||||
ConstantInfo& info = iter->second;
|
||||
|
||||
if (iter == m_const_info.end())
|
||||
if (inserted)
|
||||
{
|
||||
void* ptr = std::align(ALIGNMENT, value_size, m_current_ptr, m_remaining_size);
|
||||
ASSERT_MSG(DYNA_REC, ptr, "Constant pool has run out of space.");
|
||||
|
@ -51,10 +52,9 @@ const void* ConstantPool::GetConstant(const void* value, size_t element_size, si
|
|||
m_remaining_size -= value_size;
|
||||
|
||||
std::memcpy(ptr, value, value_size);
|
||||
iter = m_const_info.emplace(std::make_pair(value, ConstantInfo{ptr, value_size})).first;
|
||||
info = ConstantInfo{ptr, value_size};
|
||||
}
|
||||
|
||||
const ConstantInfo& info = iter->second;
|
||||
ASSERT_MSG(DYNA_REC, info.m_size == value_size, "Constant has incorrect size in constant pool.");
|
||||
u8* location = static_cast<u8*>(info.m_location);
|
||||
return location + element_size * index;
|
||||
|
|
|
@ -727,12 +727,12 @@ static bool ValidateHeaders(const StateHeader& header)
|
|||
std::string loaded_str = header.version_string;
|
||||
const u32 loaded_version = header.version_header.version_cookie - COOKIE_BASE;
|
||||
|
||||
if (s_old_versions.contains(loaded_version))
|
||||
if (const auto it = s_old_versions.find(loaded_version); it != s_old_versions.end())
|
||||
{
|
||||
// This is a REALLY old version, before we started writing the version string to file
|
||||
success = false;
|
||||
|
||||
std::pair<std::string, std::string> version_range = s_old_versions.find(loaded_version)->second;
|
||||
std::pair<std::string, std::string> version_range = it->second;
|
||||
std::string oldest_version = version_range.first;
|
||||
std::string newest_version = version_range.second;
|
||||
|
||||
|
|
|
@ -251,17 +251,18 @@ static std::unique_ptr<QDirIterator> GetIterator(const QString& dir)
|
|||
void GameTracker::RemoveDirectoryInternal(const QString& dir)
|
||||
{
|
||||
RemovePath(dir);
|
||||
auto it = GetIterator(dir);
|
||||
while (it->hasNext())
|
||||
const auto dir_it = GetIterator(dir);
|
||||
while (dir_it->hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it->next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
QString path = QFileInfo(dir_it->next()).canonicalFilePath();
|
||||
if (const auto it = m_tracked_files.find(path); it != m_tracked_files.end())
|
||||
{
|
||||
m_tracked_files[path].remove(dir);
|
||||
if (m_tracked_files[path].empty())
|
||||
auto& set = *it;
|
||||
set.remove(dir);
|
||||
if (set.isEmpty())
|
||||
{
|
||||
RemovePath(path);
|
||||
m_tracked_files.remove(path);
|
||||
m_tracked_files.erase(it);
|
||||
if (m_started)
|
||||
emit GameRemoved(path.toStdString());
|
||||
}
|
||||
|
@ -271,16 +272,14 @@ void GameTracker::RemoveDirectoryInternal(const QString& dir)
|
|||
|
||||
void GameTracker::UpdateDirectoryInternal(const QString& dir)
|
||||
{
|
||||
auto it = GetIterator(dir);
|
||||
while (it->hasNext() && !m_processing_halted)
|
||||
const auto dir_it = GetIterator(dir);
|
||||
while (dir_it->hasNext() && !m_processing_halted)
|
||||
{
|
||||
QString path = QFileInfo(it->next()).canonicalFilePath();
|
||||
QString path = QFileInfo(dir_it->next()).canonicalFilePath();
|
||||
|
||||
if (m_tracked_files.contains(path))
|
||||
if (const auto it = m_tracked_files.find(path); it != m_tracked_files.end())
|
||||
{
|
||||
auto& tracked_file = m_tracked_files[path];
|
||||
if (!tracked_file.contains(dir))
|
||||
tracked_file.insert(dir);
|
||||
it->insert(dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -339,8 +338,7 @@ QSet<QString> GameTracker::FindMissingFiles(const QString& dir)
|
|||
while (it->hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it->next()).canonicalFilePath();
|
||||
if (m_tracked_files.contains(path))
|
||||
missing_files.remove(path);
|
||||
m_tracked_files.remove(path);
|
||||
}
|
||||
|
||||
return missing_files;
|
||||
|
|
|
@ -656,8 +656,9 @@ void NetPlayDialog::UpdateGUI()
|
|||
|
||||
auto* name_item = new QTableWidgetItem(QString::fromStdString(p->name));
|
||||
name_item->setToolTip(name_item->text());
|
||||
const auto& status_info = player_status.contains(p->game_status) ?
|
||||
player_status.at(p->game_status) :
|
||||
const auto it = player_status.find(p->game_status);
|
||||
const auto& status_info = it != player_status.end() ?
|
||||
it->second :
|
||||
std::make_pair(QStringLiteral("?"), QStringLiteral("?"));
|
||||
auto* status_item = new QTableWidgetItem(status_info.first);
|
||||
status_item->setToolTip(status_info.second);
|
||||
|
|
|
@ -197,14 +197,13 @@ void GraphicsModManager::Load(const GraphicsModGroupConfig& config)
|
|||
{
|
||||
for (const GraphicsTargetGroupConfig& group : mod.m_groups)
|
||||
{
|
||||
if (m_groups.contains(group.m_name))
|
||||
if (const bool inserted = m_groups.insert(group.m_name).second; !inserted)
|
||||
{
|
||||
WARN_LOG_FMT(
|
||||
VIDEO,
|
||||
"Specified graphics mod group '{}' for mod '{}' is already specified by another mod.",
|
||||
group.m_name, mod.m_title);
|
||||
}
|
||||
m_groups.insert(group.m_name);
|
||||
|
||||
const auto internal_group = fmt::format("{}.{}", mod.m_title, group.m_name);
|
||||
for (const GraphicsTargetConfig& target : group.m_targets)
|
||||
|
|
|
@ -1535,26 +1535,21 @@ const AbstractPipeline* ShaderCache::GetTextureReinterpretPipeline(TextureFormat
|
|||
TextureFormat to_format)
|
||||
{
|
||||
const auto key = std::make_pair(from_format, to_format);
|
||||
auto iter = m_texture_reinterpret_pipelines.find(key);
|
||||
if (iter != m_texture_reinterpret_pipelines.end())
|
||||
const auto [iter, inserted] = m_texture_reinterpret_pipelines.emplace(key, nullptr);
|
||||
|
||||
if (!inserted)
|
||||
return iter->second.get();
|
||||
|
||||
std::string shader_source =
|
||||
FramebufferShaderGen::GenerateTextureReinterpretShader(from_format, to_format);
|
||||
if (shader_source.empty())
|
||||
{
|
||||
m_texture_reinterpret_pipelines.emplace(key, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractShader> shader = g_gfx->CreateShaderFromSource(
|
||||
ShaderStage::Pixel, shader_source,
|
||||
fmt::format("Texture reinterpret pixel shader: {} to {}", from_format, to_format));
|
||||
if (!shader)
|
||||
{
|
||||
m_texture_reinterpret_pipelines.emplace(key, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AbstractPipelineConfig config;
|
||||
config.vertex_format = nullptr;
|
||||
|
@ -1566,8 +1561,8 @@ const AbstractPipeline* ShaderCache::GetTextureReinterpretPipeline(TextureFormat
|
|||
config.blending_state = RenderState::GetNoBlendingBlendState();
|
||||
config.framebuffer_state = RenderState::GetRGBA8FramebufferState();
|
||||
config.usage = AbstractPipelineUsage::Utility;
|
||||
auto iiter = m_texture_reinterpret_pipelines.emplace(key, g_gfx->CreatePipeline(config));
|
||||
return iiter.first->second.get();
|
||||
iter->second = g_gfx->CreatePipeline(config);
|
||||
return iter->second.get();
|
||||
}
|
||||
|
||||
const AbstractShader*
|
||||
|
@ -1576,17 +1571,14 @@ ShaderCache::GetTextureDecodingShader(TextureFormat format,
|
|||
{
|
||||
const auto key = std::make_pair(static_cast<u32>(format),
|
||||
static_cast<u32>(palette_format.value_or(TLUTFormat::IA8)));
|
||||
const auto iter = m_texture_decoding_shaders.find(key);
|
||||
if (iter != m_texture_decoding_shaders.end())
|
||||
const auto [iter, inserted] = m_texture_decoding_shaders.emplace(key, nullptr);
|
||||
if (!inserted)
|
||||
return iter->second.get();
|
||||
|
||||
const std::string shader_source =
|
||||
TextureConversionShaderTiled::GenerateDecodingShader(format, palette_format, APIType::OpenGL);
|
||||
if (shader_source.empty())
|
||||
{
|
||||
m_texture_decoding_shaders.emplace(key, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const std::string name =
|
||||
palette_format.has_value() ?
|
||||
|
@ -1596,12 +1588,9 @@ ShaderCache::GetTextureDecodingShader(TextureFormat format,
|
|||
std::unique_ptr<AbstractShader> shader =
|
||||
g_gfx->CreateShaderFromSource(ShaderStage::Compute, shader_source, name);
|
||||
if (!shader)
|
||||
{
|
||||
m_texture_decoding_shaders.emplace(key, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const auto iiter = m_texture_decoding_shaders.emplace(key, std::move(shader));
|
||||
return iiter.first->second.get();
|
||||
iter->second = std::move(shader);
|
||||
return iter->second.get();
|
||||
}
|
||||
} // namespace VideoCommon
|
||||
|
|
|
@ -652,8 +652,8 @@ void TextureCacheBase::DoSaveState(PointerWrap& p)
|
|||
|
||||
auto refpair1 = std::make_pair(*id1, *id2);
|
||||
auto refpair2 = std::make_pair(*id2, *id1);
|
||||
if (!reference_pairs.contains(refpair1) && !reference_pairs.contains(refpair2))
|
||||
reference_pairs.insert(refpair1);
|
||||
if (!reference_pairs.contains(refpair2))
|
||||
reference_pairs.insert(std::move(refpair1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue