mirror of https://github.com/stella-emu/stella.git
moved PlusROM id generation outside GUI code
This commit is contained in:
parent
ff4bb3cd77
commit
7c2721ef2e
|
@ -513,6 +513,21 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
|
||||||
if(myConsole->cartridge().isPlusROM() &&
|
if(myConsole->cartridge().isPlusROM() &&
|
||||||
settings().getString("plusroms.id") == EmptyString)
|
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);
|
myEventHandler->changeStateByEvent(Event::PlusRomsSetupMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "PlusRomsSetupDialog.hxx"
|
#include "PlusRomsSetupDialog.hxx"
|
||||||
|
|
||||||
static const int MAX_NICK_LEN = 16;
|
static const int MAX_NICK_LEN = 16;
|
||||||
static const int ID_LEN = 32 - 2; // WE prefix added later
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& parent,
|
PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& parent,
|
||||||
|
@ -40,20 +39,6 @@ PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& pare
|
||||||
void PlusRomsSetupDialog::loadConfig()
|
void PlusRomsSetupDialog::loadConfig()
|
||||||
{
|
{
|
||||||
setText(instance().settings().getString("plusroms.nick"));
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
Loading…
Reference in New Issue