WATCHMAKER: Move WaitingMsgs into MessageSystem

This commit is contained in:
Einar Johan Trøan Sømåen 2023-04-08 12:01:00 +02:00 committed by Eugene Sandulenko
parent cf8e6d668d
commit 439b210bcf
9 changed files with 73 additions and 65 deletions

View File

@ -265,7 +265,7 @@ void NextCameraStep(WGame &game) {
bMovingCamera = false;
DestCamera = nullptr;
t3dVectFill(&OldCameraTarget, 0.0f);
// AddWaitingMsgs( MP_WAIT_CAMERA );
// _vm->_messageSystem.addWaitingMsgs( MP_WAIT_CAMERA );
GetCameraTarget(init, &t3dCurCamera->Target);
game._renderer->setCurCameraViewport(t3dCurCamera->Fov, bSuperView);
@ -286,7 +286,7 @@ void NextCameraStep(WGame &game) {
CurCameraStep = NumCameraSteps = 0;
bMovingCamera = false;
DestCamera = nullptr;
AddWaitingMsgs(MP_WAIT_CAMERA);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_CAMERA);
// if( (bFirstPerson) && ( ( CurRoom == r32 ) && ( PlayerPos[CurPlayer+ocDARRELL] == 6 ) ) )
// PlayerSpeak( Obj[o32OROLOGIO].action[CurPlayer+ocDARRELL] );
@ -606,14 +606,14 @@ void ProcessCamera(WGame &game) {
bForceDirectCamera = TRUE;
t3dCurCameraIndex = 255;
t3dLastCameraIndex = 255;
AddWaitingMsgs(MP_WAIT_PORTAL);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_PORTAL);
// DebugLogFile("PortalCrossed %s",PortalCrossed->Name);
// PortalCrossed = nullptr;
if (bMovingCamera) {
CurCameraStep = NumCameraSteps = 0;
bMovingCamera = FALSE;
DestCamera = nullptr;
AddWaitingMsgs(MP_WAIT_CAMERA);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_CAMERA);
}
if (bFirstPerson)
_vm->_messageSystem.doEvent(EventClass::MC_CAMERA, ME_CAMERA3TO1, MP_DEFAULT, 0, 0, 0, nullptr, nullptr, nullptr);

View File

@ -135,7 +135,7 @@ void doPlayer(WGame &game) {
Player->Walk.NumPathNodes = Player->Walk.CurrentStep = Player->Walk.NumSteps = bNotSkippableWalk = 0;
if ((!bDialogActive) || (TimeWalk == CurPlayer + ocDARRELL) || (TimeWalk == ocBOTH))
AddWaitingMsgs(MP_WAIT_ACT);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_ACT);
if (TheMessage->event == ME_PLAYERGOTOEXAMINE)
_vm->_messageSystem.doEvent(EventClass::MC_ACTION, ME_MOUSEEXAMINE, MP_DEFAULT, TheMessage->wparam1, TheMessage->wparam2, 0, &TheMessage->lparam[0], nullptr, nullptr);
@ -169,7 +169,7 @@ void ProcessCharacters(WGame &game) {
if (Character[i] && (Character[i] != Player) && (Character[i]->Walk.NumSteps))
if (!CharNextFrame(game, i))
if ((bDialogActive) && (TimeWalk == i))
AddWaitingMsgs(MP_WAIT_ACT);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_ACT);
for (i = 0; i < T3D_MAX_CHARACTERS; i++) {
c = Character[i];

View File

@ -176,7 +176,7 @@ void doString(WGame &game) {
bSkipTalk = false;
bAnimWaitText = false;
ClearText();
if (!bDialogActive) AddWaitingMsgs(MP_WAIT_LINK);
if (!bDialogActive) _vm->_messageSystem.addWaitingMsgs(MP_WAIT_LINK);
} else {
TheMessage->flags |= MP_WAIT_RETRACE;
ReEvent();
@ -197,7 +197,7 @@ void doString(WGame &game) {
bSkipTalk = false;
bAnimWaitText = false;
ClearText();
if (!bDialogActive) AddWaitingMsgs(MP_WAIT_LINK);
if (!bDialogActive) _vm->_messageSystem.addWaitingMsgs(MP_WAIT_LINK);
} else {
TheMessage->flags |= MP_WAIT_RETRACE;
ReEvent();

View File

@ -542,7 +542,7 @@ void ProcessTime(WGame &game) {
ProcessGopherCamera(game);
}
// Aggiunge eventi che devo essere lanciati alla fine del frame
AddWaitingMsgs(MP_WAIT_RETRACE);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_RETRACE);
// Azzera il numero di eventi inviati tra un refresh e l'altro
NumTimes = 0;
@ -821,14 +821,14 @@ void doSystem(WGame &game) {
TheMessage->lparam[0] = LastT1;
ReEvent();
} else
AddWaitingMsgs(MP_WAITA);
_vm->_messageSystem.addWaitingMsgs(MP_WAITA);
break;
case EFFECT_FADEOUT_T2:
if (T2t) {
TheMessage->lparam[0] = LastT2;
ReEvent();
} else
AddWaitingMsgs(MP_WAITA);
_vm->_messageSystem.addWaitingMsgs(MP_WAITA);
break;
case EFFECT_MOVEIN_T1:
@ -846,7 +846,7 @@ void doSystem(WGame &game) {
ReEvent();
LastT1 = TheMessage->lparam[0];
} else
DeleteWaitingMsgs(MP_WAITA);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAITA);
break;
case EFFECT_MOVEIN_T2:
T2t = nullptr;
@ -863,7 +863,7 @@ void doSystem(WGame &game) {
ReEvent();
LastT2 = TheMessage->lparam[0];
} else
DeleteWaitingMsgs(MP_WAITA);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAITA);
break;
case EFFECT_ROOMINFO: {
int32 width, height, bpp, time;

View File

@ -777,7 +777,7 @@ void ProcessATF(WGame &game, int32 an, int32 atf) {
for (a = 0, obj = h->LoopMask; a < MAX_SUBANIMS; a++)
if (!bAnimWaitText && h->sub[a].ptr && (h->sub[a].ptr->CurFrame >= 0) && !(obj & (1 << a)))
if ((h->sub[a].ptr->Flags & T3D_MESH_CHARACTER) && (bDialogActive)) {
AddWaitingMsgs(MP_WAIT_LINK);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_LINK);
h->sub[a].ptr->CurFrame = h->LoopEnd;
h->sub[a].ptr->BlendPercent = 0;
h->CurFrame = h->LoopEnd;
@ -1611,11 +1611,11 @@ void StopAnim(WGame &game, int32 an) {
// Se sono in un dialogo controlla che sia finita l'animazione di Time
else if (bDialogActive) {
if (an == TimeAnim)
AddWaitingMsgs(MP_WAIT_ANIM);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_ANIM);
}
// Altrimenti aggiungo tutte le anim
else
AddWaitingMsgs(MP_WAIT_ANIM);
_vm->_messageSystem.addWaitingMsgs(MP_WAIT_ANIM);
}

View File

@ -39,36 +39,31 @@
namespace Watchmaker {
#define MAXWAITINGMSGS 30
message WaitingMsg[MAXWAITINGMSGS];
void MessageSystem::addWaitingMsgs(uint16 flags) {
for (int8 a = 0; a < MAXWAITINGMSGS; a++) {
_waitingMsg[a].flags &= ~flags;
}
/* -----------------18/03/98 16.41-------------------
* AddWaitingMsgs
* --------------------------------------------------*/
void AddWaitingMsgs(uint16 flags) {
int8 a;
for (a = 0; a < MAXWAITINGMSGS; a++)
WaitingMsg[a].flags &= ~flags;
for (a = 0; a < MAXWAITINGMSGS; a++)
if (WaitingMsg[a].classe != EventClass::MC_IDLE && (WaitingMsg[a].flags < MP_WAITA)) {
_vm->_messageSystem.doEvent(WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags,
WaitingMsg[a].wparam1, WaitingMsg[a].wparam2,
WaitingMsg[a].bparam, &WaitingMsg[a].lparam[0], &WaitingMsg[a].lparam[1], &WaitingMsg[a].lparam[2]);
memset(&WaitingMsg[a], 0, sizeof(WaitingMsg[a]));
for (int8 a = 0; a < MAXWAITINGMSGS; a++) {
if (_waitingMsg[a].classe != EventClass::MC_IDLE && (_waitingMsg[a].flags < MP_WAITA)) {
_vm->_messageSystem.doEvent(_waitingMsg[a].classe, _waitingMsg[a].event, _waitingMsg[a].flags,
_waitingMsg[a].wparam1, _waitingMsg[a].wparam2,
_waitingMsg[a].bparam, &_waitingMsg[a].lparam[0], &_waitingMsg[a].lparam[1], &_waitingMsg[a].lparam[2]);
memset(&_waitingMsg[a], 0, sizeof(_waitingMsg[a]));
}
}
}
/* -----------------25/09/98 16.33-------------------
* DeleteWaitingMsgs
* --------------------------------------------------*/
void DeleteWaitingMsgs(uint16 flags) {
void MessageSystem::deleteWaitingMsgs(uint16 flags) {
for (int a = 0; a < MAXWAITINGMSGS; a++)
WaitingMsg[a].flags &= ~flags;
_waitingMsg[a].flags &= ~flags;
for (int a = 0; a < MAXWAITINGMSGS; a++)
if (WaitingMsg[a].classe != EventClass::MC_IDLE && (WaitingMsg[a].flags < MP_WAITA))
memset(&WaitingMsg[a], 0, sizeof(WaitingMsg[a]));
if (_waitingMsg[a].classe != EventClass::MC_IDLE && (_waitingMsg[a].flags < MP_WAITA))
memset(&_waitingMsg[a], 0, sizeof(_waitingMsg[a]));
}
/* -----------------08/02/99 10.09-------------------
@ -82,7 +77,7 @@ bool _GetMessage(pqueue *lq) {
lq->len--;
if (TheMessage->flags & MP_CLEARA)
AddWaitingMsgs(MP_WAITA);
_vm->_messageSystem.addWaitingMsgs(MP_WAITA);
return true;
}
@ -101,7 +96,7 @@ void MessageSystem::init() {
}
for (int i = 0; i < MAXWAITINGMSGS; i++) {
memset(&WaitingMsg[i], 0, sizeof(WaitingMsg[i]));
memset(&_waitingMsg[i], 0, sizeof(_waitingMsg[i]));
}
}
@ -136,25 +131,31 @@ void MessageSystem::doEvent(EventClass classe, uint8 event, uint16 flags, int16
if (flags >= MP_WAITA) {
int8 a;
for (a = 0; a < MAXWAITINGMSGS; a++)
if (WaitingMsg[a].classe == EventClass::MC_IDLE)
if (_waitingMsg[a].classe == EventClass::MC_IDLE)
break;
if (a < MAXWAITINGMSGS) {
WaitingMsg[a].classe = classe;
WaitingMsg[a].event = event;
WaitingMsg[a].flags = flags;
WaitingMsg[a].wparam1 = wparam1;
WaitingMsg[a].wparam2 = wparam2;
WaitingMsg[a].bparam = bparam;
if (p0 != nullptr) WaitingMsg[a].lparam[0] = *(int32 *)p0;
else WaitingMsg[a].lparam[0] = 0;
if (p1 != nullptr) WaitingMsg[a].lparam[1] = *(int32 *)p1;
else WaitingMsg[a].lparam[1] = 0;
if (p2 != nullptr) WaitingMsg[a].lparam[2] = *(int32 *)p2;
else WaitingMsg[a].lparam[2] = 0;
_waitingMsg[a].classe = classe;
_waitingMsg[a].event = event;
_waitingMsg[a].flags = flags;
_waitingMsg[a].wparam1 = wparam1;
_waitingMsg[a].wparam2 = wparam2;
_waitingMsg[a].bparam = bparam;
if (p0 != nullptr)
_waitingMsg[a].lparam[0] = *(int32 *)p0;
else
_waitingMsg[a].lparam[0] = 0;
if (p1 != nullptr)
_waitingMsg[a].lparam[1] = *(int32 *)p1;
else
_waitingMsg[a].lparam[1] = 0;
if (p2 != nullptr)
_waitingMsg[a].lparam[2] = *(int32 *)p2;
else
_waitingMsg[a].lparam[2] = 0;
return;
} else {
for (a = 0; a < MAXWAITINGMSGS; a++)
warning("%d: %d %d %d %d", a, WaitingMsg[a].classe, WaitingMsg[a].event, WaitingMsg[a].flags, WaitingMsg[a].lparam[1]);
warning("%d: %d %d %d %d", a, _waitingMsg[a].classe, _waitingMsg[a].event, _waitingMsg[a].flags, _waitingMsg[a].lparam[1]);
warning("ERRORE! CODA WAITING PIENA! - messy %d %d MAX %d", classe, event, MAXWAITINGMSGS);
return;
@ -305,8 +306,8 @@ void MessageSystem::removeEvent(EventClass classe, uint8 event) {
}
for (b = 0; b < MAXWAITINGMSGS; b++)
if ((WaitingMsg[b].classe == classe) && ((event == ME_ALL) || (WaitingMsg[b].event == event)))
memset(&WaitingMsg[b], 0, sizeof(WaitingMsg[b]));
if ((_waitingMsg[b].classe == classe) && ((event == ME_ALL) || (_waitingMsg[b].event == event)))
memset(&_waitingMsg[b], 0, sizeof(_waitingMsg[b]));
}
/* -----------------18/12/00 16.32-------------------
@ -331,8 +332,8 @@ void MessageSystem::removeEvent_bparam(EventClass classe, uint8 event, uint8 bpa
}
for (b = 0; b < MAXWAITINGMSGS; b++)
if ((WaitingMsg[b].classe == classe) && ((event == ME_ALL) || (WaitingMsg[b].event == event)) && (WaitingMsg[b].bparam == bparam))
memset(&WaitingMsg[b], 0, sizeof(WaitingMsg[b]));
if ((_waitingMsg[b].classe == classe) && ((event == ME_ALL) || (_waitingMsg[b].event == event)) && (_waitingMsg[b].bparam == bparam))
memset(&_waitingMsg[b], 0, sizeof(_waitingMsg[b]));
}
/* -----------------08/02/99 10.11-------------------

View File

@ -30,8 +30,10 @@ namespace Watchmaker {
void ProcessTheMessage(WGame &game);
void ReEvent();
void DeleteWaitingMsgs(uint16 flags);
void AddWaitingMsgs(uint16 flags);
void deleteWaitingMsgs(uint16 flags);
void addWaitingMsgs(uint16 flags);
#define MAXWAITINGMSGS 30
class MessageSystem {
public:
@ -39,7 +41,11 @@ public:
void removeEvent(EventClass classe, uint8 event);
void removeEvent_bparam(EventClass classe, uint8 event, uint8 bparam);
void scheduler(); // TODO: Rename
void doEvent(EventClass classe, uint8 event, uint16 flags, int16 wparam1, int16 wparam2, uint8 bparam, void *p0, void *p1, void *p2);
void addWaitingMsgs(uint16 flags);
void deleteWaitingMsgs(uint16 flags);
message GameMessage[MAX_MESSAGES];
pqueue Game;
// message *TheMessage; // TODO: Replace the global variable with this
@ -47,6 +53,7 @@ public:
uint8 SuperEventActivate;
private:
int _maxmsg = 0;
message _waitingMsg[MAXWAITINGMSGS];
void initQueue(pqueue *lq);
};

View File

@ -2356,7 +2356,7 @@ void doT2DMouse(WGame &game) {
if ((bSomeOneSpeak) && ((TheMessage->event == ME_MLEFT) || (TheMessage->event == ME_MRIGHT))) {
bSkipTalk = TRUE;
ClearText();
DeleteWaitingMsgs(MP_WAIT_LINK);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_LINK);
return;
}

View File

@ -297,9 +297,9 @@ void CheckCharacterWithoutBounds(WGame &game, int32 oc, const uint8 *dpl, uint8
}
bNotSkippableWalk = TRUE;
BuildStepList(oc, dp, back);
DeleteWaitingMsgs(MP_WAIT_PORTAL);
DeleteWaitingMsgs(MP_WAIT_ANIM);
DeleteWaitingMsgs(MP_WAIT_ACT);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_PORTAL);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ANIM);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ACT);
}
/* -----------------01/07/98 16.10-------------------
@ -643,9 +643,9 @@ bool CheckCharacterWithBounds(WGame &game, int32 oc, t3dV3F *Pos, uint8 dp, uint
t3dVectCopy(&Char->Pos, &Char->Mesh->Trasl);
FindPath(oc, t3dCurCamera); // Calc path
if (CheckPathNodes(oc)) BuildStepList(oc, dp, back);
DeleteWaitingMsgs(MP_WAIT_PORTAL);
DeleteWaitingMsgs(MP_WAIT_ANIM);
DeleteWaitingMsgs(MP_WAIT_ACT);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_PORTAL);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ANIM);
_vm->_messageSystem.deleteWaitingMsgs(MP_WAIT_ACT);
if (Char->Walk.NumSteps >= 2) return TRUE;
else return FALSE;
}