summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorleo2004-05-05 16:50:38 +0000
committerleo2004-05-05 16:50:38 +0000
commitb6f4b5a61c74e319ebd627f14fb4fe0b56284b2b (patch)
tree7f18bddac7b72a5256947d0dda04de834f4562ea /common
parent28ccb1197b0a527ef1d44b68e631923b0d3ba9b9 (diff)
Fixed crash reloading pieces stored as shorts but expanded to longs when loaded.
git-svn-id: http://svn.leocad.org/trunk@357 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common')
-rw-r--r--common/pieceinf.cpp22
-rw-r--r--common/pieceinf.h11
2 files changed, 22 insertions, 11 deletions
diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp
index ed4d347..90652db 100644
--- a/common/pieceinf.cpp
+++ b/common/pieceinf.cpp
@@ -493,12 +493,17 @@ void PieceInfo::LoadInformation()
bytes++; // should be 0
}
- m_fVertexArray = (float*)malloc(3*sizeof(float)*verts);
- m_nVertexCount = verts;
- if ((verts > 65535) || (quads > 65535) || (fixquads > 65535))
- m_nFlags |= LC_PIECE_LONGDATA;
- else
- m_nFlags &= ~LC_PIECE_LONGDATA;
+ m_fVertexArray = (float*)malloc(3*sizeof(float)*verts);
+ m_nVertexCount = verts;
+ if ((verts > 65535) || (quads > 65535) || (fixquads > 65535))
+ {
+ if ((m_nFlags & LC_PIECE_LONGDATA) == 0)
+ {
+ m_nFlags |= LC_PIECE_LONGDATA | LC_PIECE_LONGDATA_RUNTIME;
+ }
+ }
+ else
+ m_nFlags &= ~(LC_PIECE_LONGDATA | LC_PIECE_LONGDATA_RUNTIME);
// Copy the 'fixed' vertexes
shorts = (lcint16*)(longs + 1);
@@ -1527,6 +1532,11 @@ void PieceInfo::FreeInformation()
free(m_pTextures);
m_pTextures = NULL;
}
+
+ if (m_nFlags & LC_PIECE_LONGDATA_RUNTIME)
+ {
+ m_nFlags &= ~(LC_PIECE_LONGDATA | LC_PIECE_LONGDATA_RUNTIME);
+ }
}
// Zoom extents for the preview window & print catalog
diff --git a/common/pieceinf.h b/common/pieceinf.h
index 3a06fea..008b1fa 100644
--- a/common/pieceinf.h
+++ b/common/pieceinf.h
@@ -10,11 +10,12 @@
#include "opengl.h"
#endif
-#define LC_PIECE_COUNT 0x01 // Count this piece in the totals ?
-#define LC_PIECE_LONGDATA 0x02 // unsigned long/short index
-#define LC_PIECE_CCW 0x04 // Use back-face culling
-#define LC_PIECE_SMALL 0x10 // scale = 10000
-#define LC_PIECE_MEDIUM 0x20 // scale = 1000 (otherwise = 100)
+#define LC_PIECE_COUNT 0x01 // Count this piece in the totals ?
+#define LC_PIECE_LONGDATA 0x02 // unsigned long/short index
+#define LC_PIECE_CCW 0x04 // Use back-face culling
+#define LC_PIECE_SMALL 0x10 // scale = 10000
+#define LC_PIECE_MEDIUM 0x20 // scale = 1000 (otherwise = 100)
+#define LC_PIECE_LONGDATA_RUNTIME 0x40 // If the original data is 16 bits but we expanded to 32 bits
class File;
class Texture;