From 0b6c04c04b519413f9d55752bc345be54bad405c Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 8 Dec 2009 07:50:58 +0000 Subject: [PATCH] win32: fix the most egregious cheats bugs for large cheat values --- desmume/src/NDSSystem.cpp | 6 +++++- desmume/src/windows/cheatsWin.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index e59535295..e2d62a373 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -744,13 +744,17 @@ int NDS_LoadROM(const char *filename, const char *logicalFilename) loadrom(path.path); } else if ( !strcasecmp(path.extension().c_str(), "nds")) { + type = ROM_NDS; loadrom(path.path); //n.b. this does nothing if the file can't be found (i.e. if it was an extracted tempfile)... //...but since the data was extracted to gameInfo then it is ok - type = ROM_NDS; } //ds.gba in archives, it's already been loaded into memory at this point else if (path.isdsgba(std::string(logicalFilename))) { type = ROM_DSGBA; + } else { + //well, try to load it as an nds rom anyway + type = ROM_NDS; + loadrom(path.path); } if(type == ROM_DSGBA) diff --git a/desmume/src/windows/cheatsWin.cpp b/desmume/src/windows/cheatsWin.cpp index e61878569..ef8a5a535 100644 --- a/desmume/src/windows/cheatsWin.cpp +++ b/desmume/src/windows/cheatsWin.cpp @@ -195,7 +195,7 @@ INT_PTR CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam memset(editBuf, 0, sizeof(editBuf)); GetWindowText(GetDlgItem(dialog, IDC_EDIT1), editBuf[0], 10); - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 10); + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 11); CheckDlgButton(dialog, IDC_CHECK1, BST_CHECKED); CheckDlgButton(dialog, searchSizeIDDs[searchAddSize], BST_CHECKED); @@ -217,7 +217,7 @@ INT_PTR CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam { oldEditProc = saveOldEditProc; searchAddAddress = tmp_addr; - searchAddValue = atol(editBuf[1]); + searchAddValue = strtoul(editBuf[1],NULL,10); EndDialog(dialog, TRUE); } @@ -258,14 +258,14 @@ INT_PTR CALLBACK CheatsAddProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam { if (HIWORD(wparam) == EN_UPDATE) { - GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 10); + GetWindowText(GetDlgItem(dialog, IDC_EDIT2), editBuf[1], 11); if ( (strlen(editBuf[0]) < 6) || (!strlen(editBuf[1])) ) { EnableWindow(GetDlgItem(dialog, IDOK), FALSE); return TRUE; } - u32 val = atol(editBuf[1]); + u32 val = strtoul(editBuf[1],NULL,10); if (val > searchRange[searchAddSize][1]) { EnableWindow(GetDlgItem(dialog, IDOK), FALSE);