2019-09-19 22:42:45 +00:00
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
/*
|
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
2020-11-21 14:09:38 +00:00
|
|
|
|
Copyright (C) 2020 Christoph Oelckers
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
This file is part of Raze.
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
Raze is free software; you can redistribute it and/or
|
2019-09-19 22:42:45 +00:00
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
#include "ns.h"
|
2020-11-08 08:47:32 +00:00
|
|
|
|
#include <set>
|
2019-09-19 22:42:45 +00:00
|
|
|
|
#include "build.h"
|
2020-11-21 14:09:38 +00:00
|
|
|
|
#include "printf.h"
|
2020-12-09 14:56:32 +00:00
|
|
|
|
#include "blood.h"
|
2019-11-12 23:44:33 +00:00
|
|
|
|
#include "secrets.h"
|
2020-11-21 14:09:38 +00:00
|
|
|
|
#include "serializer.h"
|
2020-12-03 17:00:07 +00:00
|
|
|
|
#include "bloodactor.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
|
2020-11-08 08:47:32 +00:00
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
const int kMaxID = 1024;
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject rxBucket[kChannelMax];
|
2020-11-21 14:09:38 +00:00
|
|
|
|
unsigned short bucketHead[kMaxID + 1];
|
|
|
|
|
static int bucketCount;
|
|
|
|
|
static std::multiset<EVENT> queue;
|
2020-11-08 08:47:32 +00:00
|
|
|
|
|
2021-11-23 17:05:24 +00:00
|
|
|
|
|
|
|
|
|
FString EventObject::description() const
|
|
|
|
|
{
|
|
|
|
|
if (isActor()) return FStringf("actor %d", ActorP->GetIndex()); // do not add a read barrier here!
|
|
|
|
|
if (isSector()) return FStringf("sector %d", int(index >> 8));
|
|
|
|
|
if (isWall()) return FStringf("wall %d", int(index >> 8));
|
|
|
|
|
return FString("invalid object");
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2020-11-08 08:47:32 +00:00
|
|
|
|
|
2021-12-05 19:55:19 +00:00
|
|
|
|
static int GetBucketChannel(EventObject* pBucket)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2021-12-01 10:32:10 +00:00
|
|
|
|
if (pBucket->isSector())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-01 10:32:10 +00:00
|
|
|
|
auto pSector = pBucket->sector();
|
2021-11-19 00:13:33 +00:00
|
|
|
|
assert(pSector->hasX());
|
|
|
|
|
return pSector->xs().rxID;
|
|
|
|
|
}
|
2021-12-01 10:32:10 +00:00
|
|
|
|
if (pBucket->isWall())
|
2021-11-19 00:13:33 +00:00
|
|
|
|
{
|
2021-12-01 10:32:10 +00:00
|
|
|
|
auto pWall = pBucket->wall();
|
2021-11-19 00:13:33 +00:00
|
|
|
|
assert(pWall->hasX());
|
|
|
|
|
return pWall->xw().rxID;
|
|
|
|
|
}
|
2021-12-01 10:32:10 +00:00
|
|
|
|
if (pBucket->isActor())
|
|
|
|
|
{
|
|
|
|
|
auto pActor = pBucket->actor();
|
2021-12-29 19:45:55 +00:00
|
|
|
|
return pActor ? pActor->xspr.rxID : 0;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 10:32:10 +00:00
|
|
|
|
Printf(PRINT_HIGH, "Unexpected rxBucket %s", pBucket->description().GetChars());
|
2020-11-21 14:09:38 +00:00
|
|
|
|
return 0;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
2021-12-05 19:55:19 +00:00
|
|
|
|
static int CompareChannels(EventObject* ref1, EventObject* ref2)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
return GetBucketChannel(ref1) - GetBucketChannel(ref2);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
2021-11-23 17:49:48 +00:00
|
|
|
|
static EventObject* SortGetMiddle(EventObject* a1, EventObject* a2, EventObject* a3)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
if (CompareChannels(a1, a2) > 0)
|
|
|
|
|
{
|
|
|
|
|
if (CompareChannels(a1, a3) > 0)
|
|
|
|
|
{
|
|
|
|
|
if (CompareChannels(a2, a3) > 0)
|
|
|
|
|
return a2;
|
|
|
|
|
return a3;
|
|
|
|
|
}
|
|
|
|
|
return a1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (CompareChannels(a1, a3) < 0)
|
|
|
|
|
{
|
|
|
|
|
if (CompareChannels(a2, a3) > 0)
|
|
|
|
|
return a3;
|
|
|
|
|
return a2;
|
|
|
|
|
}
|
|
|
|
|
return a1;
|
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 17:49:48 +00:00
|
|
|
|
static void SortSwap(EventObject* a, EventObject* b)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject t = *a;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
*a = *b;
|
|
|
|
|
*b = t;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static void SortRXBucket(int nCount)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject* v144[32];
|
2020-11-21 14:09:38 +00:00
|
|
|
|
int vc4[32];
|
|
|
|
|
int v14 = 0;
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject* pArray = rxBucket;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
while (nCount > 1)
|
|
|
|
|
{
|
|
|
|
|
if (nCount < 16)
|
|
|
|
|
{
|
|
|
|
|
for (int nDist = 3; nDist > 0; nDist -= 2)
|
|
|
|
|
{
|
2021-11-23 17:49:48 +00:00
|
|
|
|
for (EventObject* pI = pArray + nDist; pI < pArray + nCount; pI += nDist)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-23 17:49:48 +00:00
|
|
|
|
for (EventObject* pJ = pI; pJ > pArray && CompareChannels(pJ - nDist, pJ) > 0; pJ -= nDist)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
SortSwap(pJ, pJ - nDist);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2021-12-29 19:45:55 +00:00
|
|
|
|
EventObject* middle = pArray + nCount / 2;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
if (nCount > 29)
|
|
|
|
|
{
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject* first = pArray;
|
|
|
|
|
EventObject* last = pArray + nCount - 1;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
if (nCount > 42)
|
|
|
|
|
{
|
|
|
|
|
int eighth = nCount / 8;
|
|
|
|
|
first = SortGetMiddle(first, first + eighth, first + eighth * 2);
|
|
|
|
|
middle = SortGetMiddle(middle - eighth, middle, middle + eighth);
|
|
|
|
|
last = SortGetMiddle(last - eighth * 2, last - eighth, last);
|
|
|
|
|
}
|
|
|
|
|
middle = SortGetMiddle(first, middle, last);
|
|
|
|
|
}
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject pivot = *middle;
|
|
|
|
|
EventObject* first = pArray;
|
|
|
|
|
EventObject* last = pArray + nCount - 1;
|
|
|
|
|
EventObject* vbx = first;
|
|
|
|
|
EventObject* v4 = last;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
while (vbx <= v4)
|
|
|
|
|
{
|
|
|
|
|
int nCmp = CompareChannels(vbx, &pivot);
|
|
|
|
|
if (nCmp > 0)
|
|
|
|
|
break;
|
|
|
|
|
if (nCmp == 0)
|
|
|
|
|
{
|
|
|
|
|
SortSwap(vbx, first);
|
|
|
|
|
first++;
|
|
|
|
|
}
|
|
|
|
|
vbx++;
|
|
|
|
|
}
|
|
|
|
|
while (vbx <= v4)
|
|
|
|
|
{
|
|
|
|
|
int nCmp = CompareChannels(v4, &pivot);
|
|
|
|
|
if (nCmp < 0)
|
|
|
|
|
break;
|
|
|
|
|
if (nCmp == 0)
|
|
|
|
|
{
|
|
|
|
|
SortSwap(v4, last);
|
|
|
|
|
last--;
|
|
|
|
|
}
|
|
|
|
|
v4--;
|
|
|
|
|
}
|
|
|
|
|
if (vbx > v4)
|
|
|
|
|
break;
|
|
|
|
|
SortSwap(vbx, v4);
|
|
|
|
|
v4--;
|
|
|
|
|
vbx++;
|
|
|
|
|
}
|
2021-11-23 17:49:48 +00:00
|
|
|
|
EventObject* v2c = pArray + nCount;
|
2021-05-12 00:00:06 +00:00
|
|
|
|
int vt = int(min(vbx - first, first - pArray));
|
2020-11-21 14:09:38 +00:00
|
|
|
|
for (int i = 0; i < vt; i++)
|
|
|
|
|
{
|
|
|
|
|
SortSwap(&vbx[i - vt], &pArray[i]);
|
|
|
|
|
}
|
2021-05-12 00:00:06 +00:00
|
|
|
|
vt = int(min(last - v4, v2c - last - 1));
|
2020-11-21 14:09:38 +00:00
|
|
|
|
for (int i = 0; i < vt; i++)
|
|
|
|
|
{
|
|
|
|
|
SortSwap(&v2c[i - vt], &vbx[i]);
|
|
|
|
|
}
|
2021-05-12 00:00:06 +00:00
|
|
|
|
int vvsi = int(last - v4);
|
|
|
|
|
int vvdi = int(vbx - first);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
if (vvsi >= vvdi)
|
|
|
|
|
{
|
|
|
|
|
vc4[v14] = vvsi;
|
|
|
|
|
v144[v14] = v2c - vvsi;
|
|
|
|
|
nCount = vvdi;
|
|
|
|
|
v14++;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
vc4[v14] = vvdi;
|
|
|
|
|
v144[v14] = pArray;
|
|
|
|
|
nCount = vvsi;
|
|
|
|
|
pArray = v2c - vvsi;
|
|
|
|
|
v14++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (v14 == 0)
|
|
|
|
|
return;
|
|
|
|
|
v14--;
|
|
|
|
|
pArray = v144[v14];
|
|
|
|
|
nCount = vc4[v14];
|
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
static void createBucketHeads()
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
int i, j;
|
|
|
|
|
// create the list of header indices
|
|
|
|
|
for (i = 0, j = 0; i < kMaxID; i++)
|
|
|
|
|
{
|
|
|
|
|
bucketHead[i] = (short)j;
|
|
|
|
|
while (j < bucketCount && GetBucketChannel(&rxBucket[j]) == i)
|
|
|
|
|
{
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bucketHead[i] = (short)j;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2021-12-03 20:36:32 +00:00
|
|
|
|
void evInit(TArray<DBloodActor*>& actors)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
|
|
|
|
queue.clear();
|
|
|
|
|
memset(rxBucket, 0, sizeof(rxBucket));
|
|
|
|
|
|
|
|
|
|
// add all the tags to the bucket array
|
2021-12-29 19:45:55 +00:00
|
|
|
|
for (auto& sect : sector)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-19 00:16:20 +00:00
|
|
|
|
if (sect.hasX() && sect.xs().rxID > 0)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
assert(nCount < kChannelMax);
|
2021-11-23 17:43:19 +00:00
|
|
|
|
rxBucket[nCount] = EventObject(§);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
nCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-29 19:45:55 +00:00
|
|
|
|
for (auto& wal : wall)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-19 00:16:20 +00:00
|
|
|
|
if (wal.hasX() && wal.xw().rxID > 0)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
assert(nCount < kChannelMax);
|
2021-11-23 17:43:19 +00:00
|
|
|
|
rxBucket[nCount] = EventObject(&wal);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
nCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 20:36:32 +00:00
|
|
|
|
for (auto actor : actors)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-22 15:49:41 +00:00
|
|
|
|
if (actor->exists() && actor->hasX() && actor->xspr.rxID > 0)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-03 20:36:32 +00:00
|
|
|
|
assert(nCount < kChannelMax);
|
2021-11-23 17:43:19 +00:00
|
|
|
|
rxBucket[nCount] = EventObject(actor);
|
2021-12-03 20:36:32 +00:00
|
|
|
|
nCount++;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
2021-12-03 20:36:32 +00:00
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
SortRXBucket(nCount);
|
|
|
|
|
bucketCount = nCount;
|
|
|
|
|
createBucketHeads();
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
2021-12-05 19:55:19 +00:00
|
|
|
|
static bool evGetSourceState(EventObject& eob)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (eob.isSector())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
auto pSect = eob.sector();
|
|
|
|
|
return pSect->hasX() && pSect->xs().state != 0;
|
|
|
|
|
}
|
|
|
|
|
else if (eob.isWall())
|
|
|
|
|
{
|
|
|
|
|
auto pWall = eob.wall();
|
|
|
|
|
return pWall->hasX() && pWall->xw().state != 0;
|
|
|
|
|
}
|
|
|
|
|
else if (eob.isActor())
|
|
|
|
|
{
|
|
|
|
|
auto actor = eob.actor();
|
|
|
|
|
if (actor && actor->hasX())
|
2021-12-22 15:49:41 +00:00
|
|
|
|
return actor->xspr.state != 0;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// shouldn't reach this point
|
|
|
|
|
return false;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evSend(EventObject& eob, int rxId, COMMAND_ID command, DBloodActor* initiator)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
switch (command) {
|
|
|
|
|
case kCmdState:
|
2021-11-23 17:05:24 +00:00
|
|
|
|
command = evGetSourceState(eob) ? kCmdOn : kCmdOff;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
break;
|
|
|
|
|
case kCmdNotState:
|
2021-11-23 17:05:24 +00:00
|
|
|
|
command = evGetSourceState(eob) ? kCmdOff : kCmdOn;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EVENT event;
|
2021-11-23 17:05:24 +00:00
|
|
|
|
event.target = eob;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
event.cmd = command;
|
2022-08-10 21:45:29 +00:00
|
|
|
|
event.initiator = gModernMap? initiator : nullptr;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
|
|
|
|
|
switch (rxId) {
|
|
|
|
|
case kChannelTextOver:
|
|
|
|
|
if (command >= kCmdNumberic) trTextOver(command - kCmdNumberic);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
else viewSetSystemMessage("Invalid TextOver command by %s", eob.description().GetChars());
|
2020-11-21 14:09:38 +00:00
|
|
|
|
return;
|
|
|
|
|
case kChannelLevelExitNormal:
|
|
|
|
|
levelEndLevel(0);
|
|
|
|
|
return;
|
|
|
|
|
case kChannelLevelExitSecret:
|
|
|
|
|
levelEndLevel(1);
|
|
|
|
|
return;
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
|
|
|
|
// finished level and load custom level <20> via numbered command.
|
|
|
|
|
case kChannelModernEndLevelCustom:
|
|
|
|
|
if (command >= kCmdNumberic) levelEndLevelCustom(command - kCmdNumberic);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
else viewSetSystemMessage("Invalid Level-Exit# command by %s", eob.description().GetChars());
|
2020-11-21 14:09:38 +00:00
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
case kChannelSetTotalSecrets:
|
2021-08-30 20:27:25 +00:00
|
|
|
|
if (command >= kCmdNumberic) gSecretMgr.SetCount(command - kCmdNumberic);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
else viewSetSystemMessage("Invalid Total-Secrets command by %s", eob.description().GetChars());
|
2020-11-21 14:09:38 +00:00
|
|
|
|
break;
|
|
|
|
|
case kChannelSecretFound:
|
2021-12-29 19:45:55 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
int nIndex = -1;
|
2022-03-20 11:47:23 +00:00
|
|
|
|
int nType = -1;
|
|
|
|
|
if (eob.isActor() && eob.actor()) nIndex = eob.actor()->GetIndex(), nType = Secret_Sprite;
|
|
|
|
|
else if (eob.isSector()) nIndex = eob.rawindex(), nType = Secret_Sector;
|
|
|
|
|
else if (eob.isWall()) nIndex = eob.rawindex(), nType = Secret_Wall;
|
|
|
|
|
if (SECRET_Trigger(nIndex, nType)) // if the hint system knows this secret it's a retrigger - skip that.
|
2020-12-01 11:49:24 +00:00
|
|
|
|
{
|
2021-08-30 20:27:25 +00:00
|
|
|
|
if (command >= kCmdNumberic)
|
|
|
|
|
{
|
|
|
|
|
gSecretMgr.Found(command - kCmdNumberic);
|
|
|
|
|
if (gGameOptions.nGameType == 0)
|
|
|
|
|
{
|
2022-01-22 08:38:01 +00:00
|
|
|
|
viewSetMessage(GStrings(FStringf("TXTB_SECRET%d", Random(2))), nullptr, MESSAGE_PRIORITY_SECRET);
|
2021-08-30 20:27:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-23 17:05:24 +00:00
|
|
|
|
else viewSetSystemMessage("Invalid Trigger-Secret command by %s", eob.description().GetChars());
|
2020-12-01 11:49:24 +00:00
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
break;
|
2021-11-23 17:05:24 +00:00
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
case kChannelRemoteBomb0:
|
|
|
|
|
case kChannelRemoteBomb1:
|
|
|
|
|
case kChannelRemoteBomb2:
|
|
|
|
|
case kChannelRemoteBomb3:
|
|
|
|
|
case kChannelRemoteBomb4:
|
|
|
|
|
case kChannelRemoteBomb5:
|
|
|
|
|
case kChannelRemoteBomb6:
|
|
|
|
|
case kChannelRemoteBomb7:
|
|
|
|
|
{
|
2021-08-27 14:44:24 +00:00
|
|
|
|
BloodStatIterator it(kStatThing);
|
|
|
|
|
while (auto actor = it.Next())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-22 23:41:35 +00:00
|
|
|
|
if (actor->spr.flags & 32)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
continue;
|
2021-08-27 14:44:24 +00:00
|
|
|
|
if (actor->hasX())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-23 13:21:33 +00:00
|
|
|
|
if (actor->xspr.rxID == rxId)
|
2021-09-05 06:27:34 +00:00
|
|
|
|
trMessageSprite(actor, event);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
case kChannelTeamAFlagCaptured:
|
|
|
|
|
case kChannelTeamBFlagCaptured:
|
|
|
|
|
{
|
2021-08-27 14:44:24 +00:00
|
|
|
|
BloodStatIterator it(kStatItem);
|
|
|
|
|
while (auto actor = it.Next())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-22 23:41:35 +00:00
|
|
|
|
if (actor->spr.flags & 32)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
continue;
|
2021-08-27 14:44:24 +00:00
|
|
|
|
if (actor->hasX())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-23 13:21:33 +00:00
|
|
|
|
if (actor->xspr.rxID == rxId)
|
2021-09-05 06:27:34 +00:00
|
|
|
|
trMessageSprite(actor, event);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef NOONE_EXTENSIONS
|
2021-12-29 19:45:55 +00:00
|
|
|
|
if (gModernMap)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
// allow to send commands on player sprites
|
|
|
|
|
PLAYER* pPlayer = NULL;
|
2021-12-29 19:45:55 +00:00
|
|
|
|
if (playerRXRngIsFine(rxId))
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2020-12-06 20:56:09 +00:00
|
|
|
|
if ((pPlayer = getPlayerById((rxId - kChannelPlayer7) + kMaxPlayers)) != nullptr)
|
2022-08-10 21:45:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (command == kCmdEventKillFull)
|
|
|
|
|
evKillActor(pPlayer->actor);
|
|
|
|
|
else
|
|
|
|
|
trMessageSprite(pPlayer->actor, event);
|
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
2021-12-29 19:45:55 +00:00
|
|
|
|
else if (rxId == kChannelAllPlayers)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-29 19:45:55 +00:00
|
|
|
|
for (int i = 0; i < kMaxPlayers; i++)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
if ((pPlayer = getPlayerById(i)) != nullptr)
|
2022-08-10 21:45:29 +00:00
|
|
|
|
{
|
|
|
|
|
if (command == kCmdEventKillFull)
|
|
|
|
|
evKillActor(pPlayer->actor);
|
|
|
|
|
else
|
|
|
|
|
trMessageSprite(pPlayer->actor, event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// send command on sprite which created the event sequence
|
|
|
|
|
else if (rxId == kChannelEventCauser && event.initiator != nullptr)
|
|
|
|
|
{
|
|
|
|
|
DBloodActor* einitiator = event.initiator;
|
|
|
|
|
if (!(einitiator->spr.flags & kHitagFree) && !(einitiator->spr.flags & kHitagRespawn))
|
|
|
|
|
{
|
|
|
|
|
if (command == kCmdEventKillFull)
|
|
|
|
|
evKillActor(einitiator);
|
|
|
|
|
else
|
|
|
|
|
trMessageSprite(einitiator, event);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
2022-08-10 21:45:29 +00:00
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (command == kCmdEventKillFull)
|
|
|
|
|
{
|
|
|
|
|
killEvents(rxId, command);
|
2021-12-29 19:45:55 +00:00
|
|
|
|
return;
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2021-12-29 19:45:55 +00:00
|
|
|
|
for (int i = bucketHead[rxId]; i < bucketHead[rxId + 1]; i++)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-23 17:43:19 +00:00
|
|
|
|
auto eo = rxBucket[i];
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (!event.event_isObject(eo))
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-23 17:41:18 +00:00
|
|
|
|
if (eo.isSector())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-23 19:58:30 +00:00
|
|
|
|
trMessageSector(eo.sector(), event);
|
2021-11-23 17:41:18 +00:00
|
|
|
|
}
|
|
|
|
|
else if (eo.isWall())
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-11-23 19:58:30 +00:00
|
|
|
|
trMessageWall(eo.wall(), event);
|
2021-11-23 17:41:18 +00:00
|
|
|
|
}
|
|
|
|
|
else if (eo.isActor())
|
|
|
|
|
{
|
|
|
|
|
auto actor = eo.actor();
|
2021-09-01 17:48:33 +00:00
|
|
|
|
|
2021-12-21 22:18:23 +00:00
|
|
|
|
if (actor && actor->hasX() && !(actor->spr.flags & 32))
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
2021-12-22 15:49:41 +00:00
|
|
|
|
if (actor->xspr.rxID > 0)
|
2021-09-05 06:27:34 +00:00
|
|
|
|
trMessageSprite(actor, event);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evPost_(EventObject& eob, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
assert(command != kCmdCallback);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (command == kCmdState) command = evGetSourceState(eob) ? kCmdOn : kCmdOff;
|
|
|
|
|
else if (command == kCmdNotState) command = evGetSourceState(eob) ? kCmdOff : kCmdOn;
|
2022-08-10 21:45:29 +00:00
|
|
|
|
EVENT evn = { eob, (int8_t)command, 0, PlayClock + (int)nDelta, MakeObjPtr(gModernMap ? initiator : nullptr) };
|
2020-11-21 14:09:38 +00:00
|
|
|
|
queue.insert(evn);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 17:05:24 +00:00
|
|
|
|
void evPost_(const EventObject& eob, unsigned int nDelta, CALLBACK_ID callback)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2021-12-29 19:45:55 +00:00
|
|
|
|
EVENT evn = { eob, kCmdCallback, (int16_t)callback, PlayClock + (int)nDelta };
|
2020-11-21 14:09:38 +00:00
|
|
|
|
queue.insert(evn);
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evPostActor(DBloodActor* actor, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator)
|
2020-12-03 17:00:07 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(actor);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evPost_(ev, nDelta, command, initiator);
|
2020-12-03 17:00:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 07:44:47 +00:00
|
|
|
|
void evPostActor(DBloodActor* actor, unsigned int nDelta, CALLBACK_ID callback)
|
2020-12-03 17:00:07 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
evPost_(EventObject(actor), nDelta, callback);
|
2021-08-26 20:02:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evPostSector(sectortype* sect, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator)
|
2021-08-26 20:02:55 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(sect);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evPost_(ev, nDelta, command, initiator);
|
2021-08-26 20:02:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 16:21:07 +00:00
|
|
|
|
void evPostSector(sectortype* sect, unsigned int nDelta, CALLBACK_ID callback)
|
2021-08-26 20:02:55 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
evPost_(EventObject(sect), nDelta, callback);
|
2020-12-03 17:00:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evPostWall(walltype* wal, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator)
|
2021-08-27 08:18:33 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(wal);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evPost_(ev, nDelta, command, initiator);
|
2021-08-27 08:18:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
2021-11-23 17:05:24 +00:00
|
|
|
|
void evKill_(const EventObject& eob)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
for (auto ev = queue.begin(); ev != queue.end();)
|
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (ev->event_isObject(eob)) ev = queue.erase(ev);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
else ev++;
|
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evKill_(const EventObject& eob, DBloodActor* initiator)
|
|
|
|
|
{
|
|
|
|
|
for (auto ev = queue.begin(); ev != queue.end();)
|
|
|
|
|
{
|
|
|
|
|
if (ev->event_isObject(eob) && ev->initiator.ForceGet() == initiator) ev = queue.erase(ev);
|
|
|
|
|
else ev++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 17:05:24 +00:00
|
|
|
|
void evKill_(const EventObject& eob, CALLBACK_ID cb)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
for (auto ev = queue.begin(); ev != queue.end();)
|
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (ev->event_isObject(eob) && ev->funcID == cb) ev = queue.erase(ev);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
else ev++;
|
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 07:44:47 +00:00
|
|
|
|
void evKillActor(DBloodActor* actor)
|
2020-12-03 17:00:07 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
evKill_(EventObject(actor));
|
2020-12-03 17:00:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evKillActor(DBloodActor* actor, DBloodActor* initiator)
|
|
|
|
|
{
|
|
|
|
|
if (!gModernMap)
|
|
|
|
|
evKill_(EventObject(actor));
|
|
|
|
|
else
|
|
|
|
|
evKill_(EventObject(actor), initiator);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 07:44:47 +00:00
|
|
|
|
void evKillActor(DBloodActor* actor, CALLBACK_ID cb)
|
2021-09-16 17:42:54 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
evKill_(EventObject(actor));
|
2021-09-16 17:42:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 16:45:42 +00:00
|
|
|
|
void evKillWall(walltype* wal)
|
2021-08-27 08:18:33 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
evKill_(EventObject(wal));
|
2021-08-27 08:18:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 16:45:42 +00:00
|
|
|
|
void evKillSector(sectortype* sec)
|
2021-08-27 08:18:33 +00:00
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
evKill_(EventObject(sec));
|
2021-08-27 08:18:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evKillWall(walltype* wal, DBloodActor* initiator)
|
|
|
|
|
{
|
|
|
|
|
evKill_(EventObject(wal), initiator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void evKillSector(sectortype* sec, DBloodActor* initiator)
|
|
|
|
|
{
|
|
|
|
|
evKill_(EventObject(sec), initiator);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-27 08:46:57 +00:00
|
|
|
|
// these have no target.
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evSendGame(int rxId, COMMAND_ID command, DBloodActor* initiator = nullptr)
|
2021-08-27 08:46:57 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(nullptr);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evSend(ev, rxId, command, initiator);
|
2021-08-27 08:46:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evSendActor(DBloodActor* actor, int rxId, COMMAND_ID command, DBloodActor* initiator = nullptr)
|
2021-08-27 08:46:57 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(actor);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evSend(ev, rxId, command, initiator);
|
2021-08-27 08:46:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evSendSector(sectortype* sect, int rxId, COMMAND_ID command, DBloodActor* initiator = nullptr)
|
2021-08-27 08:46:57 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(sect);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evSend(ev, rxId, command, initiator);
|
2021-08-27 08:46:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-10 21:45:29 +00:00
|
|
|
|
void evSendWall(walltype* wal, int rxId, COMMAND_ID command, DBloodActor* initiator = nullptr)
|
2021-08-27 08:46:57 +00:00
|
|
|
|
{
|
2021-12-05 19:55:19 +00:00
|
|
|
|
auto ev = EventObject(wal);
|
2022-08-10 21:45:29 +00:00
|
|
|
|
evSend(ev, rxId, command, initiator);
|
2021-08-27 08:46:57 +00:00
|
|
|
|
}
|
2021-08-27 08:18:33 +00:00
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
void evProcess(unsigned int time)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-12-31 14:48:42 +00:00
|
|
|
|
while (queue.size() > 0 && (int)time >= queue.begin()->priority)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
{
|
|
|
|
|
EVENT event = *queue.begin();
|
|
|
|
|
queue.erase(queue.begin());
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (event.target.isActor())
|
2021-09-04 08:21:19 +00:00
|
|
|
|
{
|
|
|
|
|
// Don't call events on destroyed actors. Seems to happen occasionally.
|
2021-12-21 22:18:23 +00:00
|
|
|
|
if (!event.target.actor() || event.target.actor()->spr.statnum == kStatFree) continue;
|
2021-09-04 08:21:19 +00:00
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
|
|
|
|
|
if (event.cmd == kCmdCallback)
|
|
|
|
|
{
|
|
|
|
|
assert(event.funcID < kCallbackMax);
|
2021-11-24 00:05:17 +00:00
|
|
|
|
if (event.target.isActor()) gCallback[event.funcID](event.target.actor(), nullptr);
|
|
|
|
|
else if (event.target.isSector()) gCallback[event.funcID](nullptr, event.target.sector());
|
2021-11-23 17:05:24 +00:00
|
|
|
|
// no case for walls defined here.
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
if (event.target.isActor()) trMessageSprite(event.target.actor(), event);
|
2021-11-23 19:58:30 +00:00
|
|
|
|
else if (event.target.isSector()) trMessageSector(event.target.sector(), event);
|
|
|
|
|
else if (event.target.isWall()) trMessageWall(event.target.wall(), event);
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
2021-12-29 19:45:55 +00:00
|
|
|
|
}
|
2020-11-21 14:09:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2021-11-23 17:05:24 +00:00
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, EventObject& w, EventObject* def)
|
|
|
|
|
{
|
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
|
{
|
|
|
|
|
int type = w.isActor() ? 0 : w.isSector() ? 1 : 2;
|
|
|
|
|
arc("type", type);
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
2021-12-29 19:45:55 +00:00
|
|
|
|
DBloodActor* a = arc.isWriting() ? w.actor() : nullptr;
|
2021-11-23 17:05:24 +00:00
|
|
|
|
arc("actor", a);
|
2021-11-23 18:48:14 +00:00
|
|
|
|
if (arc.isReading()) w = EventObject(a);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
2021-12-29 19:45:55 +00:00
|
|
|
|
auto s = arc.isWriting() ? w.sector() : nullptr;
|
2021-11-23 17:05:24 +00:00
|
|
|
|
arc("sector", s);
|
2021-11-23 18:48:14 +00:00
|
|
|
|
if (arc.isReading()) w = EventObject(s);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
2021-12-29 19:45:55 +00:00
|
|
|
|
auto s = arc.isWriting() ? w.wall() : nullptr;
|
2021-11-23 17:05:24 +00:00
|
|
|
|
arc("wall", s);
|
2021-11-23 18:48:14 +00:00
|
|
|
|
if (arc.isReading()) w = EventObject(s);
|
2021-11-23 17:05:24 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arc.EndObject();
|
|
|
|
|
}
|
|
|
|
|
return arc;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, EVENT& w, EVENT* def)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
if (arc.BeginObject(keyname))
|
|
|
|
|
{
|
2021-11-23 17:05:24 +00:00
|
|
|
|
arc("target", w.target)
|
|
|
|
|
("command", w.cmd)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
("func", w.funcID)
|
|
|
|
|
("prio", w.priority)
|
2022-08-10 21:45:29 +00:00
|
|
|
|
("initiator",w.initiator)
|
2020-11-21 14:09:38 +00:00
|
|
|
|
.EndObject();
|
|
|
|
|
}
|
|
|
|
|
return arc;
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//---------------------------------------------------------------------------
|
2019-09-19 22:42:45 +00:00
|
|
|
|
|
2020-11-21 14:09:38 +00:00
|
|
|
|
void SerializeEvents(FSerializer& arc)
|
2019-09-19 22:42:45 +00:00
|
|
|
|
{
|
2020-11-21 14:09:38 +00:00
|
|
|
|
if (arc.BeginObject("events"))
|
|
|
|
|
{
|
|
|
|
|
arc("bucketcount", bucketCount)
|
2020-11-27 22:34:36 +00:00
|
|
|
|
.Array("buckets", rxBucket, bucketCount)
|
|
|
|
|
.Array("buckethead", bucketHead, countof(bucketHead));
|
2020-11-21 14:09:38 +00:00
|
|
|
|
|
|
|
|
|
int numEvents = (int)queue.size();
|
|
|
|
|
arc("eventcount", numEvents);
|
|
|
|
|
if (arc.BeginArray("events"))
|
|
|
|
|
{
|
|
|
|
|
if (arc.isReading())
|
|
|
|
|
{
|
|
|
|
|
queue.clear();
|
|
|
|
|
EVENT ev;
|
|
|
|
|
for (int i = 0; i < numEvents; i++)
|
|
|
|
|
{
|
|
|
|
|
arc(nullptr, ev);
|
|
|
|
|
queue.insert(ev);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (auto item : queue)
|
|
|
|
|
{
|
|
|
|
|
arc(nullptr, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arc.EndArray();
|
|
|
|
|
}
|
|
|
|
|
arc.EndObject();
|
|
|
|
|
}
|
2019-09-19 22:42:45 +00:00
|
|
|
|
}
|
2019-09-22 06:39:22 +00:00
|
|
|
|
|
|
|
|
|
END_BLD_NS
|