CleverRaven/Cataclysm-DDA — pull request #5731 by BevapDin (2014-01-26 16:41:49+00:00)
Title: Access overmap terrain by global coordinates, continues #5619

This time focused on npcs.

Moved `overmap::find_all` to `overmapbuffer`, this allows road maps to work across overmap borders.

The npc related functions have been moved from `overmap` to `overmapbuffer`, so npcs from adjacent overmaps are now accessible, too.

Doing this, I encountered the overly complicated position system of npcs. Active npcs apparently use a different coordinate system. So I have taken the liberty to simplify it:

The position of an npc is defined as this (similar for y component):
```
x = (((npc->omx * OMAPX * 2) + npc->mapx) * SEEX) + npc->posx;
```
This is similar to the definition of the PCs position:
```
x = (((g->cur_om.pos().x * OMAPX * 2) + g->levx) * SEEX) + g->u.posx;
```

This stays valid if the npc is active, and it stays valid when the npc is not active. There is no need to check the active state at all. I made `npc::mapx` and `npc::omx` private to avoid changing them accidentally.

They will automatically change when the npc spawns (`npc::spawn_at`), the npc gets shifted or when the npc moves on the overmap (`npc::perform_mission`).
These functions will also update the overmap the npc is on. Before this, npc could not change the overmap, which is now possible.

Use `npc::global_sm_location` (in global submap coordinates) or `npc::global_omt_location` (in global overmap terrain coordinates) to get the actual global position of the npc, which includes pos and mapx and omx with their respective factors.

The function `npc::place_near` has been renamed to `place_on_map` and the parameters have been removed (uses npc::posx npc::posy instead). posx and posy can be set up before calling the function. `place_on_map` will change (posx,posy) so it's relative to (g->levx,g->levy). As compensation (maps,mapy) will be changed, too. In the end the result of `npc::global_sm_location` will not change (assuming the npc can be placed on the map and there is no wall that forces it to changes its position).

`npc::spawn_at` does now the complete setup of the npc position including posx (which can be changed later anyway, but at least the npc has a valid position after `spawn_at`, which makes the check for this in `load_npcs` unnecessarily).

The calls to `place_on_map` from `game::create_starting_npcs` and `game::debug` have been removed because `game::load_npcs` will take care of the npc appearing on the map and in `game::active_npc`.

I fixed `game::disp_npcs` function and added a call to it into the debug menu (under item 7: check game state) as it was not called from anywhere at all.

I might have gone a bit over the top with theses changes. If this conflicts with the npc/creature re-factoring, I can revert those changes.

TODO:
- vehicle trackers across overmaps
- access radio towers across overmap borders