Cleaned up and de-duplicated ranklist-related code

Follow-up to 6cf032d. Special thanks to Ind.

Signed-off-by: Haru <haru@dotalux.com>
Fixed a potentially negative array subscript causing a mapserver crash

- Fixes bugreport:7717, special thanks to quesoph
  http://hercules.ws/board/tracker/issue-7717-map-crash-when-warping-on-a-floating-npc/
- Also changed various map[foo].index to the map_id2index(foo) macro.

Signed-off-by: Haru <haru@dotalux.com>
Corrected invalid values assigned to enum homun_type variables

- Fixes a warning in clang-5.0.0 (and a potentially incorrect/undefined
  behavior of the related code)

Signed-off-by: Haru <haru@dotalux.com>
Merge branch 'master' of https://github.com/HerculesWS/Hercules