From 5de239e3c631943c37f3de959116e9749efa6098 Mon Sep 17 00:00:00 2001 From: Retro-Junk Date: Tue, 27 Sep 2016 23:37:33 +0300 Subject: FULLPIPE: Revert to original bubble sort algorithm for scene objects --- engines/fullpipe/scene.cpp | 30 ++++++++++++++++++++++++++++++ engines/fullpipe/scene.h | 5 +++++ 2 files changed, 35 insertions(+) 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 &list, bool Common::sort(list.begin(), list.end(), Scene::compareObjPriority); } } +#else +template +void Scene::objectList_sortByPriority(Common::Array &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 &list, bool skipFirst = false); void objectList_sortByPriority(Common::Array &list, bool skipFirst = false); +#else + template + void objectList_sortByPriority(Common::Array &list, int startIndex = 0); +#endif }; class SceneTag : public CObject { -- cgit v1.2.3