diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 5db654622..35f48a87f 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -513,6 +513,21 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum, if(myConsole->cartridge().isPlusROM() && settings().getString("plusroms.id") == EmptyString) { + // Make sure there always is an id + if(settings().getString("plusroms.id") == EmptyString) + { + const int ID_LEN = 32 - 2; // WE prefix added later + const char* HEX_DIGITS = "0123456789ABCDEF"; + char id_chr[ID_LEN] = {0}; + + srand(time(NULL)); + for(int i = 0; i < ID_LEN; i++) + id_chr[i] = HEX_DIGITS[(rand() % 16)]; + + std::string id_str(id_chr, ID_LEN); + settings().setValue("plusroms.id", id_str); + } + myEventHandler->changeStateByEvent(Event::PlusRomsSetupMode); } } diff --git a/src/gui/PlusRomsSetupDialog.cxx b/src/gui/PlusRomsSetupDialog.cxx index 561cd4907..54f061a1b 100644 --- a/src/gui/PlusRomsSetupDialog.cxx +++ b/src/gui/PlusRomsSetupDialog.cxx @@ -21,7 +21,6 @@ #include "PlusRomsSetupDialog.hxx" static const int MAX_NICK_LEN = 16; -static const int ID_LEN = 32 - 2; // WE prefix added later // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& parent, @@ -40,20 +39,6 @@ PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& pare void PlusRomsSetupDialog::loadConfig() { setText(instance().settings().getString("plusroms.nick")); - - // Make sure there always is an id - if(instance().settings().getString("plusroms.id") == EmptyString) - { - const char* HEX_DIGITS = "0123456789ABCDEF"; - char id_chr[ID_LEN]; - - srand(time(nullptr)); - for(int i = 0; i < ID_LEN; i++) - id_chr[i] = HEX_DIGITS[(rand() % 16)]; - - std::string id_str(id_chr, ID_LEN); - instance().settings().setValue("plusroms.id", id_str); - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -