TONY: Refactored Tony to use the Common coroutine scheduler

This commit is contained in:
Paul Gilbert 2012-05-11 23:15:59 +10:00
parent 2c1ef3ab35
commit 68c1b0b0e4
19 changed files with 166 additions and 293 deletions

View file

@ -67,7 +67,7 @@ void RMTony::WaitEndOfAction(CORO_PARAM, const void *param) {
CORO_BEGIN_CODE(_ctx);
CORO_INVOKE_2(g_scheduler->waitForSingleObject, pid, INFINITE);
CORO_INVOKE_2(CoroScheduler.waitForSingleObject, pid, CORO_INFINITE);
m_bAction = false;
@ -236,15 +236,15 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) {
pid = mpalQueryDoAction(TA_COMBINE, nParm, nActionItem);
// Se è fallito il combine, proviamo con il ReceiveCombine
if (pid == INVALID_PID_VALUE) {
if (pid == CORO_INVALID_PID_VALUE) {
pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, nParm);
// Se è fallito il receive, andiamo con quelli generici
// @@@ CombineGive!
if (pid == INVALID_PID_VALUE) {
if (pid == CORO_INVALID_PID_VALUE) {
pid = mpalQueryDoAction(TA_COMBINE, nParm, 0);
if (pid == INVALID_PID_VALUE){
if (pid == CORO_INVALID_PID_VALUE){
pid = mpalQueryDoAction(TA_RECEIVECOMBINE, nActionItem, 0);
}
}
@ -254,25 +254,25 @@ void RMTony::ExecuteAction(int nAction, int nActionItem, int nParm) {
pid = mpalQueryDoAction(nAction, nActionItem, 0);
}
if (pid != INVALID_PID_VALUE) {
if (pid != CORO_INVALID_PID_VALUE) {
m_bAction = true;
g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32));
CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32));
hActionThread = pid;
} else if (nAction != TA_GOTO) {
if (nAction == TA_TALK) {
pid = mpalQueryDoAction(6, 1, 0);
m_bAction = true;
g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32));
CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32));
hActionThread = pid;
} else if (nAction == TA_PALESATI) {
pid = mpalQueryDoAction(7, 1, 0);
m_bAction = true;
g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32));
CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32));
hActionThread = pid;
} else {
pid = mpalQueryDoAction(5, 1, 0);
m_bAction = true;
g_scheduler->createProcess(WaitEndOfAction, &pid, sizeof(uint32));
CoroScheduler.createProcess(WaitEndOfAction, &pid, sizeof(uint32));
hActionThread = pid;
}
}
@ -286,7 +286,7 @@ void RMTony::StopNoAction(CORO_PARAM) {
CORO_BEGIN_CODE(_ctx);
if (m_bAction)
CORO_INVOKE_2(g_scheduler->waitForSingleObject, hActionThread, INFINITE);
CORO_INVOKE_2(CoroScheduler.waitForSingleObject, hActionThread, CORO_INFINITE);
m_bActionPending = false;
m_ActionItem = NULL;
@ -306,12 +306,12 @@ void RMTony::Stop(CORO_PARAM) {
// Richiama l'MPAL per scegliere la direzione
_ctx->pid = mpalQueryDoAction(21, m_ActionItem->MpalCode(), 0);
if (_ctx->pid == INVALID_PID_VALUE)
if (_ctx->pid == CORO_INVALID_PID_VALUE)
CORO_INVOKE_0(RMCharacter::Stop);
else {
bNeedToStop = false; // Se facciamo la OnWhichDirection, almeno dopo non dobbiamo fare la Stop()
bMoving = false;
CORO_INVOKE_2(g_scheduler->waitForSingleObject, _ctx->pid, INFINITE); // @@@ Mettere un assert dopo 10 secondi
CORO_INVOKE_2(CoroScheduler.waitForSingleObject, _ctx->pid, CORO_INFINITE); // @@@ Mettere un assert dopo 10 secondi
}
} else {
CORO_INVOKE_0(RMCharacter::Stop);