Esempio n. 1
0
 public void Init(AreaConfig Config)
 {
     _distanceFromPlayer = Config.DistanceFromPlayerBeforeMovePart;
     SizeRoadPart        = Config.SizeRoadPart;
     _offsetRoad         = new Vector3(0f, 0f, Config.SizeRoadPart);
     _roadPartLength     = Config.RoadPartLength;
     InitRoad();
 }
Esempio n. 2
0
        public void AddPermissionArea(int x1, int y1, int z1, int x2, int y2, int z2, int permissionLevel)
        {
            AreaConfig area = new AreaConfig();

            area.Level  = permissionLevel;
            area.Coords = string.Format("{0},{1},{2},{3},{4},{5}", x1, y1, z1, x2, y2, z2);
            server.config.Areas.Add(area);
            server.configNeedsSaving = true;
        }
Esempio n. 3
0
    public static List <AreaConfig> getDefaultAreas()
    {
        List <AreaConfig> defaultAreas = new List <AreaConfig>();

        AreaConfig publicArea = new AreaConfig();

        publicArea.Id     = 1;
        publicArea.Coords = "0,0,1,9984,5000,128";
        publicArea.PermittedGroups.Add("Guest");
        defaultAreas.Add(publicArea);
        AreaConfig protectedArea = new AreaConfig();

        protectedArea.Id     = 2;
        protectedArea.Coords = "0,0,1,9984,9984,128";
        protectedArea.PermittedGroups.Add("Builder");
        protectedArea.PermittedGroups.Add("Moderator");
        protectedArea.PermittedGroups.Add("Admin");
        defaultAreas.Add(protectedArea);

        return(defaultAreas);
    }
Esempio n. 4
0
    public bool AreaAdd(int sourceClientId, int id, string coords, string[] permittedGroups, string[] permittedUsers, int? level)
    {
        if (!PlayerHasPrivilege(sourceClientId, ServerClientMisc.Privilege.area_add))
        {
            SendMessage(sourceClientId, string.Format(language.Get("Server_CommandInsufficientPrivileges"), colorError));
            return false;
        }

        if (config.Areas.Find(v => v.Id == id) != null)
        {
            SendMessage(sourceClientId, string.Format(language.Get("Server_CommandAreaAddIdInUse"), colorError));
            return false;
        }

        AreaConfig newArea = new AreaConfig() { Id = id, Coords = coords };
        if (permittedGroups != null)
        {
            for (int i = 0; i < permittedGroups.Length; i++)
            {
                newArea.PermittedGroups.Add(permittedGroups[i]);
            }
        }
        if (permittedUsers != null)
        {
            for (int i = 0; i < permittedUsers.Length; i++)
            {
                newArea.PermittedUsers.Add(permittedUsers[i]);
            }
        }
        if (level != null)
        {
            newArea.Level = level;
        }

        config.Areas.Add(newArea);
        configNeedsSaving = true;
        SendMessage(sourceClientId, string.Format(language.Get("Server_CommandAreaAddSuccess"), colorSuccess, newArea.ToString()));
        ServerEventLog(string.Format("{0} adds area: {1}.", GetClient(sourceClientId), newArea.ToString()));
        return true;
    }
Esempio n. 5
0
 public void AddPermissionArea(int x1, int y1, int z1, int x2, int y2, int z2, int permissionLevel)
 {
     AreaConfig area = new AreaConfig();
     area.Level = permissionLevel;
     area.Coords = string.Format("{0},{1},{2},{3},{4},{5}", x1, y1, z1, x2, y2, z2);
     server.config.Areas.Add(area);
     server.configNeedsSaving = true;
 }
Esempio n. 6
0
    public static List<AreaConfig> getDefaultAreas()
    {
        List<AreaConfig> defaultAreas = new List<AreaConfig>();

        AreaConfig publicArea = new AreaConfig();
        publicArea.Id = 1;
        publicArea.Coords = "0,0,1,9984,5000,128";
        publicArea.PermittedGroups.Add("Guest");
        defaultAreas.Add(publicArea);
        AreaConfig protectedArea = new AreaConfig();
        protectedArea.Id = 2;
        protectedArea.Coords = "0,0,1,9984,9984,128";
        protectedArea.PermittedGroups.Add("Builder");
        protectedArea.PermittedGroups.Add("Moderator");
        protectedArea.PermittedGroups.Add("Admin");
        defaultAreas.Add(protectedArea);

        return defaultAreas;
    }
Esempio n. 7
0
        internal static bool Handle(Player p, Predicate <Player> selector, string opt, string value,
                                    AreaConfig cfg, string area)
        {
            Level lvl = p.level;

            // using if else instead of switch here reduces IL by about 200 bytes
            if (opt == "sky")
            {
                LevelEnv.SetColor(p, value, area, "sky color", ref cfg.SkyColor);
                LevelEnv.UpdateColor(selector, 0, cfg.SkyColor);
            }
            else if (opt == "cloud" || opt == "clouds")
            {
                LevelEnv.SetColor(p, value, area, "cloud color", ref cfg.CloudColor);
                LevelEnv.UpdateColor(selector, 1, cfg.CloudColor);
            }
            else if (opt == "fog")
            {
                LevelEnv.SetColor(p, value, area, "fog color", ref cfg.FogColor);
                LevelEnv.UpdateColor(selector, 2, cfg.FogColor);
            }
            else if (opt == "dark" || opt == "shadow")
            {
                LevelEnv.SetColor(p, value, area, "shadow color", ref cfg.ShadowColor);
                LevelEnv.UpdateColor(selector, 3, cfg.ShadowColor);
            }
            else if (opt == "sun" || opt == "light" || opt == "sunlight")
            {
                LevelEnv.SetColor(p, value, area, "sun color", ref cfg.LightColor);
                LevelEnv.UpdateColor(selector, 4, cfg.LightColor);
            }
            else if (opt == "weather")
            {
                LevelEnv.SetWeather(p, value, area, ref cfg.Weather);
                LevelEnv.UpdateWeather(selector, (byte)cfg.Weather);
            }
            else if (opt == "cloudheight" || opt == "cloudsheight")
            {
                LevelEnv.SetShort(p, value, area, "clouds height",
                                  lvl.Height + 2, ref cfg.CloudsHeight);
                LevelEnv.UpdateAppearance(selector, EnvProp.CloudsLevel, cfg.CloudsHeight);
            }
            else if (opt == "waterlevel" || opt == "edgelevel" || opt == "level")
            {
                LevelEnv.SetShort(p, value, area, "water level",
                                  lvl.Height / 2, ref cfg.EdgeLevel);
                LevelEnv.UpdateAppearance(selector, EnvProp.EdgeLevel, cfg.EdgeLevel);
            }
            else if (opt == "bedrockoffset" || opt == "sidesoffset" || opt == "sideoffset")
            {
                LevelEnv.SetShort(p, value, area, "bedrock offset",
                                  -2, ref cfg.SidesOffset);
                LevelEnv.UpdateAppearance(selector, EnvProp.SidesOffset, cfg.SidesOffset);
            }
            else if (opt == "maxfogdistance" || opt == "maxfog" || opt == "fogdistance")
            {
                LevelEnv.SetShort(p, value, area, "max fog distance",
                                  0, ref cfg.MaxFogDistance);
                LevelEnv.UpdateAppearance(selector, EnvProp.MaxFog, cfg.MaxFogDistance);
            }
            else if (opt == "cloudspeed" || opt == "cloudsspeed")
            {
                LevelEnv.SetFloat(p, value, area, 256, "clouds speed",
                                  256, ref cfg.CloudsSpeed, -0xFFFFFF, 0xFFFFFF);
                LevelEnv.UpdateAppearance(selector, EnvProp.CloudsSpeed, cfg.CloudsSpeed);
            }
            else if (opt == "weatherspeed")
            {
                LevelEnv.SetFloat(p, value, area, 256, "weather speed",
                                  256, ref cfg.WeatherSpeed, -0xFFFFFF, 0xFFFFFF);
                LevelEnv.UpdateAppearance(selector, EnvProp.WeatherSpeed, cfg.WeatherSpeed);
            }
            else if (opt == "weatherfade")
            {
                LevelEnv.SetFloat(p, value, area, 128, "weather fade rate",
                                  128, ref cfg.WeatherFade, 0, 255);
                LevelEnv.UpdateAppearance(selector, EnvProp.WeatherFade, cfg.WeatherFade);
            }
            else if (opt == "horizon" || opt == "edge" || opt == "water")
            {
                LevelEnv.SetBlock(p, value, area, "edge block", Block.Water, ref cfg.HorizonBlock);
                LevelEnv.UpdateAppearance(selector, EnvProp.EdgeBlock, cfg.HorizonBlock);
            }
            else if (opt == "side" || opt == "border" || opt == "bedrock")
            {
                LevelEnv.SetBlock(p, value, area, "sides block", Block.Bedrock, ref cfg.EdgeBlock);
                LevelEnv.UpdateAppearance(selector, EnvProp.SidesBlock, cfg.EdgeBlock);
            }
            else if (opt == "expfog")
            {
                LevelEnv.SetBool(p, value, area, "exp fog", 0, ref cfg.ExpFog);
                LevelEnv.UpdateAppearance(selector, EnvProp.ExpFog, cfg.ExpFog);
            }
            else if (opt == "skyboxhorspeed" || opt == "skyboxhor")
            {
                LevelEnv.SetFloat(p, value, area, 1024, "skybox horizontal speed",
                                  0, ref cfg.SkyboxHorSpeed, -0xFFFFFF, 0xFFFFFF);
                LevelEnv.UpdateAppearance(selector, EnvProp.SkyboxHorSpeed, cfg.SkyboxHorSpeed);
            }
            else if (opt == "skyboxverspeed" || opt == "skyboxver")
            {
                LevelEnv.SetFloat(p, value, area, 1024, "skybox vertical speed",
                                  0, ref cfg.SkyboxVerSpeed, -0xFFFFFF, 0xFFFFFF);
                LevelEnv.UpdateAppearance(selector, EnvProp.SkyboxVerSpeed, cfg.SkyboxVerSpeed);
            }
            else
            {
                return(false);
            }
            Level.SaveSettings(lvl);
            return(true);
        }
Esempio n. 8
0
        private static void load_areas(ControllerResolver resolver)
        {
            List <string> privateBins = new List <string>()
            {
                "bin"
            };

            MethodInfo m = null, funsion = null;

            // check if i am running under mono at runtime. bad coding style
            bool isMono = Type.GetType("Mono.Runtime") != null;

            if (!isMono)
            {
                m       = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
                funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
            }

            foreach (var dir in Directory.GetDirectories(ServerUtil.MapPath("~")))
            {
                string areaName = Path.GetFileName(dir).ToLowerInvariant();

                if (IGNORES_DIR.Contains(areaName))
                {
                    continue;
                }

                // check if the dir is a valid area
                string configfile = Path.Combine(dir, "area.config");
                if (!File.Exists(configfile))
                {
                    continue;
                }

                // load area config
                XmlNode node = null;

                using (XmlTransformableDocument x = new XmlTransformableDocument())
                {
                    x.Load(configfile);

                    string localfile = Path.Combine(dir, "area.local.config");

                    if (File.Exists(localfile))
                    {
                        using (XmlTransformation t = new XmlTransformation(localfile))
                        {
                            t.Apply(x);
                        }
                    }

                    node = x.DocumentElement;
                }

                AreaConfig config = AreaConfig.GetConfig(node);
                config.VP      = "/" + areaName;
                config.AreaKey = areaName;

                Areas.Add(@"/" + areaName, config);

                // load assemblies
                string bindir = Path.Combine(dir, "bin");

                if (Directory.Exists(bindir))
                {
                    privateBins.Add(bindir);

                    if (!isMono)
                    {
                        // hack !!!
                        if (m != null && funsion != null)
                        {
                            m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privateBins.Join(";") });
                            m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "SHADOW_COPY_DIRS", privateBins.Join(";") });
                        }
                    }

                    List <Assembly> assemblies = new List <Assembly>();

                    foreach (var item in Directory.GetFiles(bindir, "*.dll", SearchOption.TopDirectoryOnly))
                    {
                        try
                        {
                            if (isMono)
                            {
                                assemblies.Add(Assembly.Load(File.ReadAllBytes(item)));
                            }
                            else
                            {
                                assemblies.Add(AppDomain.CurrentDomain.Load(Path.GetFileNameWithoutExtension(item)));
                            }
                        }
                        catch (BadImageFormatException)
                        {
                        }
                    }

                    Dictionary <string, Type> types = new Dictionary <string, Type>();
                    foreach (var asm in assemblies)
                    {
                        foreach (var item in resolver.GetsControllerFromAssembly(asm))
                        {
                            types[item.Key] = item.Value;
                        }
                    }
                    resolver.SetSiteControllers(areaName, types);
                }
            }
        }