- premap_r.cpp + dependencies.

This commit is contained in:
Christoph Oelckers 2021-12-21 21:14:27 +01:00
parent 1f40dfa411
commit edf3fd0f82
3 changed files with 85 additions and 95 deletions

View file

@ -123,24 +123,24 @@ void lava_serialize(FSerializer& arc)
("windertime", windertime); ("windertime", windertime);
} }
void addtorch(spritetype* s) void addtorch(DDukeActor* actor)
{ {
if (torchcnt >= 64) if (torchcnt >= 64)
I_Error("Too many torch effects"); I_Error("Too many torch effects");
torchsector[torchcnt] = s->sector(); torchsector[torchcnt] = actor->spr.sector();
torchsectorshade[torchcnt] = s->sector()->floorshade; torchsectorshade[torchcnt] = actor->spr.sector()->floorshade;
torchtype[torchcnt] = s->lotag; torchtype[torchcnt] = actor->spr.lotag;
torchcnt++; torchcnt++;
} }
void addlightning(spritetype* s) void addlightning(DDukeActor* actor)
{ {
if (lightnincnt >= 64) if (lightnincnt >= 64)
I_Error("Too many lightnin effects"); I_Error("Too many lightnin effects");
lightninsector[lightnincnt] = s->sector(); lightninsector[lightnincnt] = actor->spr.sector();
lightninsectorshade[lightnincnt] = s->sector()->floorshade; lightninsectorshade[lightnincnt] = actor->spr.sector()->floorshade;
lightnincnt++; lightnincnt++;
} }

View file

@ -17,8 +17,8 @@ BEGIN_DUKE_NS
void lava_cleararrays(); void lava_cleararrays();
void addjaildoor(int p1, int p2, int iht, int jlt, int p3, sectortype* h); void addjaildoor(int p1, int p2, int iht, int jlt, int p3, sectortype* h);
void addminecart(int p1, int p2, sectortype* i, int iht, int p3, sectortype* childsectnum); void addminecart(int p1, int p2, sectortype* i, int iht, int p3, sectortype* childsectnum);
void addtorch(spritetype* i); void addtorch(DDukeActor* i);
void addlightning(spritetype* i); void addlightning(DDukeActor* i);
void movecyclers(void); void movecyclers(void);
void movedummyplayers(void); void movedummyplayers(void);

View file

@ -46,17 +46,17 @@ static inline void tloadtile(int tilenum, int palnum = 0)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
static void cachespritenum(spritetype *spr) static void cachespritenum(DDukeActor* actor)
{ {
int maxc; int maxc;
int j; int j;
int pal = spr->pal; int pal = actor->spr.pal;
if (ud.monsters_off && badguy(spr)) return; if (ud.monsters_off && badguy(actor)) return;
maxc = 1; maxc = 1;
switch (spr->picnum) switch (actor->spr.picnum)
{ {
case HYDRENT: case HYDRENT:
tloadtile(BROKEFIREHYDRENT); tloadtile(BROKEFIREHYDRENT);
@ -65,7 +65,7 @@ static void cachespritenum(spritetype *spr)
break; break;
case RRTILE2121: case RRTILE2121:
case RRTILE2122: case RRTILE2122:
tloadtile(spr->picnum, pal); tloadtile(actor->spr.picnum, pal);
break; break;
case TOILET: case TOILET:
tloadtile(TOILETBROKE); tloadtile(TOILETBROKE);
@ -121,7 +121,7 @@ static void cachespritenum(spritetype *spr)
break; break;
case COW: case COW:
maxc = 56; maxc = 56;
for (j = spr->picnum; j < (spr->picnum + maxc); j++) for (j = actor->spr.picnum; j < (actor->spr.picnum + maxc); j++)
tloadtile(j, pal); tloadtile(j, pal);
maxc = 0; maxc = 0;
break; break;
@ -273,7 +273,7 @@ static void cachespritenum(spritetype *spr)
break; break;
case VIXEN: case VIXEN:
maxc = 214; maxc = 214;
for (j = spr->picnum; j < spr->picnum + maxc; j++) for (j = actor->spr.picnum; j < actor->spr.picnum + maxc; j++)
tloadtile(j, pal); tloadtile(j, pal);
maxc = 0; maxc = 0;
break; break;
@ -282,7 +282,7 @@ static void cachespritenum(spritetype *spr)
{ {
maxc = 54; maxc = 54;
for (j = spr->picnum; j < spr->picnum + maxc; j++) for (j = actor->spr.picnum; j < actor->spr.picnum + maxc; j++)
tloadtile(j, pal); tloadtile(j, pal);
maxc = 100; maxc = 100;
for (j = SBMOVE; j < SBMOVE + maxc; j++) for (j = SBMOVE; j < SBMOVE + maxc; j++)
@ -292,7 +292,7 @@ static void cachespritenum(spritetype *spr)
break; break;
case HULK: case HULK:
maxc = 40; maxc = 40;
for (j = spr->picnum - 41; j < spr->picnum + maxc - 41; j++) for (j = actor->spr.picnum - 41; j < actor->spr.picnum + maxc - 41; j++)
tloadtile(j, pal); tloadtile(j, pal);
for (j = HULKJIBA; j <= HULKJIBC + 4; j++) for (j = HULKJIBA; j <= HULKJIBC + 4; j++)
tloadtile(j, pal); tloadtile(j, pal);
@ -300,7 +300,7 @@ static void cachespritenum(spritetype *spr)
break; break;
case MINION: case MINION:
maxc = 141; maxc = 141;
for (j = spr->picnum; j < spr->picnum + maxc; j++) for (j = actor->spr.picnum; j < actor->spr.picnum + maxc; j++)
tloadtile(j, pal); tloadtile(j, pal);
for (j = MINJIBA; j <= MINJIBC + 4; j++) for (j = MINJIBA; j <= MINJIBC + 4; j++)
tloadtile(j, pal); tloadtile(j, pal);
@ -310,7 +310,7 @@ static void cachespritenum(spritetype *spr)
} }
for (j = spr->picnum; j < (spr->picnum + maxc); j++) for (j = actor->spr.picnum; j < (actor->spr.picnum + maxc); j++)
tloadtile(j, pal); tloadtile(j, pal);
} }
@ -392,10 +392,10 @@ void cacheit_r(void)
} }
DukeSectIterator it(&sect); DukeSectIterator it(&sect);
while (auto j = it.Next()) while (auto act = it.Next())
{ {
if(j->spr.xrepeat != 0 && j->spr.yrepeat != 0 && (j->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0) if(act->spr.xrepeat != 0 && act->spr.yrepeat != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
cachespritenum(j->s); cachespritenum(act);
} }
} }
precacheMarkedTiles(); precacheMarkedTiles();
@ -436,19 +436,18 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
for(auto actor : actors) for(auto actor : actors)
{ {
if (!actor->exists()) continue; if (!actor->exists()) continue;
auto spr = actor->s; if (actor->spr.pal == 100)
if (spr->pal == 100)
{ {
if (numplayers > 1) if (numplayers > 1)
deletesprite(actor); deletesprite(actor);
else else
spr->pal = 0; actor->spr.pal = 0;
} }
else if (spr->pal == 101) else if (actor->spr.pal == 101)
{ {
spr->extra = 0; actor->spr.extra = 0;
spr->hitag = 1; actor->spr.hitag = 1;
spr->pal = 0; actor->spr.pal = 0;
ChangeActorStat(actor, 118); ChangeActorStat(actor, 118);
} }
} }
@ -468,16 +467,15 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
dist = 0; dist = 0;
while (auto act = it.Next()) while (auto act = it.Next())
{ {
auto spr = act->s; if (act->spr.picnum == RRTILE11)
if (spr->picnum == RRTILE11)
{ {
dist = spr->lotag << 4; dist = act->spr.lotag << 4;
speed = spr->hitag; speed = act->spr.hitag;
deletesprite(act); deletesprite(act);
} }
if (spr->picnum == RRTILE38) if (act->spr.picnum == RRTILE38)
{ {
sound = spr->lotag; sound = act->spr.lotag;
deletesprite(act); deletesprite(act);
} }
} }
@ -500,27 +498,25 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
DukeSectIterator it(sectp); DukeSectIterator it(sectp);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
auto sj = act->s; if (act->spr.picnum == RRTILE64)
if (sj->picnum == RRTILE64)
{ {
dist = sj->lotag << 4; dist = act->spr.lotag << 4;
speed = sj->hitag; speed = act->spr.hitag;
DukeSpriteIterator itt; DukeSpriteIterator itt;
while(auto act = itt.Next()) while(auto act = itt.Next())
{ {
auto spr = act->s; if (act->spr.picnum == RRTILE66)
if (spr->picnum == RRTILE66) if (act->spr.lotag == act->spr.sectno()) // bad map format design... Should have used a tag instead...
if (spr->lotag == sj->sectno()) // bad map format design... Should have used a tag instead...
{ {
childsectnum = spr->sector(); childsectnum = act->spr.sector();
deletesprite(act); deletesprite(act);
} }
} }
deletesprite(act); deletesprite(act);
} }
if (sj->picnum == RRTILE65) if (act->spr.picnum == RRTILE65)
{ {
sound = sj->lotag; sound = act->spr.lotag;
deletesprite(act); deletesprite(act);
} }
} }
@ -533,55 +529,54 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
DukeStatIterator it(STAT_DEFAULT); DukeStatIterator it(STAT_DEFAULT);
while (auto ac = it.Next()) while (auto ac = it.Next())
{ {
auto si = ac->s;
LoadActor(ac, -1, -1); LoadActor(ac, -1, -1);
if (si->lotag == -1 && (si->cstat & CSTAT_SPRITE_ALIGNMENT_WALL)) if (ac->spr.lotag == -1 && (ac->spr.cstat & CSTAT_SPRITE_ALIGNMENT_WALL))
{ {
ps[0].exitx = si->x; ps[0].exitx = ac->spr.x;
ps[0].exity = si->y; ps[0].exity = ac->spr.y;
} }
else switch (si->picnum) else switch (ac->spr.picnum)
{ {
case NUKEBUTTON: case NUKEBUTTON:
chickenplant = 1; chickenplant = 1;
break; break;
case GPSPEED: case GPSPEED:
si->sector()->extra = si->lotag; ac->spr.sector()->extra = ac->spr.lotag;
deletesprite(ac); deletesprite(ac);
break; break;
case CYCLER: case CYCLER:
if (numcyclers >= MAXCYCLERS) if (numcyclers >= MAXCYCLERS)
I_Error("Too many cycling sectors."); I_Error("Too many cycling sectors.");
cyclers[numcyclers].sector = si->sector(); cyclers[numcyclers].sector = ac->spr.sector();
cyclers[numcyclers].lotag = si->lotag; cyclers[numcyclers].lotag = ac->spr.lotag;
cyclers[numcyclers].shade1 = si->shade; cyclers[numcyclers].shade1 = ac->spr.shade;
cyclers[numcyclers].shade2 = si->sector()->floorshade; cyclers[numcyclers].shade2 = ac->spr.sector()->floorshade;
cyclers[numcyclers].hitag = si->hitag; cyclers[numcyclers].hitag = ac->spr.hitag;
cyclers[numcyclers].state = (si->ang == 1536); cyclers[numcyclers].state = (ac->spr.ang == 1536);
numcyclers++; numcyclers++;
deletesprite(ac); deletesprite(ac);
break; break;
case RRTILE18: case RRTILE18:
addtorch(si); addtorch(ac);
deletesprite(ac); deletesprite(ac);
break; break;
case RRTILE35: case RRTILE35:
addlightning(si); addlightning(ac);
deletesprite(ac); deletesprite(ac);
break; break;
case RRTILE68: case RRTILE68:
si->sector()->shadedsector = 1; ac->spr.sector()->shadedsector = 1;
deletesprite(ac); deletesprite(ac);
break; break;
case RRTILE67: case RRTILE67:
si->cstat |= CSTAT_SPRITE_INVISIBLE; ac->spr.cstat |= CSTAT_SPRITE_INVISIBLE;
break; break;
case SOUNDFX: case SOUNDFX:
@ -589,12 +584,12 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
I_Error("Too many ambient effects"); I_Error("Too many ambient effects");
else else
{ {
ambienthitag[ambientfx] = si->hitag; ambienthitag[ambientfx] = ac->spr.hitag;
ambientlotag[ambientfx] = si->lotag; ambientlotag[ambientfx] = ac->spr.lotag;
si->ang = ambientfx; ac->spr.ang = ambientfx;
ambientfx++; ambientfx++;
si->lotag = 0; ac->spr.lotag = 0;
si->hitag = 0; ac->spr.hitag = 0;
} }
break; break;
} }
@ -603,32 +598,30 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
for (auto actor : actors) for (auto actor : actors)
{ {
if (!actor->exists()) continue; if (!actor->exists()) continue;
auto spr = actor->s; if (actor->spr.picnum == RRTILE19)
if (spr->picnum == RRTILE19)
{ {
if (geocnt > 64) if (geocnt > 64)
I_Error("Too many geometry effects"); I_Error("Too many geometry effects");
if (spr->hitag == 0) if (actor->spr.hitag == 0)
{ {
geosector[geocnt] = spr->sector(); geosector[geocnt] = actor->spr.sector();
for (auto actor2 : actors) for (auto actor2 : actors)
{ {
auto spj = actor2->s; if (actor->spr.lotag == actor2->spr.lotag && actor2 != actor && actor2->spr.picnum == RRTILE19)
if (spr->lotag == spj->lotag && actor2 != actor && spj->picnum == RRTILE19)
{ {
if (spj->hitag == 1) if (actor2->spr.hitag == 1)
{ {
geosectorwarp[geocnt] = spj->sector(); geosectorwarp[geocnt] = actor2->spr.sector();
geox[geocnt] = spr->x - spj->x; geox[geocnt] = actor->spr.x - actor2->spr.x;
geoy[geocnt] = spr->y - spj->y; geoy[geocnt] = actor->spr.y - actor2->spr.y;
//geoz[geocnt] = spr->z - spj->z; //geoz[geocnt] = actor->spr.z - actor2->spr.z;
} }
if (spj->hitag == 2) if (actor2->spr.hitag == 2)
{ {
geosectorwarp2[geocnt] = spj->sector(); geosectorwarp2[geocnt] = actor2->spr.sector();
geox2[geocnt] = spr->x - spj->x; geox2[geocnt] = actor->spr.x - actor2->spr.x;
geoy2[geocnt] = spr->y - spj->y; geoy2[geocnt] = actor->spr.y - actor2->spr.y;
//geoz2[geocnt] = spr->z - spj->z; //geoz2[geocnt] = actor->spr.z - actor2->spr.z;
} }
} }
} }
@ -641,8 +634,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
{ {
if (actor->exists()) if (actor->exists())
{ {
auto spr = actor->s; if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR)
if (spr->picnum == SECTOREFFECTOR && spr->lotag == SE_14_SUBWAY_CAR)
continue; continue;
spriteinit_r(actor, actors); spriteinit_r(actor, actors);
} }
@ -652,14 +644,13 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
{ {
if (actor->exists()) if (actor->exists())
{ {
auto spr = actor->s; if (actor->spr.picnum == SECTOREFFECTOR && actor->spr.lotag == SE_14_SUBWAY_CAR)
if (spr->picnum == SECTOREFFECTOR && spr->lotag == SE_14_SUBWAY_CAR)
spriteinit_r(actor, actors); spriteinit_r(actor, actors);
if (spr->picnum == RRTILE19) if (actor->spr.picnum == RRTILE19)
deletesprite(actor); deletesprite(actor);
if (spr->picnum == RRTILE34) if (actor->spr.picnum == RRTILE34)
{ {
spr->sector()->keyinfo = uint8_t(spr->lotag); actor->spr.sector()->keyinfo = uint8_t(actor->spr.lotag);
deletesprite(actor); deletesprite(actor);
} }
} }
@ -670,8 +661,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
it.Reset(STAT_DEFAULT); it.Reset(STAT_DEFAULT);
while (auto ac = it.Next()) while (auto ac = it.Next())
{ {
auto spr = ac->s; switch (ac->spr.picnum)
switch (spr->picnum)
{ {
case RRTILE8464 + 1: case RRTILE8464 + 1:
if (!isRRRA()) break; if (!isRRRA()) break;
@ -693,12 +683,12 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
case NUKEBUTTON + 1: case NUKEBUTTON + 1:
for (j = 0; j < lotaglist; j++) for (j = 0; j < lotaglist; j++)
if (spr->lotag == lotags[j]) if (ac->spr.lotag == lotags[j])
break; break;
if (j == lotaglist) if (j == lotaglist)
{ {
lotags[lotaglist] = spr->lotag; lotags[lotaglist] = ac->spr.lotag;
lotaglist++; lotaglist++;
if (lotaglist > 64) if (lotaglist > 64)
I_Error("Too many switches (64 max)."); I_Error("Too many switches (64 max).");
@ -706,7 +696,7 @@ void prelevel_r(int g, TArray<DDukeActor*>& actors)
DukeStatIterator it1(STAT_EFFECTOR); DukeStatIterator it1(STAT_EFFECTOR);
while (auto j = it1.Next()) while (auto j = it1.Next())
{ {
if (j->spr.lotag == 12 && j->spr.hitag == spr->lotag) if (j->spr.lotag == 12 && j->spr.hitag == ac->spr.lotag)
j->temp_data[0] = 1; j->temp_data[0] = 1;
} }
} }