From e7466ba956c97d48d5c5880692fbf3624807a32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Tue, 19 Feb 2013 19:48:38 +0000 Subject: [PATCH] easymesh : EasyMeshData crashfix --- src/easymesh/easymesh.cpp | 1 + src/easymesh/easymesh.h | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/easymesh/easymesh.cpp b/src/easymesh/easymesh.cpp index 4ee5bf8c..ed577850 100644 --- a/src/easymesh/easymesh.cpp +++ b/src/easymesh/easymesh.cpp @@ -373,6 +373,7 @@ bool EasyMesh::Compile(char const *command) EasyMeshCompiler mc(*this); bool res = mc.ParseString(command); delete(m_build_data); + m_build_data = NULL; return res; } diff --git a/src/easymesh/easymesh.h b/src/easymesh/easymesh.h index 460fe8d4..73277507 100644 --- a/src/easymesh/easymesh.h +++ b/src/easymesh/easymesh.h @@ -167,7 +167,8 @@ struct TexCoordBuildType ExpandedStarDefault = 0, CogDefault = 0, - Max + //NEVER FORGET TO INCREMENT THIS WHEN ADDING A VALUE + Max = 1 } m_value; @@ -189,7 +190,8 @@ struct MeshFaceType BoxBottom = 5, QuadDefault = 0, - Max + //NEVER FORGET TO INCREMENT THIS WHEN ADDING A VALUE + Max = 6 } m_value; @@ -242,7 +244,7 @@ public: void SetTexCoordBuildType(MeshType mt, TexCoordBuildType tcbt) { m_texcoord_build_type[mt] = (1 << (tcbt + 1)) | (m_texcoord_build_type[mt] & 1); } TexCoordBuildType GetTexCoordBuildType(MeshType mt) { - int flag = ((m_texcoord_build_type[mt] & ~(1)) >> 1); + uint32_t flag = (uint32_t)((m_texcoord_build_type[mt] & ~(1)) >> 1); int i = 0; while (flag >>= 1) i++; @@ -329,7 +331,7 @@ public: void SetTexCoordBuildType2(MeshType mt, TexCoordBuildType tcbt) { m_texcoord_build_type2[mt] = (1 << (tcbt + 1)) | (m_texcoord_build_type2[mt] & 1); } TexCoordBuildType GetTexCoordBuildType2(MeshType mt) { - int flag = ((m_texcoord_build_type2[mt] & ~(1)) >> 1); + uint32_t flag = ((m_texcoord_build_type2[mt] & ~(1)) >> 1); int i = 0; while (flag >>= 1) i++; @@ -423,11 +425,11 @@ public: vec2 m_texcoord_offset2; vec2 m_texcoord_scale; vec2 m_texcoord_scale2; - int m_texcoord_build_type[MeshType::Max]; Array m_texcoord_custom_build[MeshType::Max]; - int m_texcoord_build_type2[MeshType::Max]; Array m_texcoord_custom_build2[MeshType::Max]; - uint16_t m_build_flags; + uint32_t m_texcoord_build_type[MeshType::Max]; + uint32_t m_texcoord_build_type2[MeshType::Max]; + uint32_t m_build_flags; }; /* A safe enum for MeshCSG operations. */