Merge pull request #416 from lioncash/cheats
Cheat Class: Replace is_valid_hex_digit
This commit is contained in:
commit
170dac9a1e
|
@ -15,21 +15,6 @@
|
||||||
enum { WM_EDITCHEAT = WM_USER + 0x120 };
|
enum { WM_EDITCHEAT = WM_USER + 0x120 };
|
||||||
enum { UM_CHANGECODEEXTENSION = WM_USER + 0x121 };
|
enum { UM_CHANGECODEEXTENSION = WM_USER + 0x121 };
|
||||||
|
|
||||||
static int is_valid_hex_digit(char symbol)
|
|
||||||
{
|
|
||||||
if (symbol < '0')
|
|
||||||
return 0; /* no valid hex figures before '0' */
|
|
||||||
if (symbol <= '9')
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
symbol &= ~('X' ^ 'x'); /* in ASCII, forces lowercase to uppercase */
|
|
||||||
if (symbol < 'A')
|
|
||||||
return 0;
|
|
||||||
if (symbol <= 'F')
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
CCheats::CCheats (const CN64Rom * Rom ) :
|
CCheats::CCheats (const CN64Rom * Rom ) :
|
||||||
m_Rom(Rom),
|
m_Rom(Rom),
|
||||||
m_rcList(new RECT),
|
m_rcList(new RECT),
|
||||||
|
@ -1786,7 +1771,7 @@ stdstr CCheats::ReadCodeString (HWND hDlg, bool &validcodes, bool &validoptions,
|
||||||
if (len <= 0) { continue; }
|
if (len <= 0) { continue; }
|
||||||
|
|
||||||
for (i=0; i<128; i++) {
|
for (i=0; i<128; i++) {
|
||||||
if (is_valid_hex_digit(str[i])) {
|
if (isxdigit(str[i])) {
|
||||||
tempformat[i] = 'X';
|
tempformat[i] = 'X';
|
||||||
}
|
}
|
||||||
if ((str[i] == ' ') || (str[i] == '?')) {
|
if ((str[i] == ' ') || (str[i] == '?')) {
|
||||||
|
@ -1860,7 +1845,7 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop
|
||||||
case 1: //option = lower byte
|
case 1: //option = lower byte
|
||||||
if (len >= 2) {
|
if (len >= 2) {
|
||||||
for (i=0; i<2; i++) {
|
for (i=0; i<2; i++) {
|
||||||
if (!is_valid_hex_digit(str[i])) {
|
if (!isxdigit(str[i])) {
|
||||||
validoptions = false;
|
validoptions = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1893,7 +1878,7 @@ stdstr CCheats::ReadOptionsString(HWND hDlg, bool &/*validcodes*/, bool &validop
|
||||||
case 2: //option = word
|
case 2: //option = word
|
||||||
if (len >= 4) {
|
if (len >= 4) {
|
||||||
for (i=0; i<4; i++) {
|
for (i=0; i<4; i++) {
|
||||||
if (!is_valid_hex_digit(str[i])) {
|
if (!isxdigit(str[i])) {
|
||||||
validoptions = false;
|
validoptions = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue