Finding and Repairing Leaks
by omegaslayer (view all articles)

1 rating / 5 stars
With the new Hammer
by omegaslayer (view all articles)

1 rating / 5 stars

Finding leaks in the new Hammer
This tutorial is meant for those new mappers to Half-Life 2. This a simplified version of the VERCs that can be found here.
The definition of a leak is a entity exposed to the "ouside" world. Basically an entity isnt enclosed in solid brushes. The key thing to look for in the compile log is this:
**** leaked ****This means we have a leak, and the entity is the one that is closest to the hole in the level. The numbers are the cordinates of the entity's center. It might be helpful to go to these co-ordinates, but sometimes the leak could travel all the way across a level before it actually gets to the hole.
Entity info_player_start (645.66 1879.28 -1239.00) leaked!
Also if you see this error:
FindPortalSide: Couldn't find a good match for which brush to assign to a portal near (3072.0, -512.0, -384.0)Then it means that you have a leak, and it will go away once the leak is fixed.
Leaf 0 contents: CONTENTS_SOLID
Leaf 1 contents:
viscontents (node 0 contents ^ node 1 contents): CONTENTS_SOLID
This means that none of the brushes in leaf 0 or 1 that touches the portal has CONTENTS_SOLID
Check for a huge brush enclosing the coordinates above that has contents CONTENTS_SOLID
Candidate brush IDs:
Also if you receive one of these errors:
The map overflows the max portal count (94909 of max 32768)!This means you have a leak. It is because VIS doesn't know which area of your map is inside or outside, so it is calculating both, thus leading to the max_portals error.
To us veterans we know how much of a pain it can be to find them, but the gods have heard our calls, and they have given us a much easier way to find them using Hammer.
Note: when finding leaks you may need to re-compile over and over again, you only need to run bsp to generate a pointfile, not vis or rad, so don't run them when trying to find leaks.
To find the leak we use what we call a pointfile. To load it we go to the Map-->> Load Pointfile.
The current version of Hammer will automatically load your pointfile (which is stored in a file called mapname.LIN, found in the same directory as the VMF you're currently working on). If it doesn't load it, then either you don't have a leak or you will need to manually load it up. When you do, Hammer will display a red line in your level which you need to follow to find your leak:

However, this method only solves "basic" leaks. Below are the different types you may encounter.
LEAK TYPE 1: Point Entity Outside of the Sealed Area
You're map may be sealed entirely, but you may have an entity out side of the sealed area, that causes a leak.

Notice that the model (prop) and light were out of the sealed level. To fix this, either delete the entities, move them into the sealed area, or build a new area around them!
LEAK TYPE 2: The Simple Hole

This is the second most simple form of a leak to solve, merely extend the brush down to cover the hole.
You can also sometimes end up with "microleaks." There are due to floating point errors when compiling, which can sometimes happen with rotated and heavily manipulated brushes. To avoid this, try to keep vertices aligned to the grid, and use displacement surfaces or models if possible rather than complex solid brush geometry.
LEAK TYPE 3: Entities or displacement surfaces sealing the map

This is a little harder to envision, everything must be enclosed by solid brushes. Displacement surfaces are not considered brushes (like the example above), they do not enclose the world, nor do any brush based entities (func_wall, func_door, func_"anything"). To solve this merely place (or I believe a better term would be "cap off") a brush behind the displacement surface or brush based entity - use the nodraw texture on it, as it will still seal leaks and means the game doesn't need to render more surfaces.
Note: to optimise performance on the map you can have the bush behind the displacement surface/brush based entity covered in the "nodraw" texture. This way the source engine wont render whats behind it, but still not create a leak.
There is also more to this leak that many may not realise:

How is this possible you ask? It's because this brush has a glass texture on one side of it. You see now in the new hammer whenever certain textures are placed on a brush, they are automatically turned into a brush based entity, like the glass example. The glass texture turned the brush into a brush based entity, and as we know brush based entitys are not allowed to enclose the world. The way you solve this is by replacing that one texture to something else, like "nodraw" or any other "solid" texture.
LEAK TYPE 4: Area Portals
This is a new type of leak that result from areaportals not being used correctly (usually, there is a path from one side of the areaportal to the other that doesn't go through any other areaportals). Simply load your pointfile to find out which areaportals are causing the error, and check out our areaportals tutorial.

Conclusion
Although this is a handy tool that Hammer comes with, the prevention of leaks in the first place is essential. Do this by avoiding the carving tool, the hollowing tool, and pay attention to resizing brushes that are not cubes (e.g. pentagons). Hope this was helpful.