Skip to content

Manic EMU is an all-in-one retro game emulator for iOS. It packs powerful features while keeping a clean, sleek UI and delivering buttery-smooth gameplay.

Swift

fix(cheat): use '+' separator for libretro cheats and fix auto-detect logic

Kazuhiro Nakamurabed437b439dc
diff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
index ef1e67dd..a3d67c44 100644
--- a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
@@ -332,8 +332,6 @@ class AddCheatCodeView: BaseView {
}
if isMatchThisFormat {
return (formatString, cheatFormat)
- } else {
- return nil
}
}
}
diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift
index ad7e0c6e..b836f42b 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift
@@ -2228,13 +2228,15 @@ extension PlayViewController {
LibretroCore.sharedInstance().resetCheatCode()
for (index, cheatCode) in self.manicGame.gameCheats.enumerated() {
if cheatCode.activate {
+ // Convert newline separators to '+' (libretro standard for multi-line cheats)
+ let coreCode: String
if CheatType(cheatCode.type) == .actionReplay16, self.manicGame.isPicodriveCore, cheatCode.code.count > 6 {
//MD不支持0123456789格式的作弊码,需要转换成012345:6789格式
- let processedCode = cheatCode.code[...5] + ":" + cheatCode.code[6...]
- LibretroCore.sharedInstance().addCheatCode(String(processedCode), index: UInt32(index), enable: true)
+ coreCode = cheatCode.code[...5] + ":" + cheatCode.code[6...]
} else {
- LibretroCore.sharedInstance().addCheatCode(cheatCode.code, index: UInt32(index), enable: true)
+ coreCode = cheatCode.code.replacingOccurrences(of: "\n", with: "+")
}
+ LibretroCore.sharedInstance().addCheatCode(String(coreCode), index: UInt32(index), enable: true)
}
}
}