Example #1
0
        public static string Set(Request packet)
        {
            int id;

            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                           Logger.LogType.Error, typeof(AiItems));
                return("[0,\"Could not find ID\"]");
            }

            if (packet.Data.Count != 2)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                           typeof(AiItems));
                return("[0,\"The request was malformed\"]");
            }

            var aiitem = GetObject(id);

            lock (aiitem.Locker)
            {
                aiitem._expiry = packet.Expiry;
                aiitem._items  = ArmaArray.Serialize(packet.Data.AsArray(0));
                aiitem._count  = ArmaArray.Serialize(packet.Data.AsArray(1));
                aiitem.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating ai_items: {0}", id), Logger.LogType.Info, typeof(AiItems));
            return("[1,\"Success\"]");
        }
Example #2
0
        public static string Set(Request packet)
        {
            long id;

            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                           Logger.LogType.Error, typeof(Player));
                return("[0,\"Could not find ID\"]");
            }

            if (packet.Table == "PLAYERSTATS")
            {
                return(UpdatePlayerStats(id, packet));
            }

            if (packet.Data.Count != 12)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                           typeof(Player));
                return("[0,\"The request was malformed\"]");
            }

            Logger.Log(String.Format("Updating Player: {0}", id), Logger.LogType.Info, typeof(Player));

            var player = GetObject(id);

            lock (player.Locker)
            {
                player._expiry        = packet.Expiry;
                player._worldspace    = ArmaArray.Serialize(packet.Data.AsArray(0));
                player._medical       = ArmaArray.Serialize(packet.Data.AsArray(1));
                player._appearance    = ArmaArray.Serialize(packet.Data.AsArray(2));
                player._vars          = ArmaArray.Serialize(packet.Data.AsArray(4));
                player._weapons       = ArmaArray.Serialize(packet.Data.AsArray(5));
                player._assignedItems = ArmaArray.Serialize(packet.Data.AsArray(6));
                player._magazinesAmmo = ArmaArray.Serialize(packet.Data.AsArray(7));
                player._itemsplayer   = ArmaArray.Serialize(packet.Data.AsArray(8));
                player._weaponsplayer = ArmaArray.Serialize(packet.Data.AsArray(9));
                player._group         = packet.Data.AsString(10);
                player._revive        = packet.Data.AsBool(11);
                player.SaveOrUpdate();
            }
            return("[1,\"Success\"]");
        }
Example #3
0
        public static string Set(Request packet)
        {
            int id;

            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                           Logger.LogType.Error, typeof(Vehicle));
                return("[0,\"Could not find ID\"]");
            }

            if (packet.Data.Count == 0)
            {
                DeleteObject(id);
                return("[1,\"Success\"]");
            }

            if (packet.Data.Count != 8)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                           typeof(Vehicle));
                return("[0,\"The request was malformed\"]");
            }

            var vehicle = GetObject(id);

            lock (vehicle.Locker)
            {
                vehicle._expiry         = packet.Expiry;
                vehicle._class          = packet.Data.AsString(0);
                vehicle._position       = ArmaArray.Serialize(packet.Data.AsArray(1));
                vehicle._damage         = packet.Data.AsFloat(2);
                vehicle._hitPointDamage = ArmaArray.Serialize(packet.Data.AsArray(3));
                vehicle._fuel           = packet.Data.AsFloat(4);
                vehicle._inventory      = ArmaArray.Serialize(packet.Data.AsArray(5));
                vehicle._magazinesAmmo  = ArmaArray.Serialize(packet.Data.AsArray(6));
                vehicle._texture        = packet.Data.AsInt(7);
                vehicle.SaveOrUpdate();
            }
            Logger.Log(String.Format("Updating Vehicle: {0}", id), Logger.LogType.Info, typeof(Vehicle));

            return("[1,\"Success\"]");
        }
Example #4
0
        public static string Set(Request packet)
        {
            long id;

            try
            {
                id = Convert.ToInt64(packet.InstanceId);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                           Logger.LogType.Error, typeof(Group));
                return("[0,\"Could not find ID\"]");
            }

            if (packet.Data.Count != 5)
            {
                Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                           typeof(Group));
                return("[0,\"The request was malformed\"]");
            }

            var group = GetObject(id);

            lock (group.Locker)
            {
                group._expiry     = packet.Expiry;
                group._groupName  = packet.Data.AsString(0);
                group._leaderName = packet.Data.AsString(1);
                group._level      = packet.Data.AsInt(2);
                group._mods       = ArmaArray.Serialize(packet.Data.AsArray(3));
                group._members    = ArmaArray.Serialize(packet.Data.AsArray(4));
                group.SaveOrUpdate();
            }

            Logger.Log(String.Format("Updating Group: {0}", id), Logger.LogType.Info, typeof(Group));

            return("[1,\"Success\"]");
        }
Example #5
0
        public Request(string request)
        {
            var parts = request.Split(Manager.Seperator);

            switch (parts[0].ToUpper())
            {
                case "SET":
                    _command = Commands.Set;
                    break;
                case "GETSYNC":
                    _command = Commands.GetSync;
                    break;
                case "GETASYNC":
                    _command = Commands.GetAsync;
                    break;
                case "DEL":
                    _command = Commands.Del;
                    break;
                case "EXPIRE":
                    _command = Commands.Expire;
                    break;
                case "GETBIT":
                    _command = Commands.GetBit;
                    break;
                case "RESPONSE":
                    _command = Commands.Response;
                    break;
                default:
                    throw new RequestException("Unknown packet type");
                    break;
            }

            try
            {
                switch (_command)
                {
                    case Commands.Set:
                        _table = parts[1].ToUpper();
                        _instanceId = parts[2];
                        _expiry = Convert.ToInt32(parts[3]);
                        _data = ArmaArray.Unserialize(parts[4]);
                        break;

                    case Commands.GetSync:
                    case Commands.GetAsync:
                    case Commands.Del:
                        _table = parts[1].ToUpper();
                        _instanceId = parts[2];
                        break;

                    case Commands.Expire:
                        _table = parts[1].ToUpper();
                        _instanceId = parts[2];
                        _expiry = Convert.ToInt32(parts[3]);
                        break;

                    case Commands.GetBit:
                        _table = parts[1].ToUpper();
                        _instanceId = parts[2];
                        _bit = Convert.ToInt32(parts[3]);
                        break;

                    case Commands.Response:
                        _tid = Convert.ToInt32(parts[1]);
                        _part = Convert.ToInt32(parts[2]);
                        break;
                }
            }
            catch (Exception ex)
            {
                throw new RequestException(String.Format("Request Error: {0} - {1}", ex.Message, request));
            }
        }
Example #6
0
        public static string Set(Request packet)
        {
            int id;

            try
            {
                id = Convert.ToInt32(packet.InstanceId.Split(':')[1]);
            }
            catch (Exception ex)
            {
                Logger.Log(String.Format("Error getting id: {0} - {1}", ex.Message, packet.InstanceId),
                           Logger.LogType.Error, typeof(Building));
                return("[0,\"Could not find ID\"]");
            }

            if (packet.Data.Count == 0)
            {
                DeleteObject(id);
                return("[1,\"Success\"]");
            }
            if (packet.Data.Count < 2)
            {
                Logger.Log(String.Format("Error parsing: {0}", packet.InstanceId), Logger.LogType.Error,
                           typeof(Building));
                return("[0,\"The request was malformed\"]");
            }
            var building = GetObject(id);

            lock (building.Locker)
            {
                building._expiry   = packet.Expiry;
                building._class    = packet.Data.AsString(0);
                building._position = ArmaArray.Serialize(packet.Data.AsArray(1));

                switch (packet.Data.Count)
                {
                case 2:
                    break;

                case 5:
                    building._storageId = packet.Data.AsInt(2);
                    building._playerId  = packet.Data.AsLong(3);
                    building._texture   = packet.Data.AsInt(4);
                    break;

                case 6:
                    building._storageId = packet.Data.AsInt(2);
                    building._playerId  = packet.Data.AsLong(3);
                    building._texture   = packet.Data.AsInt(4);
                    building._damage    = packet.Data.AsFloat(5);
                    break;

                default:
                    Logger.Log(String.Format("Parsing error: {0}", packet.Data), Logger.LogType.Error,
                               typeof(Building));
                    return("[0,\"The request was malformed\"]");
                }
                building.SaveOrUpdate();
                Logger.Log(String.Format("Updating Building: {0}", id), Logger.LogType.Info, typeof(Building));
            }
            return("[1,\"Success\"]");
        }