From 7758b1a432fcd31e5e608cb7720225f7a0cc633c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Jun 2012 22:14:38 +1000 Subject: TONY: Fix operation of TakeOwnership/ReleaseOwnership --- engines/tony/custom.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'engines/tony/custom.cpp') diff --git a/engines/tony/custom.cpp b/engines/tony/custom.cpp index 858479ca7f..6db6d5f858 100644 --- a/engines/tony/custom.cpp +++ b/engines/tony/custom.cpp @@ -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]); } /* -- cgit v1.2.3