internal void ChangeName()
{
string text = this.Request.PopFixedString();
string username = this.Session.GetHabbo().Username;
checked
{
using (IQueryAdapter queryreactor = MercuryEnvironment.GetDatabaseManager().getQueryreactor())
{
queryreactor.setQuery("SELECT username FROM users WHERE username=@name LIMIT 1");
queryreactor.addParameter("name", text);
string [USER=560981]String[/USER] = queryreactor.getString();
if (string.IsNullOrWhiteSpace [USER=560981]String[/USER]) || username.ToLower() == text.ToLower())
{
queryreactor.setQuery("UPDATE rooms SET owner = [USER=571372]newo[/USER]wner WHERE owner = [USER=1333464006]old[/USER]owner");
queryreactor.addParameter("newowner", text);
queryreactor.addParameter("oldowner", Session.GetHabbo().Username);
queryreactor.runQuery();
queryreactor.setQuery("UPDATE users SET username = [USER=376652]newname[/USER], last_name_change = [USER=1333424529]timestamp[/USER] WHERE id = [USER=1335]user[/USER]id");
queryreactor.addParameter("newname", text);
queryreactor.addParameter("timestamp", MercuryEnvironment.GetUnixTimestamp() + 43200);
queryreactor.addParameter("userid", Session.GetHabbo().Username);
queryreactor.runQuery();
this.Session.GetHabbo().LastChange = MercuryEnvironment.GetUnixTimestamp() + 43200;
this.Session.GetHabbo().Username = text;
this.Response.Init(Outgoing.UpdateUserNameMessageComposer);
this.Response.AppendInt32(0);
this.Response.AppendString(text);
this.Response.AppendInt32(0);
this.SendResponse();
this.Response.Init(Outgoing.UpdateUserDataMessageComposer);
this.Response.AppendInt32(-1);
this.Response.AppendString(this.Session.GetHabbo().Look);
this.Response.AppendString(this.Session.GetHabbo().Gender.ToLower());
this.Response.AppendString(this.Session.GetHabbo().Motto);
this.Response.AppendInt32(this.Session.GetHabbo().AchievementPoints);
this.SendResponse();
this.Session.GetHabbo().CurrentRoom.GetRoomUserManager().UpdateUser(username, text);
if (this.Session.GetHabbo().CurrentRoom != null)
{
this.Response.Init(Outgoing.UserUpdateNameInRoomMessageComposer);
this.Response.AppendUInt(this.Session.GetHabbo().Id);
this.Response.AppendUInt(this.Session.GetHabbo().CurrentRoom.RoomId);
this.Response.AppendString(text);
}
foreach (RoomData current in this.Session.GetHabbo().UsersRooms)
{
current.Owner = text;
current.SerializeRoomData(this.Response, false, this.Session, true);
Room room = MercuryEnvironment.GetGame().GetRoomManager().GetRoom(current.Id);
if (room != null)
{
room.Owner = text;
}
}
foreach (MessengerBuddy current2 in this.Session.GetHabbo().GetMessenger().friends.Values)
{
if (current2.client != null)
{
foreach (MessengerBuddy current3 in current2.client.GetHabbo().GetMessenger().friends.Values)
{
if (current3.mUsername == username)
{
current3.mUsername = text;
current3.Serialize(this.Response, current2.client);
}
}
}
}
}
}
}
}