예제 #1
0
		public void TryRedeemVoucher(GameClient Session, string Code)
		{
			if (!IsValidCode(Code))
			{
				ServerMessage Message = new ServerMessage(213);
				Message.AppendRawInt32(0);
				Session.SendMessage(Message);
			}
			else
			{
				DataRow row = null;
				using (DatabaseClient adapter = PhoenixEnvironment.GetDatabase().GetClient())
				{
					adapter.AddParamWithValue("code", Code);
					row = adapter.ReadDataRow("SELECT * FROM vouchers WHERE code = @code LIMIT 1");
				}
				int Credits = (int)row["credits"];
				int Pixels = (int)row["pixels"];
				int Points = (int)row["vip_points"];
				this.DeleteVoucher(Code);
				if (Credits > 0)
				{
					Session.GetHabbo().Credits += Credits;
					Session.GetHabbo().UpdateCreditsBalance(true);
				}
				if (Pixels > 0)
				{
					Session.GetHabbo().ActivityPoints += Pixels;
					Session.GetHabbo().UpdateActivityPointsBalance(true);
				}
				if (Points > 0)
				{
					Session.GetHabbo().shells += Points;
					Session.GetHabbo().UpdateShellsBalance(false, true);
				}
				Session.SendMessage(new ServerMessage(212));
			}
		}
예제 #2
0
파일: Room.cs 프로젝트: neto737/Phoenix_3.0
 public void RemoveBot(int int_17, bool bool_13)
 {
     RoomUser @class = this.GetRoomUserByVirtualId(int_17);
     if (@class != null && @class.IsBot)
     {
         @class.BotAI.OnSelfLeaveRoom(bool_13);
         ServerMessage Message = new ServerMessage(29u);
         Message.AppendRawInt32(@class.VirtualId);
         this.SendMessage(Message, null);
         uint num = @class.HabboId;
         for (int i = 0; i < this.UserList.Length; i++)
         {
             RoomUser class2 = this.UserList[i];
             if (class2 != null && class2.HabboId == num)
             {
                 this.UserList[i] = null;
             }
         }
     }
 }
예제 #3
0
파일: Room.cs 프로젝트: neto737/Phoenix_3.0
        public void RemoveUserFromRoom(GameClient Session, bool bool_13, bool bool_14)
        {
            int num = 1;
            if (!bool_14 || !Session.GetHabbo().isAaron)
            {
                if (this.bool_12)
                {
                    if (bool_13 && Session != null)
                    {
                        if (bool_14)
                        {
                            ServerMessage Message = new ServerMessage(33u);
                            Message.AppendInt32(4008);
                            Session.SendMessage(Message);
                        }
                        ServerMessage Message5_ = new ServerMessage(18u);
                        Session.SendMessage(Message5_);
                    }
                }
                else
                {
                    try
                    {
                        if (Session != null && Session.GetHabbo() != null)
                        {
                            num = 2;
                            RoomUser @class = this.GetRoomUserByHabbo(Session.GetHabbo().Id);
                            if (@class != null)
                            {
                                this.UserList[@class.CurrentFurniFX] = null;
                                @class.CurrentFurniFX = -1;
                                this.byte_0[@class.X, @class.Y] = @class.SqState;
                            }
                            num = 3;
                            if (bool_13)
                            {
                                if (bool_14)
                                {
                                    ServerMessage Message = new ServerMessage(33u);
                                    Message.AppendInt32(4008);
                                    Session.SendMessage(Message);
                                }
                                ServerMessage Message5_ = new ServerMessage(18u);
                                Session.SendMessage(Message5_);
                            }
                            num = 4;
                            if (@class != null && [email protected])
                            {
                                if (@class.byte_1 > 0 && @class.GetClient() != null)
                                {
                                    @class.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                                }
                                this.byte_0[@class.X, @class.Y] = @class.SqState;
                                if (!this.IsPublic)
                                {
                                    ServerMessage Message2 = new ServerMessage(700u);
                                    Message2.AppendBoolean(false);
                                    Session.SendMessage(Message2);
                                }
                                ServerMessage Message3 = new ServerMessage(29u);
                                Message3.AppendRawInt32(@class.VirtualId);
                                this.SendMessage(Message3, null);
                                if (this.HasActiveTrade(Session.GetHabbo().Id))
                                {
                                    this.TryStopTrade(Session.GetHabbo().Id);
                                }
                                num = 5;
                                if (Session.GetHabbo().Username.ToLower() == this.Owner.ToLower() && this.HasOngoingEvent)
                                {
                                    this.Event = null;
                                    ServerMessage Logging = new ServerMessage(370u);
                                    Logging.AppendStringWithBreak("-1");
                                    this.SendMessage(Logging, null);
                                }
                                num = 6;
                                if (@class.Riding != null)
                                {
                                    @class.Riding.Rider = null;
                                    @class.Riding = null;
                                    Session.GetHabbo().GetAvatarEffectsInventoryComponent().CurrentEffect = -1;
                                }
                                Session.GetHabbo().OnLeaveRoom();
                                this.bool_10 = true;
                                this.method_51();
                                List<RoomUser> list = new List<RoomUser>();
                                for (int i = 0; i < this.UserList.Length; i++)
                                {
                                    RoomUser class2 = this.UserList[i];
                                    if (class2 != null && class2.IsBot)
                                    {
                                        list.Add(class2);
                                    }
                                }
                                num = 7;
                                foreach (RoomUser current in list)
                                {
                                    current.BotAI.OnUserLeaveRoom(Session);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogCriticalException(string.Concat(new object[]
						{
							"Error during removing user from room [Part: ",
							num,
							"]: ",
							ex.ToString()
						}));
                    }
                }
            }
        }
예제 #4
0
파일: Room.cs 프로젝트: neto737/Phoenix_3.0
        private void method_33()
        {
            int num = 0;
            if (!this.bool_6 && !this.bool_7)
            {
                try
                {
                    this.int_14++;
                    if (this.bool_10 && this.int_14 >= 30)
                    {
                        using (DatabaseClient @class = PhoenixEnvironment.GetDatabase().GetClient())
                        {
                            @class.ExecuteQuery(string.Concat(new object[]
							{
								"UPDATE rooms SET users_now = '",
								this.UserCount,
								"' WHERE Id = '",
								this.Id,
								"' LIMIT 1"
							}));
                        }
                        this.int_14 = 0;
                    }
                    this.method_35();
                    int num2 = 0;
                    try
                    {
                        if (this.mFloorItems != null)
                        {
                            foreach (RoomItem class2 in this.Hashtable_0.Values)
                            {
                                if (class2.UpdateNeeded)
                                {
                                    class2.ProcessUpdates();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogThreadException(ex.ToString(), "Room [ID: " + this.RoomId + "] cycle task -- Process Floor Items");
                        this.CrashRoom();
                    }
                    try
                    {
                        if (this.mWallItems != null)
                        {
                            foreach (RoomItem class2 in this.Hashtable_1.Values)
                            {
                                if (class2.UpdateNeeded)
                                {
                                    class2.ProcessUpdates();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogThreadException(ex.ToString(), "Room [ID: " + this.RoomId + "] cycle task -- Process Wall Items");
                        this.CrashRoom();
                    }
                    List<uint> list = new List<uint>();
                    int num3 = 0;
                    if (this.UserList != null)
                    {
                        try
                        {
                            for (int i = 0; i < this.UserList.Length; i++)
                            {
                                RoomUser class3 = this.UserList[i];
                                if (class3 != null)
                                {
                                    num = 1;
                                    if (!class3.IsBot && class3.GetClient() != null)
                                    {
                                        num3++;
                                        if (class3.GetClient().GetHabbo() != null && class3.GetClient().GetHabbo().MuteLength > 0)
                                        {
                                            class3.GetClient().GetHabbo().MuteLength--;
                                            if (class3.GetClient().GetHabbo().MuteLength == 0)
                                            {
                                                class3.GetClient().GetHabbo().Muted = false;
                                            }
                                        }
                                    }
                                    if (this.musicController != null)
                                    {
                                        this.musicController.Update(this);
                                    }
                                    class3.IdleTime++;
                                    num = 2;
                                    if (!class3.IsAsleep && class3.IdleTime >= GlobalClass.IdleSleep)
                                    {
                                        class3.IsAsleep = true;
                                        ServerMessage Message = new ServerMessage(486u);
                                        Message.AppendInt32(class3.VirtualId);
                                        Message.AppendBoolean(true);
                                        this.SendMessage(Message, null);
                                    }
                                    num = 3;
                                    if (class3.GetClient() == null && !class3.IsBot)
                                    {
                                        this.UserList[i] = null;
                                        if (!class3.AllowOverride)
                                        {
                                            this.byte_0[class3.X, class3.Y] = class3.SqState;
                                        }
                                        ServerMessage Message2 = new ServerMessage(29u);
                                        Message2.AppendRawInt32(class3.VirtualId);
                                        this.SendMessage(Message2, null);
                                        this.method_50();
                                    }
                                    num = 4;
                                    if (class3.NeedsAutokick && !list.Contains(class3.HabboId))
                                    {
                                        list.Add(class3.HabboId);
                                    }
                                    num = 5;
                                    if (class3.CarryItemID > 0)
                                    {
                                        class3.CarryTimer--;
                                        if (class3.CarryTimer <= 0)
                                        {
                                            class3.CarryItem(0);
                                        }
                                    }
                                    num = 6;
                                    if (class3.SetStep && class3.Riding == null)
                                    {
                                        num = 7;
                                        if (class3.IsBot && class3.BotData.Rider != null && this.CanWalk(class3.SetX, class3.SetY, 0.0, true, true))
                                        {
                                            num = 8;
                                            this.method_85(class3);
                                            class3.X = class3.SetX;
                                            class3.Y = class3.SetY;
                                            class3.Z = class3.SetZ;
                                            class3.BotData.Rider.X = class3.SetX;
                                            class3.BotData.Rider.Y = class3.SetY;
                                            class3.BotData.Rider.Z = class3.SetZ + 1.0;
                                            class3.BotData.Rider.SetStep = false;
                                            class3.BotData.Rider.RemoveStatus("mv");
                                            if (class3.X == this.Model.DoorX && class3.Y == this.Model.DoorY && !list.Contains(class3.BotData.Rider.HabboId))
                                            {
                                                list.Add(class3.BotData.Rider.HabboId);
                                            }
                                            this.UpdateUserStatus(class3, true, true);
                                        }
                                        else
                                        {
                                            if (this.CanWalk(class3.SetX, class3.SetY, 0.0, true, class3.AllowOverride))
                                            {
                                                num = 8;
                                                this.method_85(class3);
                                                class3.X = class3.SetX;
                                                class3.Y = class3.SetY;
                                                class3.Z = class3.SetZ;
                                                if (class3.X == this.Model.DoorX && class3.Y == this.Model.DoorY && !list.Contains(class3.HabboId) && !class3.IsBot)
                                                {
                                                    list.Add(class3.HabboId);
                                                }
                                                this.UpdateUserStatus(class3, true, true);
                                            }
                                        }
                                        class3.SetStep = false;
                                    }
                                    num = 9;
                                    if (class3.IsWalking && !class3.bool_5 && class3.Riding == null)
                                    {
                                        num = 10;
                                        SquarePoint @struct = DreamPathfinder.GetNextStep(class3.X, class3.Y, class3.GoalX, class3.GoalY, this.byte_0, this.double_1, this.class28_0.SqFloorHeight, this.double_2, this.class28_0.MapSizeX, this.class28_0.MapSizeY, class3.AllowOverride, this.bool_5);
                                        num = 11;
                                        if (@struct.X != class3.X || @struct.Y != class3.Y)
                                        {
                                            num = 12;
                                            int int32_ = @struct.X;
                                            int int32_2 = @struct.Y;
                                            class3.RemoveStatus("mv");
                                            double num4 = this.method_84(int32_, int32_2, this.method_93(int32_, int32_2));
                                            class3.Statusses.Remove("lay");
                                            class3.Statusses.Remove("sit");
                                            class3.AddStatus("mv", string.Concat(new object[]
											{
												int32_,
												",",
												int32_2,
												",",
												num4.ToString().Replace(',', '.')
											}));
                                            num = 13;
                                            if (class3.IsBot && class3.BotData.Rider != null)
                                            {
                                                class3.BotData.Rider.AddStatus("mv", string.Concat(new object[]
												{
													int32_,
													",",
													int32_2,
													",",
													(num4 + 1.0).ToString().Replace(',', '.')
												}));
                                            }
                                            int num5;
                                            if (class3.WalkBackwards)
                                            {
                                                num5 = Rotation.CalculateMoonWalk(class3.X, class3.Y, int32_, int32_2);
                                            }
                                            else
                                            {
                                                num5 = Rotation.Calculate(class3.X, class3.Y, int32_, int32_2);
                                            }
                                            class3.RotBody = num5;
                                            class3.RotHead = num5;
                                            class3.SetStep = true;
                                            class3.SetX = int32_;
                                            class3.SetY = int32_2;
                                            class3.SetZ = num4;
                                            num = 14;
                                            if (class3.IsBot && class3.BotData.Rider != null)
                                            {
                                                class3.BotData.Rider.RotBody = num5;
                                                class3.BotData.Rider.RotHead = num5;
                                                class3.BotData.Rider.SetStep = true;
                                                class3.BotData.Rider.SetX = int32_;
                                                class3.BotData.Rider.SetY = int32_2;
                                                class3.BotData.Rider.SetZ = num4 + 1.0;
                                            }
                                            try
                                            {
                                                num = 15;
                                                if (!class3.IsBot)
                                                {
                                                    if (class3.GetClient().GetHabbo().Gender.ToLower() == "m" && this.byte_1[int32_, int32_2] > 0 && class3.byte_1 != this.byte_1[int32_, int32_2])
                                                    {
                                                        class3.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyEffect((int)this.byte_1[int32_, int32_2], true);
                                                        class3.byte_1 = this.byte_1[int32_, int32_2];
                                                    }
                                                    else
                                                    {
                                                        if (class3.GetClient().GetHabbo().Gender.ToLower() == "f" && this.byte_2[int32_, int32_2] > 0 && class3.byte_1 != this.byte_2[int32_, int32_2])
                                                        {
                                                            class3.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyEffect((int)this.byte_2[int32_, int32_2], true);
                                                            class3.byte_1 = this.byte_2[int32_, int32_2];
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (!class3.IsPet)
                                                    {
                                                        if (this.byte_1[int32_, int32_2] > 0)
                                                        {
                                                            class3.BotData.EffectId = (int)this.byte_1[int32_, int32_2];
                                                            class3.byte_1 = this.byte_1[int32_, int32_2];
                                                        }
                                                        ServerMessage Message3 = new ServerMessage(485u);
                                                        Message3.AppendInt32(class3.VirtualId);
                                                        Message3.AppendInt32(class3.BotData.EffectId);
                                                        this.SendMessage(Message3, null);
                                                    }
                                                }
                                                goto IL_CE1;
                                            }
                                            catch
                                            {
                                                goto IL_CE1;
                                            }
                                        IL_B8B:
                                            this.UpdateUserStatus(class3, false, true);
                                            class3.UpdateNeeded = true;
                                            if (class3.IsBot && class3.BotData.Rider != null)
                                            {
                                                this.UpdateUserStatus(class3.BotData.Rider, true, true);
                                                class3.BotData.Rider.UpdateNeeded = true;
                                                goto IL_BE0;
                                            }
                                            goto IL_BE0;
                                        IL_CE1:
                                            num = 16;
                                            this.byte_0[class3.X, class3.Y] = class3.SqState;
                                            class3.SqState = this.byte_0[class3.SetX, class3.SetY];
                                            if (this.AllowWalkthrough)
                                            {
                                                goto IL_B8B;
                                            }
                                            this.byte_0[int32_, int32_2] = 0;
                                            goto IL_B8B;
                                        }
                                        num = 12;
                                        class3.IsWalking = false;
                                        class3.RemoveStatus("mv");
                                        class3.PathRecalcNeeded = false;
                                        if (class3.IsBot && class3.BotData.Rider != null)
                                        {
                                            class3.BotData.Rider.RemoveStatus("mv");
                                            class3.BotData.Rider.IsWalking = false;
                                            class3.BotData.Rider.PathRecalcNeeded = false;
                                            class3.BotData.Rider.UpdateNeeded = true;
                                        }
                                    IL_BE0:
                                        class3.UpdateNeeded = true;
                                    }
                                    else
                                    {
                                        num = 17;
                                        if (class3.Statusses.ContainsKey("mv") && class3.Riding == null)
                                        {
                                            num = 18;
                                            class3.RemoveStatus("mv");
                                            class3.UpdateNeeded = true;
                                            if (class3.IsBot && class3.BotData.Rider != null)
                                            {
                                                class3.BotData.Rider.RemoveStatus("mv");
                                                class3.BotData.Rider.UpdateNeeded = true;
                                            }
                                        }
                                    }
                                    if (class3.IsBot || class3.IsPet)
                                    {
                                        try
                                        {
                                            class3.BotAI.OnTimerTick();
                                            goto IL_C9F;
                                        }
                                        catch
                                        {
                                            goto IL_C9F;
                                        }
                                    }
                                    goto IL_C9B;
                                IL_C9F:
                                    if (class3.int_9 > 0)
                                    {
                                        if (class3.int_9 == 1)
                                        {
                                            this.UpdateUserStatus(class3, true, true);
                                        }
                                        class3.int_9--;
                                        goto IL_CD6;
                                    }
                                    goto IL_CD6;
                                IL_C9B:
                                    num2++;
                                    goto IL_C9F;
                                }
                            IL_CD6: ;
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.LogThreadException(ex.ToString(), string.Concat(new object[]
							{
								"Room [ID: ",
								this.RoomId,
								"] [Part: ",
								num,
								" cycle task -- Process Users Updates"
							}));
                            this.CrashRoom();
                        }
                    }
                    try
                    {
                        foreach (uint current in list)
                        {
                            this.RemoveUserFromRoom(PhoenixEnvironment.GetGame().GetClientManager().GetClientByHabbo(current), true, false);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogThreadException(ex.ToString(), "Room [ID: " + this.RoomId + "] cycle task -- Remove Users");
                        this.CrashRoom();
                    }
                    if (num2 >= 1)
                    {
                        this.int_8 = 0;
                    }
                    else
                    {
                        this.int_8++;
                    }
                    if (!this.bool_6 && !this.bool_7)
                    {
                        try
                        {
                            if (this.int_8 >= 60)
                            {
                                PhoenixEnvironment.GetGame().GetRoomManager().UnloadRoom(this);
                                return;
                            }
                            ServerMessage Logging = this.method_67(false);
                            if (Logging != null)
                            {
                                this.SendMessage(Logging, null);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logging.LogThreadException(ex.ToString(), "Room [ID: " + this.RoomId + "] cycle task -- Cycle End");
                            this.CrashRoom();
                        }
                    }
                    this.mRoomData.UsersNow = num3;
                }
                catch (Exception ex)
                {
                    Logging.LogThreadException(ex.ToString(), "Room [ID: " + this.RoomId + "] cycle task");
                }
            }
        }