Exemple #1
0
/**
 * Runs actor's glitter code.
 */
static void ActorTinselProcess(CORO_PARAM, const void *param) {
	// COROUTINE
	CORO_BEGIN_CONTEXT;
		INT_CONTEXT *pic;
		bool bTookControl;
	CORO_END_CONTEXT(_ctx);

	// get the stuff copied to process when it was created
	const ATP_INIT *atp = (const ATP_INIT *)param;

	CORO_BEGIN_CODE(_ctx);

	if (TinselV2) {
		// Take control for CONVERSE events
		if (atp->event == CONVERSE) {
			_ctx->bTookControl = GetControl();
			HideConversation(true);
		} else
			_ctx->bTookControl = false;

		// Run the Glitter code
		CORO_INVOKE_1(Interpret, atp->pic);

		// Restore conv window if applicable
		if (atp->event == CONVERSE) {
			// Free control if we took it
			if (_ctx->bTookControl)
				ControlOn();

			HideConversation(false);
		}
	} else {
		CORO_INVOKE_1(AllowDclick, atp->bev);		// May kill us if single click

		// Run the Glitter code
		assert(actorInfo[atp->id - 1].actorCode); // no code to run

		_ctx->pic = InitInterpretContext(GS_ACTOR, actorInfo[atp->id - 1].actorCode,
			atp->event, NOPOLY, atp->id, NULL);
		CORO_INVOKE_1(Interpret, _ctx->pic);

		// If it gets here, actor's code has run to completion
		actorInfo[atp->id - 1].completed = true;
	}

	CORO_END_CODE;
}
Exemple #2
0
/**
 * Runs glitter code associated with a polygon.
 */
void PolyTinselProcess(CORO_PARAM, const void *param) {
	// COROUTINE
	CORO_BEGIN_CONTEXT;
		INT_CONTEXT *pic;
		bool bTookControl;	// Set if this function takes control

	CORO_END_CONTEXT(_ctx);

	const PTP_INIT *to = (const PTP_INIT *)param;	// get the stuff copied to process when it was created

	CORO_BEGIN_CODE(_ctx);

	if (TinselV2) {

		// Take control for CONVERSE events
		if (to->event == CONVERSE) {
			_ctx->bTookControl = GetControl();
			HideConversation(true);
		} else
			_ctx->bTookControl = false;

		CORO_INVOKE_1(Interpret, to->pic);

		// Restore conv window if applicable
		if (to->event == CONVERSE) {
			// Free control if we took it
			if (_ctx->bTookControl)
				ControlOn();

			HideConversation(false);
		}

	} else {

		CORO_INVOKE_1(AllowDclick, to->bev);	// May kill us if single click

		// Control may have gone off during AllowDclick()
		if (!TestToken(TOKEN_CONTROL)
			&& (to->event == WALKTO || to->event == ACTION || to->event == LOOK))
			CORO_KILL_SELF();

		// Take control, if requested
		if (to->take_control)
			_ctx->bTookControl = GetControl(CONTROL_OFF);
		else
			_ctx->bTookControl = false;

		// Hide conversation if appropriate
		if (to->event == CONVERSE)
			HideConversation(true);

		// Run the code
		_ctx->pic = InitInterpretContext(GS_POLYGON, GetPolyScript(to->hPoly), to->event, to->hPoly, to->actor, NULL);
		CORO_INVOKE_1(Interpret, _ctx->pic);

		// Free control if we took it
		if (_ctx->bTookControl)
			Control(CONTROL_ON);

		// Restore conv window if applicable
		if (to->event == CONVERSE)
			HideConversation(false);
	}

	CORO_END_CODE;
}