diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp index bf922a26586..676edb021cf 100644 --- a/engines/groovie/script.cpp +++ b/engines/groovie/script.cpp @@ -331,11 +331,23 @@ void Script::loadgame(uint slot) { } void Script::savegame(uint slot) { + char save[15]; + char newchar; Common::String filename = ConfMan.getActiveDomainName() + ".00" + ('0' + slot); Common::OutSaveFile *file = _vm->_system->getSavefileManager()->openForSaving(filename.c_str()); // Saving the variables. It is endian safe because they're byte variables file->write(_variables, 0x400); + for (int i = 0; i < 15; i++) { + newchar = _variables[i] + 0x30; + if ((newchar < 0x30 || newchar > 0x39) && (newchar < 0x41 || newchar > 0x7A)) { + save[i] = '\0'; + break; + } else { + save[i] = newchar; + } + } + _saveNames[slot] = save; delete file; } @@ -1166,37 +1178,20 @@ void Script::o_hotspot_slot() { if (hotspot(rect, address, cursor)) { char savename[15]; - Common::String filename = ConfMan.getActiveDomainName() + ".00" + ('0' + slot); - Common::StringList files = _vm->_system->getSavefileManager()->listSavefiles(filename.c_str()); - if (!files.empty()) { - Common::InSaveFile *file = _vm->_system->getSavefileManager()->openForLoading(filename.c_str()); - if (file) { - uint8 i; - char temp; - - for (i = 0; i < 15; i++) { - file->read(&temp, 1); - savename[i] = temp + 0x30; - } - - delete file; - } else { - strcpy(savename, "ERROR"); - } - } else { - strcpy(savename, "E M P T Y"); + if (_hotspotSlot == slot) { + return; } // Load the font if required if (!_font) { _font = new Font(_vm->_system); } + strcpy(savename, _saveNames[slot].c_str()); _font->printstring(savename); // Save the currently highlighted slot _hotspotSlot = slot; } else { - Common::Point mousepos = _vm->_system->getEventManager()->getMousePos(); if (_hotspotSlot == slot) { Common::Rect topbar(640, 80); @@ -1239,6 +1234,31 @@ void Script::o_checkvalidsaves() { it++; } + for (int slots = 0; slots < 10; slots++) { + char savename[15]; + Common::String filename = ConfMan.getActiveDomainName() + ".00" + ('0' + slots); + Common::StringList files = _vm->_system->getSavefileManager()->listSavefiles(filename.c_str()); + if (!files.empty()) { + Common::InSaveFile *file = _vm->_system->getSavefileManager()->openForLoading(filename.c_str()); + if (file) { + uint8 i; + char temp; + + for (i = 0; i < 15; i++) { + file->read(&temp, 1); + savename[i] = temp + 0x30; + } + + delete file; + } else { + strcpy(savename, "ERROR"); + } + } else { + strcpy(savename, "E M P T Y"); + } + _saveNames[slots] = savename; + } + // Save the number of valid saves setVariable(0x104, count); debugScript(1, true, " Found %d valid savegames", count); diff --git a/engines/groovie/script.h b/engines/groovie/script.h index 682638afec3..ee4933a828f 100644 --- a/engines/groovie/script.h +++ b/engines/groovie/script.h @@ -66,6 +66,9 @@ private: Common::String _scriptFile; Common::String _savedScriptFile; + // Save names + Common::String _saveNames[10]; + // Code byte *_code; uint16 _currentInstruction;