From e1901a2f082eb2385335386e3febd82b8dd1e2c6 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 30 Aug 2010 03:34:42 +0000 Subject: [PATCH] win32: dont crash when dragdropping a savestate while no rom is loaded. its tacky. and fix a couple of warnings --- desmume/src/windows/cheatsWin.cpp | 4 ++-- desmume/src/windows/main.cpp | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/desmume/src/windows/cheatsWin.cpp b/desmume/src/windows/cheatsWin.cpp index 69fc0735c..235eab036 100644 --- a/desmume/src/windows/cheatsWin.cpp +++ b/desmume/src/windows/cheatsWin.cpp @@ -1407,7 +1407,7 @@ INT_PTR CALLBACK CheatsExportProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpa lvi.iItem = INT_MAX; SendMessage(exportListView, WM_SETREDRAW, (WPARAM)FALSE,0); - for (int i = 0; i < cheatsExport->getCheatsNum(); i++) + for (u32 i = 0; i < cheatsExport->getCheatsNum(); i++) { CHEATS_LIST *tmp = (CHEATS_LIST*)cheatsExport->getCheats(); lvi.pszText= tmp[i].description; @@ -1428,7 +1428,7 @@ INT_PTR CALLBACK CheatsExportProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpa if (count > 0) { u32 prev = ListView_GetNextItem(exportListView, -1, LVIS_SELECTED); - for (int i = 0; i < count; i++) + for (u32 i = 0; i < count; i++) { CHEATS_LIST *tmp = (CHEATS_LIST*)cheatsExport->getCheats(); cheats->add_AR_Direct(tmp[prev]); diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 9dd07adda..6c5c4d172 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -4380,13 +4380,16 @@ DOKEYDOWN: //------------------------------------------------------- else if (!(fileDropped.find(".ds") == string::npos)) { - size_t extIndex = fileDropped.find(".ds"); - if (extIndex <= fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character + if(romloaded) { - if ((fileDropped[extIndex+3] >= '0' && fileDropped[extIndex+3] <= '9') || fileDropped[extIndex+3] == '-' || fileDropped[extIndex+3] == 't') //If last character is 0-9 (making .ds0 - .ds9) or .dst + size_t extIndex = fileDropped.find(".ds"); + if (extIndex <= fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character { - savestate_load(filename); - UpdateToolWindows(); + if ((fileDropped[extIndex+3] >= '0' && fileDropped[extIndex+3] <= '9') || fileDropped[extIndex+3] == '-' || fileDropped[extIndex+3] == 't') //If last character is 0-9 (making .ds0 - .ds9) or .dst + { + savestate_load(filename); + UpdateToolWindows(); + } } } }