Qt: Swap P1 and other player's save if P1 loaded it first (closes #2750)

This commit is contained in:
Vicki Pfau 2023-03-26 23:58:44 -07:00
parent 2cba34d83a
commit 3c353b572b
2 changed files with 7 additions and 8 deletions

View File

@ -38,6 +38,7 @@ Misc:
- Qt: Include wayland QPA in AppImage (fixes mgba.io/i/2796)
- Qt: Stop eating boolean action key events (fixes mgba.io/i/2636)
- Qt: Automatically change video file extension as appropriate
- Qt: Swap P1 and other player's save if P1 loaded it first (closes mgba.io/i/2750)
- Scripting: Add `callbacks:oneshot` for single-call callbacks
0.10.1: (2023-01-10)

View File

@ -293,13 +293,6 @@ void CoreController::loadConfig(ConfigController* config) {
mCoreConfigCopyValue(&m_threadContext.core->config, config->config(), "mute");
m_preload = config->getOption("preload").toInt();
int playerId = m_multiplayer->playerId(this) + 1;
QVariant savePlayerId = config->getOption("savePlayerId");
if (m_multiplayer->attached() < 2 && savePlayerId.canConvert<int>()) {
playerId = savePlayerId.toInt();
}
mCoreConfigSetOverrideIntValue(&m_threadContext.core->config, "savePlayerId", playerId);
QSize sizeBefore = screenDimensions();
m_activeBuffer.resize(256 * 224 * sizeof(color_t));
m_threadContext.core->setVideoBuffer(m_threadContext.core, reinterpret_cast<color_t*>(m_activeBuffer.data()), sizeBefore.width());
@ -1220,7 +1213,12 @@ void CoreController::updatePlayerSave() {
int savePlayerId = 0;
mCoreConfigGetIntValue(&m_threadContext.core->config, "savePlayerId", &savePlayerId);
if (savePlayerId == 0 || m_multiplayer->attached() > 1) {
savePlayerId = m_multiplayer->playerId(this) + 1;
if (savePlayerId == m_multiplayer->playerId(this) + 1) {
// Player 1 is using our save, so let's use theirs, at least for now.
savePlayerId = 1;
} else {
savePlayerId = m_multiplayer->playerId(this) + 1;
}
}
QString saveSuffix;