mirror of
https://github.com/DrBeef/Raze.git
synced 2025-04-03 22:50:47 +00:00
- Duke: cleanup of cycler code.
Now uses a struct instead of an array with magic indices.
This commit is contained in:
parent
1c0e3d849b
commit
c3cbd1b1eb
8 changed files with 64 additions and 33 deletions
|
@ -318,21 +318,21 @@ void movecyclers(void)
|
|||
{
|
||||
for (int q = numcyclers - 1; q >= 0; q--)
|
||||
{
|
||||
short* c = &cyclers[q][0];
|
||||
int s = c[0];
|
||||
Cycler* c = &cyclers[q];
|
||||
auto sect = c->sector();
|
||||
|
||||
int t = c[3];
|
||||
int j = t + bsin(c[1], -10);
|
||||
int cshade = c[2];
|
||||
int t = c->shade2;
|
||||
int j = t + bsin(c->lotag, -10);
|
||||
int cshade = c->shade1;
|
||||
|
||||
if (j < cshade) j = cshade;
|
||||
else if (j > t) j = t;
|
||||
|
||||
c[1] += sector[s].extra;
|
||||
if (c[5])
|
||||
c->lotag += sect->extra;
|
||||
if (c->state)
|
||||
{
|
||||
auto wal = &wall[sector[s].wallptr];
|
||||
for (int x = sector[s].wallnum; x > 0; x--, wal++)
|
||||
auto wal = &wall[sect->wallptr];
|
||||
for (int x = sect->wallnum; x > 0; x--, wal++)
|
||||
if (wal->hitag != 1)
|
||||
{
|
||||
wal->shade = j;
|
||||
|
@ -341,7 +341,7 @@ void movecyclers(void)
|
|||
wall[wal->nextwall].shade = j;
|
||||
|
||||
}
|
||||
sector[s].floorshade = sector[s].ceilingshade = j;
|
||||
sect->floorshade = sect->ceilingshade = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ float cloudx;
|
|||
float cloudy;
|
||||
int cloudclock;
|
||||
int numcyclers; // sector lighting effects
|
||||
int16_t cyclers[MAXCYCLERS][6];
|
||||
Cycler cyclers[MAXCYCLERS];
|
||||
int mirrorcnt;
|
||||
int mirrorsector[64]; // mirrors
|
||||
int mirrorwall[64];
|
||||
|
|
|
@ -96,7 +96,7 @@ extern float cloudy;
|
|||
extern int cloudclock;
|
||||
|
||||
extern DDukeActor *spriteq[1024];
|
||||
extern int16_t cyclers[MAXCYCLERS][6];
|
||||
extern Cycler cyclers[MAXCYCLERS];
|
||||
extern int mirrorsector[64];
|
||||
extern int mirrorwall[64];
|
||||
|
||||
|
|
|
@ -299,12 +299,12 @@ void prelevel_d(int g)
|
|||
case CYCLER:
|
||||
if (numcyclers >= MAXCYCLERS)
|
||||
I_Error("Too many cycling sectors.");
|
||||
cyclers[numcyclers][0] = si->sectnum;
|
||||
cyclers[numcyclers][1] = si->lotag;
|
||||
cyclers[numcyclers][2] = si->shade;
|
||||
cyclers[numcyclers][3] = si->sector()->floorshade;
|
||||
cyclers[numcyclers][4] = si->hitag;
|
||||
cyclers[numcyclers][5] = (si->ang == 1536);
|
||||
cyclers[numcyclers].sectnum = si->sectnum;
|
||||
cyclers[numcyclers].lotag = si->lotag;
|
||||
cyclers[numcyclers].shade1 = si->shade;
|
||||
cyclers[numcyclers].shade2 = si->sector()->floorshade;
|
||||
cyclers[numcyclers].hitag = si->hitag;
|
||||
cyclers[numcyclers].state = (si->ang == 1536);
|
||||
numcyclers++;
|
||||
deletesprite(ac);
|
||||
break;
|
||||
|
|
|
@ -554,12 +554,12 @@ void prelevel_r(int g)
|
|||
case CYCLER:
|
||||
if (numcyclers >= MAXCYCLERS)
|
||||
I_Error("Too many cycling sectors.");
|
||||
cyclers[numcyclers][0] = si->sectnum;
|
||||
cyclers[numcyclers][1] = si->lotag;
|
||||
cyclers[numcyclers][2] = si->shade;
|
||||
cyclers[numcyclers][3] = si->sector()->floorshade;
|
||||
cyclers[numcyclers][4] = si->hitag;
|
||||
cyclers[numcyclers][5] = (si->ang == 1536);
|
||||
cyclers[numcyclers].sectnum = si->sectnum;
|
||||
cyclers[numcyclers].lotag = si->lotag;
|
||||
cyclers[numcyclers].shade1 = si->shade;
|
||||
cyclers[numcyclers].shade2 = si->sector()->floorshade;
|
||||
cyclers[numcyclers].hitag = si->hitag;
|
||||
cyclers[numcyclers].state = (si->ang == 1536);
|
||||
numcyclers++;
|
||||
deletesprite(ac);
|
||||
break;
|
||||
|
|
|
@ -298,6 +298,23 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, DDukeActor& w, DDu
|
|||
return arc;
|
||||
}
|
||||
|
||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, Cycler& w, Cycler* def)
|
||||
{
|
||||
static Cycler nul;
|
||||
if (!def) def = &nul;
|
||||
if (arc.BeginObject(keyname))
|
||||
{
|
||||
arc("sector", w.sectnum, def->sectnum)
|
||||
("lotag", w.lotag, def->lotag)
|
||||
("hitag", w.hitag, def->hitag)
|
||||
("shade1", w.shade1, def->shade1)
|
||||
("shade2", w.shade2, def->shade2)
|
||||
("state", w.state, def->state)
|
||||
.EndObject();
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
|
||||
void GameInterface::SerializeGameState(FSerializer& arc)
|
||||
{
|
||||
|
@ -366,7 +383,7 @@ void GameInterface::SerializeGameState(FSerializer& arc)
|
|||
|
||||
.Array("spriteq", spriteq, 1024)
|
||||
("numcyclers", numcyclers)
|
||||
.Array("cyclers", &cyclers[0][0], 6 * numcyclers)
|
||||
.Array("cycler", cyclers, numcyclers)
|
||||
("mirrorcnt", mirrorcnt)
|
||||
.Array("mirrorsector", mirrorsector, mirrorcnt)
|
||||
.Array("mirrorwall", mirrorwall, mirrorcnt)
|
||||
|
|
|
@ -1077,21 +1077,23 @@ void operatesectors(int sn, DDukeActor *actor)
|
|||
void operateactivators(int low, int plnum)
|
||||
{
|
||||
int i, j, k;
|
||||
short * p;
|
||||
Cycler * p;
|
||||
walltype* wal;
|
||||
|
||||
for (i = numcyclers - 1; i >= 0; i--)
|
||||
{
|
||||
p = &cyclers[i][0];
|
||||
p = &cyclers[i];
|
||||
|
||||
if (p[4] == low)
|
||||
|
||||
if (p->hitag == low)
|
||||
{
|
||||
p[5] = !p[5];
|
||||
auto sect = p->sector();
|
||||
p->state = !p->state;
|
||||
|
||||
sector[p[0]].floorshade = sector[p[0]].ceilingshade = (int8_t)p[3];
|
||||
wal = &wall[sector[p[0]].wallptr];
|
||||
for (j = sector[p[0]].wallnum; j > 0; j--, wal++)
|
||||
wal->shade = (int8_t)p[3];
|
||||
sect->floorshade = sect->ceilingshade = (int8_t)p->shade2;
|
||||
wal = &wall[sect->wallptr];
|
||||
for (j = sect->wallnum; j > 0; j--, wal++)
|
||||
wal->shade = (int8_t)p->shade2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,18 @@ struct player_struct
|
|||
|
||||
};
|
||||
|
||||
struct Cycler
|
||||
{
|
||||
int sectnum;
|
||||
int16_t lotag;
|
||||
int16_t hitag;
|
||||
int16_t shade1;
|
||||
int16_t shade2;
|
||||
bool state;
|
||||
|
||||
sectortype* sector() const { return &::sector[sectnum]; }
|
||||
};
|
||||
|
||||
// Wrapper around the insane collision info mess from Build.
|
||||
struct Collision
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue