# joy_maproundvalues

## What it is for
`joy_maproundvalues` cleans up long floating-point values inside a map file.

In Kingpin / Quake II mapping workflows, entity or coordinate values can sometimes end up with very long decimal tails. That can lead to strange compile-time or in-game issues, especially when values should really just be rounded cleanly.

For compile-stack use, this tool is most useful for rounding map values that have unintended precision errors.

## Typical use
Place this tool **near the top of your compile stack**, before `kpbsp` / `qbsp`.

A common setup is:
1. `joy_strip_tb_header`
2. `joy_maproundvalues`
3. BSP compiler
4. Later compile steps

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

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

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

That means:
- `-s` = silent mode, so the tool does not stop and prompt during the compile chain

## Usage
```bat
joy_maproundvalues.exe [options] <file-or-folder>
```

## Useful arguments
- `-s` or `-silent`  
  Silent mode. No commit prompt and no pause.

- `-verbose`  
  Shows line-by-line changes.

- `-p N` or `-precision N`  
  Forces standard rounding to `N` decimal places.

## Behavior without `-p`
If you do **not** supply `-p`, the tool uses smarter cleanup rules instead of fixed precision rounding:
- trims long runs of fractional zeroes
- rounds long runs of fractional nines
- converts extremely tiny scientific-notation values to `0`

## Examples
Round one map file in silent mode:

```bat
joy_maproundvalues.exe -s C:\games\kingpin\main\maps\mymap.map
```

Process all `.map` files in a folder:

```bat
joy_maproundvalues.exe C:\games\kingpin\main\maps
```

## Notes
- This tool can process a single file or an entire directory.
- If no target path is supplied, it processes `.map` files in the current directory.
- For TrenchBroom compile stacks, silent mode is strongly recommended.
