private static void DOWNLOAD_MAP_REPLY(byte[] bytes)
    {
        DownloadMapReply input = DownloadMapReply.Parser.ParseFrom(bytes);

        if (!input.Ret)
        {
            string msg = "下载地图失败!";
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Error);
            GameRoomManager.Instance.Log("MSG: DOWNLOAD_MAP_REPLY Error - " + msg);
            return;
        }

        if (input.PackageIndex == 0)
        {// 第一条此类消息
            mapDataBuffers.Clear();
            GameRoomManager.Instance.Log($"MSG: DOWNLOAD_MAP_REPLY - 开始下载地图!地图名:{input.RoomName}");
        }
        mapDataBuffers.Add(input.MapData.ToByteArray());

        bool ret = false;

        if (input.IsLastPackage)
        {// 最后一条此类消息了
            int totalSize = 0;
            foreach (var package in mapDataBuffers)
            {
                totalSize += package.Length;
            }
            // 同时确保文件名的唯一性和可读性
            string mapName = $"{input.RoomName}_{input.RoomId}";

            // 把服务器传过来的地图数据写入本地文件
            BinaryWriter writer = GameRoomManager.Instance.HexmapHelper.BeginSaveBuffer(mapName);
            if (writer == null)
            {
                return;
            }

            foreach (var package in mapDataBuffers)
            {
                GameRoomManager.Instance.HexmapHelper.SaveBuffer(writer, package);
            }

            GameRoomManager.Instance.HexmapHelper.EndSaveBuffer(ref writer);
            GameRoomManager.Instance.Log($"MSG: DOWNLOAD_MAP_REPLY - 下载地图成功!地图名:{mapName} - Total Map Size:{totalSize}");

            // 从本地文件读取地图,并显示出来
            GameRoomManager.Instance.HexmapHelper.Load(mapName);
            GameRoomManager.Instance.Log($"MSG: DOWNLOAD_MAP_REPLY - 显示地图!地图名:{mapName}");

            // 设置房间ID和名字
            GameRoomManager.Instance.RoomId   = input.RoomId;
            GameRoomManager.Instance.RoomName = input.RoomName;
            string msg = $"进入战场 - {input.RoomName}";
            GameRoomManager.Instance.Log("MSG: DOWNLOAD_MAP_REPLY OK - " + msg);
            UIManager.Instance.SystemTips(msg, PanelSystemTips.MessageType.Success);

            // 2-补充内容,获取城市信息
            DownloadCities output = new DownloadCities()
            {
                RoomId = input.RoomId,
            };
            GameRoomManager.Instance.SendMsg(ROOM.DownloadCities, output.ToByteArray());

            // 3-补充内容,获取单位信息
            DownloadActors output2 = new DownloadActors()
            {
                RoomId = input.RoomId,
            };
            GameRoomManager.Instance.SendMsg(ROOM.DownloadActors, output2.ToByteArray());

            // 4-刷新玩家身上的资源
            UpdateRes output3 = new UpdateRes()
            {
                RoomId  = input.RoomId,
                OwnerId = GameRoomManager.Instance.CurrentPlayer.TokenId,
            };
            GameRoomManager.Instance.SendMsg(ROOM.UpdateRes, output3.ToByteArray());

            // 5-刷新玩家身上的行动点
            UpdateActionPoint output4 = new UpdateActionPoint()
            {
                RoomId  = input.RoomId,
                OwnerId = GameRoomManager.Instance.CurrentPlayer.TokenId,
            };
            GameRoomManager.Instance.SendMsg(ROOM.UpdateActionPoint, output4.ToByteArray());
        }
    }
    private static void DOWNLOAD_MAP(byte[] bytes)
    {
        DownloadMap input     = DownloadMap.Parser.ParseFrom(bytes);
        string      tableName = $"MAP:{input.RoomId}";

        if (!ServerRoomManager.Instance.Redis.CSRedis.Exists(tableName))
        {
            string msg = $"Cannot find the table - {tableName}"; // Redis中没有找到地图表格
            ServerRoomManager.Instance.Log("MSG:DOWNLOAD_MAP - " + msg);
            DownloadMapReply output = new DownloadMapReply()
            {
                Ret    = false,
                ErrMsg = msg,
            };
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
            return;
        }

        //////////////
        // 校验地图的RoomId是否和Redis中保存的一致
        long roomId = ServerRoomManager.Instance.Redis.CSRedis.HGet <long>(tableName, "RoomId");

        if (roomId != input.RoomId)
        {
            string msg = $"Read map data from redis failed! RoomId is not matched! RoomId from client:{input.RoomId} - RoomId from Redis:{roomId}"; // 从Redis中读取地图数据失败!roomId不匹配!传来的RoomId // Redis中保存的RoomId
            ServerRoomManager.Instance.Log("MSG:DOWNLOAD_MAP - " + msg);
            DownloadMapReply output = new DownloadMapReply()
            {
                Ret    = false,
                ErrMsg = msg,
            };
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
            return;
        }
        string roomName = ServerRoomManager.Instance.Redis.CSRedis.HGet <string>(tableName, "RoomName");

        //////////////
        // 计算这张地图是不是我自己创建的
        PlayerInfo pi = ServerRoomManager.Instance.GetPlayer(_args);

        if (pi == null)
        {
            string msg = $"Read map data from redis failed! Player is not found! MapName:{roomName} - RoomId:{roomId}"; // 从Redis中读取地图数据失败!我自己并没有在战场服务器!地图名
            ServerRoomManager.Instance.Log("MSG:DOWNLOAD_MAP - " + msg);
            DownloadMapReply output = new DownloadMapReply()
            {
                Ret    = false,
                ErrMsg = msg,
            };
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
            return;
        }
        long TokenId      = ServerRoomManager.Instance.Redis.CSRedis.HGet <long>(tableName, "Creator");
        bool IsCreateByMe = TokenId == pi.Enter.TokenId;

        //////////////
        // 其他数据
        int maxPlayerCount = ServerRoomManager.Instance.Redis.CSRedis.HGet <int>(tableName, "MaxPlayerCount");

        //////////////
        // 读取地图数据
        byte[] totalData = ServerRoomManager.Instance.Redis.CSRedis.HGet <byte[]>(tableName, "MapData");
        int    totalSize = totalData.Length;

        //////////////
        // 服务器把这份数据留起来自己用——这部分代码暂时无效
        var roomLogic = ServerRoomManager.Instance.GetRoomLogic(roomId);

        if (roomLogic == null)
        {
            string msg = ($"The Battlefield is not created or has been disposed! MapName:{roomName} - RoomId:{roomId}"); // 该战场尚未创建或者已经被销毁!地图名
            ServerRoomManager.Instance.Log("MSG:DOWNLOAD_MAP - " + msg);
            DownloadMapReply output = new DownloadMapReply()
            {
                Ret    = false,
                ErrMsg = msg,
            };
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
            return;
        }
        if (!roomLogic.SetMap(totalData))
        {
            string msg = ($"Map data is not valid, can be currupted! MapName:{roomName} - RoomId:{roomId}"); // 地图数据不合法,可能已经被损坏!地图名
            ServerRoomManager.Instance.Log("MSG:DOWNLOAD_MAP - " + msg);
            DownloadMapReply output = new DownloadMapReply()
            {
                Ret    = false,
                ErrMsg = msg,
            };
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
            return;
        }

        //////////////
        // 把地图数据下发到客户端
        const int CHUNK_SIZE = 900;
        int       remainSize = totalSize;
        int       index      = 0;
        int       position   = 0;

        while (remainSize > CHUNK_SIZE)
        {
            DownloadMapReply output = new DownloadMapReply()
            {
                RoomName       = roomName,
                RoomId         = input.RoomId,
                MaxPlayerCount = maxPlayerCount,
                IsCreatedByMe  = IsCreateByMe,
                IsLastPackage  = false,
                PackageIndex   = index++,
                Ret            = true,
            };
            byte[] sendBytes = new byte[CHUNK_SIZE];
            Array.Copy(totalData, position, sendBytes, 0, CHUNK_SIZE);
            output.MapData = ByteString.CopyFrom(sendBytes);
            position      += CHUNK_SIZE;
            remainSize    -= CHUNK_SIZE;
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
        }

        {
            DownloadMapReply output = new DownloadMapReply()
            {
                RoomName       = roomName,
                RoomId         = input.RoomId,
                MaxPlayerCount = maxPlayerCount,
                IsCreatedByMe  = IsCreateByMe,
                IsLastPackage  = true,
                PackageIndex   = index++,
                Ret            = true,
            };
            byte[] sendBytes = new byte[remainSize];
            Array.Copy(totalData, position, sendBytes, 0, remainSize);
            output.MapData = ByteString.CopyFrom(sendBytes);
            position      += remainSize;
            remainSize    -= remainSize;
            ServerRoomManager.Instance.SendMsg(_args, ROOM_REPLY.DownloadMapReply, output.ToByteArray());
        }

        ServerRoomManager.Instance.Log($"MSG: DOWNLOAD_MAP - Download map data succeeded! MapName:{roomName} - Total Map Size:{totalSize}"); // 地图数据下载完成!地图名
    }