protected void updateHud() {
        // If the players ship is dead.
        if (player.ship == null)
            return;

        if (disabled) return;

        try {
            tick++;
            int offset;

            updateScanner();

            if (tick == 64)
                tick = 0;

            if (player.playerOptions.getOption(TrekPlayerOptions.OPTION_XYZUPDATE) == 0) {
                setHudValue("MyCurrentX", new Integer(new Double(player.ship.point.x).intValue()).toString());
                setHudValue("MyCurrentY", new Integer(new Double(player.ship.point.y).intValue()).toString());
                setHudValue("MyCurrentZ", new Integer(new Double(player.ship.point.z).intValue()).toString());
            } else {
                // by making this test for '1' instead of '0', we can force the stuff to show on initial ship load
                if ((tick % player.playerOptions.getOption(TrekPlayerOptions.OPTION_XYZUPDATE)) == 1) {
                    setHudValue("MyCurrentX", new Integer(new Double(player.ship.point.x).intValue()).toString());
                    setHudValue("MyCurrentY", new Integer(new Double(player.ship.point.y).intValue()).toString());
                    setHudValue("MyCurrentZ", new Integer(new Double(player.ship.point.z).intValue()).toString());
                }
            }

            String buffer1 = "", buffer2 = "", buffer3 = "";

            // Update the quadrant name and whether or not we are cloaked.
            if (!getHudValueString("MyCurrentQuadrant").equals(player.ship.currentQuadrant.name)) {
                player.sendText(TrekAnsi.locate(16, 43, player) + player.ship.currentQuadrant.name + "-");
                setHudValue("MyCurrentQuadrant", player.ship.currentQuadrant.name);
            }

            // Draw the objects in the tactical display.
            drawObjects();


            // Draw our stats screen for this ship.
            drawHudLine(4, format("Warp Energy:", new Integer(player.ship.getWarpEnergy()).toString(), 20));
            drawHudLine(5, format("Impulse Energy:", new Integer(player.ship.impulseEnergy).toString(), 20));
            drawHudLine(6, format("Power Unused:", new Integer(player.ship.getAvailablePower()).toString(), 20));

            if (player.ship.transwarpEngaged) {
                if (player.ship.warpSpeed >= 0) {
                    buffer1 = format("Warp:", "* " + getFormattedWarpSpeed(player.ship.warpSpeed - 30), 20);
                } else {
                    buffer1 = format("Warp:", "* " + getFormattedWarpSpeed(player.ship.warpSpeed + 30), 20);
                }
            } else {
                buffer1 = format("Warp:", getFormattedWarpSpeed(player.ship.warpSpeed), 20);
            }
            drawHudLine(7, buffer1);

            drawHudLine(8, format("Shields:", new Integer(player.ship.shields).toString() + "%", 20));

            buffer1 = format("Ph:", new Integer(player.ship.phasers).toString(), 7);
            buffer2 = getHudValueString("MyPhasers");

            if (!buffer2.equals(buffer1)) {
                offset = getOffset(buffer2, buffer1);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(9, offset + 1, player) + getOptimizedOutput(buffer2, buffer1));
                } else {
                    player.sendText(TrekAnsi.locate(9, 1, player) + buffer1);
                }

                setHudValue("MyPhasers", buffer1);
            }

            buffer2 = format("Damage:", new Integer(player.ship.damage).toString(), 11);
            buffer1 = getHudValueString("MyDamage");

            if (!buffer1.equals(buffer2)) {
                offset = getOffset(buffer1, buffer2);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(9, 10 + offset, player) + getOptimizedOutput(buffer1, buffer2));
                } else {
                    player.sendText(TrekAnsi.locate(9, 10, player) + buffer2);
                }

                setHudValue("MyDamage", buffer2);
            }

            buffer1 = format("Tp:", new Integer(player.ship.torpedoes).toString(), 7);
            buffer2 = getHudValueString("MyTorpedoes");

            if (!buffer2.equals(buffer1)) {
                offset = getOffset(buffer2, buffer1);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(10, offset + 1, player) + getOptimizedOutput(buffer2, buffer1));
                } else {
                    player.sendText(TrekAnsi.locate(10, 1, player) + buffer1);
                }

                setHudValue("MyTorpedoes", buffer1);
            }

            buffer2 = format("DmgCtl:", new Integer(player.ship.damageControl).toString(), 11);
            buffer1 = getHudValueString("MyDamageControl");

            if (!buffer1.equals(buffer2)) {
                offset = getOffset(buffer1, buffer2);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(10, 10 + offset, player) + getOptimizedOutput(buffer1, buffer2));
                } else {
                    player.sendText(TrekAnsi.locate(10, 10, player) + buffer2);
                }

                setHudValue("MyDamageControl", buffer2);
            }

            drawHudLine(11, format("Life Support:", new Integer(player.ship.lifeSupport).toString() + "%", 20));
            if (tick == 1 || (player.ship.orbiting && player.ship.orbitTarget.givesAntimatter(player.ship)))
                drawHudLine(12, format("Anti-Matter:", new Integer(player.ship.antiMatter).toString(), 20));

            // Draw all the rest as seperate.
            buffer1 = format("X:", getHudValueString("MyCurrentX"), 9);
            buffer2 = getHudValueString("MyHudX");

            if (!buffer2.equals(buffer1)) {
                offset = getOffset(buffer2, buffer1);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(13, offset + 1, player) + getOptimizedOutput(buffer2, buffer1));
                } else {
                    player.sendText(TrekAnsi.locate(13, 1, player) + buffer1);
                }

                setHudValue("MyHudX", buffer1);
            }

            if (player.ship.cloak) {
                buffer2 = format("Cloak:", new Integer(player.ship.cloakTimeCurrent).toString(), 10);
            } else {
                if (player.ship.drones) {
                    buffer2 = format("Drones:", new Integer(player.ship.droneCount).toString(), 10);
                } else if (player.ship.mines) {
                    buffer2 = format("Mines:", new Integer(player.ship.mineCount).toString(), 10);
                } else {
                    buffer2 = "          ";
                }
            }

            buffer1 = getHudValueString("MyHudX2");

            if (!buffer1.equals(buffer2)) {
                offset = getOffset(buffer1, buffer2);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(13, 11 + offset, player) + getOptimizedOutput(buffer1, buffer2));
                } else {
                    player.sendText(TrekAnsi.locate(13, 11, player) + buffer2);
                }

                setHudValue("MyHudX2", buffer2);
            }

            buffer1 = format("Y:", getHudValueString("MyCurrentY"), 9);
            buffer2 = getHudValueString("MyHudY");

            if (!buffer2.equals(buffer1)) {
                offset = getOffset(buffer2, buffer1);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(14, 1 + offset, player) + getOptimizedOutput(buffer2, buffer1));
                } else {
                    player.sendText(TrekAnsi.locate(14, 1, player) + buffer1);
                }

                setHudValue("MyHudY", buffer1);
            }

            if (player.ship.cloak) {
                if (player.ship.drones) {
                    buffer2 = format("Drones:", new Integer(player.ship.droneCount).toString(), 10);
                } else if (player.ship.mines) {
                    buffer2 = format("Mines:", new Integer(player.ship.mineCount).toString(), 10);
                } else {
                    buffer2 = "          ";
                }
            } else {
                if (player.ship.mines) {
                    if (player.ship.cloak || player.ship.drones) {
                        buffer2 = format("Mines:", new Integer(player.ship.mineCount).toString(), 10);
                    }
                } else {
                    buffer2 = "          ";
                }
            }

            buffer1 = getHudValueString("MyHudY2");

            if (!buffer1.equals(buffer2)) {
                offset = getOffset(buffer1, buffer2);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(14, 11 + offset, player) + getOptimizedOutput(buffer1, buffer2));
                } else {
                    player.sendText(TrekAnsi.locate(14, 11, player) + buffer2);
                }

                setHudValue("MyHudY2", buffer2);
            }

            buffer1 = format("Z:", getHudValueString("MyCurrentZ"), 9);
            buffer2 = getHudValueString("MyHudZ");

            if (!buffer2.equals(buffer1)) {
                offset = getOffset(buffer2, buffer1);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(15, 1 + offset, player) + getOptimizedOutput(buffer2, buffer1));
                } else {
                    player.sendText(TrekAnsi.locate(15, 1, player) + buffer1);
                }

                setHudValue("MyHudZ", buffer1);
            }

            buffer2 = format("HD:", player.ship.getHeading() + "'" + player.ship.getPitch(), 10);
            buffer1 = getHudValueString("MyHudZ2");

            if (!buffer1.equals(buffer2)) {
                offset = getOffset(buffer1, buffer2);

                if (offset != 0) {
                    player.sendText(TrekAnsi.locate(15, 11 + offset, player) + getOptimizedOutput(buffer1, buffer2));
                } else {
                    player.sendText(TrekAnsi.locate(15, 11, player) + buffer2);
                }

                setHudValue("MyHudZ2", buffer2);
            }

            // Intercept, Orbitable, In Orbit, Docable, Docked, exceeded warp speeds maxes.
            if (Math.abs(player.ship.warpSpeed) != 0) {
                if (Math.abs(player.ship.warpSpeed) <= player.ship.maxCruiseWarp) {
                    buffer1 = format("", "", 23);
                }

                if (Math.abs(player.ship.warpSpeed) > player.ship.maxTurnWarp) {
                    buffer1 = format("Exceeding Turn Warp", "", 23);
                }

                if (Math.abs(player.ship.warpSpeed) > player.ship.maxCruiseWarp) {
                    buffer1 = format("Exceeding Cruise Warp", "", 23);
                }

                if (player.ship.dockable || player.ship.orbitable) {
                    if (player.ship.dockable)
                        buffer1 = format("Dockable", "", 23);
                    else
                        buffer1 = format("Orbitable", "", 23);
                }
            } else {
                if (player.ship.docked || player.ship.orbiting) {
                    if (player.ship.docked)
                        buffer1 = format("Docked", "", 23);
                    else
                        buffer1 = format("In Orbit", "", 23);
                } else {
                    if (player.ship.dockable || player.ship.orbitable) {
                        if (player.ship.dockable)
                            buffer1 = format("Dockable", "", 23);
                        else
                            buffer1 = format("Orbitable", "", 23);
                    } else {
                        buffer1 = format("", "", 23);
                    }
                }
            }

            if (player.ship.cloaked) {
                buffer2 = format("Cloak", "", 7);
            } else {
                buffer2 = format("", "", 7);
            }

            if (!loadingMessage.equals(""))
                buffer3 = format(loadingMessage, "", 29);
            else
                buffer3 = format("", "", 29);

            drawHudLine(17, buffer1 + buffer2 + buffer3);

            if (player.ship.isIntercepting()) {
                if (player.ship.interceptTarget != null)
                    buffer1 = "Intercepting: " + player.ship.interceptTarget.name + TrekAnsi.eraseToEndOfLine(player);
                else if (player.ship.intCoordPoint != null)
                    buffer1 = "Intercepting: " + player.ship.intCoordPoint.toString() + TrekAnsi.eraseToEndOfLine(player);
            } else {
                buffer1 = TrekAnsi.clearRow(18, player);
            }

            drawHudLine(18, buffer1);

            // Weapons lock.
            if (player.ship.lockTarget != null) {
                drawScannerLine(17, format("Weapons Locked (" + player.ship.lockTarget.scanLetter + ")", "", 20));
            } else {
                drawScannerLine(17, format("", "", 20));
            }
        } catch (NullPointerException npe) {
            // in case we killed the socket
        }
    }