Publisher agrees to pay prince ‘substantial damages’ to drop long-running legal claims