forked from fte/fteqw
1
0
Fork 0

Routing: We forgot to pass the linkflags a way-file may define, fixed that

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5796 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Eukara 2020-12-29 07:22:21 +00:00
parent f152acaa12
commit a98bd4eaf6
1 changed files with 15 additions and 7 deletions

View File

@ -867,7 +867,13 @@ void Route_Calculated(void *ctx, void *data, size_t a, size_t b)
//#define FLOODALL //#define FLOODALL
#define COST_INFINITE FLT_MAX #define COST_INFINITE FLT_MAX
static qboolean Route_Completed(struct routecalc_s *r, int *nodecamefrom) typedef struct
{
int id;
int flags;
} nodefrom_t;
static qboolean Route_Completed(struct routecalc_s *r, nodefrom_t *nodecamefrom)
{ {
size_t u; size_t u;
struct waypointnetwork_s *n = r->waynet; struct waypointnetwork_s *n = r->waynet;
@ -884,11 +890,11 @@ static qboolean Route_Completed(struct routecalc_s *r, int *nodecamefrom)
for (;;) for (;;)
{ {
VectorCopy(n->waypoints[u].org, r->resultnodes[r->numresultnodes].pos); VectorCopy(n->waypoints[u].org, r->resultnodes[r->numresultnodes].pos);
r->resultnodes[r->numresultnodes].linkflags = 0; r->resultnodes[r->numresultnodes].linkflags = nodecamefrom[u].flags;
r->numresultnodes++; r->numresultnodes++;
if (u == r->startn) if (u == r->startn)
break; break;
u = nodecamefrom[u]; u = nodecamefrom[u].id;
} }
//and include the start point, because we can //and include the start point, because we can
@ -918,7 +924,7 @@ static qboolean Route_Process(struct routecalc_s *r)
float cost; float cost;
} *open = alloca(sizeof(*open)*n->numwaypoints); } *open = alloca(sizeof(*open)*n->numwaypoints);
float *nodecost = alloca(sizeof(*nodecost)*n->numwaypoints); float *nodecost = alloca(sizeof(*nodecost)*n->numwaypoints);
int *nodecamefrom = alloca(sizeof(*nodecamefrom)*n->numwaypoints); nodefrom_t *nodecamefrom = alloca(sizeof(*nodecamefrom)*n->numwaypoints);
for(u = 0; u < n->numwaypoints; u++) for(u = 0; u < n->numwaypoints; u++)
nodecost[u] = COST_INFINITE; nodecost[u] = COST_INFINITE;
@ -962,7 +968,8 @@ static qboolean Route_Process(struct routecalc_s *r)
if (realcost >= nodecost[linkidx]) if (realcost >= nodecost[linkidx])
continue; continue;
nodecamefrom[linkidx] = nodeidx; nodecamefrom[linkidx].id = nodeidx;
nodecamefrom[linkidx].flags = l->linkflags;
nodecost[linkidx] = realcost; nodecost[linkidx] = realcost;
for (j = opennodes-1; j >= 0; j--) for (j = opennodes-1; j >= 0; j--)
@ -1009,7 +1016,7 @@ static qboolean Route_Process(struct routecalc_s *r)
//we use an open list in a desperate attempt to avoid recursing the entire network //we use an open list in a desperate attempt to avoid recursing the entire network
int *open = alloca(sizeof(*open)*n->numwaypoints); int *open = alloca(sizeof(*open)*n->numwaypoints);
float *nodecost = alloca(sizeof(*nodecost)*n->numwaypoints); float *nodecost = alloca(sizeof(*nodecost)*n->numwaypoints);
int *nodecamefrom = alloca(sizeof(*nodecamefrom)*n->numwaypoints); nodefrom_t *nodecamefrom = alloca(sizeof(*nodecamefrom)*n->numwaypoints);
for(u = 0; u < n->numwaypoints; u++) for(u = 0; u < n->numwaypoints; u++)
nodecost[u] = COST_INFINITE; nodecost[u] = COST_INFINITE;
@ -1035,7 +1042,8 @@ static qboolean Route_Process(struct routecalc_s *r)
if (realcost >= nodecost[linkidx]) if (realcost >= nodecost[linkidx])
continue; continue;
nodecamefrom[linkidx] = nodeidx; nodecamefrom[linkidx].id = nodeidx;
nodecamefrom[linkidx].flags = l->linkflags;
nodecost[linkidx] = realcost; nodecost[linkidx] = realcost;
for (j = 0; j < opennodes; j++) for (j = 0; j < opennodes; j++)