public CaravanServerConnectorClientSide()
        {
            var worldRepository = new WorldRepositoryClientSide();

            var newInstanceFactory = new NewInstanceFactoryClientSide(worldRepository);

            var processorsProvider = new ProcessorsProvider(newInstanceFactory);
            var newWorldGenerator  = new NewWorldGenerator(newInstanceFactory, worldRepository);

            CaravanServer = new CaravanServerClientSide(processorsProvider, newInstanceFactory, newWorldGenerator, worldRepository);
        }
        public IProcessWorldResponse GetNewWorld(IGetNewWorldRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (string.IsNullOrWhiteSpace(request.UserGuid))
            {
                throw new Exception("UserGuid is empty");
            }

            var generated = NewWorldGenerator.GenerateWorld(request.UserGuid);


            var result = new ProcessWorldResponseClientSideEntity();

            result.Player = generated.Item2;
            result.World  = generated.Item1;

            return(result);
        }
Beispiel #3
0
        public void Start()
        {
            Server server = new Server();

            server.LoadConfig();
            var map = new ManicDiggerServer.ServerMap();

            map.d_CurrentTime = server;
            map.chunksize     = 32;

            // TODO: make it possible to change the world generator at run-time!
            var generator = new NewWorldGenerator();

            generator.ChunkSize = map.chunksize;
            // apply chunk size to generator
            map.d_Generator  = generator;
            server.chunksize = 32;

            map.d_Heightmap = new InfiniteMapChunked2d()
            {
                chunksize = server.chunksize, d_Map = map
            };
            map.Reset(server.config.MapSizeX, server.config.MapSizeY, server.config.MapSizeZ);
            server.d_Map       = map;
            server.d_Generator = generator;
            string[] datapaths       = new[] { Path.Combine(Path.Combine(Path.Combine("..", ".."), ".."), "data"), "data" };
            string[] datapathspublic = new[] { Path.Combine(datapaths[0], "public"), Path.Combine(datapaths[1], "public") };
            server.PublicDataPaths = datapathspublic;
            var getfile = new GetFileStream(datapaths);
            var data    = new GameDataCsv();

            data.Load(MyStream.ReadAllLines(getfile.GetFile("blocks.csv")),
                      MyStream.ReadAllLines(getfile.GetFile("defaultmaterialslots.csv")),
                      MyStream.ReadAllLines(getfile.GetFile("lightlevels.csv")));
            var craftingrecipes = new CraftingRecipes();

            craftingrecipes.data = data;
            craftingrecipes.Load(MyStream.ReadAllLines(getfile.GetFile("craftingrecipes.csv")));
            server.d_CraftingRecipes   = craftingrecipes;
            server.d_Data              = data;
            server.d_CraftingTableTool = new CraftingTableTool()
            {
                d_Map = map
            };
            server.LocalConnectionsOnly = !Public;
            server.d_GetFile            = getfile;
            var networkcompression = new CompressionGzip();
            var diskcompression    = new CompressionGzip();
            var chunkdb            = new ChunkDbCompressed()
            {
                d_ChunkDb = new ChunkDbSqlite(), d_Compression = diskcompression
            };

            server.d_ChunkDb            = chunkdb;
            map.d_ChunkDb               = chunkdb;
            server.d_NetworkCompression = networkcompression;
            map.d_Data         = server.d_Data;
            server.d_DataItems = new GameDataItemsBlocks()
            {
                d_Data = data
            };
            server.d_Water = new WaterFinite()
            {
                data = server.d_Data
            };
            server.d_GroundPhysics = new GroundPhysics()
            {
                data = server.d_Data
            };
            server.SaveFilenameWithoutExtension = SaveFilenameWithoutExtension;
            if (Socket == null)
            {
                server.d_MainSocket = new SocketNet()
                {
                    d_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                };
            }
            else
            {
                server.d_MainSocket = Socket;
            }
            server.d_Heartbeat = new ServerHeartbeat();
            server.Start();
            if ((Public) && (server.config.Public))
            {
                new Thread((a) => { for (; ;)
                                    {
                                        server.SendHeartbeat(); Thread.Sleep(TimeSpan.FromMinutes(1));
                                    }
                           }).Start();
            }
            for (; ;)
            {
                server.Process();
                Thread.Sleep(1);
                if (d_Exit != null && d_Exit.exit)
                {
                    return;
                }
            }
        }
Beispiel #4
0
        public void Start()
        {
            Server server = new Server();
            server.LoadConfig();
            var map = new ManicDiggerServer.ServerMap();
            map.d_CurrentTime = server;
            map.chunksize = 32;

            // TODO: make it possible to change the world generator at run-time!
            var generator = new NewWorldGenerator();
            generator.ChunkSize = map.chunksize;
            // apply chunk size to generator
            map.d_Generator = generator;
            server.chunksize = 32;

            map.d_Heightmap = new InfiniteMapChunked2d() { chunksize = server.chunksize, d_Map = map };
            map.Reset(server.config.MapSizeX, server.config.MapSizeY, server.config.MapSizeZ);
            server.d_Map = map;
            server.d_Generator = generator;
            string[] datapaths = new[] { Path.Combine(Path.Combine(Path.Combine("..", ".."), ".."), "data"), "data" };
            string[] datapathspublic = new[] { Path.Combine(datapaths[0], "public"), Path.Combine(datapaths[1], "public") };
            server.PublicDataPaths = datapathspublic;
            var getfile = new GetFileStream(datapaths);
            var data = new GameDataCsv();
            data.Load(MyStream.ReadAllLines(getfile.GetFile("blocks.csv")),
                MyStream.ReadAllLines(getfile.GetFile("defaultmaterialslots.csv")),
                MyStream.ReadAllLines(getfile.GetFile("lightlevels.csv")));
            var craftingrecipes = new CraftingRecipes();
            craftingrecipes.data = data;
            craftingrecipes.Load(MyStream.ReadAllLines(getfile.GetFile("craftingrecipes.csv")));
            server.d_CraftingRecipes = craftingrecipes;
            server.d_Data = data;
            server.d_CraftingTableTool = new CraftingTableTool() { d_Map = map };
            server.LocalConnectionsOnly = !Public;
            server.d_GetFile = getfile;
            var networkcompression = new CompressionGzip();
            var diskcompression = new CompressionGzip();
            var chunkdb = new ChunkDbCompressed() { d_ChunkDb = new ChunkDbSqlite(), d_Compression = diskcompression };
            server.d_ChunkDb = chunkdb;
            map.d_ChunkDb = chunkdb;
            server.d_NetworkCompression = networkcompression;
            map.d_Data = server.d_Data;
            server.d_DataItems = new GameDataItemsBlocks() { d_Data = data };
            server.d_Water = new WaterFinite() { data = server.d_Data };
            server.d_GroundPhysics = new GroundPhysics() { data = server.d_Data };
            server.SaveFilenameWithoutExtension = SaveFilenameWithoutExtension;
            if (Socket == null)
            {
                server.d_MainSocket = new SocketNet()
                {
                    d_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                };
            }
            else
            {
                server.d_MainSocket = Socket;
            }
            server.d_Heartbeat = new ServerHeartbeat();
            server.Start();
            if ((Public) && (server.config.Public))
            {
                new Thread((a) => { for (; ; ) { server.SendHeartbeat(); Thread.Sleep(TimeSpan.FromMinutes(1)); } }).Start();
            }
            for (; ; )
            {
                server.Process();
                Thread.Sleep(1);
                if (d_Exit != null && d_Exit.exit) { return; }
            }
        }
Beispiel #5
0
 public Instances(ICrvServiceContext context, INewInstanceFactory newInstanceFactory)
 {
     WorldRepository    = new WorldRepositoryEntity(context);
     ProcessorsProvider = new ProcessorsProvider(newInstanceFactory);
     NewWorldGenerator  = new NewWorldGenerator(newInstanceFactory, WorldRepository);
 }