Exemple #1
0
 // SingleTon Pattern - as we only want to load the Data once at startup and manage
 public static DataLoader getInstance()
 {
     if (Instance == null)
     {
         Instance = new DataLoader();
     }
     return Instance;
 }
        public void processObjectStatic(ref byte[] packet)
        {
            byte[] objectID = new byte[4];
            byte[] sectorID = new byte[2];
            ArrayUtils.copyTo(packet, 0, objectID, 0, 4);
            ArrayUtils.copyTo(objectID, 2, sectorID, 0, 2);


            UInt32 numericObjectId = NumericalUtils.ByteArrayToUint32(objectID, 1);

            // Ok sector Bytes are something like 30 39 (reversed but the result must be 39 03)
            UInt16 numericSectorId = NumericalUtils.ByteArrayToUint16(sectorID, 1);
            // strip out object id
            string id = StringUtils.bytesToString_NS(objectID);


            // get the type
            byte[] objectType = new byte[1];
            ArrayUtils.copy(packet, 4, objectType, 0, 1);
            int objectTypeID = packet[4];

            DataLoader        objectLoader = DataLoader.getInstance();
            StaticWorldObject objectValues = objectLoader.getObjectValues(NumericalUtils.ByteArrayToUint32(objectID, 1));


            // create a new System message but fill it in the switch block
            ServerPackets pak = new ServerPackets();

            switch (objectTypeID)
            {
            // Case 03 is not only a staticWorldObject ...
            case (int)objectTypesStatic.DOOR:

                Output.writeToLogForConsole("[OI HELPER] INTERACT WITH DOOR | Object ID :" + id + " Sector ID : " + numericSectorId);

                // just a test

                if (objectValues != null && objectValues.type != null)
                {
                    GameObjectItem item = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1));
                    //Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("[OI HELPER] Door StrType: !" + item.getName() + " with Type ID " + StringUtils.bytesToString_NS(objectValues.type), Store.currentClient));
                    this.processObjectInteraction(objectValues, item);
                }

                break;

            case (int)objectTypesStatic.HARDLINE_SYNC:

                pak.sendSystemChatMessage(Store.currentClient, "Hardline Interaction(not done yet)!", "MODAL");
                break;

            case (int)objectTypesStatic.HARDLINE_UPLOAD:
                Output.writeToLogForConsole("[OBJECT HELPER] Upload Hardline will be used for combat tests");
                Store.currentClient.playerData.lastClickedObjectId = numericObjectId;
                new TestUnitHandler().processTestCombat(ref packet);
                break;

            case (int)objectTypesStatic.HARDLINE_LAEXIT:
                // Exit LA
                pak.sendSystemChatMessage(Store.currentClient, "Exit to LA Dialog should popup", "MODAL");
                new TeleportHandler().processHardlineExitRequest();
                break;

            case (int)objectTypesStatic.HUMAN_NPC:
                pak.sendSystemChatMessage(Store.currentClient, "Open Vendor Dialog for Object ID" + StringUtils.bytesToString_NS(objectID), "MODAL");
                this.processVendorOpen(ref objectID);
                break;

            case (int)objectTypesStatic.COLLECTOR:
                pak.sendSystemChatMessage(Store.currentClient, "Collector Interaction (not done yet)!", "MODAL");
                break;

            case (int)objectTypesStatic.ENVIROMENT:
                GameObjectItem enviromentItem   = objectLoader.getGameObjectItemById(NumericalUtils.ByteArrayToUint16(objectValues.type, 1));
                UInt16         enviromentTypeID = NumericalUtils.ByteArrayToUint16(objectValues.type, 1);
                switch (enviromentTypeID)
                {
                case 6952:
                    // ToDo: implement Elevator Panel
                    pak.sendElevatorPanel(Store.currentClient, objectValues);
                    break;

                default:
                    pak.sendSystemChatMessage(Store.currentClient, "Enviroment Type ID " + objectValues.type + " name " + enviromentItem.getName(), "MODAL");
                    break;
                }
                pak.sendSystemChatMessage(Store.currentClient, "Enviroment Type ID " + objectValues.type + " name " + enviromentItem.getName(), "MODAL");
                break;


            default:
                pak.sendSystemChatMessage(Store.currentClient, "[OI HELPER] Unknown Object Type : " + objectTypeID.ToString() + "| Object ID :" + id, "MODAL");
                break;
            }
        }
Exemple #3
0
        public void processUnmountItem(ref byte[] rpcData)
        {
            byte sourceSlot = rpcData[0];
            byte destSlot   = rpcData[1];

            UInt32       clothingItemId = Store.dbManager.WorldDbHandler.GetItemGOIDAtInventorySlot(rpcData[0]);
            DataLoader   dataLoader     = DataLoader.getInstance();
            ClothingItem item           = dataLoader.getItemValues(clothingItemId);

            // Update Appeareance as we know which appeareance to update (as we unmount item it should be ok to set zeros for the values)
            string partModel = null;
            string partColor = null;

            switch (item.getClothesType())
            {
            case "1950892361":
            case "FEMALE HAT":
            case "MALE HAT":
                partModel = "hat";
                break;

            case "2001027401":
            case "FEMALE GLASSES":
            case "MALE GLASSES":
                partModel = "glasses";
                partColor = "glassescolor";
                break;

            case "1750286665":     // New Way but lets stay old values there
            case "FEMALE SHIRT":
            case "MALE SHIRT":
                partModel = "shirt";
                partColor = "shirtcolor";
                break;

            case "1816609097":
            case "FEMALE GLOVES":
            case "MALE GLOVES":
                partModel = "gloves";
                break;

            case "2001682761":
            case "FEMALE COAT":
            case "MALE COAT":
                partModel = "coat";
                partColor = "coatcolor";
                break;

            case "1397768521":
            case "MALE PANTS":
            case "FEMALE PANTS":
                partModel = "pants";
                partColor = "pantscolor";
                break;

            case "1733050697":
            case "FEMALE LEGGINGS":
                partModel = "leggins";
                break;

            case "2001092937":
            case "FEMALE SHOES":
            case "MALE SHOES":
                partModel = "shoes";
                partColor = "shoecolor";
                break;
            }

            if (partModel != null)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partModel, 0);
            }

            if (partColor != null && item.getColorId() > 0)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partColor, 0);
            }
            // Move slot
            UInt16 newSlotId = Store.dbManager.WorldDbHandler.getFirstNewSlot();

            Store.dbManager.WorldDbHandler.updateInventorySlot(sourceSlot, newSlotId);

            // Send move packet
            ServerPackets pak = new ServerPackets();

            pak.sendInventoryItemMove(sourceSlot, newSlotId, Store.currentClient);

            Store.dbManager.WorldDbHandler.setRsiValues();

            int[] current = Store.currentClient.playerData.getRsiValues();
            Store.currentClient.playerData.setRsiValues(current);
            byte[] rsiData = PacketsUtils.getRSIBytes(current);
            pak.sendAppeareanceUpdate(Store.currentClient, rsiData);
        }
Exemple #4
0
        public void processMountItem(ref byte[] rpcData)
        {
            byte sourceSlot = rpcData[0];
            byte destSlot   = rpcData[1];


            UInt32       clothingItemId = Store.dbManager.WorldDbHandler.GetItemGOIDAtInventorySlot(rpcData[0]);
            DataLoader   dataLoader     = DataLoader.getInstance();
            ClothingItem item           = dataLoader.getItemValues(clothingItemId);


            string partModel = null;
            string partColor = null;

            UInt16 toRealSlotId = 0;

            switch (item.getClothesType())
            {
            case "1950892361":
            case "FEMALE HAT":
            case "MALE HAT":
                toRealSlotId = 0x61;
                partModel    = "hat";
                break;

            case "2001027401":
            case "FEMALE GLASSES":
            case "MALE GLASSES":
                toRealSlotId = 0x62;
                partModel    = "glasses";
                partColor    = "glassescolor";
                break;

            case "1750286665":     // New Way but lets stay old values there
            case "FEMALE SHIRT":
            case "MALE SHIRT":
                toRealSlotId = 0x63;
                partModel    = "shirt";
                partColor    = "shirtcolor";
                break;

            case "1816609097":
            case "FEMALE GLOVES":
            case "MALE GLOVES":
                toRealSlotId = 0x64;
                partModel    = "gloves";
                break;

            case "2001682761":
            case "FEMALE COAT":
            case "MALE COAT":
                toRealSlotId = 0x65;
                partModel    = "coat";
                partColor    = "coatcolor";
                break;

            case "1397768521":
            case "MALE PANTS":
            case "FEMALE PANTS":
                toRealSlotId = 0x66;
                partModel    = "pants";
                partColor    = "pantscolor";
                break;

            case "1733050697":
            case "FEMALE LEGGINGS":
                toRealSlotId = 0x67;
                partModel    = "leggins";
                break;

            case "2001092937":
            case "FEMALE SHOES":
            case "MALE SHOES":
                toRealSlotId = 0x68;
                partModel    = "shoes";
                partColor    = "shoecolor";
                break;
            }

            if (partModel != null)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partModel, item.getModelId());
            }

            if (partColor != null)
            {
                Store.dbManager.WorldDbHandler.updateRsiPartValue(partColor, item.getColorId());
            }
            Store.dbManager.WorldDbHandler.setRsiValues();

            int[] current = Store.currentClient.playerData.getRsiValues();
            Store.currentClient.playerData.setRsiValues(current);
            byte[] rsiData = PacketsUtils.getRSIBytes(current);


            // Move the wear item from the wearing slot to the next new slot (but maybe doesnt work if inventory is full)

            ServerPackets pak = new ServerPackets();

            if (Store.dbManager.WorldDbHandler.isSlotinUseByItem(toRealSlotId))
            {
                UInt16 newSlotId = Store.dbManager.WorldDbHandler.getFirstNewSlot();
                Store.dbManager.WorldDbHandler.updateInventorySlot(toRealSlotId, newSlotId);
                pak.sendInventoryItemMove(toRealSlotId, newSlotId, Store.currentClient);
            }
            pak.sendAppeareanceUpdate(Store.currentClient, rsiData);
            Store.dbManager.WorldDbHandler.updateInventorySlot(sourceSlot, toRealSlotId);
            pak.sendInventoryItemMove(sourceSlot, toRealSlotId, Store.currentClient);
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            var customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();

            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;
            HealthCheck hc = new HealthCheck();

            if (hc.doTests())
            {
                Output.WriteLine("\nHealth checks OK. Proceeding.\n");
                // Create
                Store.auth         = new AuthSocket();
                Store.margin       = new MarginSocket();
                Store.world        = new WorldSocket();
                Store.worldThreads = new WorldThreads();

                Store.config = new ServerConfig("Config.xml");
                Store.config.LoadDbParams();
                Store.config.LoadServerParams();

                Store.worldConfig = new WorldConfig("WorldConfig.xml");

                /* Load Game Data */
                DataLoader.getInstance();

                /* Initialize DB Stuff */

                Store.dbManager = new databases.DatabaseManager();

                if (Store.config.dbParams.DbType == "mysql")
                {
                    Store.dbManager.AuthDbHandler   = new databases.MyAuthDBAccess();
                    Store.dbManager.MarginDbHandler = new databases.MyMarginDBAccess();
                    Store.dbManager.WorldDbHandler  = new databases.MyWorldDbAccess();
                }

                /* Initialize the MPM object */
                Store.dbManager.WorldDbHandler.ResetOnlineStatus();
                Store.Mpm = new MultiProtocolManager();

                /* Initialize the scripting server */
                Store.rpcScriptManager = new ScriptManager();
                var scrLoader = new ScriptLoader();
                scrLoader.LoadScripts(); //<<-- This does


                /* External console */
                if (Store.config.serverParams.AdminConsoleEnabled)
                {
                    ConsoleSocket adminConsole = new ConsoleSocket();
                    adminConsole.startServer();
                }


                // Now everything should be loaded - START THE ENGINES!!!
                Store.auth.startServer();
                Store.margin.startServer();
                Store.world.startServer();

                // Check if execution keeps going after starting
                Output.WriteLine("Im'running :D");


                // Capture Ctrl C key to clean and then end the program
                Console.CancelKeyPress += delegate
                {
                    Output.WriteLine("Closing Auth server and threads");
                    Store.auth.stopServer();

                    Output.WriteLine("Closing Margin server and threads");
                    Store.margin.stopServer();

                    Output.WriteLine("Closing World server and threads");
                    Store.world.stopServer();

                    Output.WriteLine("Server exited");
                };
            }
            else
            {
                Output.WriteLine("\nHealth checks not passed. Aborting launch.");
                Output.WriteLine("Please check the errors above or press Enter to close the window.");
                Console.ReadLine();
            }
        }
Exemple #6
0
        private void createCharacterRSI(byte[] packet, NetworkStream client)
        {
            // Instance the Data Loader
            DataLoader ItemLoader = DataLoader.getInstance();

            isNewCreatedChar = true;

            string debugHexPacket = StringUtils.bytesToString_NS(packet);

            // lets read the values
            // the IDs for the Appeareance is always uint16 goID
            byte[] bodyTypeIDByte         = new byte[4];
            byte[] professionByte         = new byte[4];
            byte[] facialdetailBytes      = new byte[4];
            byte[] facialdetailColorBytes = new byte[4];
            byte[] hairBytes      = new byte[4];
            byte[] hairColorBytes = new byte[4];
            byte[] skintoneBytes  = new byte[4];
            byte[] tatooBytes     = new byte[4];
            byte[] headIDBytes    = new byte[4];

            // Clothing
            byte[] shirtIDBytes     = new byte[4];
            byte[] pantsIDBytes     = new byte[4];
            byte[] outerwearIDBytes = new byte[4];
            byte[] hatIDBytes       = new byte[4];
            byte[] eyewearIDBytes   = new byte[4];
            byte[] footwearIDBytes  = new byte[4];
            byte[] glovesIDBytes    = new byte[4];
            //byte[] legginsIDBytes           = new byte[4];

            // RSI
            ArrayUtils.copy(packet, 3, skintoneBytes, 0, 2);        // Done!
            ArrayUtils.copy(packet, 7, bodyTypeIDByte, 0, 2);       // Done!
            ArrayUtils.copy(packet, 15, hairBytes, 0, 2);           // Done!
            ArrayUtils.copy(packet, 19, hairColorBytes, 0, 2);      // Done!
            ArrayUtils.copy(packet, 23, tatooBytes, 0, 2);          // Done!
            ArrayUtils.copy(packet, 27, headIDBytes, 0, 2);
            ArrayUtils.copy(packet, 31, facialdetailBytes, 0, 2);
            ArrayUtils.copy(packet, 35, facialdetailColorBytes, 0, 2);
            ArrayUtils.copy(packet, 67, professionByte, 0, 2);

            UInt16 body       = 0;
            UInt16 gender     = 0;
            UInt32 bodyTypeId = NumericalUtils.ByteArrayToUint32(bodyTypeIDByte, 1);

            UInt16 hairId            = NumericalUtils.ByteArrayToUint16(hairBytes, 1);
            UInt16 haircolor         = NumericalUtils.ByteArrayToUint16(hairColorBytes, 1);
            UInt16 tattoo            = NumericalUtils.ByteArrayToUint16(tatooBytes, 1);
            UInt16 facialDetailColor = NumericalUtils.ByteArrayToUint16(facialdetailColorBytes, 1);
            UInt16 skintone          = NumericalUtils.ByteArrayToUint16(skintoneBytes, 1);
            UInt16 headID            = NumericalUtils.ByteArrayToUint16(headIDBytes, 1);

            // Get Values by "NewRSI" IDs
            NewRSIItem hairItem = ItemLoader.getNewRSIItemByTypeAndID("HAIR", hairId);
            NewRSIItem bodyItem = ItemLoader.getNewRSIItemByTypeAndID("BODY", (ushort)bodyTypeId);
            NewRSIItem headItem = ItemLoader.getNewRSIItemByTypeAndID("HEAD", headID);

            Store.dbManager.MarginDbHandler.updateRSIValue("body", bodyItem.internalId.ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("sex", bodyItem.gender.ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("face", headItem.internalId.ToString(), newCharID);              // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("hair", hairItem.internalId.ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("haircolor", haircolor.ToString(), newCharID);                   // ToDo: check if it is correct
            Store.dbManager.MarginDbHandler.updateRSIValue("tattoo", tattoo.ToString(), newCharID);                         // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("facialdetailcolor", facialDetailColor.ToString(), newCharID);   // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("skintone", skintone.ToString(), newCharID);
            // Clothing Items
            // ToDo: GLOVES ARE MISSING!
            ArrayUtils.copy(packet, 43, shirtIDBytes, 0, 2);
            ArrayUtils.copy(packet, 47, glovesIDBytes, 0, 2);
            ArrayUtils.copy(packet, 55, pantsIDBytes, 0, 2);
            ArrayUtils.copy(packet, 51, outerwearIDBytes, 0, 2);
            ArrayUtils.copy(packet, 34, hatIDBytes, 0, 2);
            ArrayUtils.copy(packet, 39, eyewearIDBytes, 0, 2);
            ArrayUtils.copy(packet, 63, footwearIDBytes, 0, 2);

            ClothingItem shirt     = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(shirtIDBytes, 1));
            ClothingItem pants     = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(pantsIDBytes, 1));
            ClothingItem outerwear = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(outerwearIDBytes, 1));
            ClothingItem hat       = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(hatIDBytes, 1));
            ClothingItem eyewear   = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(eyewearIDBytes, 1));
            ClothingItem footwear  = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(footwearIDBytes, 1));
            ClothingItem gloves    = ItemLoader.getItemValues(NumericalUtils.ByteArrayToUint16(glovesIDBytes, 1));


            Store.dbManager.MarginDbHandler.updateRSIValue("hat", hat.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shirt", shirt.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shirtcolor", shirt.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("coat", outerwear.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("coatcolor", outerwear.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("pants", pants.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("pantscolor", pants.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shoes", pants.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shoecolor", pants.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("glasses", pants.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("glassescolor", pants.getModelId().ToString(), newCharID);

            // ToDO: Figre out the ITem Slots for "currentlyWearing" Items and add the ITems correctly to the Inventory

            // FirstName
            UInt16 currentOffset = 79;

            byte[] firstNameLenBytes = new byte[2];
            ArrayUtils.copy(packet, currentOffset, firstNameLenBytes, 0, 2);
            UInt16 firstNameLen = NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1);

            currentOffset += 2;

            byte[] firstNameBytes = new byte[NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1) - 1];
            ArrayUtils.copy(packet, currentOffset, firstNameBytes, 0, firstNameLen - 1);
            string firstNameString = StringUtils.charBytesToString(firstNameBytes);

            currentOffset += firstNameLen;

            // LastName
            byte[] lastNameLenBytes = new byte[2];
            ArrayUtils.copy(packet, currentOffset, lastNameLenBytes, 0, 2);
            UInt16 lastNameLen = NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1);

            currentOffset += 2;

            byte[] lastNameBytes = new byte[NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1) - 1];
            ArrayUtils.copy(packet, currentOffset, lastNameBytes, 0, lastNameLen - 1);
            string lastNameString = StringUtils.charBytesToString(lastNameBytes);

            currentOffset += lastNameLen;

            // Description
            byte[] descriptionLenBytes = new byte[2];
            ArrayUtils.copy(packet, currentOffset, descriptionLenBytes, 0, 2);
            UInt16 descriptionLen = NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1);

            currentOffset += 2;

            byte[] descriptionBytes = new byte[NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1) - 1];
            ArrayUtils.copy(packet, currentOffset, descriptionBytes, 0, descriptionLen - 1);
            string descriptionString = StringUtils.charBytesToString(descriptionBytes);

            currentOffset += lastNameLen;

            // Update Characters values
            Store.dbManager.MarginDbHandler.updateCharacter(firstNameString, lastNameString, descriptionString, newCharID);

            // Add the Basic Abilitys...
            Store.dbManager.MarginDbHandler.addAbility(-2147481600, 0, newCharID, 1, 1);
            Store.dbManager.MarginDbHandler.addAbility(-2147367936, 1, newCharID, 1, 1);
            Store.dbManager.MarginDbHandler.addAbility(-2147294208, 2, newCharID, 0, 1);
            Store.dbManager.MarginDbHandler.addAbility(-2147281920, 3, newCharID, 0, 0);
            Store.dbManager.MarginDbHandler.addAbility(-2147280896, 4, newCharID, 0, 0);
            Store.dbManager.MarginDbHandler.addAbility(-2147437568, 5, newCharID, 1, 1);
            Store.dbManager.MarginDbHandler.addAbility(-2147425280, 6, newCharID, 0, 0);
            Store.dbManager.MarginDbHandler.addAbility(-2147404800, 7, newCharID, 0, 0);
            Store.dbManager.MarginDbHandler.addAbility(-2147445760, 8, newCharID, 0, 0);
            Store.dbManager.MarginDbHandler.addAbility(-2146493440, 9, newCharID, 0, 0);
            Store.dbManager.MarginDbHandler.addAbility(-2146453504, 10, newCharID, 1, 0);

            // we have all created - lets load the charData
            loadCharacter(packet, client, this.newCharID);
        }
Exemple #7
0
        private void createCharacterRSI(byte[] packet, NetworkStream client)
        {
            // Instance the Data Loader
            DataLoader itemLoader = DataLoader.getInstance();

            isNewCreatedChar = true;
            string debugHexPacket = StringUtils.bytesToString_NS(packet);

            // ToDo: Replace all with Packet Reader Instance
            PacketReader reader = new PacketReader(packet);

            reader.incrementOffsetByValue(3);


            UInt16 body   = 0;
            UInt16 gender = 0;


            UInt16 skintone = reader.readUInt16(1);

            reader.setOffsetOverrideValue(7);
            UInt16 bodyTypeId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(15);
            UInt16 hairId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(19);
            UInt16 haircolor = reader.readUInt16(1);

            reader.setOffsetOverrideValue(23);
            UInt16 tattoo = reader.readUInt16(1);

            reader.setOffsetOverrideValue(27);
            UInt16 headId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(31);
            UInt16 facialDetail = reader.readUInt16(1);

            reader.setOffsetOverrideValue(35);
            // ToDo: it has a bug - figure out correct position
            UInt16 facialDetailColor = reader.readUInt16(1);

            // ToDo: Remove this when facialDetailColor is parsed properly
            facialDetailColor = 0;
            reader.setOffsetOverrideValue(67);
            UInt16 profession = reader.readUInt16(1);


            // lets read the values
            // the IDs for the Appeareance is always uint16 goID
            // Extra Hint: there are no leggins in Char Creation Process
            reader.setOffsetOverrideValue(35);
            UInt16 hatId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(39);
            UInt16 eyewearId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(43);
            UInt16 shirtId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(47);
            UInt16 glovesId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(51);
            UInt16 outerwearId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(55);
            UInt16 pantsId = reader.readUInt16(1);

            reader.setOffsetOverrideValue(63);
            UInt16 footwearId = reader.readUInt16(1);


            // Get Values by "NewRSI" IDs
            NewRSIItem hairItem = itemLoader.getNewRSIItemByTypeAndID("HAIR", hairId);
            NewRSIItem bodyItem = itemLoader.getNewRSIItemByTypeAndID("BODY", (ushort)bodyTypeId);
            NewRSIItem headItem = itemLoader.getNewRSIItemByTypeAndID("HEAD", headId);

            Store.dbManager.MarginDbHandler.updateRSIValue("body", bodyItem.internalId.ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("sex", bodyItem.gender.ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("face", headItem.internalId.ToString(), newCharID);              // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("hair", hairItem.internalId.ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("haircolor", haircolor.ToString(), newCharID);                   // ToDo: check if it is correct
            Store.dbManager.MarginDbHandler.updateRSIValue("tattoo", tattoo.ToString(), newCharID);                         // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("facialdetail", facialDetail.ToString(), newCharID);             // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("facialdetailcolor", facialDetailColor.ToString(), newCharID);   // ToDo:
            Store.dbManager.MarginDbHandler.updateRSIValue("skintone", skintone.ToString(), newCharID);


            // Clothing Items
            ClothingItem shirt     = itemLoader.getItemValues(shirtId);
            ClothingItem pants     = itemLoader.getItemValues(pantsId);
            ClothingItem outerwear = itemLoader.getItemValues(outerwearId);
            ClothingItem hat       = itemLoader.getItemValues(hatId);
            ClothingItem eyewear   = itemLoader.getItemValues(eyewearId);
            ClothingItem footwear  = itemLoader.getItemValues(footwearId);
            ClothingItem gloves    = itemLoader.getItemValues(glovesId);

            Store.dbManager.MarginDbHandler.updateRSIValue("hat", hat.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shirt", shirt.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shirtcolor", shirt.getColorId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("coat", outerwear.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("coatcolor", outerwear.getColorId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("pants", pants.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("pantscolor", pants.getColorId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shoes", footwear.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("shoecolor", footwear.getColorId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("glasses", eyewear.getModelId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("glassescolor", eyewear.getColorId().ToString(), newCharID);
            Store.dbManager.MarginDbHandler.updateRSIValue("gloves", gloves.getModelId().ToString(), newCharID);

            Store.dbManager.MarginDbHandler.AddItemToSlot(hatId, 0x61, newCharID);
            Store.dbManager.MarginDbHandler.AddItemToSlot(eyewearId, 0x62, newCharID);
            Store.dbManager.MarginDbHandler.AddItemToSlot(shirtId, 0x63, newCharID);
            Store.dbManager.MarginDbHandler.AddItemToSlot(glovesId, 0x64, newCharID);
            Store.dbManager.MarginDbHandler.AddItemToSlot(outerwearId, 0x65, newCharID);
            Store.dbManager.MarginDbHandler.AddItemToSlot(pantsId, 0x66, newCharID);
            Store.dbManager.MarginDbHandler.AddItemToSlot(footwearId, 0x68, newCharID);


            // FirstName
            UInt16 currentOffset = 79;

            byte[] firstNameLenBytes = new byte[2];
            ArrayUtils.copy(packet, currentOffset, firstNameLenBytes, 0, 2);
            UInt16 firstNameLen = NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1);

            currentOffset += 2;

            byte[] firstNameBytes = new byte[NumericalUtils.ByteArrayToUint16(firstNameLenBytes, 1) - 1];
            ArrayUtils.copy(packet, currentOffset, firstNameBytes, 0, firstNameLen - 1);
            string firstNameString = StringUtils.charBytesToString(firstNameBytes);

            currentOffset += firstNameLen;

            // LastName
            byte[] lastNameLenBytes = new byte[2];
            ArrayUtils.copy(packet, currentOffset, lastNameLenBytes, 0, 2);
            UInt16 lastNameLen = NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1);

            currentOffset += 2;

            byte[] lastNameBytes = new byte[NumericalUtils.ByteArrayToUint16(lastNameLenBytes, 1) - 1];
            ArrayUtils.copy(packet, currentOffset, lastNameBytes, 0, lastNameLen - 1);
            string lastNameString = StringUtils.charBytesToString(lastNameBytes);

            currentOffset += lastNameLen;

            // Description
            byte[] descriptionLenBytes = new byte[2];
            ArrayUtils.copy(packet, currentOffset, descriptionLenBytes, 0, 2);
            UInt16 descriptionLen = NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1);

            currentOffset += 2;

            byte[] descriptionBytes = new byte[NumericalUtils.ByteArrayToUint16(descriptionLenBytes, 1) - 1];
            ArrayUtils.copy(packet, currentOffset, descriptionBytes, 0, descriptionLen - 1);
            string descriptionString = StringUtils.charBytesToString(descriptionBytes);

            currentOffset += lastNameLen;

            // Update Characters values
            Store.dbManager.MarginDbHandler.updateCharacter(firstNameString, lastNameString, descriptionString, newCharID);

            // Add the Basic Abilitys...
            addStartAbilitys(newCharID);

            // we have all created - lets load the charData
            loadCharacter(packet, client, this.newCharID);
        }