@@ -1033,12 +1033,13 @@ static int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, in
10331033 int water_bestarea2groundedgenum , water_foundreach ;
10341034 int side1 , area1swim , faceside1 , groundface1num ;
10351035 float dist , dist1 , dist2 , diff , ortdot ;
1036+ // float invgravitydot;
10361037 float x1 , x2 , x3 , x4 , y1 , y2 , y3 , y4 , tmp , y ;
10371038 float length , ground_bestlength , water_bestlength , ground_bestdist , water_bestdist ;
10381039 vec3_t v1 , v2 , v3 , v4 , tmpv , p1area1 , p1area2 , p2area1 , p2area2 ;
10391040 vec3_t normal , ort , edgevec , start , end , dir ;
1040- vec3_t ground_beststart , ground_bestend , ground_bestnormal ;
1041- vec3_t water_beststart , water_bestend , water_bestnormal ;
1041+ vec3_t ground_beststart = { 0 , 0 , 0 }, ground_bestend = { 0 , 0 , 0 }, ground_bestnormal = { 0 , 0 , 0 } ;
1042+ vec3_t water_beststart = { 0 , 0 , 0 }, water_bestend = { 0 , 0 , 0 }, water_bestnormal = { 0 , 0 , 0 } ;
10421043 vec3_t invgravity = {0 , 0 , 1 };
10431044 vec3_t testpoint ;
10441045 aas_plane_t * plane ;
@@ -1143,6 +1144,7 @@ static int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, in
11431144 // edges if they overlap in the direction orthogonal to
11441145 // the gravity direction
11451146 CrossProduct (invgravity , normal , ort );
1147+ // invgravitydot = DotProduct(invgravity, invgravity);
11461148 ortdot = DotProduct (ort , ort );
11471149 // projection into the step plane
11481150 // NOTE: since gravity is vertical this is just the z coordinate
@@ -1506,7 +1508,7 @@ static int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, in
15061508 trace .endpos [2 ] += 1 ;
15071509 if (AAS_PointAreaNum (trace .endpos ) == area2num ) {
15081510 // if not going through a cluster portal
1509- numareas = AAS_TraceAreas (start , end , areas , NULL , sizeof (areas ) / sizeof ( int ));
1511+ numareas = AAS_TraceAreas (start , end , areas , NULL , ARRAY_LEN (areas ));
15101512 for (i = 0 ; i < numareas ; i ++ )
15111513 if (AAS_AreaClusterPortal (areas [i ]))
15121514 break ;
@@ -2032,7 +2034,7 @@ static int AAS_Reachability_Jump(int area1num, int area2num) {
20322034 int stopevent , areas [10 ], numareas ;
20332035 float phys_jumpvel , maxjumpdistance , maxjumpheight , height , bestdist , speed ;
20342036 vec_t * v1 , * v2 , * v3 , * v4 ;
2035- vec3_t beststart , beststart2 , bestend , bestend2 ;
2037+ vec3_t beststart = { 0 } , beststart2 = { 0 } , bestend = { 0 } , bestend2 = { 0 } ;
20362038 vec3_t teststart , testend , dir , velocity , cmdmove , up = {0 , 0 , 1 }, sidewards ;
20372039 aas_area_t * area1 , * area2 ;
20382040 aas_face_t * face1 , * face2 ;
@@ -2220,7 +2222,7 @@ static int AAS_Reachability_Jump(int area1num, int area2num) {
22202222 // because the predicted jump could have rushed through the area
22212223 VectorMA (move .endpos , -64 , dir , teststart );
22222224 teststart [2 ] += 1 ;
2223- numareas = AAS_TraceAreas (move .endpos , teststart , areas , NULL , sizeof (areas ) / sizeof ( int ));
2225+ numareas = AAS_TraceAreas (move .endpos , teststart , areas , NULL , ARRAY_LEN (areas ));
22242226 for (j = 0 ; j < numareas ; j ++ ) {
22252227 if (areas [j ] == area2num )
22262228 break ;
@@ -2281,16 +2283,16 @@ static int AAS_Reachability_Jump(int area1num, int area2num) {
22812283// Returns: -
22822284// Changes Globals: -
22832285//===========================================================================
2284- int AAS_Reachability_Ladder (int area1num , int area2num ) {
2285- int i , j , k , l , edge1num , edge2num , sharededgenum , lowestedgenum ;
2286- int face1num , face2num , ladderface1num , ladderface2num ;
2286+ static int AAS_Reachability_Ladder (int area1num , int area2num ) {
2287+ int i , j , k , l , edge1num , edge2num , sharededgenum = 0 , lowestedgenum = 0 ;
2288+ int face1num , face2num , ladderface1num = 0 , ladderface2num = 0 ;
22872289 int ladderface1vertical , ladderface2vertical , firstv ;
2288- float face1area , face2area , bestface1area , bestface2area ;
2290+ float face1area , face2area , bestface1area = -9999 , bestface2area = -9999 ;
22892291 float phys_jumpvel , maxjumpheight ;
22902292 vec3_t area1point , area2point , v1 , v2 , up = {0 , 0 , 1 };
2291- vec3_t mid , lowestpoint , start , end , sharededgevec , dir ;
2293+ vec3_t mid , lowestpoint = { 0 , 0 } , start , end , sharededgevec , dir ;
22922294 aas_area_t * area1 , * area2 ;
2293- aas_face_t * face1 , * face2 , * ladderface1 , * ladderface2 ;
2295+ aas_face_t * face1 , * face2 , * ladderface1 = NULL , * ladderface2 = NULL ;
22942296 aas_plane_t * plane1 , * plane2 ;
22952297 aas_edge_t * sharededge , * edge1 ;
22962298 aas_lreachability_t * lreach ;
@@ -2305,16 +2307,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num) {
23052307
23062308 area1 = & aasworld .areas [area1num ];
23072309 area2 = & aasworld .areas [area2num ];
2308- //
2309- ladderface1 = NULL ;
2310- ladderface2 = NULL ;
2311- ladderface1num = 0 ; // make compiler happy
2312- ladderface2num = 0 ; // make compiler happy
2313- bestface1area = -9999 ;
2314- bestface2area = -9999 ;
2315- sharededgenum = 0 ; // make compiler happy
2316- lowestedgenum = 0 ; // make compiler happy
2317- //
2310+
23182311 for (i = 0 ; i < area1 -> numfaces ; i ++ ) {
23192312 face1num = aasworld .faceindex [area1 -> firstface + i ];
23202313 face1 = & aasworld .faces [abs (face1num )];
@@ -2378,18 +2371,18 @@ int AAS_Reachability_Ladder(int area1num, int area2num) {
23782371 VectorMA (area1point , -32 , dir , area1point );
23792372 VectorMA (area2point , 32 , dir , area2point );
23802373 //
2381- ladderface1vertical = fabs (DotProduct (plane1 -> normal , up )) < 0.1f ;
2382- ladderface2vertical = fabs (DotProduct (plane2 -> normal , up )) < 0.1f ;
2374+ ladderface1vertical = fabsf (DotProduct (plane1 -> normal , up )) < 0.1 ;
2375+ ladderface2vertical = fabsf (DotProduct (plane2 -> normal , up )) < 0.1 ;
23832376 // there's only reachability between vertical ladder faces
23842377 if (!ladderface1vertical && !ladderface2vertical )
23852378 return qfalse ;
23862379 // if both vertical ladder faces
23872380 if (ladderface1vertical &&
23882381 ladderface2vertical
23892382 // and the ladder faces do not make a sharp corner
2390- && DotProduct (plane1 -> normal , plane2 -> normal ) > 0.7f
2383+ && DotProduct (plane1 -> normal , plane2 -> normal ) > 0.7
23912384 // and the shared edge is not too vertical
2392- && fabs (DotProduct (sharededgevec , up )) < 0.7f ) {
2385+ && fabsf (DotProduct (sharededgevec , up )) < 0.7 ) {
23932386 // create a new reachability link
23942387 lreach = AAS_AllocReachability ();
23952388 if (!lreach )
@@ -2510,7 +2503,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num) {
25102503 //
25112504 if (face2 -> faceflags & FACE_LADDER ) {
25122505 plane2 = & aasworld .planes [face2 -> planenum ];
2513- if (fabs (DotProduct (plane2 -> normal , up )) < 0.1f )
2506+ if (fabsf (DotProduct (plane2 -> normal , up )) < 0.1 )
25142507 break ;
25152508 } // end if
25162509 } // end for
@@ -3115,7 +3108,7 @@ static aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int n
31153108 int facenum , edgenum , bestfacenum ;
31163109 float * v1 , * v2 , * v3 , * v4 ;
31173110 float bestdist , speed , hordist , dist ;
3118- vec3_t beststart , beststart2 , bestend , bestend2 , tmp , hordir , testpoint ;
3111+ vec3_t beststart = { 0 } , beststart2 = { 0 } , bestend = { 0 } , bestend2 = { 0 } , tmp , hordir , testpoint ;
31193112 aas_lreachability_t * lreach , * lreachabilities ;
31203113 aas_area_t * area ;
31213114 aas_face_t * face ;
@@ -3462,6 +3455,7 @@ static void AAS_Reachability_JumpPad(void) {
34623455 // int modelnum, ent2;
34633456 // float dist, time, height, gravity, forward;
34643457 float speed , zvel ;
3458+ // float hordist;
34653459 aas_face_t * face2 ;
34663460 aas_area_t * area2 ;
34673461 aas_lreachability_t * lreach ;
@@ -3685,6 +3679,8 @@ static void AAS_Reachability_JumpPad(void) {
36853679 // direction towards the face center
36863680 VectorSubtract (facecenter , areastart , dir );
36873681 dir [2 ] = 0 ;
3682+ // hordist = VectorNormalize(dir);
3683+ // if (hordist < 1.6 * facecenter[2] - areastart[2])
36883684 {
36893685 // get command movement
36903686 VectorScale (dir , speed , cmdmove );
@@ -3696,7 +3692,8 @@ static void AAS_Reachability_JumpPad(void) {
36963692 area2num , visualize );
36973693 // if prediction time wasn't enough to fully predict the movement
36983694 // don't enter slime or lava and don't fall from too high
3699- if (move .frames < 30 && !(move .stopevent & (SE_ENTERSLIME | SE_ENTERLAVA )) &&
3695+ if (move .frames < 30 &&
3696+ !(move .stopevent & (SE_ENTERSLIME | SE_ENTERLAVA )) &&
37003697 (move .stopevent & (SE_HITGROUNDAREA | SE_TOUCHJUMPPAD | SE_TOUCHTELEPORTER ))) {
37013698 // never go back to the same jumppad
37023699 for (link = areas ; link ; link = link -> next_area ) {
@@ -3755,7 +3752,7 @@ static int AAS_Reachability_Grapple(int area1num, int area2num) {
37553752 aas_face_t * face2 ;
37563753 aas_area_t * area1 , * area2 ;
37573754 aas_lreachability_t * lreach ;
3758- vec3_t areastart , facecenter , start , end , dir , down = {0 , 0 , -1 };
3755+ vec3_t areastart = { 0 , 0 , 0 } , facecenter , start , end , dir , down = {0 , 0 , -1 };
37593756 vec_t * v ;
37603757
37613758 // only grapple when on the ground or swimming
@@ -3970,6 +3967,7 @@ static void AAS_SetWeaponJumpAreaFlags(void) {
39703967int AAS_Reachability_WeaponJump (int area1num , int area2num ) {
39713968 int face2num , i , n , ret , visualize ;
39723969 float speed , zvel ;
3970+ // float hordist;
39733971 aas_face_t * face2 ;
39743972 aas_area_t * area1 , * area2 ;
39753973 aas_lreachability_t * lreach ;
@@ -4035,6 +4033,8 @@ int AAS_Reachability_WeaponJump(int area1num, int area2num) {
40354033 // direction towards the face center
40364034 VectorSubtract (facecenter , areastart , dir );
40374035 dir [2 ] = 0 ;
4036+ // hordist = VectorNormalize(dir);
4037+ // if (hordist < 1.6 * (facecenter[2] - areastart[2]))
40384038 {
40394039 // get command movement
40404040 VectorScale (dir , speed , cmdmove );
@@ -4218,7 +4218,7 @@ static void AAS_Reachability_WalkOffLedge(int areanum) {
42184218 break ;
42194219 } // end if
42204220 // if not going through a cluster portal
4221- numareas = AAS_TraceAreas (mid , testend , areas , NULL , sizeof (areas ) / sizeof ( int ));
4221+ numareas = AAS_TraceAreas (mid , testend , areas , NULL , ARRAY_LEN (areas ));
42224222 for (p = 0 ; p < numareas ; p ++ )
42234223 if (AAS_AreaClusterPortal (areas [p ]))
42244224 break ;
@@ -4603,7 +4603,7 @@ void AAS_StoreReachability(void) {
46034603 if (aasworld .reachability )
46044604 FreeMemory (aasworld .reachability );
46054605 aasworld .reachability =
4606- (aas_reachability_t * )GetClearedMemory ((numlreachabilities + 10 ) * sizeof (aas_reachability_t )); // cyr
4606+ (aas_reachability_t * )GetClearedMemory ((numlreachabilities + 10 ) * sizeof (aas_reachability_t ));
46074607 aasworld .reachabilitysize = 1 ;
46084608 for (i = 0 ; i < aasworld .numareas ; i ++ ) {
46094609 areasettings = & aasworld .areasettings [i ];
0 commit comments