From d21525d7fe93b9b6d15c442a1263149e89eb70bc Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 5 Sep 2004 22:57:09 +0000 Subject: Implement roomOp 234 svn-id: r14913 --- scumm/script_v6he.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'scumm/script_v6he.cpp') diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index 1b53af05c1..5ff7d026f9 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -535,7 +535,7 @@ void ScummEngine_v6he::o6_roomOps() { case 234: // HE 7.2 b = pop(); a = pop(); - warning("o6_roomOps: case %d (%d, %d)", op, b, a); + swapObjects(a, b); break; case 236: // HE 7.2 b = pop(); @@ -547,6 +547,32 @@ void ScummEngine_v6he::o6_roomOps() { } } +void ScummEngine_v6he::swapObjects(int object1, int object2) { + int idx1 = -1, idx2 = -1; + + if (_numObjectsInRoom >= 0) { // how could it be negative? + for (int i = 0; i < _numObjectsInRoom; i++) { + if (_objs[i].obj_nr == object1) + idx1 = i; + + if (_objs[i].obj_nr == object2) + idx2 = i; + } + } + + if (idx1 == -1 || idx2 == -1 || idx1 >= idx2) + return; + + stopObjectScript(object1); + stopObjectScript(object2); + + struct ObjectData tmpOd; + + memcpy(&tmpOd, &_objs[idx1], sizeof(tmpOd)); + memcpy(&_objs[idx1], &_objs[idx2], sizeof(tmpOd)); + memcpy(&_objs[idx2], &tmpOd, sizeof(tmpOd)); +} + void ScummEngine_v6he::o6_actorOps() { Actor *a; int i, j, k; -- cgit v1.2.3