mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 13:50:03 +00:00 
			
		
		
		
	Add cheats in per game configuration (#6379)
This commit is contained in:
		
							parent
							
								
									ea649263b7
								
							
						
					
					
						commit
						7327c334ca
					
				
					 13 changed files with 86 additions and 122 deletions
				
			
		|  | @ -19,9 +19,12 @@ namespace Cheats { | |||
| // we use the same value
 | ||||
| constexpr u64 run_interval_ticks = 50'000'000; | ||||
| 
 | ||||
| CheatEngine::CheatEngine(Core::System& system_) : system(system_) { | ||||
| CheatEngine::CheatEngine(u64 title_id_, Core::System& system_) | ||||
|     : system(system_), title_id{title_id_} { | ||||
|     LoadCheatFile(); | ||||
|     Connect(); | ||||
|     if (system.IsPoweredOn()) { | ||||
|         Connect(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CheatEngine::Connect() { | ||||
|  | @ -32,7 +35,9 @@ void CheatEngine::Connect() { | |||
| } | ||||
| 
 | ||||
| CheatEngine::~CheatEngine() { | ||||
|     system.CoreTiming().UnscheduleEvent(event, 0); | ||||
|     if (system.IsPoweredOn()) { | ||||
|         system.CoreTiming().UnscheduleEvent(event, 0); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| std::vector<std::shared_ptr<CheatBase>> CheatEngine::GetCheats() const { | ||||
|  | @ -65,8 +70,7 @@ void CheatEngine::UpdateCheat(std::size_t index, const std::shared_ptr<CheatBase | |||
| 
 | ||||
| void CheatEngine::SaveCheatFile() const { | ||||
|     const std::string cheat_dir = FileUtil::GetUserPath(FileUtil::UserPath::CheatsDir); | ||||
|     const std::string filepath = fmt::format( | ||||
|         "{}{:016X}.txt", cheat_dir, system.Kernel().GetCurrentProcess()->codeset->program_id); | ||||
|     const std::string filepath = fmt::format("{}{:016X}.txt", cheat_dir, title_id); | ||||
| 
 | ||||
|     if (!FileUtil::IsDirectory(cheat_dir)) { | ||||
|         FileUtil::CreateDir(cheat_dir); | ||||
|  | @ -81,8 +85,7 @@ void CheatEngine::SaveCheatFile() const { | |||
| 
 | ||||
| void CheatEngine::LoadCheatFile() { | ||||
|     const std::string cheat_dir = FileUtil::GetUserPath(FileUtil::UserPath::CheatsDir); | ||||
|     const std::string filepath = fmt::format( | ||||
|         "{}{:016X}.txt", cheat_dir, system.Kernel().GetCurrentProcess()->codeset->program_id); | ||||
|     const std::string filepath = fmt::format("{}{:016X}.txt", cheat_dir, title_id); | ||||
| 
 | ||||
|     if (!FileUtil::IsDirectory(cheat_dir)) { | ||||
|         FileUtil::CreateDir(cheat_dir); | ||||
|  |  | |||
|  | @ -24,7 +24,7 @@ class CheatBase; | |||
| 
 | ||||
| class CheatEngine { | ||||
| public: | ||||
|     explicit CheatEngine(Core::System& system); | ||||
|     explicit CheatEngine(u64 title_id_, Core::System& system); | ||||
|     ~CheatEngine(); | ||||
|     void Connect(); | ||||
|     std::vector<std::shared_ptr<CheatBase>> GetCheats() const; | ||||
|  | @ -40,5 +40,6 @@ private: | |||
|     mutable std::shared_mutex cheats_list_mutex; | ||||
|     Core::TimingEventType* event; | ||||
|     Core::System& system; | ||||
|     u64 title_id; | ||||
| }; | ||||
| } // namespace Cheats
 | ||||
|  |  | |||
|  | @ -312,12 +312,12 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st | |||
|         } | ||||
|     } | ||||
|     kernel->SetCurrentProcess(process); | ||||
|     cheat_engine = std::make_unique<Cheats::CheatEngine>(*this); | ||||
|     title_id = 0; | ||||
|     if (app_loader->ReadProgramId(title_id) != Loader::ResultStatus::Success) { | ||||
|         LOG_ERROR(Core, "Failed to find title id for ROM (Error {})", | ||||
|                   static_cast<u32>(load_result)); | ||||
|     } | ||||
|     cheat_engine = std::make_unique<Cheats::CheatEngine>(title_id, *this); | ||||
|     perf_stats = std::make_unique<PerfStats>(title_id); | ||||
| 
 | ||||
|     if (Settings::values.custom_textures) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue