Skip to content

Commit

Permalink
TONY: Fix operation of TakeOwnership/ReleaseOwnership
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jun 9, 2012
1 parent da39f4d commit 7758b1a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions engines/tony/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2043,12 +2043,25 @@ DECLARE_CUSTOM_FUNCTION(StartDialog)(CORO_PARAM, uint32 nDialog, uint32 nStartGr
*/

DECLARE_CUSTOM_FUNCTION(TakeOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) {
CoroScheduler.waitForSingleObject(coroParam, GLOBALS.mut[num], CORO_INFINITE);
CORO_BEGIN_CONTEXT;
bool expired;
CORO_END_CONTEXT(_ctx);

CORO_BEGIN_CODE(_ctx);

// The event is operating as a mutex, so if the event is already set, wait until it's reset
do {
CORO_INVOKE_3(CoroScheduler.waitForSingleObject, GLOBALS.mut[num], 0, &_ctx->expired);
} while (!_ctx->expired);

// Set the event to flag ownership
CoroScheduler.setEvent(GLOBALS.mut[num]);

CORO_END_CODE;
}

DECLARE_CUSTOM_FUNCTION(ReleaseOwnership)(CORO_PARAM, uint32 num, uint32, uint32, uint32) {
CoroScheduler.pulseEvent(GLOBALS.mut[num]);
warning("TODO: Validate that the use of events in TakeOwnership/ReleaseOwnership match original");
CoroScheduler.resetEvent(GLOBALS.mut[num]);
}

/*
Expand Down

0 comments on commit 7758b1a

Please sign in to comment.