[12383] Rewrite GetHeight functions to return a reasonable height if possible

Thanks to Cyberium for problem research, suggestions and discussion

(based on commit [12273] - f98a3a0)