Blockmap overflow

The blockmap overflow happens on very large maps. Its consequences include player noclipping, hitscan traces getting mysteriously blocked in midair, preventing from picking up items, and other issues with collision detection.

The Doom map format technically allows for map coordinates between -32768 and 32767, for a 65535×65535 area. Each blockmap block is 128×128 units. Therefore, a map can require up to a 512×512 blockmap grid. However, to convert coordinates into block coordinates, a shift is used. The shift is defined as this: This only leaves nine bits for the value, the first of which being the sign bit. As a result, the block coordinates are expressed as a value between -256 and 255, and distances between map blocks of 256 or more cannot be expressed.
 * 1) define MAPBLOCKSHIFT	(FRACBITS+7)

The second half of the bug happens in P_PathTraverse. The blockmap origin point is subtracted from the coordinates considered, which can cause an overflow. Fixing this requires casting the coordinates to 64-bit integer before subtracting the blockmap origin point.

The bug was discovered by Andrey Budko (entryway) and fixed by him and Maes. It is fixed in PrBoom+ 2.5.1.4+ (if the option "Fix clipping problems in large levels" under "Compatibility with common mapping errors" is set to "Yes"), Mocha Doom 1.6+, and ZDoom 2.6.0+.