コード例 #1
0
ファイル: MyWorldDbAccess.cs プロジェクト: neowhoru/mxo-hd
        public void setPlayerValues()
        {
            UInt32 charID   = Store.currentClient.playerData.getCharID();
            string sqlQuery = "Select handle,x,y,z,rotation,healthC,healthM,innerStrC,innerStrM,level,profession,alignment,pvpflag,firstName,lastName,exp,cash,district,districtId,factionId,crewId from characters where charId='" + charID + "'";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read())
            {
                Store.currentClient.playerInstance.CharacterID.setValue(charID);
                Store.currentClient.playerInstance.CharacterName.setValue(dr.GetString(0));

                double x = (double)(dr.GetFloat(1));
                double y = (double)(dr.GetFloat(2));
                double z = (double)(dr.GetFloat(3));

                Store.currentClient.playerInstance.Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                Store.currentClient.playerInstance.YawInterval.setValue((byte)dr.GetDecimal(4));
                Store.currentClient.playerInstance.Health.setValue((UInt16)dr.GetDecimal(5));
                Store.currentClient.playerInstance.MaxHealth.setValue((UInt16)dr.GetDecimal(6));

                Store.currentClient.playerInstance.InnerStrengthAvailable.setValue((UInt16)dr.GetDecimal(7));
                Store.currentClient.playerInstance.InnerStrengthMax.setValue((UInt16)dr.GetDecimal(8));

                Store.currentClient.playerInstance.Level.setValue((byte)dr.GetDecimal(9));

                Store.currentClient.playerInstance.TitleAbility.setValue((UInt32)dr.GetDecimal(10));
                Store.currentClient.playerInstance.OrganizationID.setValue((byte)dr.GetDecimal(11));

                //data.setPlayerValue("pvpFlag",(int)dr.GetDecimal(12));
                Store.currentClient.playerInstance.RealFirstName.setValue(dr.GetString(13));
                Store.currentClient.playerInstance.RealLastName.setValue(dr.GetString(14));

                Store.currentClient.playerData.setExperience((long)dr.GetDecimal(15));
                Store.currentClient.playerData.setInfo((long)dr.GetDecimal(16));
                Store.currentClient.playerData.setDistrict(dr.GetString(17));
                Store.currentClient.playerData.setDistrictId((uint)dr.GetInt16(18));
                Store.currentClient.playerInstance.FactionID.setValue((uint)dr.GetInt16(19));
                Store.currentClient.playerInstance.CrewID.setValue((uint)dr.GetInt16(20));
            }

            dr.Close();
        }
コード例 #2
0
        public void SavePlayer(WorldClient client)
        {
            System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
            customCulture.NumberFormat.NumberDecimalSeparator    = ".";
            System.Threading.Thread.CurrentThread.CurrentCulture = customCulture;

            UInt32 charID = NumericalUtils.ByteArrayToUint32(client.playerInstance.CharacterID.getValue(), 1);
            string handle = StringUtils.charBytesToString_NZ(client.playerInstance.CharacterName.getValue());

            int [] rsiValues = client.playerData.getRsiValues();

            double x = 0; double y = 0; double z = 0;

            byte[] Ltvector3d = client.playerInstance.Position.getValue();
            NumericalUtils.LtVector3dToDoubles(Ltvector3d, ref x, ref y, ref z);

            int rotation = client.playerInstance.YawInterval.getValue()[0];

            string positionQuery = "update characters set x =" + x + " ,y=" + y + " ,z=" + z + " , rotation=" +
                                   rotation + ", districtId=" + client.playerData.getDistrictId() + " where handle='" +
                                   handle + "' ";

            ExecuteNonResultQuery(positionQuery);
            Output.WriteLine(StringUtils.bytesToString(StringUtils.stringToBytes(positionQuery)));
            Output.writeToLogForConsole("[WORLD DB ACCESS ]" + positionQuery);

            string rsiQuery = "update rsivalues set sex='" + rsiValues[0] + "',body='" + rsiValues[1] + "',hat='" +
                              rsiValues[2] + "',face='" + rsiValues[3] + "',shirt='" + rsiValues[4] + "',coat='" +
                              rsiValues[5] + "',pants='" + rsiValues[6] + "',shoes='" + rsiValues[7] +
                              "',gloves='" + rsiValues[8] + "',glasses='" + rsiValues[9] + "',hair='" +
                              rsiValues[10] + "',facialdetail='" + rsiValues[11] + "',shirtcolor='" +
                              rsiValues[12] + "',pantscolor='" + rsiValues[13] + "',coatcolor='" + rsiValues[14] +
                              "',shoecolor='" + rsiValues[15] + "',glassescolor='" + rsiValues[16] +
                              "',haircolor='" + rsiValues[17] + "',skintone='" + rsiValues[18] + "',tattoo='" +
                              rsiValues[19] + "',facialdetailcolor='" + rsiValues[20] + "',leggins='" +
                              rsiValues[21] + "' where charId='" + charID + "';";

            ExecuteNonResultQuery(rsiQuery);

            Output.writeToLogForConsole("[WORLD DB ACCESS ]" + rsiQuery);
        }
コード例 #3
0
        public string loadAllHardlines()
        {
            conn.Open();
            string sqlQuery = "SELECT DistrictId, HardLineId FROM data_hardlines ORDER BY DistrictId ASC ";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;

            dr = queryExecuter.ExecuteReader();

            string hexpacket = "";

            while (dr.Read())
            {
                string districtHex = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArrayShort((UInt16)dr.GetInt16(0)));
                string hardlineHex = StringUtils.bytesToString_NS(NumericalUtils.uint16ToByteArray((UInt16)dr.GetInt16(1), 1));
                hexpacket = hexpacket + districtHex + hardlineHex + "0000";
            }
            conn.Close();
            return(hexpacket);
        }
コード例 #4
0
ファイル: MyWorldDbAccess.cs プロジェクト: neowhoru/mxo-hd
        public UInt32 getUserIdForCharId(byte[] charIdHex)
        {
            UInt32 charId = NumericalUtils.ByteArrayToUint32(charIdHex, 1);

            Output.OptWriteLine("[WORLD] Checking from DB:" + charId);
            string sqlQuery = "Select userid from characters where charid ='" + charId + "'";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            UInt32 userId = new UInt32();

            while (dr.Read())
            {
                userId = (UInt32)dr.GetDecimal(0);
            }

            dr.Close();

            return(userId);
        }
コード例 #5
0
ファイル: MyWorldDbAccess.cs プロジェクト: neowhoru/mxo-hd
        public void updateLocationByHL(UInt16 district, UInt16 hardline)
        {
            string sqlQuery = "SELECT DH.X,DH.Y,DH.Z,DH.ROT,DIS.key,DH.DistrictId FROM data_hardlines AS DH, districts as DIS WHERE DH.DistrictId = '" + district.ToString() + "' AND DH.HardLineId = '" + hardline.ToString() + "' AND DH.DistrictId=DIS.id ";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read())
            {
                double x      = (double)(dr.GetFloat(0));
                double y      = (double)(dr.GetFloat(1));
                double z      = (double)(dr.GetFloat(2));
                string disKey = dr.GetString(4);
                Output.WriteLine("USER DIS IS NOW " + disKey);
                Store.currentClient.playerData.setDistrict(disKey);
                Store.currentClient.playerData.setDistrictId((uint)dr.GetInt16(5));
                Store.currentClient.playerInstance.Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                //Store.currentClient.playerInstance.YawInterval.setValue((byte)dr.GetDecimal(3));
            }
            dr.Close();
            savePlayer(Store.currentClient);
        }
コード例 #6
0
        public void SetPlayerValues()
        {
            OpenConnection();
            UInt32 charID   = Store.currentClient.playerData.getCharID();
            string sqlQuery = "Select handle,x,y,z,rotation,healthC,healthM,innerStrC,innerStrM,level,profession,alignment,pvpflag,firstName,lastName,exp,cash,district,districtId,factionId,crewId, repMero, repMachine, repNiobe, repEPN, repCYPH, repGM, repZion from characters where charId='" + charID + "'";

            queryExecuter             = conn.CreateCommand();
            queryExecuter.CommandText = sqlQuery;
            dr = queryExecuter.ExecuteReader();

            while (dr.Read())
            {
                Store.currentClient.playerInstance.CharacterID.setValue(charID);
                Store.currentClient.playerInstance.CharacterName.setValue(dr.GetString(0));

                double x = dr.GetDouble(1);
                double y = dr.GetDouble(2);
                double z = dr.GetDouble(3);

                Store.currentClient.playerInstance.Position.setValue(NumericalUtils.doublesToLtVector3d(x, y, z));
                Store.currentClient.playerInstance.YawInterval.setValue((byte)dr.GetDecimal(4));
                Store.currentClient.playerInstance.Health.setValue((UInt16)dr.GetDecimal(5));
                Store.currentClient.playerInstance.MaxHealth.setValue((UInt16)dr.GetDecimal(6));

                Store.currentClient.playerInstance.InnerStrengthAvailable.setValue((UInt16)dr.GetDecimal(7));
                Store.currentClient.playerInstance.InnerStrengthMax.setValue((UInt16)dr.GetDecimal(8));

                Store.currentClient.playerInstance.Level.setValue((byte)dr.GetDecimal(9));

                Store.currentClient.playerInstance.TitleAbility.setValue((UInt32)dr.GetDecimal(10));
                Store.currentClient.playerInstance.OrganizationID.setValue((byte)dr.GetDecimal(11));

                //data.setPlayerValue("pvpFlag",(int)dr.GetDecimal(12));
                Store.currentClient.playerInstance.RealFirstName.setValue(dr.GetString(13));
                Store.currentClient.playerInstance.RealLastName.setValue(dr.GetString(14));

                Store.currentClient.playerData.setExperience((long)dr.GetDecimal(15));
                Store.currentClient.playerData.setInfo((long)dr.GetDecimal(16));
                Store.currentClient.playerData.setDistrict(dr.GetString(17));
                Store.currentClient.playerData.setDistrictId((uint)dr.GetInt16(18));



                UInt32 factionId = (uint)dr.GetInt16(19);
                UInt32 crewId    = (uint)dr.GetInt16(20);

                Store.currentClient.playerInstance.FactionID.enable();
                Store.currentClient.playerInstance.FactionID.setValue(factionId);

                Store.currentClient.playerInstance.CrewID.enable();
                Store.currentClient.playerInstance.CrewID.setValue(crewId);

                Store.currentClient.playerInstance.ReputationMerovingian.setValue((UInt16)dr.GetDecimal(21));
                Store.currentClient.playerInstance.ReputationMachines.setValue((UInt16)dr.GetDecimal(22));
                Store.currentClient.playerInstance.ReputationNiobe.setValue((UInt16)dr.GetDecimal(23));
                Store.currentClient.playerInstance.ReputationPluribusNeo.setValue((UInt16)dr.GetDecimal(24));
                Store.currentClient.playerInstance.ReputationCypherites.setValue((UInt16)dr.GetDecimal(25));
                Store.currentClient.playerInstance.ReputationGMOrganization.setValue((UInt16)dr.GetDecimal(26));
                Store.currentClient.playerInstance.ReputationZionMilitary.setValue((UInt16)dr.GetDecimal(27));
            }

            dr.Close();
            CloseConnection();
        }
コード例 #7
0
ファイル: AuthServer.cs プロジェクト: vitalyo7/mxo-hd
        public byte[] processHandleAuthChallenge_Response(byte[] data, int maxBytes)
        {
            int blobSize = (int)data[4];

            byte[] encryptedBlob = new byte[blobSize];
            byte[] decryptedBlob = new byte[blobSize];

            ArrayUtils.copy(data, 6, encryptedBlob, 0, blobSize);

            // Reset IV to 0
            tf.setIV(blankIV);
            tf.decrypt(encryptedBlob, decryptedBlob);

            byte[] receivedMD5 = new byte[16];
            ArrayUtils.copy(decryptedBlob, 1, receivedMD5, 0, 16);


            // Security says that must be the same
            if (!ArrayUtils.equal(receivedMD5, md5edChallenge))
            {
                Output.WriteLine("The Md5 from client and Our Md5 are not same, aborting");
                Output.WriteLine("Decrypted (TF) blob:" + StringUtils.bytesToString(decryptedBlob));
                Output.WriteLine("Stored MD5ed Challenge:" + StringUtils.bytesToString(md5edChallenge));
                throw new AuthException("Md5 challenge differs");
            }

            // We take the pass from the decrypted Blob and subtract 1 byte, the ending "0"
            int passSize = ((int)decryptedBlob[23]) - 1;

            byte[] passwordB = new byte[passSize];
            ArrayUtils.copy(decryptedBlob, 25, passwordB, 0, passSize);

            Output.OptWriteLine("-> Password decrypted, size:" + passSize);

            // Set WorldList password
            wl.setPassword(StringUtils.bytesToString_NS(md5.digest(passwordB)));

            if (Store.dbManager.AuthDbHandler.fetchWordList(ref wl))
            {
                // Do calculations magic
                byte[] hexUserID = NumericalUtils.uint32ToByteArray((UInt32)wl.getUserID(), 1);

                byte[] nameH = new byte[33];

                string name = wl.getUsername();
                for (int i = 0; i < name.Length; i++)
                {
                    nameH[i] = (byte)name[i];
                }

                byte[] padding = new byte[4];                 // 4 empty byte ==> [0x00,0x00,0x00,0x00]

                // +10 mins from now, so 60secs per min
                byte[] expiredTime = TimeUtils.getUnixTime(60 * 10);

                byte[] padding2    = new byte[32];              // 32 empty byte ==> [0x00,0x00,0x00,0x00,...]
                byte[] pubModulusH = wl.getPublicModulus();
                byte[] createdTime = NumericalUtils.uint32ToByteArray((UInt32)wl.getTimeCreated(), 1);


                // Create signed data
                DynamicArray signedData = new DynamicArray();
                signedData.append(new byte[] { 0x01 });
                signedData.append(hexUserID);
                signedData.append(nameH);
                signedData.append(new byte[] { 0x00, 0x01 });
                signedData.append(padding);
                signedData.append(expiredTime);
                signedData.append(padding2);
                signedData.append(new byte[] { 0x00, 0x11 });
                signedData.append(pubModulusH);
                signedData.append(createdTime);

                byte[] md5FromStructure = md5.digest(signedData.getBytes());

                // Do MD5 to the signed data and RSA encrypt the result
                byte[] signature = rsa.signWithMD5(md5FromStructure);


                Output.OptWriteLine("-> Signing with RSA");

                // Do: privExp = Twofish(privExp)
                byte[] privExp = wl.getPrivateExponent();
                byte[] buffer  = new byte[privExp.Length];

                // We keep the Key from before this part
                // Set the challenge we saved before as IV
                tf.setIV(challenge);
                tf.encrypt(privExp, buffer);

                privExp = buffer;

                byte [] privExpSize = NumericalUtils.uint16ToByteArray((UInt16)privExp.Length, 1);

                // Calculate offsets
                int offsetAuthData      = 33 + wl.getCharPack().getPackLength() + wl.getWorldPack().getTotalSize();
                int offsetEncryptedData = offsetAuthData + signature.Length + signedData.getSize() + 2;
                int offsetCharData      = 33;
                int offsetServerData    = 33 + wl.getCharPack().getPackLength();
                int offsetUsernameLast  = offsetEncryptedData + 2 + privExp.Length;

                // Create the auth header

                DynamicArray authHeader = new DynamicArray();
                authHeader.append(new byte[] { 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
                authHeader.append(NumericalUtils.uint16ToByteArray((UInt16)offsetAuthData, 1));
                authHeader.append(NumericalUtils.uint16ToByteArray((UInt16)offsetEncryptedData, 1));
                authHeader.append(new byte[] { 0x1f, 0x00, 0x00, 0x00 });
                authHeader.append(NumericalUtils.uint16ToByteArray((UInt16)offsetCharData, 1));
                authHeader.append(new byte[] { 0x6E, 0xD1, 0x00, 0x00 });
                authHeader.append(NumericalUtils.uint32ToByteArray((UInt32)offsetServerData, 1));
                authHeader.append(NumericalUtils.uint32ToByteArray((UInt32)offsetUsernameLast, 1));

                byte [] usernameSize = NumericalUtils.uint16ToByteArray((UInt16)(name.Length + 1), 1);

                // Create the semiResponse (full data, except the total size)
                DynamicArray semiResponse = new DynamicArray();
                semiResponse.append(authHeader.getBytes());
                semiResponse.append(wl.getCharPack().getByteContents());
                semiResponse.append(wl.getWorldPack().getByteContents());
                semiResponse.append(new byte[] { 0x36, 0x01 });
                semiResponse.append(signature);
                semiResponse.append(signedData.getBytes());
                semiResponse.append(privExpSize);
                semiResponse.append(privExp);
                semiResponse.append(usernameSize);


                byte [] tempName = new byte[name.Length];

                for (int i = 0; i < name.Length; i++)
                {
                    tempName[i] = (byte)name[i];
                }

                semiResponse.append(tempName);
                semiResponse.append(new byte[] { 0x00 });

                int bigSize = semiResponse.getSize();
                bigSize += 0x8000;                // Add TCP Len Var

                byte [] finalSize = NumericalUtils.uint16ToByteArray((UInt16)bigSize, 0);

                // Create the finalResponse (full data, plus total size)
                DynamicArray finalResponse = new DynamicArray();
                finalResponse.append(finalSize);
                finalResponse.append(semiResponse.getBytes());


                Output.OptWriteLine("Sending world list.");
                status = -1;

                return(finalResponse.getBytes());
            }

            byte [] worldListPacket = { 0x00, 0x00 };

            status = -1;           // trick
            return(worldListPacket);
        }