diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2013-01-17 18:48:09 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:48:54 +0300 |
commit | 30909a0d8f974441e765475dee2af2a295345faa (patch) | |
tree | 9fa148d5518bd1c9f6f352181263d557d8e9924b /geometry | |
parent | b14b56ec5a23dc0125bbf578816a9daa2041b27f (diff) |
fixed crash with overwriting Resource in m_resources map with the same ID(happens when two different parent resources use same cacheKey).
Diffstat (limited to 'geometry')
-rw-r--r-- | geometry/packer.cpp | 13 | ||||
-rw-r--r-- | geometry/packer.hpp | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/geometry/packer.cpp b/geometry/packer.cpp index 6eb77fed84..eddf799128 100644 --- a/geometry/packer.cpp +++ b/geometry/packer.cpp @@ -75,6 +75,19 @@ namespace m2 return curHandle; } + Packer::handle_t Packer::freeHandle() + { + if (m_currentHandle == m_maxHandle) + { + callOverflowFns(); + reset(); + m_currentHandle = 0; + } + + handle_t res = m_currentHandle++; + return res; + } + bool Packer::hasRoom(unsigned width, unsigned height) const { return ((m_width >= width) && (m_height - m_currentY - m_yStep >= height)) diff --git a/geometry/packer.hpp b/geometry/packer.hpp index c3879e3060..85526e142e 100644 --- a/geometry/packer.hpp +++ b/geometry/packer.hpp @@ -74,6 +74,9 @@ namespace m2 /// the simplest one will just clear the whole rect and start the packing process again). handle_t pack(unsigned width, unsigned height); + /// return free handle + handle_t freeHandle(); + /// Does we have room to pack another rectangle? bool hasRoom(unsigned width, unsigned height) const; |