aboutsummaryrefslogtreecommitdiff
path: root/sword2/sync.cpp
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-11-13 19:29:32 +0000
committerTorbjörn Andersson2005-11-13 19:29:32 +0000
commit267fc7e2f652feaf6168d65ccf2916e09fe12edb (patch)
treed21682b10737fa5969374c7c59418b9502243000 /sword2/sync.cpp
parentc4ad2ecb49e4b11a2f71b96b32d6ae17036e4d68 (diff)
downloadscummvm-rg350-267fc7e2f652feaf6168d65ccf2916e09fe12edb.tar.gz
scummvm-rg350-267fc7e2f652feaf6168d65ccf2916e09fe12edb.tar.bz2
scummvm-rg350-267fc7e2f652feaf6168d65ccf2916e09fe12edb.zip
Cleanup
svn-id: r19587
Diffstat (limited to 'sword2/sync.cpp')
-rw-r--r--sword2/sync.cpp20
1 files changed, 18 insertions, 2 deletions
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;
}