- trMessage* functions.

# Conflicts:
#	source/games/blood/src/eventq.cpp
This commit is contained in:
Christoph Oelckers 2021-11-23 20:58:30 +01:00
parent 45a8654fc2
commit 7bffcad49f
5 changed files with 41 additions and 35 deletions

View file

@ -484,11 +484,11 @@ void evSend(const EventObject& eob, int rxId, COMMAND_ID command)
{ {
if (eo.isSector()) if (eo.isSector())
{ {
trMessageSector(sectnum(eo.sector()), event); trMessageSector(eo.sector(), event);
} }
else if (eo.isWall()) else if (eo.isWall())
{ {
trMessageWall(wallnum(eo.wall()), event); trMessageWall(eo.wall(), event);
} }
else if (eo.isActor()) else if (eo.isActor())
{ {
@ -646,8 +646,8 @@ void evProcess(unsigned int time)
else else
{ {
if (event.target.isActor()) trMessageSprite(event.target.actor(), event); if (event.target.isActor()) trMessageSprite(event.target.actor(), event);
else if (event.target.isSector()) trMessageSector(sectnum(event.target.sector()), event); else if (event.target.isSector()) trMessageSector(event.target.sector(), event);
else if (event.target.isWall()) trMessageWall(wallnum(event.target.wall()), event); else if (event.target.isWall()) trMessageWall(event.target.wall(), event);
} }
} }
} }

View file

@ -4718,7 +4718,7 @@ void modernTypeSendCommand(DBloodActor* actor, int destChannel, COMMAND_ID comma
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void modernTypeTrigger(int destObjType, int destObjIndex, DBloodActor* destactor, const EVENT& event) void modernTypeTrigger(int destObjType, sectortype* destSect, walltype* destWall, DBloodActor* destactor, const EVENT& event)
{ {
if (!event.isActor()) return; if (!event.isActor()) return;
auto pActor = event.getActor(); auto pActor = event.getActor();
@ -4726,12 +4726,15 @@ void modernTypeTrigger(int destObjType, int destObjIndex, DBloodActor* destactor
spritetype* pSource = &pActor->s(); spritetype* pSource = &pActor->s();
XSPRITE* pXSource = &pActor->x(); XSPRITE* pXSource = &pActor->x();
int destObjIndex = -1;
switch (destObjType) { switch (destObjType) {
case OBJ_SECTOR: case OBJ_SECTOR:
if (!sector[destObjIndex].hasX()) return; if (!destSect || !destSect->hasX()) return;
destObjIndex = sectnum(destSect);
break; break;
case OBJ_WALL: case OBJ_WALL:
if (!wall[destObjIndex].hasX()) return; if (!destWall || !destWall->hasX()) return;
destObjIndex = wallnum(destWall);
break; break;
case OBJ_SPRITE: case OBJ_SPRITE:
{ {

View file

@ -331,7 +331,7 @@ void seqTxSendCmdAll(DBloodActor* pXSource, DBloodActor* nIndex, COMMAND_ID cmd,
void trPlayerCtrlLink(DBloodActor* pXSource, PLAYER* pPlayer, bool checkCondition); void trPlayerCtrlLink(DBloodActor* pXSource, PLAYER* pPlayer, bool checkCondition);
void trPlayerCtrlStopScene(PLAYER* pPlayer); void trPlayerCtrlStopScene(PLAYER* pPlayer);
// ------------------------------------------------------------------------- // // ------------------------------------------------------------------------- //
void modernTypeTrigger(int type, int nDest, DBloodActor* actor, const EVENT& event); void modernTypeTrigger(int type, sectortype*sect, walltype* wal, DBloodActor* actor, const EVENT& event);
bool modernTypeOperateSector(int nSector, sectortype* pSector, XSECTOR* pXSector, const EVENT& event); bool modernTypeOperateSector(int nSector, sectortype* pSector, XSECTOR* pXSector, const EVENT& event);
bool modernTypeOperateSprite(DBloodActor*, const EVENT& event); bool modernTypeOperateSprite(DBloodActor*, const EVENT& event);
bool modernTypeOperateWall(int nWall, walltype* pWall, XWALL* pXWall, EVENT event); bool modernTypeOperateWall(int nWall, walltype* pWall, XWALL* pXWall, EVENT event);

View file

@ -1512,16 +1512,17 @@ void OperatePath(unsigned int nSector, XSECTOR *pXSector, EVENT event)
} }
} }
void OperateSector(unsigned int nSector, XSECTOR *pXSector, EVENT event) void OperateSector(sectortype* pSector, EVENT event)
{ {
assert(nSector < (unsigned int)numsectors); if (!pSector->hasX()) return;
sectortype *pSector = &sector[nSector]; auto pXSector = &pSector->xs();
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
if (gModernMap && modernTypeOperateSector(nSector, pSector, pXSector, event)) if (gModernMap && modernTypeOperateSector(sectnum(pSector), pSector, pXSector, event))
return; return;
#endif #endif
int nSector = sectnum(pSector);
switch (event.cmd) { switch (event.cmd) {
case kCmdLock: case kCmdLock:
pXSector->locked = 1; pXSector->locked = 1;
@ -1727,7 +1728,7 @@ void trTriggerSector(sectortype* pSector, int command)
else { else {
EVENT event; EVENT event;
event.cmd = command; event.cmd = command;
OperateSector(sectnum(pSector), pXSector, event); OperateSector(pSector, event);
} }
} }
@ -1775,47 +1776,47 @@ void trTriggerSprite(DBloodActor* actor, int command)
} }
} }
void trMessageSector(unsigned int nSector, EVENT event) void trMessageSector(sectortype* pSector, EVENT event)
{ {
assert(validSectorIndex(nSector)); if (!pSector->hasX()) return;
assert(sector[nSector].hasX()); XSECTOR *pXSector = &pSector->xs();
XSECTOR *pXSector = &sector[nSector].xs(); if (!pXSector->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock)
if (!pXSector->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock) { {
switch (event.cmd) { switch (event.cmd)
{
case kCmdLink: case kCmdLink:
LinkSector(nSector, pXSector, event); LinkSector(sectnum(pSector), pXSector, event);
break; break;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kCmdModernUse: case kCmdModernUse:
modernTypeTrigger(6, nSector, nullptr, event); modernTypeTrigger(OBJ_SECTOR, pSector, nullptr, nullptr, event);
break; break;
#endif #endif
default: default:
OperateSector(nSector, pXSector, event); OperateSector(pSector, event);
break; break;
} }
} }
} }
void trMessageWall(unsigned int nWall, EVENT event) void trMessageWall(walltype* pWall, const EVENT& event)
{ {
assert(validWallIndex(nWall));
auto pWall = &wall[nWall];
assert(pWall->hasX()); assert(pWall->hasX());
XWALL *pXWall = &pWall->xw(); XWALL *pXWall = &pWall->xw();
if (!pXWall->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock) { if (!pXWall->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock)
{
switch (event.cmd) { switch (event.cmd) {
case kCmdLink: case kCmdLink:
LinkWall(nWall, pXWall, event); LinkWall(wallnum(pWall), pXWall, event);
break; break;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kCmdModernUse: case kCmdModernUse:
modernTypeTrigger(0, nWall, nullptr, event); modernTypeTrigger(OBJ_WALL, nullptr, pWall, nullptr, event);
break; break;
#endif #endif
default: default:
OperateWall(&wall[nWall], event); OperateWall(pWall, event);
break; break;
} }
} }
@ -1827,14 +1828,16 @@ void trMessageSprite(DBloodActor* actor, EVENT event)
auto pXSprite = &actor->x(); auto pXSprite = &actor->x();
if (pSprite->statnum != kStatFree) { if (pSprite->statnum != kStatFree) {
if (!pXSprite->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock) { if (!pXSprite->locked || event.cmd == kCmdUnlock || event.cmd == kCmdToggleLock)
switch (event.cmd) { {
switch (event.cmd)
{
case kCmdLink: case kCmdLink:
LinkSprite(actor, event); LinkSprite(actor, event);
break; break;
#ifdef NOONE_EXTENSIONS #ifdef NOONE_EXTENSIONS
case kCmdModernUse: case kCmdModernUse:
modernTypeTrigger(OBJ_SPRITE, 0, actor, event); modernTypeTrigger(OBJ_SPRITE, 0, 0, actor, event);
break; break;
#endif #endif
default: default:

View file

@ -54,9 +54,9 @@ extern BUSY gBusy[kMaxBusyCount];
extern int gBusyCount; extern int gBusyCount;
void trTriggerSector(sectortype *pSector, int command); void trTriggerSector(sectortype *pSector, int command);
void trMessageSector(unsigned int nSector, EVENT event); void trMessageSector(sectortype* pSector, EVENT event);
void trTriggerWall(walltype*, int command); void trTriggerWall(walltype*, int command);
void trMessageWall(unsigned int nWall, EVENT event); void trMessageWall(walltype* pWall, const EVENT& event);
void trTriggerSprite(DBloodActor* actor, int command); void trTriggerSprite(DBloodActor* actor, int command);
void trMessageSprite(DBloodActor* actor, EVENT event); void trMessageSprite(DBloodActor* actor, EVENT event);
void trProcessBusy(void); void trProcessBusy(void);