Ejemplo n.º 1
0
    public Dictionary <Xyz, ushort[]> GetChunksFromDatabase(List <Xyz> chunks, string filename)
    {
        if (chunks == null)
        {
            return(null);
        }

        if (!GameStorePath.IsValidName(filename))
        {
            Console.WriteLine("Invalid backup filename: " + filename);
            return(null);
        }
        if (!Directory.Exists(GameStorePath.gamepathbackup))
        {
            Directory.CreateDirectory(GameStorePath.gamepathbackup);
        }
        string finalFilename = Path.Combine(GameStorePath.gamepathbackup, filename + MapManipulator.BinSaveExtension);

        Dictionary <Xyz, ushort[]> deserializedChunks = new Dictionary <Xyz, ushort[]>();
        Dictionary <Xyz, byte[]>   serializedChunks   = ChunkDb.GetChunksFromFile(d_ChunkDb, chunks, finalFilename);

        foreach (var k in serializedChunks)
        {
            ServerChunk c = null;
            if (k.Value != null)
            {
                c = DeserializeChunk(k.Value);
            }
            deserializedChunks.Add(k.Key, c.data);
        }
        return(deserializedChunks);
    }