summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorleo2003-01-09 05:35:37 +0000
committerleo2003-01-09 05:35:37 +0000
commit900f32a6882b0ba81d03e404ad6a9fb41a40639b (patch)
treec30cafdcf8e25cba999b2f68ac563a08ac13cc51 /common
parentb8688ce70f27788865a1cbb2b3047fe1c340af2f (diff)
Fixed crash loading files in computers with different decimal points.
git-svn-id: http://svn.leocad.org/trunk@332 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common')
-rw-r--r--common/project.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/common/project.cpp b/common/project.cpp
index ec1f35b..2e339db 100644
--- a/common/project.cpp
+++ b/common/project.cpp
@@ -6,6 +6,7 @@
#include <string.h>
#include <float.h>
#include <math.h>
+#include <locale.h>
#include "opengl.h"
#include "vector.h"
#include "matrix.h"
@@ -631,15 +632,27 @@ bool Project::FileLoad(File* file, bool bUndo, bool bMerge)
file->Seek(0, SEEK_SET);
file->Read(id, 32);
sscanf(&id[7], "%f", &fv);
+
+ // Fix the ugly floating point reading on computers with different decimal points.
+ if (fv == 0.0f)
+ {
+ lconv *loc = localeconv();
+ id[8] = loc->decimal_point[0];
+ sscanf(&id[7], "%f", &fv);
+
+ if (fv == 0.0f)
+ return false;
+ }
+
if (fv > 0.4f)
- file->ReadFloat (&fv, 1);
+ file->ReadFloat (&fv, 1);
file->ReadLong (&rgb, 1);
if (!bMerge)
{
- m_fBackground[0] = (float)((unsigned char) (rgb))/255;
- m_fBackground[1] = (float)((unsigned char) (((unsigned short) (rgb)) >> 8))/255;
- m_fBackground[2] = (float)((unsigned char) ((rgb) >> 16))/255;
+ m_fBackground[0] = (float)((unsigned char) (rgb))/255;
+ m_fBackground[1] = (float)((unsigned char) (((unsigned short) (rgb)) >> 8))/255;
+ m_fBackground[2] = (float)((unsigned char) ((rgb) >> 16))/255;
}
if (fv < 0.6f) // old view