mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 03:22:30 +02:00
InputCommon: improve code that returns a controller attachment index
casting a value to a u32 when it's originally an int, and it's exposed as int to users, could end up in cases where a negative number would result as a positive one. This doesn't really affect the value range of the attachment enum, still I think the code was wrong. Heavily tested.
This commit is contained in:
parent
d43a06ff6a
commit
a19a0096db
@ -17,10 +17,11 @@ void Attachments::AddAttachment(std::unique_ptr<EmulatedController> att)
|
|||||||
|
|
||||||
u32 Attachments::GetSelectedAttachment() const
|
u32 Attachments::GetSelectedAttachment() const
|
||||||
{
|
{
|
||||||
const u32 value = m_selection_value.GetValue();
|
// This is originally an int, treat it as such
|
||||||
|
const int value = m_selection_value.GetValue();
|
||||||
|
|
||||||
if (value < m_attachments.size())
|
if (value > 0 && static_cast<size_t>(value) < m_attachments.size())
|
||||||
return value;
|
return u32(value);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user