diff options
author | Torbjörn Andersson | 2005-11-13 19:29:32 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-11-13 19:29:32 +0000 |
commit | 267fc7e2f652feaf6168d65ccf2916e09fe12edb (patch) | |
tree | d21682b10737fa5969374c7c59418b9502243000 /sword2 | |
parent | c4ad2ecb49e4b11a2f71b96b32d6ae17036e4d68 (diff) | |
download | scummvm-rg350-267fc7e2f652feaf6168d65ccf2916e09fe12edb.tar.gz scummvm-rg350-267fc7e2f652feaf6168d65ccf2916e09fe12edb.tar.bz2 scummvm-rg350-267fc7e2f652feaf6168d65ccf2916e09fe12edb.zip |
Cleanup
svn-id: r19587
Diffstat (limited to 'sword2')
-rw-r--r-- | sword2/events.cpp | 12 | ||||
-rw-r--r-- | sword2/function.cpp | 14 | ||||
-rw-r--r-- | sword2/logic.h | 7 | ||||
-rw-r--r-- | sword2/sync.cpp | 20 |
4 files changed, 28 insertions, 25 deletions
diff --git a/sword2/events.cpp b/sword2/events.cpp index 289c60b5cc..49b6222438 100644 --- a/sword2/events.cpp +++ b/sword2/events.cpp @@ -26,7 +26,7 @@ namespace Sword2 { void Logic::sendEvent(uint32 id, uint32 interact_id) { - for (int i = 0; i < MAX_events; i++) { + for (int i = 0; i < ARRAYSIZE(_eventList); i++) { if (_eventList[i].id == id || !_eventList[i].id) { _eventList[i].id = id; _eventList[i].interact_id = interact_id; @@ -43,7 +43,7 @@ void Logic::setPlayerActionEvent(uint32 id, uint32 interact_id) { } int Logic::checkEventWaiting() { - for (int i = 0; i < MAX_events; i++) { + for (int i = 0; i < ARRAYSIZE(_eventList); i++) { if (_eventList[i].id == readVar(ID)) return 1; } @@ -55,7 +55,7 @@ void Logic::startEvent() { // call this from stuff like fnWalk // you must follow with a return IR_TERMINATE - for (int i = 0; i < MAX_events; i++) { + for (int i = 0; i < ARRAYSIZE(_eventList); i++) { if (_eventList[i].id == readVar(ID)) { logicOne(_eventList[i].interact_id); _eventList[i].id = 0; @@ -67,7 +67,7 @@ void Logic::startEvent() { } void Logic::clearEvent(uint32 id) { - for (int i = 0; i < MAX_events; i++) { + for (int i = 0; i < ARRAYSIZE(_eventList); i++) { if (_eventList[i].id == id) { _eventList[i].id = 0; return; @@ -76,7 +76,7 @@ void Logic::clearEvent(uint32 id) { } void Logic::killAllIdsEvents(uint32 id) { - for (int i = 0; i < MAX_events; i++) { + for (int i = 0; i < ARRAYSIZE(_eventList); i++) { if (_eventList[i].id == id) _eventList[i].id = 0; } @@ -87,7 +87,7 @@ void Logic::killAllIdsEvents(uint32 id) { uint32 Logic::countEvents() { uint32 count = 0; - for (int i = 0; i < MAX_events; i++) { + for (int i = 0; i < ARRAYSIZE(_eventList); i++) { if (_eventList[i].id) count++; } diff --git a/sword2/function.cpp b/sword2/function.cpp index 9f015f3bac..98e7a1fe05 100644 --- a/sword2/function.cpp +++ b/sword2/function.cpp @@ -444,19 +444,7 @@ int32 Logic::fnSendSync(int32 *params) { // params: 0 sync's recipient // 1 sync value - for (int i = 0; i < MAX_syncs; i++) { - if (_syncList[i].id == 0) { - debug(5, "%d sends sync %d to %d", readVar(ID), params[1], params[0]); - _syncList[i].id = params[0]; - _syncList[i].sync = params[1]; - return IR_CONT; - } - } - - // The original code didn't even check for this condition, so maybe - // it should be a fatal error? - - warning("No free sync slot"); + sendSync(params[0], params[1]); return IR_CONT; } diff --git a/sword2/logic.h b/sword2/logic.h index f41932b188..108192f015 100644 --- a/sword2/logic.h +++ b/sword2/logic.h @@ -31,9 +31,6 @@ struct MovieTextObject; #define MAX_events 10 -// There won't be many, will there? Probably 2 at most i reckon -#define MAX_syncs 10 - #define TREE_SIZE 3 // This must allow for the largest number of objects in a screen @@ -170,9 +167,11 @@ public: uint32 sync; }; - SyncUnit _syncList[MAX_syncs]; + // There won't be many, will there? Probably 2 at most i reckon + SyncUnit _syncList[10]; void clearSyncs(uint32 id); + void sendSync(uint32 id, uint32 sync); int getSync(); Router *_router; diff --git a/sword2/sync.cpp b/sword2/sync.cpp index 256ecf5097..35055860e1 100644 --- a/sword2/sync.cpp +++ b/sword2/sync.cpp @@ -32,7 +32,7 @@ namespace Sword2 { */ void Logic::clearSyncs(uint32 id) { - for (int i = 0; i < MAX_syncs; i++) { + for (int i = 0; i < ARRAYSIZE(_syncList); i++) { if (_syncList[i].id == id) { debug(5, "removing sync %d for %d", i, id); _syncList[i].id = 0; @@ -40,6 +40,22 @@ void Logic::clearSyncs(uint32 id) { } } +void Logic::sendSync(uint32 id, uint32 sync) { + for (int i = 0; i < ARRAYSIZE(_syncList); i++) { + if (_syncList[i].id == 0) { + debug(5, "%d sends sync %d to %d", readVar(ID), sync, id); + _syncList[i].id = id; + _syncList[i].sync = sync; + return; + } + } + + // The original code didn't even check for this condition, so maybe + // it should be a fatal error? + + warning("No free sync slot"); +} + /** * Check for a sync waiting for this character. Called from fnAnim() to see if * animation is to be finished. Returns an index into _syncList[], or -1. @@ -48,7 +64,7 @@ void Logic::clearSyncs(uint32 id) { int Logic::getSync() { uint32 id = readVar(ID); - for (int i = 0; i < MAX_syncs; i++) { + for (int i = 0; i < ARRAYSIZE(_syncList); i++) { if (_syncList[i].id == id) return i; } |