From b3aac821fd57389eff367ea8f7e55ed5a03a2531 Mon Sep 17 00:00:00 2001 From: Lars Persson Date: Sat, 9 Jul 2005 23:07:46 +0000 Subject: 1. Fixed divide by zero defect (exception on my symbian target, Windows just return max val) 2. Fixed so Saga compiles for VC6. 3. Added GCC_PACK & pragma pack to gfx.h svn-id: r18527 --- saga/actor.cpp | 4 ++-- saga/events.cpp | 11 ++++++++++- saga/gfx.h | 9 +++++---- saga/ite_introproc.cpp | 4 ++-- saga/list.h | 19 ++++++++++--------- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/saga/actor.cpp b/saga/actor.cpp index e7ddb291b1..d8394c505d 100644 --- a/saga/actor.cpp +++ b/saga/actor.cpp @@ -279,8 +279,8 @@ Actor::Actor(SagaEngine *vm) : _vm(vm) { } } else { - // TODO. - static ActorData dummyActor; + // TODO. This is causing problems for SYMBIAN os as it does n't like a static class here + ActorData dummyActor; dummyActor.frames = NULL; dummyActor.walkStepsPoints = NULL; diff --git a/saga/events.cpp b/saga/events.cpp index 0ac071bb5d..5bc603751d 100644 --- a/saga/events.cpp +++ b/saga/events.cpp @@ -127,8 +127,11 @@ int Events::handleContinuous(EVENT *event) { Surface *backGroundSurface; BGInfo bgInfo; Rect rect; - + if(event->duration != 0) { event_pc = ((double)event->duration - event->time) / event->duration; + } else { + event_pc = 1.0; + } if (event_pc >= 1.0) { // Cap percentage to 100 @@ -205,7 +208,13 @@ int Events::handleImmediate(EVENT *event) { double event_pc = 0.0; // Event completion percentage bool event_done = false; + // Duration might be 0 so dont do division then + if(event->duration != 0) { event_pc = ((double)event->duration - event->time) / event->duration; + } else { + // Just make sure that event_pc is 1.0 so event_done is true + event_pc = 1.0; + } if (event_pc >= 1.0) { // Cap percentage to 100 diff --git a/saga/gfx.h b/saga/gfx.h index 8e6a94c1c1..3be73e8471 100644 --- a/saga/gfx.h +++ b/saga/gfx.h @@ -32,6 +32,7 @@ namespace Saga { using Common::Point; using Common::Rect; +#pragma START_PACK_STRUCTS struct ClipData { // input members @@ -70,20 +71,20 @@ struct ClipData { return true; } -}; +}GCC_PACK; struct PalEntry { byte red; byte green; byte blue; -}; +}GCC_PACK; struct Color { int red; int green; int blue; int alpha; -}; +}GCC_PACK; struct Surface : Graphics::Surface { @@ -110,7 +111,7 @@ struct Surface : Graphics::Surface { } } }; - +#pragma END_PACK_STRUCTS #define PAL_ENTRIES 256 diff --git a/saga/ite_introproc.cpp b/saga/ite_introproc.cpp index 322a88e4a5..7f3b0cd3ba 100644 --- a/saga/ite_introproc.cpp +++ b/saga/ite_introproc.cpp @@ -292,8 +292,7 @@ int Scene::ITEIntroAnimProc(int param) { EVENT *q_event; switch (param) { - case SCENE_BEGIN: - + case SCENE_BEGIN:{ // Background for intro scene is the first frame of the // intro animation; display it and set the palette event.type = ONESHOT_EVENT; @@ -352,6 +351,7 @@ int Scene::ITEIntroAnimProc(int param) { event.time = 0; q_event = _vm->_events->chain(q_event, &event); + } break; case SCENE_END: break; diff --git a/saga/list.h b/saga/list.h index 17106bdfcd..03cc7e5cd4 100644 --- a/saga/list.h +++ b/saga/list.h @@ -33,7 +33,8 @@ public: typedef typename Common::List::iterator iterator; typedef typename Common::List::const_iterator const_iterator; - + typedef typename Common::List Common_List; + public: iterator pushFront(const T& element) { @@ -41,20 +42,20 @@ public: } iterator pushBack(const T& element) { - return insert(Common::List::end(), element); + return insert(Common_List::end(), element); } iterator insert(iterator pos, const T& element) { - Common::List::insert(pos, element); + Common_List::insert(pos, element); return --pos; } iterator pushFront() { - return insert(Common::List::begin()); + return insert(Common_List::begin()); } iterator pushBack() { - return insert(Common::List::end()); + return insert(Common_List::end()); } iterator insert(iterator pos) { @@ -67,13 +68,13 @@ public: } iterator pushBack(const T& element, CompareFunction compareFunction) { - return insert(Common::List::end(), element, compareFunction); + return insert(Common_List::end(), element, compareFunction); } iterator insert(iterator pos, const T& element, CompareFunction compareFunction) { int res; - for (iterator i = Common::List::begin(); i != Common::List::end(); ++i) { + for (iterator i = Common_List::begin(); i != Common_List::end(); ++i) { res = compareFunction(element, i.operator*()); if (res < 0) { return insert(i, element); @@ -120,7 +121,7 @@ public: } iterator eraseAndPrev(iterator pos) { - assert(pos != Common::List::end()); + assert(pos != Common_List::end()); iterator res(pos); --res; @@ -129,7 +130,7 @@ public: } void remove(const T* val) { - for (iterator i = Common::List::begin(); i != Common::List::end(); ++i) + for (iterator i = Common_List::begin(); i != Common_List::end(); ++i) if (val == i.operator->()) { erase(i); return; -- cgit v1.2.3