mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 11:05:42 -04:00
Pad: Fix crash with mismatched cards in save state
This commit is contained in:
parent
872a9b95c7
commit
9bf805c2af
@ -71,25 +71,20 @@ bool Pad::DoStateController(StateWrapper& sw, u32 i)
|
||||
g_host_interface->TranslateString(
|
||||
"OSDMessage", "Save state contains controller type %s in port %u, but %s is used. Switching."),
|
||||
Settings::GetControllerTypeName(state_controller_type), i + 1u,
|
||||
Settings::GetControllerTypeName(controller_type)
|
||||
);
|
||||
Settings::GetControllerTypeName(controller_type));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
10.0f,
|
||||
g_host_interface->TranslateString("OSDMessage", "Ignoring mismatched controller type %s in port %u."),
|
||||
Settings::GetControllerTypeName(state_controller_type), i + 1u
|
||||
);
|
||||
10.0f, g_host_interface->TranslateString("OSDMessage", "Ignoring mismatched controller type %s in port %u."),
|
||||
Settings::GetControllerTypeName(state_controller_type), i + 1u);
|
||||
}
|
||||
|
||||
// dev-friendly untranslated console log.
|
||||
Log_DevPrintf("Controller type mismatch in slot %u: state=%s(%u) ui=%s(%u) load_from_state=%s",
|
||||
i + 1u,
|
||||
Log_DevPrintf("Controller type mismatch in slot %u: state=%s(%u) ui=%s(%u) load_from_state=%s", i + 1u,
|
||||
Settings::GetControllerTypeName(state_controller_type), state_controller_type,
|
||||
Settings::GetControllerTypeName(controller_type), controller_type,
|
||||
g_settings.load_devices_from_save_states ? "yes" : "no"
|
||||
);
|
||||
g_settings.load_devices_from_save_states ? "yes" : "no");
|
||||
|
||||
if (g_settings.load_devices_from_save_states)
|
||||
{
|
||||
@ -132,6 +127,16 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i)
|
||||
|
||||
sw.Do(&card_present_in_state);
|
||||
|
||||
if (card_present_in_state && !m_memory_cards[i] && g_settings.load_devices_from_save_states)
|
||||
{
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
20.0f,
|
||||
g_host_interface->TranslateString(
|
||||
"OSDMessage", "Memory card %u present in save state but not in system. Creating temporary card."),
|
||||
i + 1u);
|
||||
m_memory_cards[i] = MemoryCard::Create();
|
||||
}
|
||||
|
||||
MemoryCard* card_ptr = m_memory_cards[i].get();
|
||||
std::unique_ptr<MemoryCard> card_from_state;
|
||||
|
||||
@ -169,8 +174,7 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i)
|
||||
20.0f,
|
||||
g_host_interface->TranslateString(
|
||||
"OSDMessage", "Memory card %u from save state does match current card data. Simulating replugging."),
|
||||
i + 1u
|
||||
);
|
||||
i + 1u);
|
||||
|
||||
// this is a potentially serious issue - some games cache info from memcards and jumping around
|
||||
// with savestates can lead to card corruption on the next save attempts (and may not be obvious
|
||||
@ -186,33 +190,21 @@ bool Pad::DoStateMemcard(StateWrapper& sw, u32 i)
|
||||
{
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
20.0f,
|
||||
g_host_interface->TranslateString(
|
||||
"OSDMessage", "Memory card %u present in save state but not in system. Ignoring card."),
|
||||
i + 1u
|
||||
);
|
||||
g_host_interface->TranslateString("OSDMessage",
|
||||
"Memory card %u present in save state but not in system. Ignoring card."),
|
||||
i + 1u);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (card_present_in_state && !m_memory_cards[i])
|
||||
if (!card_present_in_state && m_memory_cards[i])
|
||||
{
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
20.0f,
|
||||
g_host_interface->TranslateString(
|
||||
"OSDMessage", "Memory card %u present in save state but not in system. Creating temporary card."),
|
||||
i + 1u
|
||||
);
|
||||
m_memory_cards[i] = MemoryCard::Create();
|
||||
}
|
||||
else if (!card_present_in_state && m_memory_cards[i])
|
||||
{
|
||||
g_host_interface->AddFormattedOSDMessage(
|
||||
20.0f,
|
||||
g_host_interface->TranslateString(
|
||||
"OSDMessage", "Memory card %u present in system but not in save state. Removing card."),
|
||||
i + 1u
|
||||
);
|
||||
g_host_interface->TranslateString("OSDMessage",
|
||||
"Memory card %u present in system but not in save state. Removing card."),
|
||||
i + 1u);
|
||||
m_memory_cards[i].reset();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user