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>
Merge branch 'master' of https://github.com/HerculesWS/Hercules into ghbb
移除多余封包。