Skip to content

Commit e5d26ce

Browse files
committed
Fix using ldraw zip without LDraw dir
1 parent 1718bae commit e5d26ce

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

LDLoader/LDLMainModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool LDLMainModel::load(const char *filename)
8787
{
8888
LDrawIniComputeRealDirs(sm_lDrawIni, 1, 0, filename);
8989
}
90-
if (!strlen(lDrawDir()))
90+
if (strlen(lDrawDir()) == 0 && LDLModel::sm_ldrawZipPath.empty())
9191
{
9292
ldrawDirNotFound();
9393
return false;

LDLoader/LDLModel.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -888,29 +888,36 @@ bool LDLModel::initializeNewSubModel(
888888
// NOTE: static function.
889889
bool LDLModel::verifyLDrawDir(const char *value)
890890
{
891-
char currentDir[1024];
892-
bool retValue = false;
893-
894-
if (value && getcwd(currentDir, sizeof(currentDir)))
891+
if (strlen(value) > 0)
895892
{
896-
if (chdir(value) == 0)
893+
char currentDir[1024];
894+
bool retValue = false;
895+
896+
if (value && getcwd(currentDir, sizeof(currentDir)))
897897
{
898-
if (!sm_verifyLDrawSubDirs || (chdir("parts") == 0 && chdir("..") == 0 && chdir("p") == 0))
898+
if (chdir(value) == 0)
899899
{
900-
retValue = true;
900+
if (!sm_verifyLDrawSubDirs || (chdir("parts") == 0 && chdir("..") == 0 && chdir("p") == 0))
901+
{
902+
retValue = true;
903+
}
901904
}
902-
}
903-
if (chdir(currentDir) != 0)
904-
{
905-
debugPrintf("Error going back to original directory.\n");
906-
debugPrintf("currentDir before: <%s>\n", currentDir);
907-
if (getcwd(currentDir, sizeof(currentDir)) != NULL)
905+
if (chdir(currentDir) != 0)
908906
{
909-
debugPrintf("currentDir after: <%s>\n", currentDir);
907+
debugPrintf("Error going back to original directory.\n");
908+
debugPrintf("currentDir before: <%s>\n", currentDir);
909+
if (getcwd(currentDir, sizeof(currentDir)) != NULL)
910+
{
911+
debugPrintf("currentDir after: <%s>\n", currentDir);
912+
}
910913
}
911914
}
915+
return retValue;
916+
}
917+
else
918+
{
919+
return checkLDrawZipPath(sm_ldrawZipPath.c_str());
912920
}
913-
return retValue;
914921
}
915922

916923
// NOTE: static function.

0 commit comments

Comments
 (0)