- float m = e.dphitcontentsmask;
- e.dphitcontentsmask = goodcontents | badcontents;
-
- vector org = boundmin;
- vector delta = boundmax - boundmin;
-
- vector start, end;
- start = end = org;
- int j; // used after the loop
- for(j = 0; j < attempts; ++j)
- {
- start.x = org.x + random() * delta.x;
- start.y = org.y + random() * delta.y;
- start.z = org.z + random() * delta.z;
-
- // rule 1: start inside world bounds, and outside
- // solid, and don't start from somewhere where you can
- // fall down to evil
- tracebox(start, e.mins, e.maxs, start - '0 0 1' * delta.z, MOVE_NORMAL, e);
- if (trace_fraction >= 1)
- continue;
- if (trace_startsolid)
- continue;
- if (trace_dphitcontents & badcontents)
- continue;
- if (trace_dphitq3surfaceflags & badsurfaceflags)
- continue;
-
- // rule 2: if we are too high, lower the point
- if (trace_fraction * delta.z > maxaboveground)
- start = trace_endpos + '0 0 1' * maxaboveground;
- vector enddown = trace_endpos;
-
- // rule 3: make sure we aren't outside the map. This only works
- // for somewhat well formed maps. A good rule of thumb is that
- // the map should have a convex outside hull.
- // these can be traceLINES as we already verified the starting box
- vector mstart = start + 0.5 * (e.mins + e.maxs);
- traceline(mstart, mstart + '1 0 0' * delta.x, MOVE_NORMAL, e);
- if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
- continue;
- traceline(mstart, mstart - '1 0 0' * delta.x, MOVE_NORMAL, e);
- if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
- continue;
- traceline(mstart, mstart + '0 1 0' * delta.y, MOVE_NORMAL, e);
- if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
- continue;
- traceline(mstart, mstart - '0 1 0' * delta.y, MOVE_NORMAL, e);
- if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
- continue;
- traceline(mstart, mstart + '0 0 1' * delta.z, MOVE_NORMAL, e);
- if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
- continue;
+ float m = e.dphitcontentsmask;
+ e.dphitcontentsmask = goodcontents | badcontents;
+
+ vector org = boundmin;
+ vector delta = boundmax - boundmin;
+
+ vector start, end;
+ start = end = org;
+ int j; // used after the loop
+ for(j = 0; j < attempts; ++j)
+ {
+ start.x = org.x + random() * delta.x;
+ start.y = org.y + random() * delta.y;
+ start.z = org.z + random() * delta.z;
+
+ // rule 1: start inside world bounds, and outside
+ // solid, and don't start from somewhere where you can
+ // fall down to evil
+ tracebox(start, e.mins, e.maxs, start - '0 0 1' * delta.z, MOVE_NORMAL, e);
+ if (trace_fraction >= 1)
+ continue;
+ if (trace_startsolid)
+ continue;
+ if (trace_dphitcontents & badcontents)
+ continue;
+ if (trace_dphitq3surfaceflags & badsurfaceflags)
+ continue;
+
+ // rule 2: if we are too high, lower the point
+ if (trace_fraction * delta.z > maxaboveground)
+ start = trace_endpos + '0 0 1' * maxaboveground;
+ vector enddown = trace_endpos;
+
+ // rule 3: make sure we aren't outside the map. This only works
+ // for somewhat well formed maps. A good rule of thumb is that
+ // the map should have a convex outside hull.
+ // these can be traceLINES as we already verified the starting box
+ vector mstart = start + 0.5 * (e.mins + e.maxs);
+ traceline(mstart, mstart + '1 0 0' * delta.x, MOVE_NORMAL, e);
+ if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
+ continue;
+ traceline(mstart, mstart - '1 0 0' * delta.x, MOVE_NORMAL, e);
+ if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
+ continue;
+ traceline(mstart, mstart + '0 1 0' * delta.y, MOVE_NORMAL, e);
+ if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
+ continue;
+ traceline(mstart, mstart - '0 1 0' * delta.y, MOVE_NORMAL, e);
+ if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
+ continue;
+ traceline(mstart, mstart + '0 0 1' * delta.z, MOVE_NORMAL, e);
+ if (trace_fraction >= 1 || trace_dphittexturename == "common/caulk")
+ continue;