Index: source/simulation2/helpers/Grid.h =================================================================== --- source/simulation2/helpers/Grid.h +++ source/simulation2/helpers/Grid.h @@ -26,6 +26,9 @@ #define GRID_BOUNDS_DEBUG 1 #endif +// The default array initialization is broken on VS2013 +#define VS2013_workaround 1 + /** * Basic 2D array, intended for storing tile data, plus support for lazy updates * by ICmpObstructionManager. @@ -189,9 +192,14 @@ { size_t b = (j >> BucketBits) * m_BW + (i >> BucketBits); if (!m_Data[b]) +#if VS2013_workaround { - m_Data[b] = new T[BucketSize*BucketSize](); + m_Data[b] = new T[BucketSize*BucketSize]; + memset(m_Data[b], 0, BucketSize*BucketSize*sizeof(T)); } +#else + m_Data[b] = new T[BucketSize*BucketSize](); +#endif return m_Data[b]; } @@ -203,7 +211,12 @@ m_BW = (u16)((m_W + BucketSize-1) >> BucketBits); m_BH = (u16)((m_H + BucketSize-1) >> BucketBits); +#if VS2013_workaround + m_Data = new T*[m_BW*m_BH]; + memset(m_Data, 0, m_BW*m_BH*sizeof(T*)); +#else m_Data = new T*[m_BW*m_BH](); +#endif } ~SparseGrid() @@ -217,8 +230,12 @@ for (size_t i = 0; i < (size_t)(m_BW*m_BH); ++i) delete[] m_Data[i]; +#if VS2013_workaround + memset(m_Data, 0, m_BW*m_BH*sizeof(T*)); +#else // Reset m_Data by value-constructing in place with placement new. m_Data = new (m_Data) T*[m_BW*m_BH](); +#endif } void set(int i, int j, const T& value) @@ -287,4 +304,6 @@ } }; +#undef VS2013_workaround + #endif // INCLUDED_GRID