From 728745767294ecc3abf7fcb730370ff8951999ed Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Sat, 11 Apr 2009 09:54:55 +0000 Subject: Got rid of SortedList svn-id: r39928 --- engines/saga/actor.cpp | 19 +++++++++++++--- engines/saga/actor.h | 6 ++--- engines/saga/events.h | 1 - engines/saga/font.h | 1 - engines/saga/list.h | 59 -------------------------------------------------- engines/saga/saga.h | 1 - engines/saga/scene.h | 1 - engines/saga/script.h | 1 - 8 files changed, 19 insertions(+), 70 deletions(-) delete mode 100644 engines/saga/list.h (limited to 'engines') diff --git a/engines/saga/actor.cpp b/engines/saga/actor.cpp index 17834aec35..feef8595b9 100644 --- a/engines/saga/actor.cpp +++ b/engines/saga/actor.cpp @@ -960,11 +960,24 @@ uint16 Actor::hitTest(const Point &testPoint, bool skipProtagonist) { return result; // in IHNM, return the last result found (read above) } +void Actor::drawOrderListAdd(const CommonObjectDataPointer& element, CompareFunction compareFunction) { + int res; + + for (CommonObjectOrderList::iterator i = _drawOrderList.begin(); i !=_drawOrderList.end(); ++i) { + res = compareFunction(element, *i); + if (res < 0) { + _drawOrderList.insert(i, element); + return; + } + } + _drawOrderList.push_back(element); +} + void Actor::createDrawOrderList() { int i; ActorData *actor; ObjectData *obj; - CommonObjectOrderList::CompareFunction compareFunction = 0; + CompareFunction compareFunction = 0; if (_vm->_scene->getFlags() & kSceneFlagISO) { compareFunction = &tileCommonObjectCompare; @@ -985,7 +998,7 @@ void Actor::createDrawOrderList() { continue; if (calcScreenPosition(actor)) { - _drawOrderList.insert(actor, compareFunction); + drawOrderListAdd(actor, compareFunction); } } @@ -1005,7 +1018,7 @@ void Actor::createDrawOrderList() { continue; if (calcScreenPosition(obj)) { - _drawOrderList.insert(obj, compareFunction); + drawOrderListAdd(obj, compareFunction); } } } diff --git a/engines/saga/actor.h b/engines/saga/actor.h index cae8dd8355..a46de5d292 100644 --- a/engines/saga/actor.h +++ b/engines/saga/actor.h @@ -32,7 +32,6 @@ #include "saga/sprite.h" #include "saga/itedata.h" -#include "saga/list.h" #include "saga/saga.h" #include "saga/font.h" @@ -328,7 +327,7 @@ public: typedef CommonObjectData *CommonObjectDataPointer; -typedef SortedList CommonObjectOrderList; +typedef Common::List CommonObjectOrderList; class ObjectData: public CommonObjectData { public: @@ -558,7 +557,7 @@ struct SpeechData { } }; - +typedef int (*CompareFunction) (const CommonObjectDataPointer& a, const CommonObjectDataPointer& b); class Actor { friend class IsoMap; @@ -662,6 +661,7 @@ private: void stepZoneAction(ActorData *actor, const HitZone *hitZone, bool exit, bool stopped); void loadActorSpriteList(ActorData *actor); + void drawOrderListAdd(const CommonObjectDataPointer& element, CompareFunction compareFunction); void createDrawOrderList(); bool calcScreenPosition(CommonObjectData *commonObjectData); bool getSpriteParams(CommonObjectData *commonObjectData, int &frameNumber, SpriteList *&spriteList); diff --git a/engines/saga/events.h b/engines/saga/events.h index 299e707195..512e28bbf5 100644 --- a/engines/saga/events.h +++ b/engines/saga/events.h @@ -28,7 +28,6 @@ #ifndef SAGA_EVENT_H #define SAGA_EVENT_H -#include "saga/list.h" namespace Saga { diff --git a/engines/saga/font.h b/engines/saga/font.h index 37ff56ea2d..0064c22afc 100644 --- a/engines/saga/font.h +++ b/engines/saga/font.h @@ -28,7 +28,6 @@ #ifndef SAGA_FONT_H #define SAGA_FONT_H -#include "saga/list.h" #include "saga/gfx.h" namespace Saga { diff --git a/engines/saga/list.h b/engines/saga/list.h deleted file mode 100644 index 66aaf69ec2..0000000000 --- a/engines/saga/list.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -// List functions - -#ifndef SAGA_LIST_H -#define SAGA_LIST_H - -#include "common/list.h" - -namespace Saga { - -template -class SortedList : public Common::List { -public: - typedef typename Common::List::iterator iterator; - typedef typename Common::List::const_iterator const_iterator; - typedef int (*CompareFunction) (const T& a, const T& b); - - iterator insert(const T& element, CompareFunction compareFunction) { - int res; - - for (typename Common::List::iterator i = Common::List::begin(); i != Common::List::end(); ++i) { - res = compareFunction(element, *i); - if (res < 0) { - Common::List::insert(i, element); - return --i; - } - } - Common::List::push_back(element); - return --Common::List::end(); - } -}; - -} // End of namespace Saga - -#endif diff --git a/engines/saga/saga.h b/engines/saga/saga.h index 97215b8228..d62b147f3d 100644 --- a/engines/saga/saga.h +++ b/engines/saga/saga.h @@ -32,7 +32,6 @@ #include "sound/mididrv.h" #include "saga/gfx.h" -#include "saga/list.h" struct ADGameFileDescription; diff --git a/engines/saga/scene.h b/engines/saga/scene.h index 90be245437..9e90e60b7d 100644 --- a/engines/saga/scene.h +++ b/engines/saga/scene.h @@ -29,7 +29,6 @@ #define SAGA_SCENE_H #include "saga/font.h" -#include "saga/list.h" #include "saga/actor.h" #include "saga/interface.h" #include "saga/puzzle.h" diff --git a/engines/saga/script.h b/engines/saga/script.h index 423e4d0ee7..d252518729 100644 --- a/engines/saga/script.h +++ b/engines/saga/script.h @@ -31,7 +31,6 @@ #include "common/endian.h" #include "saga/font.h" -#include "saga/list.h" namespace Saga { -- cgit v1.2.3