TsundereStation/src
LibretroAdmin 6acddfd1d8 core/cheats: remove dead code unreachable from the libretro frontend
This file was forked from Duckstation, which has a full Qt+ImGui
cheat-manager UI (file-format loaders, a memory scanner, a
watch list, type/activation name tables, code groups, master
enable, etc.). swanstation only exposes cheats through the
libretro retro_cheat_set / retro_cheat_reset entry points, and
that flow needs a much smaller surface area than the
Qt-targeted API supplies. The unused code never reaches a
caller in this tree.

Audited the entire src/ directory; the libretro-reachable cheat
API is exactly:

  CheatList()                              ctor   from libretro_host_interface
  ~CheatList()                             dtor   from libretro_host_interface
  CheatList::SetCode(uint32_t, CheatCode)         from libretro_host_interface:981
  CheatList::Apply()                              from system.cpp:1188
  CheatList::ParseLibretroCheat(...)       static from libretro_host_interface:978
  CheatList::ResetSharedScratchRegisters() static from system.cpp
  CheatCode::Apply()                              from CheatList::Apply (internal)
  CheatCode::GetNextNonConditionalInstruction()   from CheatCode::Apply (internal)
  CheatCode::Valid()                              kept (cheap, plausible future use)

Removed from cheats.h:

  CheatCode::Type enum + value Gameshark
  CheatCode::Activation enum + values Manual/EndFrame
  CheatCode fields:  group, comments, type, activation
  CheatCode methods: IsManuallyActivated,
                     GetInstructionsAsString,
                     SetInstructionsFromString,
                     ApplyOnDisable,
                     GetTypeName/GetTypeDisplayName/ParseTypeName,
                     GetActivationName/GetActivationDisplayName/ParseActivationName
  CheatList::Format enum + values Autodetect/PCSXR/Libretro/EPSXe/Count
  CheatList methods: GetCode (both overloads),
                     GetCodeCount, IsCodeEnabled,
                     GetMasterEnable, SetMasterEnable,
                     FindCode (both overloads),
                     AddCode, RemoveCode,
                     GetEnabledCodeCount, GetCodeGroups,
                     EnableCode, DisableCode, SetCodeEnabled,
                     LoadFromPCSXRString,
                     LoadFromLibretroString,
                     LoadFromEPSXeString,
                     ApplyCode,
                     MergeList
  CheatList field:   m_master_enable
  Classes:           MemoryScan (entire class, including
                     Operator enum, Result struct, ResultVector
                     alias, accessors and search/update methods)
                     MemoryWatchList (entire class, including
                     Entry struct, EntryVector alias, accessors,
                     entry mutation, and freeze handling)
  Include:           <optional> (was only needed for
                     ParseTypeName / ParseActivationName
                     return types)

Removed from cheats.cpp:

  static helpers:    IsHexCharacter, SignedCharToInt, FindKey,
                     KeyValuePairVector alias - all three were
                     only used by the format-loader methods above
  CheatList method bodies for everything dropped from cheats.h
  CheatCode method bodies for everything dropped from cheats.h
  m_master_enable check inside Apply() (the field had no
  setter outside the now-dead SetMasterEnable accessor, so
  default-true was the only value it ever held and the
  'if (!m_master_enable) return;' guard was a constant-false
  branch)
  Static arrays:     s_cheat_code_type_names,
                     s_cheat_code_type_display_names,
                     s_cheat_code_activation_names,
                     s_cheat_code_activation_display_names
                     and their TRANSLATABLE wrappers - all four
                     only fed the Get*Name methods that are gone
  MemoryScan and MemoryScan::Result method bodies
  MemoryWatchList method bodies
  Unused includes:   common/byte_stream.h
                     common/string.h
                     common/string_util.h
                     core/host_interface.h
                     <cctype>
                     <iomanip>
                     <sstream>

Behaviour preserved:
  - retro_cheat_set / retro_cheat_reset paths unchanged.
  - System::Shutdown still calls CheatList::ResetSharedScratchRegisters
    via the unique_ptr<CheatList> path; the static cht_register
    array and its fill(0) are unchanged.
  - CheatCode::Apply and GetNextNonConditionalInstruction (the
    GameShark interpreter, ~1200 lines including the giant
    instruction switch) are completely untouched.

Diff:
  src/core/cheats.h:   315 -> 127 lines (-188, -60%)
  src/core/cheats.cpp: 3011 -> 1942 lines (-1069, -35%)
  Total:              -1257 lines

Build: Makefile.libretro platform=unix - clean, no warnings.
swanstation_libretro.so size: 8020336 -> 7965960 bytes
(-54376, roughly the eight removed static name/display-name
tables, the MemoryScan / MemoryWatchList method bodies, the
file-format loaders and their stringstream machinery, and the
inlined dead branches that survive in -O3 builds).
retro_* exports: 25 (unchanged).
2026-05-14 15:42:17 +02:00
..
common common/state_wrapper: include <array> directly 2026-05-14 15:42:13 +02:00
core core/cheats: remove dead code unreachable from the libretro frontend 2026-05-14 15:42:17 +02:00
libretro common/types: use stdint typedefs everywhere instead of custom u32/s32 aliases 2026-05-14 15:13:16 +02:00
CMakeLists.txt only #include <malloc.h> if it exists 2024-07-07 23:17:16 +00:00
config.h.cmake only #include <malloc.h> if it exists 2024-07-07 23:17:16 +00:00