Prior to radar optical ranging was used that was located high on the ships mast to see as far as possible. If you look back at the battleships they had seaplanes that were used as observation/spotters when firing over the horizon. They would walk shoots unto the target.