Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.55 KB | None | 0 0
  1. private void LOGIN(TcpConnection connection, ClientMessage message)
  2.         {
  3.             string username = message.ReadNextArgument();
  4.             string password = message.ReadNextArgument();
  5.  
  6.             User user = UserManager.GetUser(username);
  7.  
  8.             ServerMessage response;
  9.  
  10.             if (user != null)
  11.             {
  12.                 if (user.Password == password)
  13.                 {
  14.                     connection.User = user;
  15.  
  16.                     if (connection.User.Hand == null)
  17.                         connection.User.Hand = new UserHand(connection.User.Id);
  18.  
  19.                     response = new ServerMessage("U_RTS");
  20.                     response.AppendBreakObj("fuse_performance_panel");
  21.                     connection.SendMessage(response);
  22.  
  23.                     try
  24.                     {
  25.                         string roomEntryData = message.ReadNextArgument();
  26.  
  27.                         if (roomEntryData == "0")
  28.                         {
  29.                             connection.User.Room = RoomManager.GetRoom(37302);
  30.  
  31.                             #region Objects
  32.                             response = new ServerMessage("OBJECTS WORLD");
  33.                             response.Append(" 0 " + connection.User.Room.Model);
  34.                             response.Append("{13}r2112 roommatic 21 12 1 4{13}r2212 roommatic 22 12 1 4{13}r2312 roommatic 23 12 1 4{13}r2412 roommatic 24 12 1 4".Replace("{13}", (char)13 + ""));
  35.                             connection.SendMessage(response);
  36.                             #endregion
  37.  
  38.                             #region Heightmap
  39.                             response = new ServerMessage("HEIGHTMAP");
  40.                             response.AppendBreakObj(connection.User.Room.Map.SerializeHeightmap(connection.User.Room));
  41.                             connection.SendMessage(response);
  42.                             #endregion
  43.  
  44.                             #region Users
  45.                             response = new ServerMessage("USERS");
  46.  
  47.                             foreach (RoomUser roomUser in connection.User.Room.RoomUsers.Values)
  48.                             {
  49.                                 roomUser.Serialize(response);
  50.                             }
  51.                  
  52.                             connection.SendMessage(response);
  53.  
  54.                             connection.User.Room.AddUser(connection);
  55.                             connection.User.RoomUser = connection.User.Room.RoomUsers[connection.User.Name];
  56.  
  57.                             response = new ServerMessage("STATUS");
  58.                             connection.User.RoomUser.SerializeStatus(response);
  59.                             connection.User.Room.SendMessage(response);
  60.  
  61.                             response = new ServerMessage("USERS");
  62.                             connection.User.RoomUser.Serialize(response);
  63.                             connection.User.Room.SendMessage(response);
  64.                             #endregion
  65.                         }
  66.                     }
  67.                     catch
  68.                     {
  69.                     }
  70.                 }
  71.                 else
  72.                 {
  73.                     response = new ServerMessage("ERROR:");
  74.                     response.AppendDelimObj("login incorrect", ' ');
  75.                     connection.SendMessage(response);
  76.                 }
  77.             }
  78.             else
  79.             {
  80.                 response = new ServerMessage("ERROR:");
  81.                 response.AppendDelimObj("login incorrect", ' ');
  82.                 connection.SendMessage(response);
  83.             }
  84.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement