- track stuff

This commit is contained in:
Christoph Oelckers 2021-11-25 18:16:56 +01:00
parent b3eceb3b56
commit 1457cf2c0d
9 changed files with 35 additions and 40 deletions

View file

@ -486,7 +486,7 @@ int DoActorOperate(DSWActor* actor)
if (nearsector >= 0 && nearhitdist < 1024) if (nearsector >= 0 && nearhitdist < 1024)
{ {
if (OperateSector(nearsector, false)) if (OperateSector(&sector[nearsector], false))
{ {
u->WaitTics = 2 * 120; u->WaitTics = 2 * 120;

View file

@ -1646,12 +1646,15 @@ struct SECTOR_OBJECTstruct
DSWActor* so_actors[MAX_SO_SPRITE]; // hold the actors of the object DSWActor* so_actors[MAX_SO_SPRITE]; // hold the actors of the object
DSWActor* match_event_actor; // spritenum of the match event sprite DSWActor* match_event_actor; // spritenum of the match event sprite
sectortype* sectortype
sectp[MAX_SO_SECTOR], *sectp[MAX_SO_SECTOR],
*scratch, // Just a filler to account for shitty loop tests. *scratch, // Just a filler to account for shitty loop tests.
*op_main_sector, // main sector operational SO moves in - for speed purposes *op_main_sector, // main sector operational SO moves in - for speed purposes
*mid_sector; // middle sector *mid_sector; // middle sector
walltype
* morph_wall_point; // actual wall point to drag
int vel, // velocity int vel, // velocity
vel_tgt, // target velocity vel_tgt, // target velocity
@ -1735,7 +1738,6 @@ struct SECTOR_OBJECTstruct
scale_y_mult, // y multiplyer for scaling scale_y_mult, // y multiplyer for scaling
// Used for center point movement // Used for center point movement
morph_wall_point, // actual wall point to drag
morph_ang, // angle moving from CENTER morph_ang, // angle moving from CENTER
morph_speed, // speed of movement morph_speed, // speed of movement
morph_dist_max, // radius boundry morph_dist_max, // radius boundry
@ -2080,7 +2082,7 @@ void LoadGameDescr(short save_num, char *descr); // save.c
void SetRotatorActive(DSWActor* actor); // rotator.c void SetRotatorActive(DSWActor* actor); // rotator.c
bool VatorSwitch(short match, short setting); // vator.c bool VatorSwitch(short match, short setting); // vator.c
void MoveSpritesWithSector(int sectnum,int z_amt,bool type); // vator.c void MoveSpritesWithSector(sectortype* sect,int z_amt,bool type); // vator.c
void SetVatorActive(DSWActor*); // vator.c void SetVatorActive(DSWActor*); // vator.c
void DoSpikeMatch(short match); // spike.c void DoSpikeMatch(short match); // spike.c

View file

@ -311,7 +311,7 @@ MorphTornado(SECTOR_OBJECTp sop)
sop->morph_z += Z(sop->morph_z_speed); sop->morph_z += Z(sop->morph_z_speed);
// move vector // move vector
if (sop->morph_wall_point < 0) if (sop->morph_wall_point == nullptr)
return; return;
// place at correct x,y offset from center // place at correct x,y offset from center
@ -392,7 +392,7 @@ MorphFloor(SECTOR_OBJECTp sop)
sop->morph_z -= Z(sop->morph_z_speed); sop->morph_z -= Z(sop->morph_z_speed);
// move vector // move vector
if (sop->morph_wall_point < 0) if (sop->morph_wall_point == nullptr)
return; return;
// place at correct x,y offset from center // place at correct x,y offset from center
@ -520,7 +520,7 @@ SpikeFloor(SECTOR_OBJECTp sop)
sop->morph_z -= Z(sop->morph_z_speed); sop->morph_z -= Z(sop->morph_z_speed);
// move vector // move vector
if (sop->morph_wall_point < 0) if (sop->morph_wall_point == nullptr)
return; return;
// place at correct x,y offset from center // place at correct x,y offset from center

View file

@ -61,7 +61,7 @@ BEGIN_SW_NS
void pSpriteControl(PLAYERp pp); void pSpriteControl(PLAYERp pp);
int WeaponOperate(PLAYERp pp); int WeaponOperate(PLAYERp pp);
SECTOR_OBJECTp PlayerOnObject(short sectnum_match); SECTOR_OBJECTp PlayerOnObject(sectortype* sect_match);
void PlayerRemoteReset(PLAYERp pp, sectortype* sect); void PlayerRemoteReset(PLAYERp pp, sectortype* sect);
void KillAllPanelInv(PLAYERp pp); void KillAllPanelInv(PLAYERp pp);
void DoPlayerDeathDrown(PLAYERp pp); void DoPlayerDeathDrown(PLAYERp pp);
@ -4963,7 +4963,7 @@ void DoPlayerBeginOperate(PLAYERp pp)
int cz, fz; int cz, fz;
int i; int i;
sop = PlayerOnObject(pp->cursectnum); sop = PlayerOnObject(pp->cursector());
// if someone already controlling it // if someone already controlling it
if (sop->controller) if (sop->controller)

View file

@ -383,6 +383,7 @@ void SectorSetup(void)
SectorObject[ndx].sp_child = nullptr; SectorObject[ndx].sp_child = nullptr;
SectorObject[ndx].mid_sector = nullptr; SectorObject[ndx].mid_sector = nullptr;
SectorObject[ndx].op_main_sector = nullptr; SectorObject[ndx].op_main_sector = nullptr;
SectorObject[ndx].morph_wall_point = nullptr;
SectorObject[ndx].xmid = INT32_MAX; SectorObject[ndx].xmid = INT32_MAX;
} }
@ -689,10 +690,9 @@ short DoSpawnActorTrigger(short match)
return spawn_count; return spawn_count;
} }
int OperateSector(short sectnum, short player_is_operating) int OperateSector(sectortype* sect, short player_is_operating)
{ {
PLAYERp pp = GlobPlayerP; PLAYERp pp = GlobPlayerP;
auto sect = &sector[sectnum];
// Don't let actors operate locked or secret doors // Don't let actors operate locked or secret doors
if (!player_is_operating) if (!player_is_operating)
@ -2349,7 +2349,7 @@ void PlayerOperateEnv(PLAYERp pp)
if (neartagsector >= 0 && neartaghitdist < 1024) if (neartagsector >= 0 && neartaghitdist < 1024)
{ {
if (OperateSector(neartagsector, true)) if (OperateSector(&sector[neartagsector], true))
{ {
// Release the key // Release the key
pp->KeyPressBits &= ~SB_OPEN; pp->KeyPressBits &= ~SB_OPEN;
@ -2382,7 +2382,7 @@ void PlayerOperateEnv(PLAYERp pp)
pp->KeyPressBits &= ~SB_OPEN; pp->KeyPressBits &= ~SB_OPEN;
break; break;
case TAG_DOOR_ROTATE: case TAG_DOOR_ROTATE:
if (OperateSector(pp->cursectnum, true)) if (OperateSector(pp->cursector(), true))
pp->KeyPressBits &= ~SB_OPEN; pp->KeyPressBits &= ~SB_OPEN;
break; break;
} }

View file

@ -40,7 +40,7 @@ void DoDoorsClose(void);
short Switch(short SwitchSector); short Switch(short SwitchSector);
void PlayerOperateEnv(PLAYERp pp); void PlayerOperateEnv(PLAYERp pp);
int TeleportToSector(PLAYERp pp, int newsector); int TeleportToSector(PLAYERp pp, int newsector);
int OperateSector(short sectnum,short player_is_operating); int OperateSector(sectortype* sect,short player_is_operating);
int OperateSprite(DSWActor*, short player_is_operating); int OperateSprite(DSWActor*, short player_is_operating);
int OperateWall(short wallnum, short player_is_operating); int OperateWall(short wallnum, short player_is_operating);
void OperateTripTrigger(PLAYERp pp); void OperateTripTrigger(PLAYERp pp);

View file

@ -2149,7 +2149,7 @@ void SpriteSetup(void)
sectp->floorz += amt; sectp->floorz += amt;
u->z_tgt = u->sz; u->z_tgt = u->sz;
MoveSpritesWithSector(sp->sectnum, amt, false); // floor MoveSpritesWithSector(sp->sector(), amt, false); // floor
} }
// set orig z // set orig z
@ -2170,7 +2170,7 @@ void SpriteSetup(void)
sectp->ceilingz += amt; sectp->ceilingz += amt;
u->z_tgt = u->sz; u->z_tgt = u->sz;
MoveSpritesWithSector(sp->sectnum, amt, true); // ceiling MoveSpritesWithSector(sp->sector(), amt, true); // ceiling
} }
// set orig z // set orig z

View file

@ -116,16 +116,15 @@ point to the sprite.
*/ */
short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int *track_point_num, int *track_dir) short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int* track_point_num, int* track_dir)
{ {
USERp u = actor->u(); USERp u = actor->u();
SPRITEp sp = &actor->s(); SPRITEp sp = &actor->s();
int dist, near_dist = 999999, zdiff; int dist, near_dist = 999999, zdiff;
int track_sect=0;
int i; int i;
short end_point[2] = {0,0}; short end_point[2] = { 0,0 };
TRACKp t, near_track = nullptr; TRACKp t, near_track = nullptr;
TRACK_POINTp tp, near_tp = nullptr; TRACK_POINTp tp, near_tp = nullptr;
@ -251,25 +250,19 @@ short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int *tr
} }
auto track_sect = &sector[0];
if (near_dist < 15000) if (near_dist < 15000)
{ {
// get the sector number of the point // get the sector number of the point
updatesector(near_tp->x, near_tp->y, &track_sect); updatesector(near_tp->x, near_tp->y, &track_sect);
// if can see the point, return the track number // if can see the point, return the track number
if (FAFcansee(sp->x, sp->y, sp->z - Z(16), sp->sector(), near_tp->x, near_tp->y, sector[track_sect].floorz - Z(32), &sector[track_sect])) if (track_sect && FAFcansee(sp->x, sp->y, sp->z - Z(16), sp->sector(), near_tp->x, near_tp->y, track_sect->floorz - Z(32), track_sect))
{ {
//DSPRINTF(ds,"Found track point in sector %d\n",track_sect);
MONO_PRINT(ds);
return short(near_track - &Track[0]); return short(near_track - &Track[0]);
} }
return -1;
}
else
{
return -1;
} }
return -1;
} }
@ -844,7 +837,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECTp sop)
{ {
// for morph point - tornado style // for morph point - tornado style
if (wal.lotag == TAG_WALL_ALIGN_SLOPE_TO_POINT) if (wal.lotag == TAG_WALL_ALIGN_SLOPE_TO_POINT)
sop->morph_wall_point = k; sop->morph_wall_point = &wal;
if (wal.extra && TEST(wal.extra, WALLFX_LOOP_OUTER)) if (wal.extra && TEST(wal.extra, WALLFX_LOOP_OUTER))
FoundOutsideLoop = true; FoundOutsideLoop = true;
@ -1033,6 +1026,8 @@ void SetupSectorObject(sectortype* sectp, short tag)
memset(sop->sectp, 0, sizeof(sop->sectp)); memset(sop->sectp, 0, sizeof(sop->sectp));
memset(sop->so_actors, 0, sizeof(sop->so_actors)); memset(sop->so_actors, 0, sizeof(sop->so_actors));
sop->morph_wall_point = nullptr;
sop->op_main_sector = nullptr;
sop->scratch = nullptr; // this is a guard field for sectp, because several loops do not test the end properly. sop->scratch = nullptr; // this is a guard field for sectp, because several loops do not test the end properly.
sop->match_event_actor = nullptr; sop->match_event_actor = nullptr;
sop->crush_z = 0; sop->crush_z = 0;
@ -1411,11 +1406,10 @@ void PostSetupSectorObject(void)
} }
SECTOR_OBJECTp PlayerOnObject(short sectnum_match) SECTOR_OBJECTp PlayerOnObject(sectortype* match)
{ {
short i, j; short i, j;
SECTOR_OBJECTp sop; SECTOR_OBJECTp sop;
auto match = &sector[sectnum_match];
// place each sector object on the track // place each sector object on the track
//for (i = 0; !SO_EMPTY(&SectorObject[i]) && (i < MAX_SECTOR_OBJECTS); i++) //for (i = 0; !SO_EMPTY(&SectorObject[i]) && (i < MAX_SECTOR_OBJECTS); i++)
@ -3256,7 +3250,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor)
if (nearsector >= 0 && nearhitdist < 1024) if (nearsector >= 0 && nearhitdist < 1024)
{ {
if (OperateSector(nearsector, false)) if (OperateSector(&sector[nearsector], false))
{ {
if (!tpoint->tag_high) if (!tpoint->tag_high)
u->WaitTics = 2 * 120; u->WaitTics = 2 * 120;

View file

@ -295,15 +295,14 @@ void InterpSectorSprites(short sectnum, bool state)
} }
} }
void MoveSpritesWithSector(int sectnum, int z_amt, bool type) void MoveSpritesWithSector(sectortype* sect, int z_amt, bool type)
{ {
SPRITEp sp; SPRITEp sp;
bool both = false; bool both = false;
auto sect = &sector[sectnum];
if ( sect->hasU()) if ( sect->hasU())
both = !!TEST(sect->flags, SECTFU_VATOR_BOTH); both = !!TEST(sect->flags, SECTFU_VATOR_BOTH);
SWSectIterator it(sectnum); SWSectIterator it(sect);
while (auto actor = it.Next()) while (auto actor = it.Next())
{ {
sp = &actor->s(); sp = &actor->s();
@ -417,13 +416,13 @@ int DoVator(DSWActor* actor)
{ {
lptr = &sectp->ceilingz; lptr = &sectp->ceilingz;
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(sp->sectnum, amt, true); // ceiling MoveSpritesWithSector(sp->sector(), amt, true); // ceiling
} }
else else
{ {
lptr = &sectp->floorz; lptr = &sectp->floorz;
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(sp->sectnum, amt, false); // floor MoveSpritesWithSector(sp->sector(), amt, false); // floor
} }
// EQUAL this entry has finished // EQUAL this entry has finished
@ -579,13 +578,13 @@ int DoVatorAuto(DSWActor* actor)
{ {
lptr = &sectp->ceilingz; lptr = &sectp->ceilingz;
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(sp->sectnum, amt, true); // ceiling MoveSpritesWithSector(sp->sector(), amt, true); // ceiling
} }
else else
{ {
lptr = &sectp->floorz; lptr = &sectp->floorz;
amt = DoVatorMove(actor, lptr); amt = DoVatorMove(actor, lptr);
MoveSpritesWithSector(sp->sectnum, amt, false); // floor MoveSpritesWithSector(sp->sector(), amt, false); // floor
} }
// EQUAL this entry has finished // EQUAL this entry has finished