Pathing debug formats


DV Table dump format

This dump is called when the game detects an invalid dv table. In theory, this should never happen, but since it has we need a way to see what data has been generated.

The output is a set of tables. Each table represents one level of the map for one size of actor.

The whole dump is prefixed with the bounds of the map model:

Bounds: (<x> <y> <z>) to (<X> <Y> <Z>) (in cell units)

The lower left of each table corresponds with the min X,Y bounds and the upper right with the max bounds. Each table is prefixed with the following indicating the crouching state and z value:

cr:<int> z:<int>

cr:0 is standing and cr:1 is crouched. Each item is a set of three integers:

<int> <int> <int>

The first is the TUs used to move to that location. The second is the direction that was traveled to move into that location from the source; refer to the dvecs table in mathlib.c. The third value is the z value that the actor would move from into the current cell.

The source location has 0 TUs. These integer sets are separated by commas for easy import into a spreadsheet program.

ufo2map -debugtrace dump format

This dump can be generated by passing the -debugtrace option to ufo2map when compiling a map. Please note that this is very detailed and can generate tens of MB of output. Also, the dump is sent to the standard output. The dump has two parts: floor/ceiling tracing and wall/passage tracing.

The model tracing code starts by running floor and ceiling traces for every cell in the map. One trace may scan more than one cell at a time, but these cells will always have the same X and Y coordinates and have consecutive Z values. The individual trace begins with an announcement line:

[(126, 127, 4)]Casting floor (-48.000000, -16.000000, 316.000000) to (-48.000000, -16.000000, -64.000000)

The coordinate in square brackets indicate the initial point of the trace, in game cell coordinates. Remember that (0,0,0) is the bottom left cell when looking down at the map. The next two coordinates indicate the line that is being traced downward looking for a floor in model units. This will always scan down to beneath 0 on the z axis.

If there is no floor found at or above model coodrinate z=-QUANT (currently QUANT = 4), all cells scanned are considered bottomless and cannot be entered. The following line is displayed:

Reached bottom of map.  No floor in cell(s).

If a floor is found, then a notice indicating where and an announcement for the first ceiling trace appears:

Potential floor found at 4.031242.
   Casting leg room (80.000000, 48.000000, 4.031242) to (80.000000, 48.000000, 24.031242)

The first line indicates in model units where on the z axis a floor was found. The second indicates the coordinates of the line traced to look for a ceiling. This trace is actually looking for leg room clearance, which does not need to be a wide as for the rest of the actor.

If a ceiling brush is detected, then the floor that was found is considered invalid and the following output is generated:

Cannot use found surface- stepup obstruction found at 130.968750.

Otherwise, the following text describing the true trace for a ceiling is displayed, along with where the ceiling is actually found:

   Casting ceiling (80.000000, 48.000000, 24.031242) to (80.000000, 48.000000, 316.000000)
Valid ceiling found, bottom=4.031242, top=316.000000, fz=0, cz=4.

fz is the floor z level (0-7), and cz is the ceiling z value. The bottom and top values are the actual model locations of the floor and ceiling.

This repeats until all cells have been scanned. Then the wall/passage tracing begins. There is no indicator of the transition other than the new format for wall tracing begins. Each trace has an announcement line:

(126, 126, 0) to (127, 126, 0) as:1

The first coordinate is the originating cell in cell units, and the second is the destination location. The as value is the actor's size in cells; 2 is a 2x2 actor.

Before any real tracing takes place, the function first uses some basic rules and originating and destination floor values to determine if the actor can't enter the destination cell because of rule violations. If the originating cell is filled, the actor obviously can't start from there then the function returns:

Current cell filled. f:-1 c:0

Note that these f and c values, as well as most values that follow unless specified, are in "step-up" units from the bottom of the map. One step-up unit is QUANT model units, currently 4. So c:15 means the ceiling is at z=60 model units above the bottom of the map.

If the destination cell is out of bounds (is not on the standard 256x256x8 cell grid), the following is displayed then the function returns:

Destination cell non-existant.

If the origination cell is high enough to step up into the cell above the original destination cell and the floor int that new cell is low enough to be reached, then the destination is moved up:

Adjusting dz for stepup. z = 0, dz = 1

Next, the model is checked to ensure the destination cell is not filled and that either cells' ceiling is higher than the other cells' floor, and if so the following is displayed then the function returns:

Destination cell filled. h = 16, c = 16, ah = 16, ac = 16

Now the destination floor is checked to ensure that it is not more than PATHFINDING_MIN_STEPUP above the originating floor. If so, the following output is generated then the function returns:

Destination cell too high up. cf:2 df:9

The last check before we start tracing is to ensure that the destination ceiling is at least PATHFINDING_MIN_STEPUP above the originating floor, otherwise the following output is generated then the function returns:

Destination cell filled. h:0 ac:2

More to come...