Esempio n. 1
0
        public void RemoveTileStatus(RoomUser user, int X, int Y)
        {
            mRoomInstance.RemoveUniqueStatus(user.SessionID, "sit");
            mRoomInstance.RemoveUniqueStatus(user.SessionID, "lay");

            List<FurniInfo> objects = GetFurniObjects(X, Y);
            if (objects != null)
            {
                foreach (FurniInfo info in objects)
                {
                    if (info.Flags.PoolChange)
                    {
                        ClientMessage message = new ClientMessage();
                        message.Init(71); //AG
                        message.appendString(info.FurniVar);
                        message.appendString(" ");
                        message.appendString("open");
                        mRoomInstance.RoomBroadcast(message);

                        //Unblock the curtain position
                        int tmpX = int.Parse(info.WallLocation.Split(',')[0]);
                        int tmpY = int.Parse(info.WallLocation.Split(',')[1]);
                        mPlayerMap[tmpX, tmpY] = false;

                    }

                    if (info.Flags.CanSit || info.Flags.CanLay)
                    {
                        user.CurrentZ = mHeightMap[info.PosX, info.PosY];
                    }
                }

            }
        }
Esempio n. 2
0
 public void AnnounceUser(long sessionId)
 {
     ClientMessage mMessage = new ClientMessage();
     string pBody = GetUserEntryPacket(sessionId);
     mMessage.Init(28); //@\
     mMessage.appendString(pBody);
     RoomBroadcast(mMessage);
     AnnounceUserStatus(sessionId, true);
 }
Esempio n. 3
0
        public void BroadcastToAll(ClientMessage message)
        {
            Dictionary<long, SessionHandler>.Enumerator myEnum = mSessions.GetEnumerator();

            while (myEnum.MoveNext())
            {
                myEnum.Current.Value.SendMessage(message);
            }
        }
Esempio n. 4
0
 public static void BroadcastCallForHelp(ClientMessage message)
 {
     mSessionManager.BroadcastCFH(message);
 }
Esempio n. 5
0
 private void NotifyClientSetStuffTempOpen(int itemId)
 {
     ClientMessage mMessage = new ClientMessage();
     mMessage.Init(88); //AX
     mMessage.appendString(itemId.ToString());
     mMessage.appendChar(2);
     mMessage.appendString("TRUE");
     mMessage.appendChar(2);
     mRoomInstance.RoomBroadcast(mMessage);
     mMessage.Init(88); //AX
     mMessage.appendString(itemId.ToString());
     mMessage.appendChar(2);
     mMessage.appendString("FALSE");
     mMessage.appendChar(2);
     new RoomInstance.RoomDelayBroadcastDelegate(mRoomInstance.RoomDelayBroadcast).BeginInvoke(mMessage, 1000, null, null);
 }
Esempio n. 6
0
 private void NotifyClientDiceRoll(int itemId, int rollVal, bool isRoll)
 {
     ClientMessage mMessage = new ClientMessage();
     mMessage.Init(90); //AZ
     mMessage.appendString(itemId.ToString());
     if (isRoll) mRoomInstance.RoomBroadcast(mMessage);
     mMessage.appendString(" ");
     mMessage.appendInt(rollVal);
     if (isRoll)
     {
         new RoomInstance.RoomDelayBroadcastDelegate(mRoomInstance.RoomDelayBroadcast).BeginInvoke(mMessage, 2000, null, null);
     }
     else
     {
         mRoomInstance.RoomBroadcast(mMessage);
     }
 }
Esempio n. 7
0
        public void SendFurniMovement(bool firstTime, bool badTile, int itemId, long sessionId)
        {
            FurniInfo newInfo = GetFurniObject(itemId);
            string data = ProcessFloorFurniDefinition(newInfo);

            ClientMessage mMessage = new ClientMessage();
            if (firstTime)
            {
                mMessage.Init(93); // A]
            }
            else
            {
                mMessage.Init(95); // A_
            }

            mMessage.appendString(data);

            if (!badTile)
            {
                mRoomInstance.RoomBroadcast(mMessage);

                GenerateMaps();

                mMessage.Init(31); //@_
                mMessage.appendString(ClientMap);
                mRoomInstance.RoomBroadcast(mMessage);
            }
            else
            {
                if(!firstTime)  mRoomInstance.SendMessage(mMessage, sessionId);
            }
        }
Esempio n. 8
0
        public void RequestSetStuffDataFloorItem(int itemId, string data, RoomUser user, FurniInfo.VarTypes overrideType)
        {
            FurniInfo item = GetFurniObject(itemId);
            ClientMessage mMessage = new ClientMessage();

            if (item != null)
            {
                if (overrideType != 0) item.VarType = overrideType;

                switch (item.VarType)
                {
                    case FurniInfo.VarTypes.TempOpen:
                        if (TilesTouching(item.PosX, item.PosY, user.CurrentX, user.CurrentY))
                        {
                            InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, "FALSE");
                            if (data == "TRUE") NotifyClientSetStuffTempOpen(itemId);

                        }
                        break;

                    case FurniInfo.VarTypes.TrueFalse:
                        if (TilesTouching(item.PosX, item.PosY, user.CurrentX, user.CurrentY))
                        {
                            if ((data == "TRUE" || data == "FALSE"))
                            {
                                InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, data);
                                NotifyClientSetStuffChange(itemId, data);
                            }

                        }
                        break;

                    case FurniInfo.VarTypes.DoorDivider:
                        if (user.HasAdmin || user.HasRights)
                        {
                            if (data == "O" || data == "C")
                            {
                                if (!PlayerCheck(item.PosX, item.PosY))
                                {
                                    InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, data);
                                    NotifyClientSetStuffChange(itemId, data);
                                    mFloorFurni = InstanceManager.Game.Furni.GetRoomFloorFurni(mRoomInstance.RoomInfo.RoomID);
                                    GenerateMaps();
                                }

                            }
                        }
                        break;

                    case FurniInfo.VarTypes.Dice:
                        if (TilesTouching(item.PosX, item.PosY, user.CurrentX, user.CurrentY))
                        {
                            if (data == "dice_roll" || data == "dice_off")
                            {
                                int newVal = 0;
                                if (data == "dice_roll") newVal = SpecialMath.RandomNumber(1, 6);
                                bool isRoll = newVal > 0;
                                int rollVal = (item.FurniID * 38) + newVal;
                                InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, newVal.ToString());
                                NotifyClientDiceRoll(item.FurniID, rollVal, isRoll);
                            }
                        }
                        break;

                    case FurniInfo.VarTypes.Bottle:
                        if (data == "dice_roll")
                        {
                            int newVal = SpecialMath.RandomNumber(0, 7);
                            bool isRoll = newVal > 0;
                            int rollVal = (item.FurniID * 38) + newVal;
                            InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, newVal.ToString());
                            NotifyClientDiceRoll(item.FurniID, rollVal, isRoll);
                        }
                        break;

                    case FurniInfo.VarTypes.OnOff:
                        if (data == "ON" || data == "OFF")
                        {
                            InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, data);
                            NotifyClientSetStuffChange(itemId, data);
                        }
                        break;

                    case FurniInfo.VarTypes.OpenOrClosed:
                        if (data == "O" || data == "C")
                        {
                            InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, data);
                            NotifyClientSetStuffChange(itemId, data);
                        }
                        break;

                    case FurniInfo.VarTypes.NumericalOff:
                        int tmpNum = -1;

                        if (int.TryParse(data, out tmpNum) || data == "OFF")
                        {
                            if (tmpNum >= -1 && tmpNum < 10 && !(tmpNum == -1 && data == "-1"))
                            {
                                InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, data);
                                NotifyClientSetStuffChange(itemId, data);
                            }
                        }
                        break;

                }

            }
        }
Esempio n. 9
0
        public void RequestPickupFloorStuff(int itemId, int userId)
        {
            if (ContainsItem(itemId))
            {
                FurniInfo furni = GetFurniObject(itemId);

                if (furni != null)
                {
                    if (!furni.Flags.WallItem)
                    {
                        InstanceManager.Game.Furni.PickupItem(itemId, userId);

                        mFloorFurni = InstanceManager.Game.Furni.GetRoomFloorFurni(mRoomInstance.RoomInfo.RoomID);

                        ClientMessage mMessage = new ClientMessage();
                        mMessage.Init(94); // A^
                        mMessage.appendInt(itemId);
                        mRoomInstance.RoomBroadcast(mMessage);

                        GenerateMaps();

                        mMessage.Init(31); //@_
                        mMessage.appendString(ClientMap);
                        mRoomInstance.RoomBroadcast(mMessage);

                        // Remove statuses on users effected by this item
                        UpdateChangedUsers(furni.PosX, furni.PosY);

                        Dictionary<int, AffectedTile> affectedTiles = GetAffectedTiles(furni);

                        foreach (AffectedTile affectedTile in affectedTiles.Values)
                        {
                            UpdateChangedUsers(affectedTile.X, affectedTile.Y);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
 public void RoomBroadcast(ClientMessage message)
 {
     Logging.LogEvent("Broadcasting to room " + mRoomID.ToString() + ": " + message.ToString(), Logging.LogLevel.Debug);
     RoomBroadcast(message.ToString());
 }
Esempio n. 11
0
        public void IdleTimer()
        {
            while (true)
            {
                List<long> toRemove = new List<long>();
                foreach (SessionHandler sess in mSessions.Values)
                {
                    if (sess.LastTime.AddMinutes(60) < DateTime.Now) toRemove.Add(sess.mSessionID);
                    if (!sess.pingOk) toRemove.Add(sess.mSessionID);
                    sess.pingOk = false;
                }

                foreach (long sessid in toRemove)
                {
                    InstanceManager.Connections.EndConnection(sessid);
                }

                //Ping
                ClientMessage message = new ClientMessage();
                message.Init(50); //@r
                BroadcastToAll(message);

                Thread.Sleep(60000);
            }
        }
Esempio n. 12
0
        private void UpdateRollerUser(RoomUser user, int newX, int newY, float newZ, bool isLastRoller, int rollerId)
        {
            user.NextX = newX;
            user.NextY = newY;
            user.NextZ = newZ;

            ClientMessage mMessage = new ClientMessage();
            mMessage.Init(230); // Cf
            mMessage.appendArgumentInt(user.CurrentX);
            mMessage.appendArgumentInt(user.CurrentY);

            mMessage.appendArgumentInt(user.NextX);
            mMessage.appendArgumentInt(user.NextY);

            mMessage.appendArgumentInt(0);

            mMessage.appendArgumentInt(rollerId);

            mMessage.appendString("J");

            mMessage.appendArgumentInt(user.RoomUserID);

            mMessage.appendString(user.CurrentZ.ToString().Replace(',', '.'));
            mMessage.appendChar(2);
            mMessage.appendString(user.NextZ.ToString().Replace(',', '.'));
            mMessage.appendChar(2);

            mRollerBroadcast.Append(mMessage.ToString());

            mPlayerMap[user.CurrentX, user.CurrentY] = false;
            user.CurrentX = user.NextX;
            user.CurrentY = user.NextY;
            user.CurrentZ = user.NextZ;
            user.MustUpdate = true;
            mPlayerMap[user.CurrentX, user.CurrentY] = true;

            if (isLastRoller)
            {
                CalculateTileStatusForUser(user.CurrentX, user.CurrentY, user, true);
            }
        }
Esempio n. 13
0
        private void UpdateRollerFurni(FurniInfo info, int nextX, int nextY, float nextZ, bool isLastRoller, int rollerId)
        {
            ClientMessage mMessage = new ClientMessage();
            mMessage.Init(230); // Cf
            mMessage.appendArgumentInt(info.PosX);
            mMessage.appendArgumentInt(info.PosY);

            mMessage.appendArgumentInt(nextX);
            mMessage.appendArgumentInt(nextY);

            mMessage.appendArgumentInt(1);

            mMessage.appendArgumentInt(info.FurniID);

            mMessage.appendString(info.PosZ.ToString().Replace(',', '.'));
            mMessage.appendChar(2);
            mMessage.appendString(nextZ.ToString().Replace(',', '.'));
            mMessage.appendChar(2);

            mMessage.appendArgumentInt(rollerId);

            mRollerBroadcast.Append(mMessage.ToString());

            info.PosX = nextX;
            info.PosY = nextY;
            info.PosZ = nextZ;
            InstanceManager.Game.Furni.MoveFloorItem(info.FurniID, info.PosX, info.PosY, info.PosZ, info.PosRotation, mRoomInstance.RoomInfo);
        }
Esempio n. 14
0
        private void CalculateTileStatusForUser(int X, int Y, RoomUser user, bool isRoller)
        {
            mRoomInstance.RemoveUniqueStatus(user.SessionID, "sit");
            mRoomInstance.RemoveUniqueStatus(user.SessionID, "lay");

            List<FurniInfo> objects = GetFurniObjects(X, Y);
            if (objects != null)
            {
                foreach (FurniInfo info in objects)
                {

                    if (info.Flags.NeverBlocked)
                    {
                        mPlayerMap[X, Y] = false;
                    }

                    if (info.Flags.CanSit)
                    {
                        user.HeadDirection = info.PosRotation;
                        user.BodyDirection = info.PosRotation;
                        user.CurrentZ = info.PosZ;
                        if (!user.SpecialStates.ContainsKey("sit"))
                        {
                            user.SpecialStates.Add("sit", new RoomUser.RoomUserStatus("sit", false, info.ActionHeight.ToString().Replace(',', '.'), 0, 0, 0, null, true));
                        }
                        mRoomInstance.RemoveUniqueStatuses(user.SessionID, "carryd");
                    }
                    else if (info.Flags.CanLay)
                    {
                        user.CurrentZ = info.PosZ;
                        user.HeadDirection = info.PosRotation;
                        user.BodyDirection = info.PosRotation;
                        if (isRoller) user.CurrentZ = mHeightMap[user.CurrentX, user.CurrentY];
                        if (!user.SpecialStates.ContainsKey("lay"))
                        {
                            user.SpecialStates.Add("lay", new RoomUser.RoomUserStatus("lay", false, info.ActionHeight.ToString().Replace(',', '.'), 0, 0, 0, "", true));
                        }
                        mRoomInstance.RemoveUniqueStatuses(user.SessionID, "");
                    }
                    else if (info.Flags.PoolChange)
                    {
                        user.UserLocked = true;

                        ClientMessage message = new ClientMessage();
                        message.Init(96); //A`
                        mRoomInstance.SendMessage(message, user.SessionID);

                        message.Init(71); //AG
                        message.appendString(info.FurniVar);
                        message.appendString(" ");
                        message.appendString("close");
                        mRoomInstance.RoomBroadcast(message);

                        //Block the curtain position
                        int tmpX = int.Parse(info.WallLocation.Split(',')[0]);
                        int tmpY = int.Parse(info.WallLocation.Split(',')[1]);
                        mPlayerMap[tmpX, tmpY] = true;
                    }
                    else if (info.Flags.PoolEnter)
                    {
                        if (user.UserInfo.sPoolFigure != "")
                        {
                            mRoomInstance.RemoveUniqueStatuses(user.SessionID, "");
                            int tmpX = int.Parse(info.WallLocation.Split(',')[0]);
                            int tmpY = int.Parse(info.WallLocation.Split(',')[1]);
                            user.CurrentX = tmpX;
                            user.CurrentY = tmpY;
                            user.CurrentZ = mHeightMap[tmpX, tmpY];
                            user.IsMoving = false;
                            if (!user.SpecialStates.ContainsKey("swim"))
                            {
                                user.SpecialStates.Add("swim", new RoomUser.RoomUserStatus("swim", true, "", 0, 0, 0, null, true));
                            }

                            ClientMessage message = new ClientMessage();
                            message.Init(71); //AG
                            message.appendString(info.FurniVar);
                            message.appendString(" ");
                            message.appendString("enter");
                            mRoomInstance.RoomBroadcast(message);

                            mRoomInstance.AnnounceUserStatus(user.SessionID, true);

                        }
                    }
                    else if (info.Flags.PoolExit)
                    {
                        mRoomInstance.RemoveUniqueStatuses(user.SessionID, "");
                        int tmpX = int.Parse(info.WallLocation.Split(',')[0]);
                        int tmpY = int.Parse(info.WallLocation.Split(',')[1]);
                        user.CurrentX = tmpX;
                        user.CurrentY = tmpY;
                        user.CurrentZ = mHeightMap[tmpX, tmpY];
                        user.IsMoving = false;

                        ClientMessage message = new ClientMessage();
                        message.Init(71); //AG
                        message.appendString(info.FurniVar);
                        message.appendString(" ");
                        message.appendString("exit");
                        mRoomInstance.RoomBroadcast(message);

                        mRoomInstance.AnnounceUserStatus(user.SessionID, true);
                    }

                }
            }
            else
            {
                mRoomInstance.RemoveUniqueStatuses(user.SessionID, "carryd,dance,swim");
            }
        }
Esempio n. 15
0
        public void RequestDeleteSticky(int itemId, int userId, long sessionId)
        {
            if (ContainsItem(itemId))
            {
                FurniInfo info = GetFurniObject(itemId);

                if (info.Flags.StickyNote)
                {
                    InstanceManager.Game.Furni.DeleteFurni(itemId);
                    mWallFurni = InstanceManager.Game.Furni.GetRoomWallFurni(mRoomInstance.RoomInfo.RoomID);

                    ClientMessage mMessage = new ClientMessage();
                    mMessage.Init(84); // AT
                    mMessage.appendInt(itemId);
                    mRoomInstance.RoomBroadcast(mMessage);

                }
                else
                {
                    RequestPickupWallItem(itemId, userId);
                    InstanceManager.Sessions.InvokeReactorMethod(sessionId, "UpdateHandInvoker");
                }
            }
        }
Esempio n. 16
0
 public void RoomDelayBroadcast(ClientMessage message, int milli)
 {
     Thread.Sleep(milli);
     RoomBroadcast(message);
 }
Esempio n. 17
0
        public void RequestOpenPresent(int userId, int presentId, Users.UserInfo userInfo, long sessionId)
        {
            if (ContainsItem(presentId))
            {
                FurniInfo furni = GetFurniObject(presentId);

                if (furni != null)
                {
                    if (furni.Flags.Gift)
                    {

                        GiftInfo gift = InstanceManager.Game.Furni.GetGift(presentId);
                        int newId = 0;
                        InstanceManager.Game.Catalogue.BuyItem("0", gift.PurchaseCode, gift.Payload, ref userInfo, true, ref newId);
                        InstanceManager.Game.Furni.DeleteGift(presentId);

                        InstanceManager.Game.Furni.DeleteFurni(presentId);
                        mFloorFurni = InstanceManager.Game.Furni.GetRoomFloorFurni(mRoomInstance.RoomInfo.RoomID);
                        FurniInfo info = InstanceManager.Game.Furni.GetFurni(newId);

                        ClientMessage mMessage = new ClientMessage();
                        mMessage.Init(129); //BA
                        mMessage.appendString(info.FurniSprite);
                        mMessage.appendChar(13);
                        mMessage.appendString(info.FurniSprite);

                        if (info.Flags.WallItem)
                        {
                            mMessage.appendString(" ");
                            mMessage.appendString(info.Col);
                            mMessage.appendChar(13);
                        }
                        else
                        {
                            mMessage.appendChar(13);
                            mMessage.appendInt(info.L);

                            mMessage.appendChar(13);
                            mMessage.appendInt(info.W);

                            mMessage.appendChar(13);
                            mMessage.appendString(info.Col);
                        }

                        mRoomInstance.SendMessage(mMessage, sessionId);

                        mMessage.Init(94); // A^
                        mMessage.appendInt(presentId);
                        mRoomInstance.RoomBroadcast(mMessage);

                        GenerateMaps();

                        mMessage.Init(31); //@_
                        mMessage.appendString(ClientMap);
                        mRoomInstance.RoomBroadcast(mMessage);

                    }
                }
            }
        }
Esempio n. 18
0
 public bool RoomRightsBroadcast(ClientMessage message)
 {
     Logging.LogEvent("Rights broadcasting to room " + mRoomID.ToString() + ": " + message.ToString(), Logging.LogLevel.Debug);
     return RoomRightsBroadcast(message.ToString());
 }
Esempio n. 19
0
        public void RequestPickupWallItem(int itemId, int userId)
        {
            if (ContainsItem(itemId))
            {
                FurniInfo info = GetFurniObject(itemId);
                if (info != null)
                {
                    if (info.Flags.WallItem)
                    {
                        if (!info.Flags.StickyNote) //Can't pick up stickies
                        {
                            InstanceManager.Game.Furni.PickupItem(itemId, userId);
                            mWallFurni = InstanceManager.Game.Furni.GetRoomWallFurni(mRoomInstance.RoomInfo.RoomID);

                            ClientMessage mMessage = new ClientMessage();
                            mMessage.Init(84); // AT
                            mMessage.appendInt(itemId);
                            mRoomInstance.RoomBroadcast(mMessage);
                        }
                    }
                }
            }
        }
Esempio n. 20
0
 public void SendMessage(ClientMessage message, long sessionId)
 {
     SendMessage(message.ToString(), sessionId);
 }
Esempio n. 21
0
        public void RequestWallMoveItem(int itemId, string newPos, long sessionId)
        {
            FurniInfo info = InstanceManager.Game.Furni.GetFurni(itemId);
            if (info.OwnerID == mRoomInstance.GetUser(sessionId).UserInfo.userId)
            {
                if (info.Flags.StickyNote)
                {
                    int left = int.Parse(info.FurniVar);

                    if (left > 0)
                    {
                        int newFurni = InstanceManager.Game.Furni.CreateNewFurni(info.FurniTypeId, mRoomInstance.GetUser(sessionId).UserInfo.userId);
                        left--;

                        if (left == 0)
                        {
                            InstanceManager.Game.Furni.DeleteFurni(itemId);
                        }
                        else
                        {
                            InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, left.ToString());
                        }

                        itemId = newFurni;

                    }
                    else
                    {
                        InstanceManager.Game.Furni.DeleteFurni(itemId);
                    }
                }
                newPos = WallPositionCheck(newPos);
                if (newPos != null)
                {
                    InstanceManager.Game.Furni.MoveWallItem(itemId, newPos, mRoomInstance.RoomInfo.RoomID, mRoomInstance.RoomInfo.RoomOwner);
                    mWallFurni = InstanceManager.Game.Furni.GetRoomWallFurni(mRoomInstance.RoomInfo.RoomID);
                    FurniInfo newInfo = GetFurniObject(itemId);

                    ClientMessage mMessage = new ClientMessage();
                    mMessage.Init(83); //AS
                    mMessage.appendString(ProcessWallFurniDefinition(newInfo));
                    mRoomInstance.RoomBroadcast(mMessage);
                }

            }
        }
Esempio n. 22
0
 private void WhisperResponse(string response, long sessionid)
 {
     if (sessionid > 0)
     {
         int roomId = InstanceManager.Sessions.GetSession(sessionid).mRoomID;
         if (roomId > 0)
         {
             int roomUser = InstanceManager.Game.Rooms.GetRoomInstance(roomId).GetUser(sessionid).RoomUserID;
             ClientMessage mMessage = new ClientMessage();
             mMessage.Init(25); //@Y
             mMessage.appendString(ArgumentEncoding.encodeInt(roomUser));
             mMessage.appendString(response);
             mMessage.appendChar(2);
             InstanceManager.Game.Rooms.GetRoomInstance(roomId).SendMessage(mMessage, sessionid);
         }
     }
 }
Esempio n. 23
0
        private bool ExecuteFloorMoveItem(FurniInfo item, int itemId, int newX, int newY, int newRot, bool firstTime, long sessionId)
        {
            int furniCount = 0;
            int rollerCount = 0;

            //Work out new affectedTiles
            Dictionary<int, AffectedTile> affectedTiles = GetAffectedTiles(item.L, item.W, newX, newY, newRot);

            //Verify the new tiles exist
            if (!ValidTile(item.PosX, item.PosY)) return false;
            foreach (AffectedTile tile in affectedTiles.Values) { if (!ValidTile(tile.X, tile.Y)) return false; }

            //Verify the user has rights, or owns the item if they are dropping it
            if (firstTime && item.OwnerID != mRoomInstance.GetUser(sessionId).UserInfo.userId) return false;
            if (!firstTime && item.RoomID != mRoomInstance.RoomInfo.RoomID) return false;

            //Verify if it's the first time and not the users room, the item is tradeable
            if (firstTime && mRoomInstance.RoomInfo.RoomOwner != mRoomInstance.GetUser(sessionId).UserInfo.userId && item.CanTrade == false) return false;

            //Calculate the new height according to the heightmap
            float newZ = mHeightMap[newX, newY];

            //Is the item trying to stack on itself?
            if (item.PosRotation == newRot && item.PosX == newX && item.PosY == newY && item.PosZ != newZ) return false;

            //Check it's not a bad heightmap tile
            if (mClientMap[newX, newY] == "x") return false;
            foreach (AffectedTile tile in affectedTiles.Values) { if (mClientMap[tile.X, tile.Y] == "x") return false; }

            //Check for players
            if (mPlayerMap[newX, newY] && !(item.PosRotation != newRot && item.PosX == newX && item.PosY == newY)) return false;
            foreach (AffectedTile tile in affectedTiles.Values) { if (mPlayerMap[tile.X, tile.Y]) return false; }

            //Get the furniture counts (not including this item)
            foreach (FurniInfo tmp in mFloorFurni) { furniCount++; if (tmp.Flags.IsRoller) rollerCount++; }

            //Get the affected objects
            List<FurniInfo> objectsOnTile = GetFurniObjects(newX, newY);
            List<FurniInfo> objectsAffected = new List<FurniInfo>();
            List<FurniInfo> objectsComplete = new List<FurniInfo>();
            foreach (AffectedTile tile in affectedTiles.Values)
            {
                List<FurniInfo> objectsTmp = GetFurniObjects(tile.X, tile.Y);
                if (objectsTmp != null)
                {
                    objectsAffected.AddRange(objectsTmp);
                }
            }

            //Check the item isn't a roller and furni exists
            if (objectsComplete.Count > 0 && item.Flags.IsRoller) return false;

            if (objectsOnTile == null) objectsOnTile = new List<FurniInfo>();
            objectsComplete.AddRange(objectsOnTile);

            if (objectsAffected == null) objectsAffected = new List<FurniInfo>();
            objectsComplete.AddRange(objectsAffected);

            //Check you can stack the item
            if (objectsComplete.Count > 0 && !item.Flags.CanStack) return false;

            //Check for nonstackable items and rollers
            foreach (FurniInfo info in objectsComplete)
            {
                if (!info.Flags.CanStackOn || (info.Flags.IsRoller && (item.W > 1 || item.L > 1))) return false;
            }

            //Rotating the item, should remain at the same height for now
            if (item.PosRotation != newRot && item.PosX == newX && item.PosY == newY) newZ = item.PosZ;

            //Are any of the other tiles higher?
            foreach (FurniInfo info in objectsAffected)
            {
                if (info.TotalHeight > newZ) newZ = info.TotalHeight;
            }

            //Impose stacking limit
            if (newZ > MaxStackHeight)
            {
                newZ = MaxStackHeight;
            }

            //Impose furni limit
            if (furniCount >= 125 && firstTime)
            {

                ClientMessage mMessage = new ClientMessage();
                mMessage.Init(139); //BK
                mMessage.appendString(InstanceManager.Game.Externals.GetTextValue("room_alert_furni_limit"));
                mRoomInstance.SendMessage(mMessage, sessionId);
                return false;
            }

            //Impose roller limit
            if (item.Flags.IsRoller)
            {
                if (rollerCount >= 10 && firstTime)
                {
                    ClientMessage mMessage = new ClientMessage();
                    mMessage.Init(139); //BK
                    mMessage.appendString(InstanceManager.Game.Externals.GetTextValue("queue_tile_limit"));
                    mRoomInstance.SendMessage(mMessage, sessionId);
                    return false;
                }
            }

            //Ensure it's a valid rotation
            if (newRot != 0 && newRot != 2 && newRot != 4 && newRot != 6 && newRot != 8) newRot = 0;

            //Move the item
            int oldX = item.PosX; int oldY = item.PosY;
            affectedTiles = GetAffectedTiles(item);
            InstanceManager.Game.Furni.MoveFloorItem(itemId, newX, newY, newZ, newRot, mRoomInstance.RoomInfo);
            mFloorFurni = InstanceManager.Game.Furni.GetRoomFloorFurni(mRoomInstance.RoomInfo.RoomID);
            GenerateMaps();

            // Remove statuses on users affected by this item
            UpdateChangedUsers(oldX, oldY);
            foreach (AffectedTile affectedTile in affectedTiles.Values)
            {
                UpdateChangedUsers(affectedTile.X, affectedTile.Y);
            }

            return true;
        }
Esempio n. 24
0
 public void SendMessage(ClientMessage message)
 {
     SendMessage(message.ToString());
 }
Esempio n. 25
0
 private void NotifyClientSetStuffChange(int itemId, string data)
 {
     ClientMessage mMessage = new ClientMessage();
     mMessage.Init(88); //AX
     mMessage.appendString(itemId.ToString());
     mMessage.appendChar(2);
     mMessage.appendString(data);
     mMessage.appendChar(2);
     mRoomInstance.RoomBroadcast(mMessage);
 }
Esempio n. 26
0
        public void RequestChangeStickyData(int itemId, string newMessage, int newItemType, long sessionId)
        {
            if (ContainsItem(itemId))
            {
                FurniInfo info = GetFurniObject(itemId);

                if (info != null)
                {
                    if (info.Flags.StickyNote)
                    {
                        if (newItemType > 0) InstanceManager.Game.Furni.SetItemType(itemId, newItemType);

                        if (newMessage.Length > 685) newMessage = newMessage.Substring(0, 685);
                        newMessage = SpecialFiltering.FilterChars("2,9,47", newMessage);

                        InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, newMessage);

                        mWallFurni = InstanceManager.Game.Furni.GetRoomWallFurni(mRoomInstance.RoomInfo.RoomID);
                        info = GetFurniObject(itemId);

                        ClientMessage message = new ClientMessage();
                        message.Init(85); //AU
                        message.appendInt(itemId);
                        message.appendChar(9);
                        message.appendString(info.FurniSprite);
                        message.appendChar(9);
                        message.appendString(" ");
                        message.appendString(info.WallLocation);
                        message.appendChar(9);
                        message.appendString(info.Col);
                        mRoomInstance.RoomBroadcast(message);
                    }
                }
            }
        }
Esempio n. 27
0
        private void ProcessTeleporter(FurniInfo Teleporter1, RoomUser user)
        {
            FurniInfo Teleporter2 = null;

            Point invalidPoint = new Point(Teleporter1.PosX, Teleporter1.PosY);

            if (Teleporter1.PosRotation == 0 || Teleporter1.PosRotation == 2) invalidPoint.X++;
            if (Teleporter1.PosRotation == 4) invalidPoint.Y++;

            if (InstanceManager.Game.Furni.FurniExists(Teleporter1.TeleportId))
            {
                Teleporter2 = InstanceManager.Game.Furni.GetFurni(Teleporter1.TeleportId);
            }

            if (!user.UserLocked)
            {

                user.UserLocked = true;
                Thread.Sleep(1000);

                if (Teleporter1.PosX == user.CurrentX && Teleporter1.PosY == user.CurrentY)
                {

                    ClientMessage message = new ClientMessage();

                    if (Teleporter2 != null && Teleporter2.RoomID > 0 && Teleporter1.Flags.IsTeleport && Teleporter2.Flags.IsTeleport)
                    {
                        message.Init(89); //AY
                        message.appendInt(Teleporter1.FurniID);
                        message.appendString("/");
                        message.appendString(user.UserInfo.sUsername);
                        message.appendString("/");
                        message.appendString(Teleporter1.FurniSprite);
                        mRoomInstance.RoomBroadcast(message);

                        if (Teleporter2.RoomID == Teleporter1.RoomID) //Same room
                        {
                            Thread.Sleep(2000);
                            Teleporter2 = InstanceManager.Game.Furni.GetFurni(Teleporter1.TeleportId);
                            Teleporter1 = InstanceManager.Game.Furni.GetFurni(Teleporter1.FurniID);
                            if (Teleporter2.RoomID == Teleporter1.RoomID && Teleporter1.PosX == user.CurrentX && Teleporter1.PosY == user.CurrentY)
                            {
                                message.Init(92); //A\
                                message.appendInt(Teleporter2.FurniID);
                                message.appendString("/");
                                message.appendString(user.UserInfo.sUsername);
                                message.appendString("/");
                                message.appendString(Teleporter2.FurniSprite);
                                mRoomInstance.RoomBroadcast(message);
                                mPlayerMap[user.CurrentX, user.CurrentY] = false;
                                user.CurrentX = Teleporter2.PosX;
                                user.CurrentY = Teleporter2.PosY;
                                user.CurrentZ = Teleporter2.PosZ;
                                mRoomInstance.AnnounceUserStatus(user.SessionID, true);
                                mPlayerMap[user.CurrentX, user.CurrentY] = true;
                                user.UserLocked = false;
                            }
                            else
                            {
                                if (Teleporter1.PosX == user.CurrentX && Teleporter1.PosY == user.CurrentY)
                                {
                                    RequestSetStuffDataFloorItem(Teleporter1.FurniID, "TRUE", user, FurniInfo.VarTypes.TempOpen);
                                    RequestMovePlayer(user.SessionID, invalidPoint.X, invalidPoint.Y, null, true);
                                }
                                user.UserLocked = false;
                            }
                        }
                        else //In another room
                        {

                            InstanceManager.Sessions.GetSession(user.SessionID).authenticatedDoor = Teleporter2.FurniID;
                            InstanceManager.Sessions.GetSession(user.SessionID).authenticatedFlat = Teleporter2.RoomID;

                            message.Init(62); //@~
                            message.appendArgumentInt(Teleporter2.FurniID);
                            message.appendArgumentInt(Teleporter2.RoomID);
                            mRoomInstance.SendMessage(message, user.SessionID);
                        }

                    }
                    else //No linked teleporter exists
                    {
                        Thread.Sleep(700);
                        RequestSetStuffDataFloorItem(Teleporter1.FurniID, "TRUE", user, FurniInfo.VarTypes.TempOpen);
                        RequestMovePlayer(user.SessionID, invalidPoint.X, invalidPoint.Y, null, true);
                        user.UserLocked = false;
                    }

                }
            }
        }
Esempio n. 28
0
        public void RequestDecorateRoom(int itemId, int userId)
        {
            if (InstanceManager.Game.Furni.FurniExists(itemId))
            {
                FurniInfo info = InstanceManager.Game.Furni.GetFurni(itemId);

                if (info.Flags.Decoration && info.OwnerID == userId)
                {

                    if (info.FurniSprite == "wallpaper")
                    {
                        mRoomInstance.RoomInfo.Wallpaper = int.Parse(info.FurniVar);
                    }
                    else if (info.FurniSprite == "floor")
                    {
                        mRoomInstance.RoomInfo.Floor = int.Parse(info.FurniVar);
                    }

                    InstanceManager.Game.Rooms.UpdateRoom(mRoomInstance.RoomInfo);

                    ClientMessage mMessage = new ClientMessage();
                    mMessage.Init(46); //@n
                    mMessage.appendString(info.FurniSprite);
                    mMessage.appendString("/");
                    mMessage.appendString(info.FurniVar);
                    mRoomInstance.RoomBroadcast(mMessage);

                    InstanceManager.Game.Furni.DeleteFurni(info.FurniID);

                }

            }
        }
Esempio n. 29
0
 public static void BroadcastToAll(ClientMessage message)
 {
     mSessionManager.BroadcastToAll(message);
 }
Esempio n. 30
0
        public bool BuyItem(string isGift, string purchaseCode, string packetBody, ref Users.UserInfo info, bool noCredits, ref int newId)
        {
            info = InstanceManager.Game.Users.GetUser(info.userId);

            ClientMessage mMessage = new ClientMessage();

            try
            {
                if (purchaseCode == "special_floor" || purchaseCode == "special_wallpaper")
                {

                    string type = "";
                    if (purchaseCode == "special_floor") type = "floor";
                    if (purchaseCode == "special_wallpaper") type = "wallpaper";
                    int decorationId = int.Parse(packetBody.Split(Convert.ToChar(13))[4]);
                    int typeId = InstanceManager.Game.Furni.GetTypeFromSprite(type);

                    if (typeId > 0)
                    {
                        if (info.iCredits >= 2 || noCredits)
                        {

                            if (!noCredits)
                            {
                                info.iCredits -= 2;
                                InstanceManager.Game.Users.UpdateUser(info);
                                info = InstanceManager.Game.Users.GetUser(info.userId);
                            }

                            if (isGift == "1")
                            {
                                string targetUser = packetBody.Split(Convert.ToChar(13))[6];
                                string desc = SpecialFiltering.FilterChars("2,9,10,13,47", packetBody.Split(Convert.ToChar(13))[7]);
                                if (desc.Length > 202) desc = desc.Substring(0, 202);

                                if (InstanceManager.Game.Users.UserExists(targetUser))
                                {
                                    Users.UserInfo giftUser = InstanceManager.Game.Users.GetUser(targetUser);

                                    newId = InstanceManager.Game.Furni.CreateNewFurni(InstanceManager.Game.Furni.GetRandomPresentDefinition(), giftUser.userId);
                                    Furni.GiftInfo gift = new ThorServer.Game.Furni.GiftInfo();
                                    gift.GiftId = newId;
                                    gift.PurchaseCode = purchaseCode;
                                    gift.Payload = packetBody;
                                    InstanceManager.Game.Furni.AddGift(gift);
                                    InstanceManager.Game.Furni.SetStuffDataFloorItem(newId, "!" + desc);

                                    long tmpSession = InstanceManager.Sessions.GetSessionFromUser(giftUser.userId);
                                    if (tmpSession != -1)
                                    {
                                        InstanceManager.Sessions.InvokeReactorMethod(tmpSession, "UpdateHandInvoker");
                                    }
                                    return true;
                                }

                            }
                            else
                            {

                                int itemId = InstanceManager.Game.Furni.CreateNewFurni(typeId, info.userId);
                                newId = itemId;
                                InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, decorationId.ToString());
                                return true;
                            }

                        }
                        else
                        {
                            return false;
                        }
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {

                    CatalogueItemInfo item = InstanceManager.Game.Catalogue.GetCatalogueItem(purchaseCode);
                    if (item != null)
                    {
                        if (!item.StaffOnly || InstanceManager.Game.Roles.HasRight(info.iRole, "fuse_staff_catalogue") || noCredits)
                        {
                            if (info.iCredits >= item.ItemCost || noCredits)
                            {

                                if (!noCredits)
                                {
                                    info.iCredits -= item.ItemCost;
                                    InstanceManager.Game.Users.UpdateUser(info);
                                    info = InstanceManager.Game.Users.GetUser(info.userId);
                                }

                                if (isGift == "1")
                                {
                                    string targetUser = packetBody.Split(Convert.ToChar(13))[6];
                                    string desc = SpecialFiltering.FilterChars("2,9,10,13,47", packetBody.Split(Convert.ToChar(13))[7]);
                                    if (desc.Length > 202) desc = desc.Substring(0, 202);

                                    if (InstanceManager.Game.Users.UserExists(targetUser))
                                    {
                                        Users.UserInfo giftUser = InstanceManager.Game.Users.GetUser(targetUser);

                                        newId = InstanceManager.Game.Furni.CreateNewFurni(InstanceManager.Game.Furni.GetRandomPresentDefinition(), giftUser.userId);
                                        Furni.GiftInfo gift = new ThorServer.Game.Furni.GiftInfo();
                                        gift.GiftId = newId;
                                        gift.PurchaseCode = purchaseCode;
                                        gift.Payload = packetBody;
                                        InstanceManager.Game.Furni.AddGift(gift);
                                        InstanceManager.Game.Furni.SetStuffDataFloorItem(newId, "!" + desc);
                                        long tmpSession = InstanceManager.Sessions.GetSessionFromUser(giftUser.userId);
                                        if (tmpSession != -1)
                                        {
                                            InstanceManager.Sessions.InvokeReactorMethod(tmpSession, "UpdateHandInvoker");
                                        }
                                        return true;
                                    }

                                }
                                else
                                {
                                    int itemId = InstanceManager.Game.Furni.CreateNewFurni(item.FurniType, info.userId);
                                    newId = itemId;
                                    if (purchaseCode.StartsWith("special_teleporter_"))
                                    {
                                        int itemId2 = InstanceManager.Game.Furni.CreateNewFurni(item.FurniType, info.userId);
                                        InstanceManager.Game.Furni.SetTeleportID(itemId, itemId2);
                                        InstanceManager.Game.Furni.SetTeleportID(itemId2, itemId);
                                    }

                                    if (item.Sticky)
                                    {
                                        InstanceManager.Game.Furni.SetStuffDataFloorItem(itemId, "20");
                                    }

                                    return true;
                                }
                            }
                            else
                            {
                                return false;
                            }
                        }
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch
            {
                return false;
            }

            return false;
        }