uint16ToByteArrayShort() public static method

public static uint16ToByteArrayShort ( UInt16 data ) : byte[]
data System.UInt16
return byte[]
Esempio n. 1
0
        public void generateRpcMessageData()
        {
            // Example : 04 01 00 15 01 + submessages
            // Strcut: uint8 04 header + uint8 listcount + uint16 currentRPCCounter + submessageCounter (list1)
            // If you have 2 lists , the data struct is : uint8 submessagecount + submessages

            // TODO!!! FINALIZE!!
            // Here goes code from RPCPacket (As it should be generated on the fly)
            if (RPCMessages.Count > 0)
            {
                content.append((byte)ProtocolHeaders.RPC_PROTOCOL);
                // ToDo: Figure out what the "Lists" Count should handle ...maybe different types?
                // Why not having just one List and adding them all ? Maybe a list has a limit ?
                content.append(0x01); // List Count for RPC Messages
                Output.WriteLine(" RPC COUNTER BYTES :" + StringUtils.bytesToString(NumericalUtils.uint16ToByteArray(playerData.getRPCCounter(), 0)));
                content.append(NumericalUtils.uint16ToByteArray(playerData.getRPCCounter(), 0));
                content.append(NumericalUtils.uint16ToByteArrayShort((UInt16)RPCMessages.Count));
                foreach (SequencedMessage message in RPCMessages)
                {
                    content.append(message.content);
                }

                // Set new RPC Counter
                UInt16 incrementRpcCounter = playerData.getRPCCounter();
                Output.WriteDebugLog("Before RPC Counter :" + incrementRpcCounter.ToString());
                incrementRpcCounter += (ushort)RPCMessages.Count;
                playerData.setRPCCounter(incrementRpcCounter);
                Output.WriteDebugLog("After RPC Counter :" + incrementRpcCounter.ToString() + " (should added " + RPCMessages.Count.ToString() + ")");
            }
        }
Esempio n. 2
0
        public void processPlayFX(UInt32 fxID)
        {
            Output.writeToLogForConsole("PLAY FX FOR " + fxID.ToString());
            DynamicArray din = new DynamicArray();

            byte[] animationId = NumericalUtils.uint32ToByteArray(fxID, 1);
            byte[] viewID      = { 0x02, 0x00 };

            Random rand = new Random();
            ushort updateViewCounter = (ushort)rand.Next(3, 200);

            byte[] updateCount = NumericalUtils.uint16ToByteArrayShort(updateViewCounter);

            din.append(viewID);
            din.append(0x02);
            din.append(0x80);
            din.append(0x80);
            din.append(0x80);
            din.append(0x90);
            din.append(0xed);
            din.append(0x00);
            din.append(0x30);
            din.append(animationId);
            din.append(updateCount);

            Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false);
        }
Esempio n. 3
0
        public void processSelfAnimation(UInt16 abilityID)
        {
            DynamicArray din = new DynamicArray();
            //byte[] animationId = {0x22, 0x0a, 0x00, 0x28}; // Repair RSI
            //byte[] animationId = { 0x39, 0x0a, 0x00, 0x28 }; // Jackout


            /*
             * Array fxIDs = Enum.GetValues(typeof(FXList));
             * Random randAnim = new Random();
             * UInt32 randAnimID = (UInt32)fxIDs.GetValue(randAnim.Next(fxIDs.Length));
             */
            UInt32 randAnimID = (UInt32)FXList.FX_VIRUSCAST_SPLIT_CODE_NUKE_CODENUKE_START;

            byte[] animationId = NumericalUtils.uint32ToByteArray(randAnimID, 0);
            byte[] viewID      = { 0x02, 0x00 };

            byte[] updateCount = NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());

            din.append(viewID);
            din.append(0x02);
            din.append(0x80);
            din.append(0x80);
            din.append(0x80);
            din.append(0x90);
            din.append(0xed);
            din.append(0x00);
            din.append(0x30);
            din.append(animationId);
            din.append(updateCount);

            Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false);
        }
Esempio n. 4
0
        public void sendTCPVariableLenPacket(byte[] packet, NetworkStream client)
        {
            byte[] size     = { };
            byte[] bytesize = { };

            if (packet.Length > 127)
            {
                //Do NOT reverse here :P
                bytesize = NumericalUtils.uint16ToByteArray((UInt16)(packet.Length + 0x8000), 0);
            }
            else
            {
                bytesize = NumericalUtils.uint16ToByteArrayShort((ushort)packet.Length);
            }

            byte[] finalPacket = new byte[packet.Length + bytesize.Length];

            DynamicArray din = new DynamicArray();

            din.append(bytesize);
            din.append(packet);

            finalPacket = din.getBytes();

            try
            {
                client.Write(finalPacket, 0, finalPacket.Length);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR ex: " + ex.ToString());
                throw;
            }
            client.Flush();
        }
Esempio n. 5
0
        public void sendHyperSpeed()
        {
            byte[]        updateCount = NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());
            PacketContent pak         = new PacketContent();

            pak.addUint16(2, 1);
            pak.addHexBytes("0288058c1e6666F63F80903200b056060028");
            pak.addByteArray(updateCount);
            pak.addHexBytes("0200000000");
            Store.currentClient.messageQueue.addObjectMessage(pak.returnFinalPacket(), false);
            Store.currentClient.flushQueue();
        }
Esempio n. 6
0
        public byte[] getBytes()
        {
            DynamicArray rpcStructure = new DynamicArray();

            byte [] totalMsgBlocks = NumericalUtils.uint16ToByteArrayShort((UInt16)addedMsgBlocks);
            byte [] currentCounter = getRpcBytes();

            rpcStructure.append(currentCounter);
            rpcStructure.append(totalMsgBlocks);
            rpcStructure.append(din.getBytes());

            // Increment RPC Counter

            incrementRpcCounter(addedMsgBlocks);

            return(rpcStructure.getBytes());
        }
Esempio n. 7
0
        public byte[] loadInventory(int charID)
        {
            List <MarginInventoryItem> Inventory = new List <MarginInventoryItem>();

            Inventory = Store.dbManager.MarginDbHandler.loadInventory(charID);

            DynamicArray din = new DynamicArray();

            foreach (MarginInventoryItem item in Inventory)
            {
                din.append(NumericalUtils.uint16ToByteArrayShort(item.getSlot())); // slot
                din.append(NumericalUtils.uint32ToByteArray(item.getItemID(), 1));

                din.append(0x00);
                din.append(0x00);
                din.append(0x00); // ToDo : Figure out the bit flags shit thing for amount
                din.append(0x0c); // ToDo : same for purity
            }
            return(din.getBytes());
        }
Esempio n. 8
0
        /*
         * Add a RPC Message with size byte automatically to the queue
         */
        public void addRpcMessage(byte[] messageBlock)
        {
            byte[] rpcSizeByte;
            if (messageBlock.Length > 127)
            {
                rpcSizeByte = NumericalUtils.uint16ToByteArray((UInt16)(messageBlock.Length + 0x8000), 0);
            }
            else
            {
                rpcSizeByte = NumericalUtils.uint16ToByteArrayShort((UInt16)messageBlock.Length);
            }
            DynamicArray content = new DynamicArray();

            content.append(rpcSizeByte);
            content.append(messageBlock);

            SequencedMessage message = new SequencedMessage(content.getBytes());

            RPCMessagesQueue.Add(message);
        }
Esempio n. 9
0
        public byte[] getBytesWithHeader(bool timedRPC)
        {
            DynamicArray rpcStructure = new DynamicArray();

            byte[] noTimedHeader = { 0x04 };
            byte[] timedHeader   = new byte[6];
            byte[] time          = TimeUtils.getUnixTime();

            timedHeader[0] = 0x82;

            ArrayUtils.copy(time, 0, timedHeader, 1, 4);
            timedHeader[5] = 0x04;             // This makes it "82aabbccdd04"

            if (timedRPC)
            {
                rpcStructure.append(timedHeader);
            }
            else
            {
                rpcStructure.append(noTimedHeader);
            }

            // Calculate blocks number


            if (rpcInside == 0)            // Is just 1 group of msgblocks
            {
                rpcInside = 1;
                rpcStructure.append(NumericalUtils.uint16ToByteArrayShort((UInt16)rpcInside));
                rpcStructure.append(getBytes());                 //Append our own content
            }
            else
            {
                rpcStructure.append(NumericalUtils.uint16ToByteArrayShort((UInt16)rpcInside));
                rpcStructure.append(din.getBytes());                 //Append our own content
            }


            return(rpcStructure.getBytes());
        }
Esempio n. 10
0
        // Shows the Animation of a target Player
        public void processFXfromPlayer(UInt16 viewID, byte[] animation)
        {
            Random rand = new Random();
            ushort updateViewCounter = (ushort)rand.Next(3, 200);

            byte[] updateCount = NumericalUtils.uint16ToByteArrayShort(updateViewCounter);

            DynamicArray din = new DynamicArray();

            din.append(NumericalUtils.uint16ToByteArray(viewID, 1));
            din.append(0x00);
            din.append(0x80);
            din.append(0x80);
            din.append(0x80);
            din.append(0x0c);
            din.append(animation); // uint32 anim ID
            din.append(updateCount);
            din.append(0x00);
            din.append(0x00);

            Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false);
        }
Esempio n. 11
0
        public void sendCastAbilityOnEntityId(UInt16 viewId, UInt32 animationId)
        {
            ClientView theView = Store.currentClient.viewMan.getViewById(viewId);

            byte[] updateCount = NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());

            Random rand         = new Random();
            ushort randomHealth = (ushort)rand.Next(3, 1800);
            // RSI Health FX "send 02 03 02 00 02 80 80 80 90 ed 00 30 22 0a 00 28 06 00 00;"
            PacketContent pak = new PacketContent();

            if (viewId == 0)
            {
                viewId = 2;
            }
            pak.addUint16(viewId, 1);

            UInt32 theGoID = 12;

            if (theView != null)
            {
                theGoID = theView.GoID;
            }

            switch (theGoID)
            {
            case 12:
                pak.addByte(0x02);
                pak.addByte(0x80);
                pak.addByte(0x80);
                pak.addByte(0x80);
                if (viewId == 2)
                {
                    pak.addByte(0x80);
                    pak.addByte(0xb0);
                }
                else
                {
                    pak.addByte(0x0c);
                }
                pak.addUint32(animationId, 1);
                pak.addByteArray(updateCount);
                break;

            case 599:
                pak.addByte(0x04);
                pak.addByte(0x80);
                pak.addByte(0x80);
                pak.addByte(0x80);
                pak.addByte(0xc0);
                pak.addUint16(randomHealth, 1);     // health
                pak.addByte(0xc0);
                pak.addUint32(animationId, 1);
                pak.addByteArray(updateCount);
                pak.addByte(0x05);
                pak.addByte(0x00);
                pak.addByte(0x00);
                string hexNPC = StringUtils.bytesToString(pak.returnFinalPacket());
                // Its more a demo - we "one hit" the mob currently so we must update this
                lock (WorldSocket.npcs.SyncRoot)
                {
                    for (int i = 0; i < WorldSocket.npcs.Count; i++)
                    {
                        npc thismob = (npc)WorldSocket.npcs[i];
                        if (thismob.getEntityId() == theView.entityId)
                        {
                            thismob.setIsDead(true);
                            thismob.setIsLootable(true);
                            WorldSocket.npcs[i] = thismob;
                            this.sendNPCDies(theView.ViewID, Store.currentClient, thismob);
                        }
                    }
                }
                break;

            default:
                pak.addByte(0x02);
                pak.addByte(0x80);
                pak.addByte(0x80);
                pak.addByte(0x80);
                if (viewId == 2)
                {
                    pak.addByte(0x80);
                    pak.addByte(0xb0);
                }
                else
                {
                    pak.addByte(0x0c);
                }
                pak.addUint32(animationId, 1);
                pak.addByteArray(updateCount);
                break;
            }

            string hex = StringUtils.bytesToString(pak.returnFinalPacket());

            Store.currentClient.messageQueue.addObjectMessage(pak.returnFinalPacket(), false);
            Store.currentClient.flushQueue();
        }
Esempio n. 12
0
        public void parseCommand(string data)
        {
            Output.WriteLine("[Chat Command helper] Chat command is: '" + data + "'");
            string[] commands = data.Split(' ');

            string command = commands[0].ToLower();

            try{
                if (command.Equals("?fix") && commands.Length > 1)
                {
                    int maxRPC = int.Parse(commands[1]);
                    for (int i = 0; i < maxRPC; i++)
                    {
                        Store.currentClient.playerData.setRPCCounter((UInt16)i);
                        Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Trying to fix! " + i, Store.currentClient));
                    }
                }

                if (command.Equals("?teleport") && commands.Length == 4)
                {
                    // parse the coord parameters parameters as int
                    Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().teleport(int.Parse(commands[1]), int.Parse(commands[2]), int.Parse(commands[3])), false);
                    Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Teleported!", Store.currentClient));
                }

                if (command.Equals("?rsi") && commands.Length == 3)
                {
                    //parse the rsi part and value
                    Store.currentClient.messageQueue.addObjectMessage(new PlayerHelper().changeRsi(commands[1], int.Parse(commands[2])), false);
                    Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Rsi changed!", Store.currentClient));
                }


                if (command.StartsWith("?message"))
                {
                    Output.WriteLine("[COMMAND HELPER]MESSAGE RECEIVED");
                    byte[] theMessage = PacketsUtils.createSystemMessageWithoutRPC(commands[1]);
                    Store.world.sendRPCToAllPlayers(theMessage);
                }

                if (command.Equals("?playanim"))
                {
                    string animId = commands[1];
                    if (animId.Length == 4)
                    {
                        ServerPackets pak = new ServerPackets();
                        pak.sendPlayerAnimation(Store.currentClient, animId);
                    }
                }

                if (command.StartsWith("?playfx"))
                {
                    string       fxHEDID = commands[1];
                    DynamicArray din     = new DynamicArray();


                    byte[] animationId = StringUtils.hexStringToBytes(fxHEDID);
                    byte[] viewID      = { 0x02, 0x00 };

                    Random rand = new Random();
                    ushort updateViewCounter = (ushort)rand.Next(3, 200);
                    byte[] updateCount       = NumericalUtils.uint16ToByteArrayShort(updateViewCounter);

                    Output.WriteLine("Check if its really one byte or two : " + StringUtils.bytesToString(updateCount));


                    din.append(viewID);
                    din.append(0x02);
                    din.append(0x80);
                    din.append(0x80);
                    din.append(0x80);
                    din.append(0x90);
                    din.append(0xed);
                    din.append(0x00);
                    din.append(0x30);
                    din.append(animationId);
                    din.append(updateCount);

                    Store.currentClient.messageQueue.addObjectMessage(din.getBytes(), false);
                }

                if (command.Contains("?send"))
                {
                    // Sends a packet from a file
                    string     filename   = "packet.txt";
                    TextReader tr         = new StreamReader(filename);
                    string     hexContent = tr.ReadToEnd();
                    hexContent = hexContent.Replace(" ", string.Empty);
                    hexContent = hexContent.Replace(" ", Environment.NewLine);
                    tr.Close();

                    if (hexContent.Length > 0)
                    {
                        Store.currentClient.messageQueue.addObjectMessage(StringUtils.hexStringToBytes(hexContent), false);
                        Output.writeToLogForConsole("[SENDPACK FROM FILE] Content : " + hexContent);
                    }
                }

                if (command.Contains("?combat"))
                {
                    byte[]          dummypak = new byte[4];
                    TestUnitHandler test     = new TestUnitHandler();
                    test.testCloseCombat(ref dummypak);
                }

                if (command.Contains("?mob"))
                {
                    UInt32[] rsiIDs = new UInt32[10];
                    rsiIDs[0] = 0xB7010058;
                    rsiIDs[1] = 0x89090058;
                    rsiIDs[2] = 0xB5010058;
                    rsiIDs[3] = 0x3A030008;
                    rsiIDs[4] = 0x32030008;
                    rsiIDs[5] = 0xD0010058;
                    rsiIDs[6] = 0xD4010058;
                    rsiIDs[7] = 0xB8040004; // Smith
                    rsiIDs[8] = 0x92010058; // Seraph
                    rsiIDs[9] = 0x56050004;
                    Random rand  = new Random();
                    int    index = rand.Next(0, 9);

                    double x = 0; double y = 0; double z = 0;
                    byte[] Ltvector3d = Store.currentClient.playerInstance.Position.getValue();
                    NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z);

                    byte[] xPos = NumericalUtils.floatToByteArray((float)x, 1);
                    byte[] yPos = NumericalUtils.floatToByteArray((float)y, 1);
                    byte[] zPos = NumericalUtils.floatToByteArray((float)z, 1);

                    UInt64 currentEntityId = WorldSocket.entityIdCounter;
                    WorldSocket.entityIdCounter++;
                    uint rotation = 0;

                    npc theMob = new npc();
                    theMob.setEntityId(currentEntityId);
                    theMob.setDistrict(Convert.ToUInt16(data[0].ToString()));
                    theMob.setDistrictName(Store.currentClient.playerData.getDistrict());
                    theMob.setName("HD Protector");
                    theMob.setLevel(255);
                    theMob.setHealthM(UInt16.Parse(data[4].ToString()));
                    theMob.setHealthC(UInt16.Parse(data[5].ToString()));
                    theMob.setMobId((ushort)rsiIDs[index]);
                    theMob.setRsiHex(StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray(rsiIDs[index], 1)));
                    theMob.setXPos(x);
                    theMob.setYPos(y);
                    theMob.setZPos(z);
                    theMob.xBase = x;
                    theMob.yBase = y;
                    theMob.zBase = z;
                    theMob.setRotation(rotation);
                    theMob.setIsDead(false);
                    theMob.setIsLootable(false);
                    WorldSocket.npcs.Add(theMob);

                    // we use this for a test to see if we can spawn mobs and how we can handle them
                    // We refactor this
                }



                if (command.Contains("?sendrpc"))
                {
                    // sends a RPC Packet from a File
                    string     filename   = "rpcpacket.txt";
                    TextReader tr         = new StreamReader(filename);
                    string     hexContent = tr.ReadToEnd();
                    hexContent = hexContent.Replace(" ", string.Empty);
                    hexContent = hexContent.Replace(" ", Environment.NewLine);
                    Output.Write("SEND RPC COMMAND : CONTENT : " + hexContent);
                    tr.Close();

                    if (hexContent.Length > 0)
                    {
                        Store.currentClient.messageQueue.addRpcMessage(StringUtils.hexStringToBytes(hexContent));
                        Output.writeToLogForConsole("[SENDRPC FROM FILE] Content : " + hexContent);
                    }
                }

                if (command.Contains("?checkrpc"))
                {
                    DynamicArray din = new DynamicArray();
                    din.append(StringUtils.hexStringToBytes("2E1000FF7D020024000000310000000000000000000000000000000000000000000000000B0053796E61707A65373737001D004F6E2079656168204920646F2072656D656D62657220796F75203A2900"));
                    Store.currentClient.messageQueue.addRpcMessage(din.getBytes());
                }

                if (command.Contains("?testrpc"))
                {
                    UInt16 maxRPC = 33279;
                    // Just to reference
                    if (Store.currentClient.playerData.currentTestRPC <= maxRPC)
                    {
                        // Only if it is below we send it - we test with a 5 size packet
                        DynamicArray din = new DynamicArray();
                        if (Store.currentClient.playerData.currentTestRPC < 127)
                        {
                            din.append(NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.currentTestRPC));
                        }
                        else
                        {
                            din.append(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.currentTestRPC, 0));
                        }

                        din.append(0x00);
                        din.append(0x00);
                        din.append(0x00);

                        Store.currentClient.messageQueue.addRpcMessage(din.getBytes());

                        ServerPackets pak = new ServerPackets();
                        pak.sendSystemChatMessage(Store.currentClient, "Test RPC Header : " + Store.currentClient.playerData.currentTestRPC.ToString(), "MODAL");

                        Store.currentClient.playerData.currentTestRPC++;
                    }
                }

                if (command.Equals("?save"))
                {
                    new PlayerHelper().savePlayerInfo(Store.currentClient);

                    ServerPackets pak = new ServerPackets();
                    pak.sendSaveCharDataMessage(Store.currentClient, StringUtils.charBytesToString_NZ(Store.currentClient.playerInstance.CharacterName.getValue()));
                }
            }
            catch (Exception e) {
                Store.currentClient.messageQueue.addRpcMessage(PacketsUtils.createSystemMessage("Error parsing command!", Store.currentClient));
                Output.WriteLine("[CHAT COMMAND PARSER] Error parsing request: " + data);
                Output.WriteLine("[CHAT COMMAND PARSER] DEBUG: " + e.Message + "\n" + e.StackTrace);
            }
        }
Esempio n. 13
0
        public void processObjectInteraction(StaticWorldObject staticWorldObject, GameObjectItem item)
        {
            WorldSocket.gameServerEntities.Add(staticWorldObject);
            UInt16 typeId = NumericalUtils.ByteArrayToUint16(staticWorldObject.type, 1);

            Store.currentClient.playerData.newViewIdCounter++; // It is just for a test Later we will change this to have a List with Views and Object IDs

            NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());
            ServerPackets packets = new ServerPackets();

            packets.sendSystemChatMessage(Store.currentClient, "Door ID " + staticWorldObject.mxoId + " Type ID " + typeId.ToString() + " POS X:" + staticWorldObject.pos_x.ToString() + " Y:" + staticWorldObject.pos_y.ToString() + " Z:" + staticWorldObject.pos_z.ToString() + typeId, "BROADCAST");


            switch (typeId)
            {
            case 343:
            case 346:
            case 359:
            case 365:
            case 414:
            case 415:
            case 416:
            case 576:
            case 6958:
            case 6965:
            case 6963:
            case 6964:
            case 6972:
                // ObjectAttribute364
                ObjectAttributes364 door364 = new ObjectAttributes364("DOOR364", typeId, staticWorldObject.mxoId);
                door364.DisableAllAttributes();
                door364.Orientation.enable();
                door364.Position.enable();
                door364.CurrentState.enable();
                // Set Values
                door364.Position.setValue(NumericalUtils.doublesToLtVector3d(staticWorldObject.pos_x, staticWorldObject.pos_y, staticWorldObject.pos_z));
                door364.CurrentState.setValue(StringUtils.hexStringToBytes("34080000"));
                door364.Orientation.setValue(StringUtils.hexStringToBytes(staticWorldObject.quat));
                //door364.Orientation.setValue(StringUtils.hexStringToBytes("000000000000803F0000000000000000")); // ToDo: Replace it with staticWorldObject.quat when it is okay

                // ToDo: We make a little Entity "Hack" so that we have a unique id : metrid + fullmxostatic_id is entity
                String entityMxOHackString = "" + staticWorldObject.metrId + "" + staticWorldObject.mxoId;
                UInt64 entityId            = UInt64.Parse(entityMxOHackString);

                packets.sendSpawnStaticObject(Store.currentClient, door364, entityId);

                break;

            case 6601:
            case 6994:
            case 341:
            case 417:
            case 419:

                ObjectAttributes363 door363 = new ObjectAttributes363("DOOR363", typeId, staticWorldObject.mxoId);
                door363.DisableAllAttributes();
                door363.Orientation.enable();
                door363.Position.enable();
                door363.CurrentState.enable();
                // Set Values
                door363.Position.setValue(NumericalUtils.doublesToLtVector3d(staticWorldObject.pos_x, staticWorldObject.pos_y, staticWorldObject.pos_z));
                door363.Orientation.setValue(StringUtils.hexStringToBytes(staticWorldObject.quat));
                //door363.Orientation.setValue(StringUtils.hexStringToBytes("000000000000803F0000000000000000")); // ToDo: Replace it with staticWorldObject.quat when it is okay
                door363.CurrentState.setValue(StringUtils.hexStringToBytes("34080000"));

                // ToDo: We make a little Entity "Hack" so that we have a unique id : metrid + fullmxostatic_id is entity
                String entity363MxOHackString = "" + staticWorldObject.metrId + "" + staticWorldObject.mxoId;
                UInt64 entity363Id            = UInt64.Parse(entity363MxOHackString);

                packets.sendSpawnStaticObject(Store.currentClient, door363, entity363Id);
                break;

            case 592:
                new TeleportHandler().processHardlineExitRequest();
                break;

            default:
                new ServerPackets().sendSystemChatMessage(Store.currentClient, "Unknown Object Interaction with Object Type " + staticWorldObject.type + " and Name " + item.getName(), "MODAL");
                break;
            }
        }
Esempio n. 14
0
 public void addUintShort(UInt16 value)
 {
     packet.append(NumericalUtils.uint16ToByteArrayShort(value));
 }
Esempio n. 15
0
        public void processOpenDoor(StaticWorldObject door)
        {
            UInt16 typeId = NumericalUtils.ByteArrayToUint16(door.type, 1);

            byte[] masterViewId = { 0x01, 0x00 };
            byte[] seperator    = { 0xcd, 0xab };

            Store.currentClient.playerData.newViewIdCounter++; // It is just for a test Later we will change this to have a List with Views and Object IDs

            byte[] disarmDifficultyMaybe = { 0x03, 0x84 };
            byte[] endViewID             = { 0x00, 0x00 };

            byte[] spawnCounter = NumericalUtils.uint16ToByteArrayShort(Store.currentClient.playerData.assignSpawnIdCounter());
            Output.WriteLine("[DOOR]POS X : " + door.pos_x.ToString() + " POS Y: " + door.pos_y.ToString() + " POS Z: " + door.pos_z.ToString() + ", TypeId: " + StringUtils.bytesToString_NS(door.type));

            switch (typeId)
            {
            case 417:
            case 419:
                // ToDo: Packet Format for Elevator
                // 02 03 01 00
                // 08
                // a3 01
                // 6b 01 f0 3d be
                // cd ab 03 88 00 00 00 00 ff ff 7f 3f 00 00 00 00 f3 04 35 33
                // 22 00 00 00 00 40 f4 fb 40 00 00 00 00 00 90 75 40 00 00 00 00 00 40 af 40 ff ff ff ff 19 00 00
                // 11 00 01 00 04 61 97 e1 47 f0 bf 2d 44 de 30 35 45 00 00
                PacketContent content = new PacketContent();
                content.addByteArray(masterViewId);
                content.addByte(0x08);
                content.addByteArray(door.type);
                content.addByteArray(NumericalUtils.uint32ToByteArray(door.mxoId, 1));
                content.addByteArray(spawnCounter);                            // Spawn Object Counter
                content.addByteArray(seperator);
                content.addByte(0x03);                                         // Number of Attributes to parse (3)
                content.addByte(0x88);                                         // GROUP 1 - more groups ON, Attribute 4 (305,Orientation,LTQuaternion,16) SET (10001000)
                content.addByteArray(StringUtils.hexStringToBytes(door.quat)); // ToDo: replace it later with the real LTQuaternion
                content.addByte(0x22);                                         // GROUP 2 - more groups OFF, Attribute 2,6  SET (00100010)
                content.addDoubleLtVector3d(door.pos_x, door.pos_y, door.pos_z);
                content.addByteArray(new byte[] { 0xff, 0xff, 0xff, 0xff });
                content.addByteArray(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.newViewIdCounter, 1));
                content.addByteArray(endViewID);
                content.addByte(0x00);
                Store.currentClient.messageQueue.addObjectMessage(content.returnFinalPacket(), false);
                break;

            case 2506:
                // ToDo: Packet Format for Elevator


                break;

            default:

                PacketContent contentDefault = new PacketContent();
                contentDefault.addByteArray(masterViewId);
                contentDefault.addByte(0x08);
                contentDefault.addByteArray(door.type);
                contentDefault.addByteArray(NumericalUtils.uint32ToByteArray(door.mxoId, 1));
                contentDefault.addByteArray(spawnCounter);     // Spawn Object Counter
                contentDefault.addByteArray(seperator);
                contentDefault.addByteArray(disarmDifficultyMaybe);
                contentDefault.addByte(0x00);                                                                  // isZionAligned?
                contentDefault.addByteArray(StringUtils.hexStringToBytes("0000000000803F000000000000000041")); // ToDo: replace it later with the real values from the object
                contentDefault.addDoubleLtVector3d(door.pos_x, door.pos_y, door.pos_z);
                contentDefault.addByteArray(StringUtils.hexStringToBytes("34080000"));
                contentDefault.addByteArray(NumericalUtils.uint16ToByteArray(Store.currentClient.playerData.newViewIdCounter, 1));
                contentDefault.addByteArray(endViewID);
                contentDefault.addByte(0x00);
                Store.currentClient.messageQueue.addObjectMessage(contentDefault.returnFinalPacket(), false);
                break;
            }
        }
Esempio n. 16
0
        private void loadCharacter(byte[] packet, NetworkStream client, UInt32 theCharId)
        {
            byte[] charIDB = new byte[4];

            if (theCharId == 0)
            {
                ArrayUtils.copy(packet, 3, charIDB, 0, 4); //Offset for charID is 3 in request
                uint charId = (uint)NumericalUtils.ByteArrayToUint32(charIDB, 1);
                // Remove current instances for this character
                if (Store.margin.isAnotherClientActive(charId) == true)
                {
                    CharacterAlreadyInUseReply(client);
                    return;
                }
                this.newCharID = charId;
            }


            charIDB = NumericalUtils.uint32ToByteArray(this.newCharID, 1);

            //New harcoded sessionID is: ac 53 02 00
            //Old is: 28 A9 02 00
            string [] marginValues = new string[0x0e];
            marginValues[8]   = "000b10001e000700000001000800000000000a00000003000d00000000001c0000000100";
            marginValues[0xc] = "000e10000000";
            marginValues[0xd] = "010f10000000";

            // Some Items
            string itemData = "0170A7000000000010" + "020B8F00000000001803B80200000000001804EE9900000000000005F399000000000000065F0900000000100007C80900000000000008D59D000000000C0009EA040000000000480AD61E0000000000380BF21800000000001C0C66900000000000140DB30400000000001C0E04A80000000018000F3743000000000028108D2200000000002411441A00000000004415808C00000000004462EB0300000000001C63CC5A00000000004464ECB2000000000048651CB3000000000038663E9500000000006868EA0400000000001C";

            byte[] inventory = StringUtils.hexStringToBytes(itemData);

            // Loaded Abilities
            string loadedAbs = "000032080080070000E400800B0000E002800C00006403800E0000340180110032B400801600322C0080290032D404802B0000DC04802F00322800803000323000803E0001E404804200322005805D0000E800805E0032D000805F00327C01806B00008801806F00001C0580990001280580A40000A40080A60000AC0080AC0000EC0080B00000000180B10000040180B80032240180BB0032300180BC00004C0180C50000A00080D80001EC0480DD00012C0580EA0001E80480F400013005800D01013405801D0101680780200132740580280100E004802C01013805803601018C05803801017805803A01325C0780490100840180520100D8088056010124";

            byte[] loadAbilitys = StringUtils.hexStringToBytes(loadedAbs);

            // Known Abilities
            string abilityData = "0000320800800100014800800200017C0080030000080280040000140380050001300480060001B40080070000E4008008000018038009000F9400800A0000E002800B0000E002800C00006403800D00009000800E00003401800F00018C00801000006C0080110032B40080120000E402801300001003801400016400801500322004801600322C0080170001AC09801800012C008019000F9400801A0032C401801B00010800801C00018400801D0000F803801E001A3802801F00010400802000006C0280210001240580220032B40980230032640680240001680080250087DF11842600000400802700001C0080280032540480290032D404802A003210";

            byte[] knownAbilitiys = StringUtils.hexStringToBytes(abilityData);


            // Known Hardlines
            //string hardlineData = "0207000000021f000000022300000002240000000225000000022600000002270000000229000000022b000000022f00000002300000000231000000023200000002340000000235000000023600000002370000000238000000023b000000023f000000024000000002410000000243000000024500000002480000000249000000024a000000024b000000024d000000024e000000024f000000025000000002510000000252000000025400000002550000000256000000025700000002580000000259000000025a000000025b000000025c000000025d000000025e000000025f000000026000000002610000000262000000026300000002640000000265000000026600000002670000000269000000026a000000026b000000026c000000026d000000026e000000026f000000027000000002710000000130000000013100000001370000000141000000014500000001480000000149000000014a000000014b000000014c000000014e000000014f0000000150000000015100000001520000000163000000016400000001650000000166000000016700000001680000000169000000016a000000016b000000016d000000016f00000001700000000171000000017200000001730000000174000000017700000001780000000179000000017a000000017b000000017c000000017d000000017e000000017f000000018000000001810000000182000000018300000001840000000185000000018600000001870000000188000000018a000000018b000000018c000000018d000000018e000000019000000001910000000192000000019300000001940000000195000000019600000001970000000198000000019900000003020000000303000000030400000003050000000306000000030700000003080000000309000000030a000000030b000000030c000000030d000000030e000000030f000000031000000003110000000312000000031300000003140000000315000000031600000003170000000318000000";
            //string hardlineData = Store.dbManager.MarginDbHandler.loadAllHardlines();
            string hardlineData = "0130000000013100000001370000000141000000014500000001480000000149000000014A000000014B000000014C000000014E000000014F00000001500000000151000000015200000001530000000163000000016400000001650000000166000000016700000001680000000169000000016A000000016B000000016D000000016F00000001700000000171000000017200000001730000000174000000017700000001780000000179000000017A000000017B000000017C000000017D000000017E000000017F000000018000000001810000000182000000018300000001840000000185000000018600000001870000000188000000018A000000018B000000018C000000018D000000018E000000018F00000001900000000191000000019200000001930000000194000000019500000001960000000197000000019800000001990000000207000000021F000000022300000002240000000225000000022600000002270000000229000000022B000000022F00000002300000000231000000023200000002340000000235000000023600000002370000000238000000023B000000023F000000024000000002410000000243000000024500000002480000000249000000024A000000024B000000024D000000024E000000024F000000025000000002510000000252000000025400000002550000000256000000025700000002580000000259000000025A000000025B000000025C000000025D000000025E000000025F000000026000000002610000000262000000026300000002640000000265000000026600000002670000000269000000026A000000026B000000026C000000026D000000026E000000026F0000000270000000027100000003020000000303000000030400000003050000000306000000030700000003080000000309000000030A000000030B000000030C000000030D000000030E000000030F00000003100000000311000000031200000003130000000314000000031500000003160000000317000000031800000011010000000E010000000F0100000010020000000C010000000D01000000";

            byte[] knownHardlines = StringUtils.hexStringToBytes(hardlineData);


            // Contacts
            string missionContacts = "0700000001000800000000000a00000003000d00000000001c0000000100";

            byte[] knownContacts = StringUtils.hexStringToBytes(missionContacts);

            byte[] codeArchiveTest = StringUtils.hexStringToBytes("04000000A7010000AC010000CC010000D1010000D60100001302000019020000650200006602000068020000B4020000B5020000B6020000BB020000BC020000C2020000C4020000D5020000D6020000DE020000E2020000E3020000E6020000E7020000E90200003F03000086030000A0030000AA030000E3030000FC030000FE030000030400000604000008040000090400000A040000270400004C0400004E040000BB040000C2040000CE040000EB040000EC040000EE040000F5040000F6040000F7040000F9040000540900005F09000082090000BE090000BF090000C1090000C4090000C7090000C8090000C9090000040A0000080A0000B0120000");

            byte[] empty = new byte[0];

            // New Margin Method to send Data

            // Pre-Load Abilities so that we just need to filter the result later
            loadAbilities((int)this.newCharID);

            sendMarginCharData(empty, 0x01, client, 0, false);
            sendMarginCharData(loadBackgroundInfo((int)this.newCharID), 0x02, client, 0, false);
            sendMarginCharData(empty, 0x03, client, 0, false);                              // BuddyList (but old one)
            sendMarginCharData(empty, 0x04, client, 0, false);                              // Unknown - no one has data there so ignore it
            sendMarginCharData(loadInventory((int)this.newCharID), 0x05, client, 0, false); // Inventory
            //sendMarginCharData(StringUtils.hexStringToBytes(itemData), 0x05, client);            // Inventory CR1
            sendMarginCharData(loadEquippedAbilities(), 0x06, client, 0, false);            // Loaded Abilitys
            //sendMarginCharData(empty, 0x06, client);                          // Loaded Abilitys CR1
            sendMarginCharData(loadKnownAbilities(), 0x07, client, 0, false);               // Known Abilities
            sendMarginCharData(knownHardlines, 0x08, client, 0, false);                     // Hardlines
            sendMarginCharData(empty, 0x09, client, 0, false);                              // Access Nodes?
            //sendMarginCharData(codeArchiveTest, 0x0a, client);                // Code Storage
            sendMarginCharData(empty, 0x0a, client, 0, false);                              // Code Storage CR1
            sendMarginCharData(knownContacts, 0x0b, client, 0, false);                      // Contacts
            sendMarginCharData(empty, 0x0e, client, 0, false);

            // MotD has a special handling
            DbParams _dbParams;

            XmlParser.loadDBParams("Config.xml", out _dbParams);
            string motd = _dbParams.Motd;

            if (!motd.Equals(""))              // if MOTD not empty
            {
                DynamicArray announcement = new DynamicArray();
                byte[]       currentTime  = TimeUtils.getUnixTime();
                //Load motd from file
                byte[] text = StringUtils.stringToBytes(motd);
                byte[] size = NumericalUtils.uint16ToByteArrayShort((UInt16)(currentTime.Length + text.Length));

                //announcement.append(size);
                announcement.append(currentTime);
                announcement.append(text);

                sendMarginCharData(announcement.getBytes(), 0x0d, client, 10000, true);
            }
            /* End of the MOTD */
        }