Exemple #1
0
 public QuitCommand(Server tserver)
 {
     TheServer = tserver;
     Name = "quit";
     Description = "Closes the server entirely.";
     Arguments = "";
 }
Exemple #2
0
 public MeminfoCommand(Server tserver)
 {
     TheServer = tserver;
     Name = "meminfo";
     Description = "Shows memory usage information.";
     Arguments = "";
 }
Exemple #3
0
 public static PlayerTag For(Server tserver, string pname)
 {
     long pid;
     if (long.TryParse(pname, out pid))
     {
         foreach (PlayerEntity player in tserver.Players)
         {
             if (player.EID == pid)
             {
                 return new PlayerTag(player);
             }
         }
     }
     else
     {
         pname = pname.ToLowerFast();
         foreach (PlayerEntity player in tserver.Players)
         {
             if (player.Name.ToLowerFast() == pname)
             {
                 return new PlayerTag(player);
             }
         }
     }
     return null;
 }
 public void Init(Server tserver)
 {
     // TODO: v0.1.0 texture config update!
     MaterialImages = new MaterialImage[MaterialHelpers.Textures.Length];
     for (int i = 0; i < MaterialImages.Length; i++)
     {
         string tex = MaterialHelpers.Textures[i];
         string actualtexture = "textures/" + tex.Before(",").Before("&").Before("$").Before("@")+ ".png";
         try
         {
             Bitmap bmp1 = new Bitmap(tserver.Files.ReadToStream(actualtexture));
             Bitmap bmp2 = new Bitmap(bmp1, new Size(TexWidth, TexWidth));
             bmp1.Dispose();
             MaterialImage img = new MaterialImage();
             img.Colors = new Color[TexWidth, TexWidth];
             for (int x = 0; x < TexWidth; x++)
             {
                 for (int y = 0; y < TexWidth; y++)
                 {
                     img.Colors[x, y] = bmp2.GetPixel(x, y);
                 }
             }
             MaterialImages[i] = img;
             bmp2.Dispose();
         }
         catch (Exception ex)
         {
             Utilities.CheckException(ex);
             SysConsole.Output("loading texture for " + i + ": '" + actualtexture + "'", ex);
         }
     }
     SysConsole.Output(OutputType.INIT, "Loaded " + MaterialImages.Length + " textures!");
 }
Exemple #5
0
 public KickCommand(Server tserver)
 {
     TheServer = tserver;
     Name = "kick";
     Description = "Kicks player(s) from the server.";
     Arguments = "<player list> [message]";
 }
Exemple #6
0
 public ItemStack(byte[] data, Server tserver)
 {
     TheServer = tserver;
     DataStream ds = new DataStream(data);
     DataReader dr = new DataReader(ds);
     int attribs = dr.ReadInt();
     for (int i = 0; i < attribs; i++)
     {
         string cattrib = dr.ReadFullString();
         byte b = dr.ReadByte();
         if (b == 0)
         {
             Attributes.Add(cattrib, new IntegerTag(dr.ReadInt64()));
         }
         else if (b == 1)
         {
             Attributes.Add(cattrib, new NumberTag(dr.ReadDouble()));
         }
         else if (b == 2)
         {
             Attributes.Add(cattrib, new BooleanTag(dr.ReadByte() == 1));
         }
         else
         {
             Attributes.Add(cattrib, new TextTag(dr.ReadFullString()));
         }
     }
     Load(dr, (b) => new ItemStack(b, tserver));
 }
Exemple #7
0
 public GiveCommand(Server tserver)
 {
     TheServer = tserver;
     Name = "give";
     Description = "Gives an item to a player.";
     Arguments = "<players> <items>";
 }
Exemple #8
0
 public Connection(Server tserver, Socket psocket)
 {
     TheServer = tserver;
     PrimarySocket = psocket;
     PrimarySocket.Blocking = true;// false;
     recd = new byte[MAX];
 }
Exemple #9
0
 public SayCommand(Server tserver)
 {
     TheServer = tserver;
     Name = "say";
     Description = "Says a message to all players on the server.";
     Arguments = "<message>";
 }
Exemple #10
0
 public AddrecipeCommand(Server tserver)
 {
     TheServer = tserver;
     Name = "addrecipe";
     Description = "Adds a recipe to be crafted.";
     Arguments = "<mode> <input item> ...";
     MinimumArguments = 1;
     MaximumArguments = -1;
 }
Exemple #11
0
        /// <summary>
        /// Prepares the command system, registering all base commands.
        /// </summary>
        public void Init(Outputter _output, Server tserver)
        {
            // General Init
            TheServer = tserver;
            CommandSystem = new Commands();
            Output = _output;
            CommandSystem.Output = Output;
            CommandSystem.Init();

            // Common Commands
            CommandSystem.RegisterCommand(new MeminfoCommand(TheServer));
            CommandSystem.RegisterCommand(new QuitCommand(TheServer));
            CommandSystem.RegisterCommand(new SayCommand(TheServer));

            // File Commands
            CommandSystem.RegisterCommand(new AddpathCommand(TheServer));

            // World Commands
            // ...

            // Item Commands
            CommandSystem.RegisterCommand(new AddrecipeCommand(TheServer));
            CommandSystem.RegisterCommand(new GiveCommand(TheServer));

            // Player Management Commands
            CommandSystem.RegisterCommand(new KickCommand(TheServer));

            // Tag Bases
            CommandSystem.TagSystem.Register(new ArrowEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new BlockGroupEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new BlockItemEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new BulletEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new ColorTagBase());
            CommandSystem.TagSystem.Register(new EntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new GlowstickEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new GrenadeEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new ItemEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new ItemTagBase(TheServer));
            CommandSystem.TagSystem.Register(new LivingEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new LocationTagBase(TheServer));
            CommandSystem.TagSystem.Register(new MaterialTagBase());
            CommandSystem.TagSystem.Register(new ModelEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new PhysicsEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new PlayerTagBase(TheServer));
            CommandSystem.TagSystem.Register(new PrimitiveEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new RecipeResultTagBase(TheServer));
            CommandSystem.TagSystem.Register(new RecipeTagBase(TheServer));
            CommandSystem.TagSystem.Register(new WorldTagBase(TheServer));
            CommandSystem.TagSystem.Register(new ServerTagBase(TheServer));
            CommandSystem.TagSystem.Register(new SmokeGrenadeEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new VehicleEntityTagBase(TheServer));
            CommandSystem.TagSystem.Register(new VehiclePartEntityTagBase(TheServer));

            // Wrap up
            CommandSystem.PostInit();
        }
Exemple #12
0
 public CVarSetPacketOut(CVar var, Server tserver)
 {
     UsageType = NetUsageType.GENERAL;
     ID = ServerToClientPacket.CVAR_SET;
     DataStream ds = new DataStream();
     DataWriter dw = new DataWriter(ds);
     dw.WriteInt(tserver.Networking.Strings.IndexForString(var.Name.ToLowerFast()));
     dw.WriteFullString(var.Value);
     Data = ds.ToArray();
 }
 public PlaySoundPacketOut(Server tserver, string sound, double vol, double pitch, Location pos)
 {
     UsageType = NetUsageType.EFFECTS;
     ID = ServerToClientPacket.PLAY_SOUND;
     Data = new byte[4 + 4 + 4 + 24];
     Utilities.IntToBytes(tserver.Networking.Strings.IndexForString(sound)).CopyTo(Data, 0);
     Utilities.FloatToBytes((float)vol).CopyTo(Data, 4);
     Utilities.FloatToBytes((float)pitch).CopyTo(Data, 4 + 4);
     pos.ToDoubleBytes().CopyTo(Data, 4 + 4 + 4);
 }
Exemple #14
0
 public ItemStack(string name, string secondary_name, Server tserver, int count, string tex, string display, string descrip,
     System.Drawing.Color color, string model, bool bound, int datum, params KeyValuePair<string, TemplateObject>[] attrs)
 {
     TheServer = tserver;
     Load(name, secondary_name, count, tex, display, descrip, color, model, datum);
     IsBound = bound;
     if (attrs != null)
     {
         foreach (KeyValuePair<string, TemplateObject> attr in attrs)
         {
             Attributes.Add(attr.Key, attr.Value);
         }
     }
 }
Exemple #15
0
 public static RecipeTag For(Server tserver, TagData data, TemplateObject input)
 {
     if (input is RecipeTag)
     {
         return (RecipeTag)input;
     }
     int ind = (int)IntegerTag.For(data, input).Internal;
     if (ind < 0 || ind >= tserver.Recipes.Recipes.Count)
     {
         data.Error("Invalid recipe input!");
         return null;
     }
     return new RecipeTag(tserver.Recipes.Recipes[ind]);
 }
Exemple #16
0
 public static RecipeResultTag For(Server tserver, TagData data, TemplateObject input)
 {
     if (input is RecipeResultTag)
     {
         return (RecipeResultTag)input;
     }
     ListTag list = ListTag.For(input);
     RecipeTag recipe = RecipeTag.For(tserver, data, list.ListEntries[0]);
     List<ItemStack> used = new List<ItemStack>();
     for (int i = 1; i < list.ListEntries.Count; i++)
     {
         used.Add(ItemTag.For(tserver, list.ListEntries[i]).Internal);
     }
     return new RecipeResultTag(new RecipeResult() { Recipe = recipe.Internal, UsedInput = used });
 }
Exemple #17
0
 public static ItemTag For(Server tserver, string input)
 {
     if (input.Contains('['))
     {
         return new ItemTag(ItemStack.FromString(tserver, input));
     }
     else
     {
         ItemStack its = tserver.Items.GetItem(input);
         if (its == null)
         {
             return null;
         }
         return new ItemTag(its);
     }
 }
Exemple #18
0
        /// <summary>
        /// Prepares the CVar system, generating default CVars.
        /// </summary>
        public void Init(Server tserver, Outputter output)
        {
            system = new CVarSystem(output);

            // System CVars
            s_filepath = Register("s_filepath", tserver.Files.BaseDirectory, CVarFlag.Textual | CVarFlag.ReadOnly, "The current system environment filepath (The directory of /data)."); // TODO: Scrap this! Tags!
            s_debug = Register("s_debug", "true", CVarFlag.Boolean, "Whether to output debug information.");
            // Game CVars
            //g_timescale = Register("g_timescale", "1", CVarFlag.Numeric, "The current game time scaling value.");
            g_fps = Register("g_fps", "30", CVarFlag.Numeric, "What framerate to use.");
            g_maxheight = Register("g_maxheight", "5000", CVarFlag.Numeric, "What the highest possible Z coordinate should be (for building)."); // TODO: Also per-world?
            g_minheight = Register("g_minheight", "-5000", CVarFlag.Numeric, "What the lowest possible Z coordinate should be (for building)."); // TODO: Also per-world?
            g_maxdist = Register("g_maxdist", "50000", CVarFlag.Numeric, "How far on the X or Y axis a player may travel from the origin."); // TODO: Also per-world?
            g_renderblocks = Register("g_renderblocks", "false", CVarFlag.Boolean, "Whether to render blocks for mapping purposes."); // TODO: Also per-world?
            // Network CVars
            n_verifyip = Register("n_verifyip", "true", CVarFlag.Boolean, "Whether to verify connecting users' IP addresses with the global server. Disabling this may help allow LAN connections.");
            n_rendersides = Register("n_rendersides", "false", CVarFlag.Boolean, "Whether to render the side-on map view for the linked webpage."); // TODO: Also per-world?
            n_chunkspertick = Register("n_chunkspertick", "15", CVarFlag.Numeric, "How many chunks can be sent in a single server tick, per player.");
            n_online = Register("n_online", "true", CVarFlag.Boolean, "Whether the server with authorize connections against the global server. Disable this if you want to play singleplayer without a live internet connection.");
            // Text CVars
            t_translateurls = Register("t_translateurls", "true", CVarFlag.Boolean, "Whether to automatically translate URLs posted in chat.");
            t_blockurls = Register("t_blockurls", "false", CVarFlag.Boolean, "Whether to block URLs as input to chat.");
            t_blockcolors = Register("t_blockcolors", "false", CVarFlag.Boolean, "Whether to block colors as input to chat.");
        }
 public ModelEntityTagBase(Server tserver)
 {
     Name = "model_entity";
     TheServer = tserver;
 }
Exemple #20
0
 /// <summary>
 /// Starts up a new server.
 /// </summary>
 public static void Init(string[] args)
 {
     Central = new Server(args.Length > 0 ? Utilities.StringToInt(args[0]) : 28010);
     Central.StartUp(() =>
     {
         if (args.Length > 1)
         {
             StringBuilder sb = new StringBuilder();
             for (int i = 1; i < args.Length; i++)
             {
                 sb.Append(args[i]);
             }
             Central.Commands.ExecuteCommands(sb.ToString());
         }
     });
 }
Exemple #21
0
 public PluginLoader(Server tserver)
 {
     TheServer = tserver;
 }
Exemple #22
0
 public NetStringManager(Server tserver)
 {
     TheServer = tserver;
 }
Exemple #23
0
 public PlayerTagBase(Server tserver)
 {
     Name = "player";
     TheServer = tserver;
 }
Exemple #24
0
 public ItemRegistry(Server tserver)
 {
     TheServer = tserver;
     Air = new ItemStack("air", TheServer, 0, "clear", "Air", "Empty air", System.Drawing.Color.White, "none", true, 0);
     BaseItems.Add("air", Air);
 }
Exemple #25
0
 public static PlayerTag For(Server tserver, TemplateObject obj)
 {
     return (obj is PlayerTag) ? (PlayerTag)obj : For(tserver, obj.ToString());
 }
Exemple #26
0
 // <--[tagbase]
 // @Base location[<LocationTag>]
 // @Group Mathematics
 // @ReturnType LocationTag
 // @Returns the location at the corresponding coordinates.
 // -->
 public LocationTagBase(Server tserver)
 {
     TheServer = tserver;
     Name = "location";
 }
Exemple #27
0
 public Entity(Region tregion, bool tickme)
 {
     TheRegion = tregion;
     TheServer = tregion.TheServer;
     Ticks = tickme;
 }
Exemple #28
0
 public WorldTagBase(Server tserver)
 {
     Name = "world";
     TheServer = tserver;
 }
Exemple #29
0
 public static LocationTag For(Server tserver, TagData dat, string input)
 {
     string[] spl = input.Split(',');
     Location coord;
     if (spl.Length < 3)
     {
         dat.Error("Invalid LocationTag input!");
     }
     coord.X = NumberTag.For(dat, spl[0]).Internal;
     coord.Y = NumberTag.For(dat, spl[1]).Internal;
     coord.Z = NumberTag.For(dat, spl[2]).Internal;
     World w = null;
     if (spl.Length >= 4)
     {
         w = tserver.GetWorld(spl[3]);
         if (w == null)
         {
             dat.Error("Invalid world for LocationTag input!");
         }
     }
     return new LocationTag(coord, w);
 }
 public GlowstickEntityTagBase(Server tserver)
 {
     Name = "glowstick_entity";
     TheServer = tserver;
 }