Ejemplo n.º 1
0
 public static void GetFullCharacter(int userId, int charSlot)
 {
     if (DatabaseFunctions.GetFullCharacter(userId, charSlot, out var fullCharBytes))
     {
         AgentConnection.connection.SendObject("FullCharacterBytes", fullCharBytes);
     }
 }
Ejemplo n.º 2
0
        public static void CreateCharacterPacket(string userIdStr, string charName, string classCodeStr, string heightCodeStr, string faceCodeStr, string hairCodeStr)
        {
            int  userID     = Int32.Parse(userIdStr);
            byte classCode  = Byte.Parse(classCodeStr);
            byte heightCode = Byte.Parse(heightCodeStr);
            byte faceCode   = Byte.Parse(faceCodeStr);
            byte hairCode   = Byte.Parse(hairCodeStr);

            if (!DatabaseFunctions.CreateCharacter(userID, charName, classCode, heightCode, faceCode, hairCode,
                                                   out var character))
            {
                return;
            }
            if (!DatabaseFunctions.AddCharacterToDB(character, out var charId))
            {
                return;
            }
            character.Id = charId;
            var sendbytes2 = new PacketStructs.CharacterInfo(character).ToBytes();
            var sendbytes1 = ByteUtils.ToByteArray(userID, 5);

            byte[] sendbytes = new byte[sendbytes2.Length + sendbytes1.Length];
            Buffer.BlockCopy(sendbytes1, 0, sendbytes, 0, sendbytes1.Length);
            Buffer.BlockCopy(sendbytes2, 0, sendbytes, sendbytes1.Length, sendbytes2.Length);
            AgentConnection.connection.SendObject("CharacterCreateSuccess", sendbytes);
            GetAllCharacters(userID);
        }
Ejemplo n.º 3
0
 public static void DeleteCharacter(int userId, int charSlot)
 {
     if (DatabaseFunctions.DeleteCharacter(userId, charSlot))
     {
         AgentConnection.connection.SendObject("CharacterDeleteSuccess", userId);
     }
     else
     {
         var errorCode = 0; //TODO implement Errocodes
         AgentConnection.connection.SendObject("CharacterDeleteFailed", new [] { errorCode, userId });
     }
 }
Ejemplo n.º 4
0
        public static void LoginPacket(string username, string pw, string connectionGUID)
        {
            Console.WriteLine("Login Request from User: "******" with GUID: " + connectionGUID);

            if (DatabaseFunctions.UserLogin(username, pw, out var userId))
            {
                AuthConnection.connection.SendObject("UserLoginSucces", new[] { userId.ToString(), connectionGUID });
            }
            else
            {
                AuthConnection.connection.SendObject("UserLoginFailed");
            }
        }
Ejemplo n.º 5
0
        public static void GetAllCharacters(int userID)
        {
            if (!DatabaseFunctions.getAllCharacters(userID, out var characterList))
            {
                return;
            }
            var returnbytes = new List <byte>();

            returnbytes.AddRange(ByteUtils.ToByteArray(userID, 4));
            returnbytes.Add((byte)characterList.Count);
            returnbytes.Add((byte)characterList.Count);
            foreach (var characterInfo in characterList)
            {
                returnbytes.AddRange(characterInfo.ToBytes());
            }

            AgentConnection.connection.SendObject("CharacterList", returnbytes.ToArray());
        }
Ejemplo n.º 6
0
 public static void CheckDuplicateName(string name, int userId)
 {
     AgentConnection.connection.SendObject(
         DatabaseFunctions.IsNameFree(name) ? "CheckDuplicateNameSuccess" : "CheckDuplicateNameFailed", userId);
 }