mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- busy interface + unlimiting.
This commit is contained in:
parent
28840b3afa
commit
7f94eee9bb
4 changed files with 26 additions and 61 deletions
|
@ -5224,22 +5224,6 @@ int aiFightGetFineTargetDist(DBloodActor* actor, DBloodActor* target)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
int sectorInMotion(int nSector)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (int i = 0; i < kMaxBusyCount; i++)
|
|
||||||
{
|
|
||||||
if (gBusy->sect == §or[nSector]) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void sectorKillSounds(sectortype* pSector)
|
void sectorKillSounds(sectortype* pSector)
|
||||||
{
|
{
|
||||||
BloodSectIterator it(pSector);
|
BloodSectIterator it(pSector);
|
||||||
|
@ -5278,11 +5262,6 @@ void sectorPauseMotion(sectortype* pSector)
|
||||||
void sectorContinueMotion(sectortype* pSector, EVENT event)
|
void sectorContinueMotion(sectortype* pSector, EVENT event)
|
||||||
{
|
{
|
||||||
if (!pSector->hasX()) return;
|
if (!pSector->hasX()) return;
|
||||||
else if (gBusyCount >= kMaxBusyCount)
|
|
||||||
{
|
|
||||||
Printf(PRINT_HIGH, "Failed to continue motion for sector. Max (%d) busy objects count reached!", kMaxBusyCount);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
XSECTOR* pXSector = &pSector->xs();
|
XSECTOR* pXSector = &pSector->xs();
|
||||||
pXSector->unused1 = 0;
|
pXSector->unused1 = 0;
|
||||||
|
@ -5367,11 +5346,8 @@ void sectorContinueMotion(sectortype* pSector, EVENT event)
|
||||||
|
|
||||||
SectorStartSound(pSector, pXSector->state);
|
SectorStartSound(pSector, pXSector->state);
|
||||||
nDelta = (pXSector->state) ? -nDelta : nDelta;
|
nDelta = (pXSector->state) ? -nDelta : nDelta;
|
||||||
gBusy[gBusyCount].sect = pSector;
|
BUSY b = { pSector, nDelta, (int)pXSector->busy, (BUSYID)busyFunc };
|
||||||
gBusy[gBusyCount].delta = nDelta;
|
gBusy.Push(b);
|
||||||
gBusy[gBusyCount].busy = pXSector->busy;
|
|
||||||
gBusy[gBusyCount].type = (BUSYID)busyFunc;
|
|
||||||
gBusyCount++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -411,7 +411,6 @@ inline bool aiInPatrolState(int nAiStateType) {
|
||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------- //
|
// ------------------------------------------------------------------------- //
|
||||||
bool readyForCrit(DBloodActor* pHunter, DBloodActor* pVictim);
|
bool readyForCrit(DBloodActor* pHunter, DBloodActor* pVictim);
|
||||||
int sectorInMotion(int nSector);
|
|
||||||
void clampSprite(DBloodActor* actor, int which = 3);
|
void clampSprite(DBloodActor* actor, int which = 3);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -130,38 +130,30 @@ bool SetSectorState(int nSector, XSECTOR *pXSector, int nState)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gBusyCount = 0;
|
TArray<BUSY> gBusy;
|
||||||
BUSY gBusy[];
|
|
||||||
|
|
||||||
void AddBusy(sectortype* pSector, BUSYID a2, int nDelta)
|
void AddBusy(sectortype* pSector, BUSYID a2, int nDelta)
|
||||||
{
|
{
|
||||||
assert(nDelta != 0);
|
assert(nDelta != 0);
|
||||||
int i;
|
for (auto& b : gBusy)
|
||||||
for (i = 0; i < gBusyCount; i++)
|
|
||||||
{
|
{
|
||||||
if (gBusy[i].sect == pSector && gBusy[i].type == a2)
|
if (b.sect == pSector && b.type == a2)
|
||||||
break;
|
{
|
||||||
}
|
b.delta = nDelta;
|
||||||
if (i == gBusyCount)
|
|
||||||
{
|
|
||||||
if (gBusyCount == kMaxBusyCount)
|
|
||||||
return;
|
return;
|
||||||
gBusy[i].sect = pSector;
|
}
|
||||||
gBusy[i].type = a2;
|
|
||||||
gBusy[i].busy = nDelta > 0 ? 0 : 65536;
|
|
||||||
gBusyCount++;
|
|
||||||
}
|
}
|
||||||
gBusy[i].delta = nDelta;
|
BUSY b = { pSector, nDelta, nDelta > 0 ? 0 : 65536, a2 };
|
||||||
|
gBusy.Push(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReverseBusy(sectortype* pSector, BUSYID a2)
|
void ReverseBusy(sectortype* pSector, BUSYID a2)
|
||||||
{
|
{
|
||||||
int i;
|
for (auto& b : gBusy)
|
||||||
for (i = 0; i < gBusyCount; i++)
|
|
||||||
{
|
{
|
||||||
if (gBusy[i].sect == pSector && gBusy[i].type == a2)
|
if (b.sect == pSector && b.type == a2)
|
||||||
{
|
{
|
||||||
gBusy[i].delta = -gBusy[i].delta;
|
b.delta = -b.delta;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1949,27 +1941,28 @@ void trProcessBusy(void)
|
||||||
{
|
{
|
||||||
sect.velCeil = sect.velFloor = 0;
|
sect.velCeil = sect.velFloor = 0;
|
||||||
}
|
}
|
||||||
for (int i = gBusyCount-1; i >= 0; i--)
|
for (auto& b : backwards(gBusy))
|
||||||
{
|
{
|
||||||
int nStatus;
|
int nStatus;
|
||||||
int oldBusy = gBusy[i].busy;
|
int oldBusy = b.busy;
|
||||||
gBusy[i].busy = ClipRange(oldBusy+gBusy[i].delta*4, 0, 65536);
|
b.busy = ClipRange(oldBusy+b.delta*4, 0, 65536);
|
||||||
#ifdef NOONE_EXTENSIONS
|
#ifdef NOONE_EXTENSIONS
|
||||||
if (!gModernMap || !gBusy[i].sect->xs().unused1) nStatus = gBusyProc[gBusy[i].type](gBusy[i].sect, gBusy[i].busy);
|
if (!gModernMap || !b.sect->xs().unused1) nStatus = gBusyProc[b.type](b.sect, b.busy);
|
||||||
else nStatus = 3; // allow to pause/continue motion for sectors any time by sending special command
|
else nStatus = 3; // allow to pause/continue motion for sectors any time by sending special command
|
||||||
#else
|
#else
|
||||||
nStatus = gBusyProc[gBusy[i].type](gBusy[i].at0, gBusy[i].at8);
|
nStatus = gBusyProc[b.type](b.at0, b.at8);
|
||||||
#endif
|
#endif
|
||||||
switch (nStatus) {
|
switch (nStatus) {
|
||||||
case 1:
|
case 1:
|
||||||
gBusy[i].busy = oldBusy;
|
b.busy = oldBusy;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
gBusy[i].busy = oldBusy;
|
b.busy = oldBusy;
|
||||||
gBusy[i].delta = -gBusy[i].delta;
|
b.delta = -b.delta;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
gBusy[i] = gBusy[--gBusyCount];
|
b = gBusy.Last();
|
||||||
|
gBusy.Pop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1981,7 +1974,7 @@ void InitGenerator(DBloodActor*);
|
||||||
|
|
||||||
void trInit(void)
|
void trInit(void)
|
||||||
{
|
{
|
||||||
gBusyCount = 0;
|
gBusy.Clear();
|
||||||
for(auto& wal : walls())
|
for(auto& wal : walls())
|
||||||
for (int i = 0; i < numwalls; i++)
|
for (int i = 0; i < numwalls; i++)
|
||||||
{
|
{
|
||||||
|
@ -2275,8 +2268,7 @@ void SerializeTriggers(FSerializer& arc)
|
||||||
{
|
{
|
||||||
if (arc.BeginObject("triggers"))
|
if (arc.BeginObject("triggers"))
|
||||||
{
|
{
|
||||||
arc("busycount", gBusyCount)
|
arc("busy", gBusy)
|
||||||
.Array("busy", gBusy, gBusyCount)
|
|
||||||
.EndObject();
|
.EndObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ enum BUSYID {
|
||||||
BUSYID_7,
|
BUSYID_7,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define kMaxBusyCount 128
|
|
||||||
struct BUSY {
|
struct BUSY {
|
||||||
sectortype* sect;
|
sectortype* sect;
|
||||||
int delta;
|
int delta;
|
||||||
|
@ -50,8 +49,7 @@ struct BUSY {
|
||||||
int/*BUSYID*/ type;
|
int/*BUSYID*/ type;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BUSY gBusy[kMaxBusyCount];
|
extern TArray<BUSY> gBusy;
|
||||||
extern int gBusyCount;
|
|
||||||
|
|
||||||
void trTriggerSector(sectortype *pSector, int command);
|
void trTriggerSector(sectortype *pSector, int command);
|
||||||
void trMessageSector(sectortype* pSector, EVENT event);
|
void trMessageSector(sectortype* pSector, EVENT event);
|
||||||
|
|
Loading…
Reference in a new issue