public static void ParsePacket(Recording recording, Packet packet)
        {
            byte[]       packetData     = packet.GetPacketData();
            InputMessage inputMessage   = new InputMessage(packetData);
            byte         lastPacketHead = 0;

            try {
                while (inputMessage.getPosition() < inputMessage.getLength())
                {
                    byte packetHead = inputMessage.getByte();
                    switch (packetHead)
                    {
                    case 0xA:
                        ParseLogin(inputMessage);
                        break;

                    case 0x14:
                        ParseDisconnectClient(inputMessage);
                        break;

                    case 0x16:
                        ParseWaitList(inputMessage);
                        break;

                    case 0x1E:
                        break;

                    case 0x64:
                        ParseMapDescription(recording, inputMessage);
                        break;

                    case 0x65:
                        ParseNorthMove(inputMessage);
                        break;

                    case 0x66:
                        ParseEastMove(inputMessage);
                        break;

                    case 0x67:
                        ParseSouthMove(inputMessage);
                        break;

                    case 0x68:
                        ParseWestMove(inputMessage);
                        break;

                    case 0x69:
                        ParseUpdateTile(inputMessage);
                        break;

                    case 0x6A:
                        ParseAddTileItem(inputMessage);
                        break;

                    case 0x6B:
                        ParseUpdateTileItem(inputMessage);
                        break;

                    case 0x6C:
                        ParseRemoveTileItem(inputMessage);
                        break;

                    case 0x6D:
                        ParseMoveCreature(inputMessage);
                        break;

                    case 0x6E:
                        ParseContainer(inputMessage);
                        break;

                    case 0x6F:
                        ParseCloseContainer(inputMessage);
                        break;

                    case 0x70:
                        ParseAddContainerItem(inputMessage);
                        break;

                    case 0x71:
                        ParseUpdateContainerItem(inputMessage);
                        break;

                    case 0x72:
                        ParseRemoveContainerItem(inputMessage);
                        break;

                    case 0x78:
                    case 0x79:
                        ParseInventoryItem(inputMessage, packetHead);
                        break;

                    case 0x7D:
                    case 0x7E:
                        ParseTradeItemRequest(inputMessage);
                        break;

                    case 0x7F:
                        break;

                    case 0x82:
                        ParseWorldLight(inputMessage);
                        break;

                    case 0x83:
                        ParseMagicEffect(inputMessage);
                        break;

                    case 0x84:
                        ParseAnimatedText(inputMessage);
                        break;

                    case 0x85:
                        ParseDistanceShoot(inputMessage);
                        break;

                    case 0x86:
                        ParseCreatureSquare(inputMessage);
                        break;

                    case 0x8C:
                        ParseCreatureHealth(inputMessage);
                        break;

                    case 0x8D:
                        ParseCreatureLight(inputMessage);
                        break;

                    case 0x8E:
                        ParseCreatureOutfit(inputMessage);
                        break;

                    case 0x8F:
                        ParseChangeSpeed(inputMessage);
                        break;

                    case 0x90:
                        ParseCreatureSkull(inputMessage);
                        break;

                    case 0x91:
                        ParseCreatureShield(inputMessage);
                        break;

                    case 0x96:
                        ParseTextWindow(inputMessage);
                        break;

                    case 0x97:
                        ParseHouseWindow(inputMessage);
                        break;

                    case 0xA0:
                        ParsePlayerStats(inputMessage);
                        break;

                    case 0xA1:
                        ParsePlayerSkills(inputMessage);
                        break;

                    case 0xA2:
                        ParsePlayerIcons(inputMessage);
                        break;

                    case 0xA3:     // cancel target
                        break;

                    case 0xAA:
                        ParseCreatureSpeak(inputMessage);
                        break;

                    case 0xAB:
                        ParseChannelsDialog(inputMessage);
                        break;

                    case 0xAC:
                        ParseChannel(inputMessage);
                        break;

                    case 0xAD:
                        ParseOpenPrivateChannel(inputMessage);
                        break;

                    case 0xAE:
                        ParseRuleViolationsChannel(inputMessage);
                        break;

                    case 0xAF:
                        ParseRemoveReport(inputMessage);
                        break;

                    case 0xB0:
                        ParsesRuleViolationCancel(inputMessage);
                        break;

                    case 0xB1:
                        ParseLockRuleViolation(inputMessage);
                        break;

                    case 0xB4:
                        ParseTextMessage(inputMessage);
                        break;

                    case 0xB2:
                        ParseCreatePrivateChannel(inputMessage);
                        break;

                    case 0xB3:
                        ParseClosePrivate(inputMessage);
                        break;

                    case 0xB5:
                        ParseCancelWalk(inputMessage);
                        break;

                    case 0xBE:
                        ParseFloorChangeUp(inputMessage);
                        break;

                    case 0xBF:
                        ParseFloorChangeDown(inputMessage);
                        break;

                    case 0xC8:
                        ParseOutfitWindow(inputMessage);
                        break;

                    case 0xD2:
                        ParseVIP(inputMessage);
                        break;

                    case 0xD3:
                        ParseVIPLogin(inputMessage);
                        break;

                    case 0xD4:
                        ParseVIPLogout(inputMessage);
                        break;

                    default:
                        throw new Exception("Invalid packet head (maybe different version?)");
                    }

                    lastPacketHead = packetHead;
                }
            } catch (Exception ex) {
                //Console.WriteLine("Corrupted packet.");
                recording.HasProblem = true;
            }
        }