diff options
-rw-r--r-- | engines/fullpipe/scene.cpp | 30 | ||||
-rw-r--r-- | engines/fullpipe/scene.h | 5 |
2 files changed, 35 insertions, 0 deletions
diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index cba688a123..b03540a5ee 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -469,6 +469,7 @@ void Scene::initObjectCursors(const char *varname) { } } +#if 0 bool Scene::compareObjPriority(const void *p1, const void *p2) { if (((const GameObject *)p1)->_priority > ((const GameObject *)p2)->_priority) return true; @@ -503,6 +504,31 @@ void Scene::objectList_sortByPriority(Common::Array<PictureObject *> &list, bool Common::sort(list.begin(), list.end(), Scene::compareObjPriority); } } +#else +template<typename T> +void Scene::objectList_sortByPriority(Common::Array<T *> &list, int startIndex) { + if (list.size() > startIndex) { + int lastIndex = list.size() - 1; + int count = lastIndex - startIndex; + bool changed; + do { + changed = false; + T *refElement = list[startIndex]; + for (int i = startIndex; i < lastIndex; i++) { + T *curElement = list[i + 1]; + if (curElement->_priority > refElement->_priority) { + // Push refElement down the list + list.remove_at(i); + list.insert_at(i + 1, refElement); + changed = true; + } else + refElement = curElement; + } + count--; + } while (changed); + } +} +#endif void Scene::draw() { debugC(6, kDebugDrawing, ">>>>> Scene::draw()"); @@ -669,9 +695,13 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { debugC(1, kDebugDrawing, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); +#if 0 if (_picObjList.size() > 2) { // We need to z-sort them objectList_sortByPriority(_picObjList, true); } +#else + objectList_sortByPriority(_picObjList, 1); +#endif if (minPri == -1 && _picObjList.size()) minPri = ((PictureObject *)_picObjList.back())->_priority - 1; diff --git a/engines/fullpipe/scene.h b/engines/fullpipe/scene.h index 1e2dae81fe..5ff24074b2 100644 --- a/engines/fullpipe/scene.h +++ b/engines/fullpipe/scene.h @@ -81,9 +81,14 @@ class Scene : public Background { void stopAllSounds(); private: +#if 0 static bool compareObjPriority(const void *p1, const void *p2); void objectList_sortByPriority(Common::Array<StaticANIObject *> &list, bool skipFirst = false); void objectList_sortByPriority(Common::Array<PictureObject *> &list, bool skipFirst = false); +#else + template<typename T> + void objectList_sortByPriority(Common::Array<T*> &list, int startIndex = 0); +#endif }; class SceneTag : public CObject { |