Exemplo n.º 1
0
        public void CreateEstateCmd(List <string> args, Common.CmdIO.TTY io, UUID limitedToScene)
        {
            EstateInfo estateInfo;
            uint       estateID;

            if (limitedToScene != UUID.Zero)
            {
                io.WriteFormatted("create estate not allowed from restricted console");
            }
            else if (args[0] == "help" || args.Count < 4)
            {
                io.Write("create estate <estatename> <estateid> parameters...\n\n" +
                         "Parameters:\n" +
                         "owner <uui>|<uuid>|<firstname>.<lastname>\n" +
                         "parentestateid <parentestateid>\n" +
                         "pricepermeter <value>\n" +
                         "billablefactor <factor>\n" +
                         "abuseemail <email>");
            }
            else if (!uint.TryParse(args[3], out estateID))
            {
                io.Write("Estate ID is not a number.");
            }
            else if (m_EstateService.ContainsKey(estateID))
            {
                io.WriteFormatted("Estate with id {0} already exists.", estateID);
            }
            else
            {
                estateInfo = new EstateInfo
                {
                    ID             = estateID,
                    Name           = args[2],
                    PricePerMeter  = 1,
                    BillableFactor = 1
                };
                for (int argi = 4; argi + 1 < args.Count; argi += 2)
                {
                    switch (args[argi].ToLower())
                    {
                    case "abuseemail":
                        estateInfo.AbuseEmail = args[argi + 1];
                        break;

                    case "parentestateid":
                        if (!uint.TryParse(args[argi + 1], out estateInfo.ParentEstateID))
                        {
                            io.WriteFormatted("{0} is not a number", args[argi + 1]);
                            return;
                        }
                        break;

                    case "owner":
                        if (!m_AvatarNameService.TranslateToUUI(args[argi + 1], out estateInfo.Owner))
                        {
                            io.WriteFormatted("{0} is not a valid owner.", args[argi + 1]);
                            return;
                        }
                        break;

                    case "billablefactor":
                        if (!double.TryParse(args[argi + 1], NumberStyles.Float, CultureInfo.InvariantCulture, out estateInfo.BillableFactor))
                        {
                            io.WriteFormatted("{0} is not a valid float number.", args[argi + 1]);
                            return;
                        }
                        break;

                    case "pricepermeter":
                        if (!int.TryParse(args[argi + 1], out estateInfo.PricePerMeter))
                        {
                            io.WriteFormatted("{0} is not a valid integer number.", args[argi + 1]);
                            return;
                        }
                        break;

                    default:
                        io.WriteFormatted("Parameter {0} is not valid.", args[argi]);
                        return;
                    }
                }

                try
                {
                    m_EstateService.Update(estateInfo);
                }
                catch (Exception e)
                {
                    io.WriteFormatted("Could not create estate: {0}", e.Message);
                }
            }
        }
Exemplo n.º 2
0
        public void ChangeEstateCmd(List <string> args, Common.CmdIO.TTY io, UUID limitedToScene)
        {
            EstateInfo estateInfo;
            uint       estateID;

            if (limitedToScene != UUID.Zero)
            {
                io.WriteFormatted("create region not allowed from restricted console");
            }
            else if (args[0] == "help" || args.Count < 3)
            {
                io.Write("change estate <estateid> parameters...\n\n" +
                         "Parameters:\n" +
                         "name <name>\n" +
                         "parentestateid <id>\n" +
                         "owner <uui>|<uuid>|<firstname>.<lastname>\n" +
                         "pricepermeter <value>\n" +
                         "billablefactor <factor>\n" +
                         "abuseemail <email>");
            }
            else if (!uint.TryParse(args[2], out estateID))
            {
                io.WriteFormatted("{0} is not a valid number.", args[2]);
            }
            else if (!m_EstateService.TryGetValue(estateID, out estateInfo))
            {
                io.WriteFormatted("Estate with id {0} does not exist.", estateID);
            }
            else
            {
                int  argi;
                bool changeEstateData = false;
                for (argi = 3; argi < args.Count; argi += 2)
                {
                    switch (args[argi].ToLower())
                    {
                    case "name":
                        estateInfo.Name  = args[argi + 1];
                        changeEstateData = true;
                        break;

                    case "abuseemail":
                        estateInfo.AbuseEmail = args[argi + 1];
                        changeEstateData      = true;
                        break;

                    case "parentestateid":
                        if (!uint.TryParse(args[argi + 1], out estateInfo.ParentEstateID))
                        {
                            io.WriteFormatted("{0} is not a number", args[argi + 1]);
                            return;
                        }
                        changeEstateData = true;
                        break;

                    case "owner":
                        if (!m_AvatarNameService.TranslateToUUI(args[argi + 1], out estateInfo.Owner))
                        {
                            io.WriteFormatted("{0} is not a valid owner.", args[argi + 1]);
                            return;
                        }
                        changeEstateData = true;
                        break;

                    case "billablefactor":
                        if (!double.TryParse(args[argi + 1], NumberStyles.Float, CultureInfo.InvariantCulture, out estateInfo.BillableFactor))
                        {
                            io.WriteFormatted("{0} is not a valid float number.", args[argi + 1]);
                            return;
                        }
                        changeEstateData = true;
                        break;

                    case "pricepermeter":
                        if (!int.TryParse(args[argi + 1], NumberStyles.Float, CultureInfo.InvariantCulture, out estateInfo.PricePerMeter))
                        {
                            io.WriteFormatted("{0} is not a valid integer number.", args[argi + 1]);
                            return;
                        }
                        changeEstateData = true;
                        break;

                    default:
                        io.WriteFormatted("Parameter {0} is not valid.", args[argi]);
                        return;
                    }
                }

                if (changeEstateData)
                {
                    try
                    {
                        m_EstateService.Update(estateInfo);
                    }
                    catch (Exception e)
                    {
                        io.WriteFormatted("Could not change estate parameters: {0}", e.Message);
                    }

                    /* trigger estate data update */
                    foreach (UUID regionid in m_EstateService.RegionMap[estateInfo.ID])
                    {
                        SceneInterface scene;
                        if (m_Scenes.TryGetValue(regionid, out scene))
                        {
                            scene.TriggerEstateUpdate();
                        }
                    }
                }
            }
        }