writeToLogForConsole() public static method

public static writeToLogForConsole ( Object obj ) : void
obj Object
return void
Exemplo n.º 1
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);
        }
Exemplo n.º 2
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
                content.append(NumericalUtils.uint16ToByteArray(playerData.getRPCCounter(), 0));
                content.append(NumericalUtils.uint16ToByteArrayShort((UInt16)RPCMessages.Count));
                foreach (SequencedMessage message in RPCMessages)
                {
                    // Do the loop
                    content.append(message.content);
                }

                // Set new RPC Counter
                Output.writeToLogForConsole("RPC COUNT BEFORE: " + playerData.getRPCCounter().ToString());
                UInt16 incrementRpcCounter = playerData.getRPCCounter();
                incrementRpcCounter += (ushort)RPCMessages.Count;
                playerData.setRPCCounter(incrementRpcCounter);
                Output.writeToLogForConsole("RPC COUNT AFTER: " + playerData.getRPCCounter().ToString());
            }
        }
Exemplo n.º 3
0
        public void loadWorldObjectsDb(string path)
        {
            Output.Write("Loading Static Objects from " + path + " - please wait...");

            ArrayList         staticWorldObjects = loadCSV(path, ',');
            StaticWorldObject worldObject        = null;
            int linecount = 1;

            foreach (string[] data in staticWorldObjects)
            {
                if (linecount > 1)
                {
                    //Output.WriteLine("Show Colums for Line : " + linecount.ToString() + " GOID:  " + data[1].ToString() + " Name " + data[0].ToString());

                    worldObject = new StaticWorldObject();

                    worldObject.metrId   = Convert.ToUInt16(data[0]);
                    worldObject.sectorID = Convert.ToUInt16(data[1]);


                    worldObject.mxoId    = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes(data[2]), 1);
                    worldObject.staticId = NumericalUtils.ByteArrayToUint32(StringUtils.hexStringToBytes(data[3]), 1);
                    worldObject.type     = StringUtils.hexStringToBytes(data[4].Substring(0, 4));
                    worldObject.exterior = Convert.ToBoolean(data[5]);
                    worldObject.pos_x    = double.Parse(data[6], CultureInfo.InvariantCulture);
                    worldObject.pos_y    = double.Parse(data[7], CultureInfo.InvariantCulture);
                    worldObject.pos_z    = double.Parse(data[8], CultureInfo.InvariantCulture);
                    worldObject.rot      = double.Parse(data[9], CultureInfo.InvariantCulture);
                    worldObject.quat     = data[10];

                    if (data[3] == "01003039")
                    {
                        Output.writeToLogForConsole("[DEMO DOOR] 01003039, X: " + worldObject.pos_x + ", Y: " + worldObject.pos_y + ", Z: " + worldObject.pos_z + ", ROT: " + worldObject.rot + ", TypeId: " + StringUtils.bytesToString_NS(worldObject.type));
                    }


                    WorldObjectsDB.Add(worldObject);
                    worldObject = null;
                }

                linecount++;
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Send a Message to One Player (like private Message by Handle)
 /// </summary>
 /// <param name="packet">Packet Stream</param>
 /// <param name="playerHandle">Player Handle to send the Packet</param>
 public void sendRPCToOnePlayerByHandle(byte[] packet, string playerHandle)
 {
     lock (Clients.SyncRoot)
     {
         foreach (string clientKey in Clients.Keys)
         {
             WorldClient client   = Clients[clientKey] as WorldClient;
             string      charname = StringUtils.charBytesToString_NZ(client.playerInstance.CharacterName.getValue());
             Output.writeToLogForConsole("Charname |" + charname + "| PlayerHandle |" + playerHandle + "|");
             int lenCharname     = charname.Length;
             int playerHandleLen = playerHandle.Length;
             if (charname == playerHandle)
             {
                 client.messageQueue.addRpcMessage(packet);
                 client.FlushQueue();
             }
         }
     }
 }
Exemplo n.º 5
0
        private void charNameRequest(byte[] packet, NetworkStream client)
        {
            // Get the handle text
            byte[] handleSize = new byte[2];
            handleSize[0] = packet[5];
            handleSize[1] = packet[6];

            int size = (int)NumericalUtils.ByteArrayToUint16(handleSize, 1);

            byte[] handleB = new byte[size - 1];
            ArrayUtils.copy(packet, 7, handleB, 0, size - 1);
            string handleBStr = StringUtils.bytesToString_NS(handleB);             // Handle as "414141"
            string handleStr  = StringUtils.charBytesToString(handleB);            // Handle as "AAA"

            // Process DB to answer the client - we directly create the character
            UInt32 dbResult = Store.dbManager.MarginDbHandler.getNewCharnameID(handleStr, userID);

            // Add the new charId so that we can work with it

            // Create the answer
            string nameRequestResponse = "";

            if (dbResult == 0)
            {
                nameRequestResponse += "0b0f00010000110000000000000000";
                nameRequestResponse += StringUtils.bytesToString_NS(handleSize);
                nameRequestResponse += handleBStr + "00";
            }
            else
            {
                newCharID            = dbResult;
                nameRequestResponse += "0b0f0000000000";
                nameRequestResponse += StringUtils.bytesToString_NS(NumericalUtils.uint32ToByteArray((UInt32)dbResult, 1));
                nameRequestResponse += "0000000000";
                nameRequestResponse += StringUtils.bytesToString_NS(handleSize);
                nameRequestResponse += handleBStr + "00";
            }

            Output.writeToLogForConsole(nameRequestResponse);
            sendMarginData(nameRequestResponse, client);
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
0
        private static void ParseContent(ref byte[] packetData)
        {
            buffer = null;
            buffer = packetData;
            offset = 0;             //initialize to initial byte

            byte temp;

            temp = BufferHandler.readByte(ref packetData, ref offset);

            // Convert to Ack Flags
            BitArray AckFlags = NumericalUtils.byteToBitArray(temp);

            /* Flag Field
             * 1 - unknown / nothing
             * 2 - isAck (should always be )
             * 3 - unknown currently
             * 4 - unknown currently
             * 5 - SERVERFLAGS_RESETRCC
             * 6 - CLIENTFLAGS_RESETDONE (so its done)
             * 7 - SERVERFLAG_SIMTIME (aka 0x82, 0xc2)
             */

            if (AckFlags.Get(1) == false)
            {
                Output.WriteDebugLog("[WARNING] Packet has acked not set and is encrypted");
            }

            if (AckFlags.Get(7) == true)
            {
                byte[] simTime = BufferHandler.readBytes(ref packetData, ref offset, 4);
                Store.currentClient.playerData.setClientSimTime(NumericalUtils.byteArrayToFloat(simTime, 1));
            }


            if (AckFlags.Get(6) == true)
            {
                Output.WriteDebugLog("[CLIENT]CLIENTFLAGS_RESETDONE found - we can init new RCC Comm ");
                // Reset comm
                Store.currentClient.playerData.setCseq(0);
                Store.currentClient.playerData.setSseq(0);
                Store.currentClient.playerData.setPss(0x00);
                Store.currentClient.playerData.setOnWorld(false);
                Store.currentClient.playerData.setRPCShutDown(false);
                Store.currentClient.playerData.setRPCCounter(0);
                PlayerHandler handler = new PlayerHandler();
                handler.processAttributes();
                handler.processPlayerSetup();
            }


            if (packetData.Length > 1 && AckFlags.Get(1) == true) //Not just ACK nor Resetting

            {
                if (packetData[offset] == 0x05)
                {
                    offset = offset + 4;
                    Output.writeToLogForConsole("Its a 05 Packet");
                    Store.currentClient.messageQueue.ackOnlyCount = Store.currentClient.messageQueue.ackOnlyCount + 1;
                    Store.currentClient.flushQueue();
                    // We dont need a handler for 05 Packets (as there is only one as i see lol)
                }

                if (packetData[offset] == 0x03)                // Is a 03 packet
                {
                    offset++;
                    offset = man03.parse(offset, ref buffer);
                }


                if (offset < packetData.Length)                 // There is no more info if we'r out of offset

                {
                    if (packetData[offset] == 0x04)                    // Is a 04 packet
                    {
                        offset++;
                        offset = man04.parse(offset, ref buffer);
                    }
                }

                if (Store.currentClient.messageQueue.ObjectMessagesQueue.Count == 0 && Store.currentClient.messageQueue.RPCMessagesQueue.Count == 0)
                {
                    // nothing to send ? we should really ack something then
                    Store.currentClient.messageQueue.ackOnlyCount = Store.currentClient.messageQueue.ackOnlyCount + 1;
                    Store.currentClient.flushQueue();
                }
            }
        }
Exemplo n.º 8
0
        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;
            }
        }
Exemplo n.º 9
0
        public void packetHandler(byte[] packet, NetworkStream client)
        {
            bool encrypted = true;
            byte opcode    = packet[2];

            byte[] data    = { };
            byte   pointer = packet[0];

            if (opcode == 0x01)
            {
                // Packet is unencrypted
                encrypted = false;
                data      = packet;
            }

            // This overrides the above IF for packets where 3rd position is a "01"
            // Happened someday, and screwed login... yeah, really
            if (pointer != 0x81)
            {
                encrypted = true;
            }

            if (encrypted == true)
            {
                byte[] encryptedPacket = { };
                if (packet[0] >= 0x80)
                {
                    // try to readjust the packet for one byte less if the lenght is too long
                    // just a crappy way
                    encryptedPacket = new byte[packet.Length - 1];
                    ArrayUtils.copy(packet, 1, encryptedPacket, 0, packet.Length - 1);
                }
                else
                {
                    encryptedPacket = packet;
                }
                // Get the IV from encrypted Packet and set it in encryptor/decryptor
                byte[] decrypted = marginEncr.decryptMargin(encryptedPacket);
                // Just 2 zero bytes for opcode handling later (As we use third byte for both state, encrypted or not
                byte[] spacer = { 0x00, 0x00 };

                DynamicArray din = new DynamicArray();
                din.append(spacer);
                din.append(decrypted);

                data = din.getBytes();
            }
            else
            {
                data = packet;
            }
            Output.WritePacketLog(StringUtils.bytesToString(data), "MARGINCLIENT", "0", "0", "0");
            opcode = data[2];

            //TODO: check if this needs "packet" or "data"
            switch (opcode)
            {
            case 0x01:
                certConnectRequest(packet, client);

                break;

            case 0x03:
                certConnectReply(packet, client);

                break;

            case 0x06:
                connectChallenge(packet, client);

                break;

            case 0x08:
                ConnectChallengeResponse(packet, client);
                break;

            case 0x0a:
                //CharNameRequest
                charNameRequest(data, client);
                break;

            case 0x0c:
                //TODO: this is creation. must be done someday
                Output.writeToLogForConsole("CREATECHAR RSI VALUES:" + StringUtils.bytesToString(data));
                //loadCharacter(data, client);
                createCharacterRSI(data, client);
                // Add the first abilitys
                // AbilityID : 2147485696 (Awakened) Level 2
                // AbilityID :

                break;

            case 0x0d:
                // Delete Charname Request
                deleteCharName(data, client);
                break;

            case 0x0f:
                loadCharacter(data, client, 0);
                break;
            }
        }
Exemplo n.º 10
0
        /**
         * This handles all RPC requests for the client
         */

        public void HandleRpc(int header, ref byte[] rpcData)
        {
            ServerPackets pak = new ServerPackets();

            pak.sendSystemChatMessage(Store.currentClient, "Handle RPC Client Request Header " + StringUtils.bytesToString_NS(NumericalUtils.int32ToByteArray(header, 0)), "BROADCAST");
            switch (header)
            {
            case (int)RPCRequestHeader.CLIENT_SPAWN_READY:
                new PlayerHandler().processSpawn();
                new PlayerHandler().processAttributes();
                break;

            case (int)RPCRequestHeader.CLIENT_CLOSE_COMBAT:
                Output.WriteRpcLog("CLOSE COMBAT REQUEST");
                new TestUnitHandler().testCloseCombat(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_LEAVE_COMBAT:

                break;

            case (int)RPCRequestHeader.CLIENT_RANGE_COMBAT:
                Output.WriteRpcLog("RANGE COMBAT REQUEST");
                new TestUnitHandler().testCloseCombat(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_CHAT:
                new ChatHandler().processChat(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_OBJECTINTERACTION_DYNAMIC:
                new ObjectInteractionHandler().processObjectDynamic(ref rpcData);
                Output.writeToLogForConsole("RPCMAIN : Handle OBJECTINTERACTION_DYNAMIC");
                break;

            case (int)RPCRequestHeader.CLIENT_OBJECTINTERACTION_STATIC:
                new ObjectInteractionHandler().processObjectStatic(ref rpcData);
                Output.writeToLogForConsole("RPCMAIN : Handle OBJECTINTERACTION_STATIC");
                break;

            case (int)RPCRequestHeader.CLIENT_JUMP:
                Output.writeToLogForConsole("RPCMAIN : Handle JUMP");
                //ToDo: Split Jump and Hyperjump
                //new TestUnitHandler().processHyperJump(ref rpcData);
                new TestUnitHandler().processHyperJump(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_TARGET:
                new PlayerHelper().processTargetChange(ref rpcData, Store.currentClient);
                break;

            case (int)RPCRequestHeader.CLIENT_MISSION_REQUEST:
                new MissionHandler().processMissionList(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_MISSION_INFO:
                new MissionHandler().processLoadMissionInfo(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_MISSION_ACCEPT:
                new MissionHandler().processMissionaccept(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_MISSION_ABORT:
                new MissionHandler().processAbortMission(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_PARTY_LEAVE:
                break;

            // Team
            case (int)RPCRequestHeader.CLIENT_HANDLE_MISSION_INVITE:
                new TeamHandler().processTeamInviteAnswer(ref rpcData);
                break;

            // Faction and Crews
            case (int)RPCRequestHeader.CLIENT_FACTION_INFO:
                new FCHandler().processLoadFactionName(ref rpcData);
                // ToDo: implement response with following format :
                // size + 80 f5 + uint32 factionId + String(40 size? unusual...)
                // Example: 30 80 f5 11 ba 00 00 48 79 50 6e 30 74 69 5a 65 44 20 4d 69 4e 64 5a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
                break;

            // Abilitys
            case (int)RPCRequestHeader.CLIENT_UPGRADE_ABILITY_LEVEL:
                // ToDo: Research and implement^^
                break;

            case (int)RPCRequestHeader.CLIENT_ABILITY_HANDLER:
                new AbilityHandler().processAbility(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_CHANGE_CT:
                new PlayerHelper().processUpdateExp();
                break;

            case (int)RPCRequestHeader.CLIENT_ABILITY_LOADER:
                new PlayerHelper().processLoadAbility(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_HARDLINE_EXIT_LA_CONFIRM:
                new TeleportHandler().processHardlineExitConfirm(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_READY_WORLDCHANGE:
                Output.WriteLine("RPCMAIN : RESET_RPC detect");
                new TeleportHandler().processTeleportReset(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_TELEPORT_HL:
                new TeleportHandler().processHardlineTeleport(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_HARDLINE_STATUS_REQUEST:
                new TeleportHandler().processHardlineStatusRequest(ref rpcData);
                break;


            // Inventory
            case (int)RPCRequestHeader.CLIENT_ITEM_MOVE_SLOT:
                new InventoryHandler().processItemMove(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_ITEM_RECYCLE:
                new InventoryHandler().processItemDelete(ref rpcData);
                break;

            // Vendor
            case (int)RPCRequestHeader.CLIENT_VENDOR_BUY:
                new VendorHandler().processBuyItem(ref rpcData);
                break;

            // MarketPlace
            case (int)RPCRequestHeader.CLIENT_MP_OPEN:
                new TestUnitHandler().processMarketTest(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_MP_LIST_ITEMS:
                new MarketPlaceHandler().processMarketplaceList(ref rpcData);
                break;


            // Command Helper
            case (int)RPCRequestHeader.CLIENT_CMD_WHEREAMI:
                new CommandHandler().processWhereamiCommand(ref rpcData);
                break;

            // Emote and Mood Helpers
            case (int)RPCRequestHeader.CLIENT_CHANGE_MOOD:
                new PlayerHandler().processMood(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_EMOTE:
                new PlayerHandler().processEmote(ref rpcData);
                break;

            case (int)RPCRequestHeader.CLIENT_REGION_LOADED:
                new RegionHandler().processRegionLoaded(ref rpcData);
                //new PlayerInitHelper().processRegionSettings();
                break;


            default:
                //PASS :D
                byte[] headers = NumericalUtils.int32ToByteArray(header, 1);

                string message = "RPCMAIN : Unknown Header " + StringUtils.bytesToString_NS(new byte[] { headers[0], headers[1] }) + " \n Content:\n " + StringUtils.bytesToString_NS(rpcData);
                Output.WriteLine(message);
                Output.WriteRpcLog(message);

                break;
            }
        }