fix 0494dfd5842227dab8830aa8e4578d0503748ee2

And that is what I got after "this is trivial, test compile is not necessary"
extract separate functions from bloated megafunction
fix old UnNetHackPlus bug caused by refactoring

fixes f6613cddae87eccbaeff969a4bf8942421f5ea86