win32: dont crash when dragdropping a savestate while no rom is loaded. its tacky. and fix a couple of warnings

This commit is contained in:
zeromus 2010-08-30 03:34:42 +00:00
parent d617c0141b
commit e1901a2f08
2 changed files with 10 additions and 7 deletions

View File

@ -1407,7 +1407,7 @@ INT_PTR CALLBACK CheatsExportProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpa
lvi.iItem = INT_MAX; lvi.iItem = INT_MAX;
SendMessage(exportListView, WM_SETREDRAW, (WPARAM)FALSE,0); 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(); CHEATS_LIST *tmp = (CHEATS_LIST*)cheatsExport->getCheats();
lvi.pszText= tmp[i].description; lvi.pszText= tmp[i].description;
@ -1428,7 +1428,7 @@ INT_PTR CALLBACK CheatsExportProc(HWND dialog, UINT msg,WPARAM wparam,LPARAM lpa
if (count > 0) if (count > 0)
{ {
u32 prev = ListView_GetNextItem(exportListView, -1, LVIS_SELECTED); 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_LIST *tmp = (CHEATS_LIST*)cheatsExport->getCheats();
cheats->add_AR_Direct(tmp[prev]); cheats->add_AR_Direct(tmp[prev]);

View File

@ -4380,13 +4380,16 @@ DOKEYDOWN:
//------------------------------------------------------- //-------------------------------------------------------
else if (!(fileDropped.find(".ds") == string::npos)) else if (!(fileDropped.find(".ds") == string::npos))
{ {
size_t extIndex = fileDropped.find(".ds"); if(romloaded)
if (extIndex <= fileDropped.length()-4) //Check to see it is both at the end (file extension) and there is on more character
{ {
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); 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
UpdateToolWindows(); {
savestate_load(filename);
UpdateToolWindows();
}
} }
} }
} }