# joy_strip_tb_header

## What it is for
`joy_strip_tb_header` removes TrenchBroom header metadata from a `.map` file before it is compiled to BSP.

This is mainly useful for **vanilla Kingpin** and **older mods** that can choke on TrenchBroom-specific header data. In practice, it strips the line that starts with `"_tb_textures"` and writes out a cleaned map file.

## Typical use
Place this tool **near the top of your compile stack**, before `kpbsp` / `qbsp` or any other BSP compiler step.

A common setup is:
1. Export or save source map to `tb_source`
2. Run `joy_strip_tb_header`
3. Run `joy_maproundvalues`
4. Run BSP / VIS / RAD / lighting steps

## TrenchBroom setup
Add a **Run Tool** in TrenchBroom:

- **Tool Path:** path to `joy_strip_tb_header.exe`
- **Parameters:**

```text
${GAME_DIR_PATH}\main\maps\tb_source\${MAP_BASE_NAME}.map
```

## What it does
- Reads the specified `.map` file
- Removes the TrenchBroom header line beginning with `"_tb_textures"`
- Saves the cleaned output **one folder above** the source folder

This matches the common workflow where TrenchBroom writes a source map into `maps\tb_source\`, and this tool writes the cleaned result back into `maps\` for the rest of the compile chain.

## Usage
From a command prompt:

```bat
joy_strip_tb_header.exe <file_path>
```

Example:

```bat
joy_strip_tb_header.exe C:\games\kingpin\main\maps\tb_source\mymap.map
```

## Notes
- This tool is intended for Windows.
- It expects a single file path.
- It is best treated as an automatic compile-stack cleanup step rather than a manual editing tool.
