T_PolyObjWaypoint: We can find waypoints in constant time now, so no need to store the waypoint mobj in the thinker anymore

This commit is contained in:
MascaraSnake 2020-05-16 09:03:02 +02:00
parent 1057c0f7c1
commit 3680b246c9
3 changed files with 1 additions and 21 deletions

View File

@ -1618,7 +1618,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
if (!po->thinker) if (!po->thinker)
po->thinker = &th->thinker; po->thinker = &th->thinker;
target = th->target; target = waypoints[th->sequence][th->pointnum];
if (!target) if (!target)
{ {
@ -1696,8 +1696,6 @@ void T_PolyObjWaypoint(polywaypoint_t *th)
target = waypoint; target = waypoint;
th->pointnum = target->health; th->pointnum = target->health;
// Set the mobj as your target! -- Monster Iestyn 27/12/19
P_SetTarget(&th->target, target);
// Calculate remaining speed // Calculate remaining speed
speed -= dist; speed -= dist;
@ -2206,9 +2204,6 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata)
// Set pointnum // Set pointnum
th->pointnum = target->health; th->pointnum = target->health;
th->target = NULL; // set to NULL first so the below doesn't go wrong
// Set the mobj as your target! -- Monster Iestyn 27/12/19
P_SetTarget(&th->target, target);
// We don't deal with the mirror crap here, we'll // We don't deal with the mirror crap here, we'll
// handle that in the T_Thinker function. // handle that in the T_Thinker function.

View File

@ -160,8 +160,6 @@ typedef struct polywaypoint_s
UINT8 returnbehavior; // behavior after reaching the last waypoint UINT8 returnbehavior; // behavior after reaching the last waypoint
UINT8 continuous; // continuously move - used with PWR_WRAP or PWR_COMEBACK UINT8 continuous; // continuously move - used with PWR_WRAP or PWR_COMEBACK
UINT8 stophere; // Will stop after it reaches the next waypoint UINT8 stophere; // Will stop after it reaches the next waypoint
mobj_t *target; // next waypoint mobj
} polywaypoint_t; } polywaypoint_t;
typedef struct polyslidedoor_s typedef struct polyslidedoor_s

View File

@ -2022,7 +2022,6 @@ static void SavePolywaypointThinker(const thinker_t *th, UINT8 type)
WRITEUINT8(save_p, ht->returnbehavior); WRITEUINT8(save_p, ht->returnbehavior);
WRITEUINT8(save_p, ht->continuous); WRITEUINT8(save_p, ht->continuous);
WRITEUINT8(save_p, ht->stophere); WRITEUINT8(save_p, ht->stophere);
WRITEUINT32(save_p, SaveMobjnum(ht->target));
} }
static void SavePolyslidedoorThinker(const thinker_t *th, const UINT8 type) static void SavePolyslidedoorThinker(const thinker_t *th, const UINT8 type)
@ -3163,7 +3162,6 @@ static inline thinker_t* LoadPolywaypointThinker(actionf_p1 thinker)
ht->returnbehavior = READUINT8(save_p); ht->returnbehavior = READUINT8(save_p);
ht->continuous = READUINT8(save_p); ht->continuous = READUINT8(save_p);
ht->stophere = READUINT8(save_p); ht->stophere = READUINT8(save_p);
ht->target = LoadMobj(READUINT32(save_p));
return &ht->thinker; return &ht->thinker;
} }
@ -3410,7 +3408,6 @@ static void P_NetUnArchiveThinkers(void)
case tc_polywaypoint: case tc_polywaypoint:
th = LoadPolywaypointThinker((actionf_p1)T_PolyObjWaypoint); th = LoadPolywaypointThinker((actionf_p1)T_PolyObjWaypoint);
restoreNum = true;
break; break;
case tc_polyslidedoor: case tc_polyslidedoor:
@ -3470,7 +3467,6 @@ static void P_NetUnArchiveThinkers(void)
if (restoreNum) if (restoreNum)
{ {
executor_t *delay = NULL; executor_t *delay = NULL;
polywaypoint_t *polywp = NULL;
UINT32 mobjnum; UINT32 mobjnum;
for (currentthinker = thlist[THINK_MAIN].next; currentthinker != &thlist[THINK_MAIN]; currentthinker = currentthinker->next) for (currentthinker = thlist[THINK_MAIN].next; currentthinker != &thlist[THINK_MAIN]; currentthinker = currentthinker->next)
{ {
@ -3481,15 +3477,6 @@ static void P_NetUnArchiveThinkers(void)
continue; continue;
delay->caller = P_FindNewPosition(mobjnum); delay->caller = P_FindNewPosition(mobjnum);
} }
for (currentthinker = thlist[THINK_POLYOBJ].next; currentthinker != &thlist[THINK_POLYOBJ]; currentthinker = currentthinker->next)
{
if (currentthinker->function.acp1 != (actionf_p1)T_PolyObjWaypoint)
continue;
polywp = (void *)currentthinker;
if (!(mobjnum = (UINT32)(size_t)polywp->target))
continue;
polywp->target = P_FindNewPosition(mobjnum);
}
} }
} }