mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-10 18:18:49 +00:00
PatchEngine: Make PatchType an enum class
Makes the enum strongly typed. A function for retrieving the string representation of the enum is also added, which allows hiding the array that contains all of the strings from view (i.e. we operate on the API, not the exposed internals). This also allows us to bounds check any querying for the strings.
This commit is contained in:
parent
a166cf2481
commit
0995cfef6a
6 changed files with 53 additions and 40 deletions
|
@ -13,20 +13,18 @@ class IniFile;
|
|||
|
||||
namespace PatchEngine
|
||||
{
|
||||
enum PatchType
|
||||
enum class PatchType
|
||||
{
|
||||
PATCH_8BIT,
|
||||
PATCH_16BIT,
|
||||
PATCH_32BIT,
|
||||
Patch8Bit,
|
||||
Patch16Bit,
|
||||
Patch32Bit,
|
||||
};
|
||||
|
||||
extern const char* PatchTypeStrings[];
|
||||
|
||||
struct PatchEntry
|
||||
{
|
||||
PatchEntry() = default;
|
||||
PatchEntry(PatchType t, u32 addr, u32 value_) : type(t), address(addr), value(value_) {}
|
||||
PatchType type = PatchType::PATCH_8BIT;
|
||||
PatchType type = PatchType::Patch8Bit;
|
||||
u32 address = 0;
|
||||
u32 value = 0;
|
||||
};
|
||||
|
@ -39,6 +37,8 @@ struct Patch
|
|||
bool user_defined = false; // False if this code is shipped with Dolphin.
|
||||
};
|
||||
|
||||
const char* PatchTypeAsString(PatchType type);
|
||||
|
||||
int GetSpeedhackCycles(const u32 addr);
|
||||
void LoadPatchSection(const std::string& section, std::vector<Patch>& patches, IniFile& globalIni,
|
||||
IniFile& localIni);
|
||||
|
@ -52,15 +52,15 @@ inline int GetPatchTypeCharLength(PatchType type)
|
|||
int size = 8;
|
||||
switch (type)
|
||||
{
|
||||
case PatchEngine::PATCH_8BIT:
|
||||
case PatchType::Patch8Bit:
|
||||
size = 2;
|
||||
break;
|
||||
|
||||
case PatchEngine::PATCH_16BIT:
|
||||
case PatchType::Patch16Bit:
|
||||
size = 4;
|
||||
break;
|
||||
|
||||
case PatchEngine::PATCH_32BIT:
|
||||
case PatchType::Patch32Bit:
|
||||
size = 8;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue