moved cheat code hex value verification to a central function
This commit is contained in:
parent
240d13366d
commit
ec9afe9c33
|
@ -15,6 +15,8 @@
|
|||
enum { WM_EDITCHEAT = WM_USER + 0x120 };
|
||||
enum { UM_CHANGECODEEXTENSION = WM_USER + 0x121 };
|
||||
|
||||
extern int is_valid_hex_digit(char symbol);
|
||||
|
||||
CCheats::CCheats (const CN64Rom * Rom ) :
|
||||
m_Rom(Rom),
|
||||
m_rcList(new RECT),
|
||||
|
@ -1845,7 +1847,7 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop
|
|||
case 1: //option = lower byte
|
||||
if (len >= 2) {
|
||||
for (i=0; i<2; i++) {
|
||||
if (!(((str[i] >= 'a') && (str[i] <= 'f')) || ((str[i] >= 'A') && (str[i] <= 'F')) || ((str[i] >= '0') && (str[i] <= '9')))) {
|
||||
if (!is_valid_hex_digit(str[i])) {
|
||||
validoptions = false;
|
||||
break;
|
||||
}
|
||||
|
@ -1878,7 +1880,7 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop
|
|||
case 2: //option = word
|
||||
if (len >= 4) {
|
||||
for (i=0; i<4; i++) {
|
||||
if (!(((str[i] >= 'a') && (str[i] <= 'f')) || ((str[i] >= 'A') && (str[i] <= 'F')) || ((str[i] >= '0') && (str[i] <= '9')))) {
|
||||
if (!is_valid_hex_digit(str[i])) {
|
||||
validoptions = false;
|
||||
break;
|
||||
}
|
||||
|
@ -1913,5 +1915,13 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop
|
|||
return optionsstring;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int is_valid_hex_digit(char symbol)
|
||||
{
|
||||
if (
|
||||
((symbol >= 'a') && (symbol <= 'f'))
|
||||
|| ((symbol >= 'A') && (symbol <= 'F'))
|
||||
|| ((symbol >= '0') && (symbol <= '9'))
|
||||
)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue