Don't abort if starnames.dat has not been loaded

Closes: #625
pull/708/head
Hleb Valoshka 2020-02-28 13:43:39 +03:00
parent 6befc1f5fd
commit fcbf8467be
2 changed files with 18 additions and 12 deletions

View File

@ -446,14 +446,17 @@ string StarDatabase::getStarNameList(const Star& star, const unsigned int maxNam
StarNameDatabase::NumberIndex::const_iterator iter = namesDB->getFirstNameIter(catalogNumber);
unsigned int count = 0;
while (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber && count < maxNames)
if (namesDB != NULL)
{
if (count != 0)
starNames += " / ";
while (iter != namesDB->getFinalNameIter() && iter->first == catalogNumber && count < maxNames)
{
if (count != 0)
starNames += " / ";
starNames += ReplaceGreekLetterAbbr(iter->second.c_str());
++iter;
++count;
starNames += ReplaceGreekLetterAbbr(iter->second.c_str());
++iter;
++count;
}
}
uint32 hip = catalogNumber;

View File

@ -4487,18 +4487,19 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
{
StarDetails::SetStarTextures(cfg.starTextures);
StarNameDatabase* starNameDB = NULL;
ifstream starNamesFile(cfg.starNamesFile.c_str(), ios::in);
if (!starNamesFile.good())
{
cerr << _("Error opening ") << cfg.starNamesFile << '\n';
return false;
}
StarNameDatabase* starNameDB = StarNameDatabase::readNames(starNamesFile);
if (starNameDB == NULL)
else
{
cerr << _("Error reading star names file\n");
return false;
starNameDB = StarNameDatabase::readNames(starNamesFile);
if (starNameDB == NULL)
{
cerr << _("Error reading star names file\n");
}
}
// First load the binary star database file. The majority of stars
@ -4525,6 +4526,8 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
}
}
if (starNameDB == NULL)
starNameDB = new StarNameDatabase();
starDB->setNameDatabase(starNameDB);
loadCrossIndex(starDB, StarDatabase::HenryDraper, cfg.HDCrossIndexFile);