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
This commit is contained in:
Lars Persson 2005-07-09 23:07:46 +00:00
parent 02d28a96ce
commit b3aac821fd
5 changed files with 29 additions and 18 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -33,7 +33,8 @@ public:
typedef typename Common::List<T>::iterator iterator;
typedef typename Common::List<T>::const_iterator const_iterator;
typedef typename Common::List<T> Common_List;
public:
iterator pushFront(const T& element) {
@ -41,20 +42,20 @@ public:
}
iterator pushBack(const T& element) {
return insert(Common::List<T>::end(), element);
return insert(Common_List::end(), element);
}
iterator insert(iterator pos, const T& element) {
Common::List<T>::insert(pos, element);
Common_List::insert(pos, element);
return --pos;
}
iterator pushFront() {
return insert(Common::List<T>::begin());
return insert(Common_List::begin());
}
iterator pushBack() {
return insert(Common::List<T>::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<T>::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<T>::begin(); i != Common::List<T>::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<T>::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<T>::begin(); i != Common::List<T>::end(); ++i)
for (iterator i = Common_List::begin(); i != Common_List::end(); ++i)
if (val == i.operator->()) {
erase(i);
return;