Only set the class and race IDs if they contain a non-empty string.

This commit is contained in:
Jan Borsodi 2010-10-22 23:18:57 +02:00
parent 6d71094f3b
commit 1f7659cb12

View file

@ -527,7 +527,9 @@ void WindowManager::onRaceDialogDone()
{ {
if (raceDialog) if (raceDialog)
{ {
environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); const std::string &raceId = raceDialog->getRaceId();
if (!raceId.empty())
environment.mMechanicsManager->setPlayerRace(raceId, raceDialog->getGender() == RaceDialog::GM_Male);
raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void(); raceDialog->eventDone = MWGui::RaceDialog::EventHandle_Void();
raceDialog->setVisible(false); raceDialog->setVisible(false);
garbageDialogs.push_back(raceDialog); garbageDialogs.push_back(raceDialog);
@ -551,7 +553,9 @@ void WindowManager::onRaceDialogBack()
{ {
if (raceDialog) if (raceDialog)
{ {
environment.mMechanicsManager->setPlayerRace(raceDialog->getRaceId(), raceDialog->getGender() == RaceDialog::GM_Male); const std::string &raceId = raceDialog->getRaceId();
if (!raceId.empty())
environment.mMechanicsManager->setPlayerRace(raceId, raceDialog->getGender() == RaceDialog::GM_Male);
raceDialog->setVisible(false); raceDialog->setVisible(false);
garbageDialogs.push_back(raceDialog); garbageDialogs.push_back(raceDialog);
raceDialog = nullptr; raceDialog = nullptr;
@ -715,7 +719,9 @@ void WindowManager::onPickClassDialogDone()
{ {
if (pickClassDialog) if (pickClassDialog)
{ {
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId()); const std::string &classId = pickClassDialog->getClassId();
if (!classId.empty())
environment.mMechanicsManager->setPlayerClass(classId);
pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void(); pickClassDialog->eventDone = MWGui::PickClassDialog::EventHandle_Void();
pickClassDialog->setVisible(false); pickClassDialog->setVisible(false);
garbageDialogs.push_back(pickClassDialog); garbageDialogs.push_back(pickClassDialog);
@ -739,7 +745,9 @@ void WindowManager::onPickClassDialogBack()
{ {
if (pickClassDialog) if (pickClassDialog)
{ {
environment.mMechanicsManager->setPlayerClass(pickClassDialog->getClassId()); const std::string classId = pickClassDialog->getClassId();
if (!classId.empty())
environment.mMechanicsManager->setPlayerClass(classId);
pickClassDialog->setVisible(false); pickClassDialog->setVisible(false);
garbageDialogs.push_back(pickClassDialog); garbageDialogs.push_back(pickClassDialog);
pickClassDialog = nullptr; pickClassDialog = nullptr;