/// <summary> /// 현재 선택된 청크를 불러오고 다음 청크를 선택한다. /// </summary> /// <returns>다음 청크의 유무</returns> public bool LoadNext() { // 열거자 얻기 if (m_currentLoadChunk == null) { m_board.Clear(); m_currentLoadChunk = Directory.EnumerateFileSystemEntries(this.BoardPath).GetEnumerator(); if (m_currentLoadChunk.MoveNext() == false) { m_currentLoadChunk = null; return(false); } } try { using (BinaryReader br = new BinaryReader(new FileStream(m_currentLoadChunk.Current, FileMode.Open))) { // 파일 버전 Utility.Version fileVersion = new Utility.Version(br.ReadString()); // 청크 위치 int chunkX = br.ReadInt32(); int chunkY = br.ReadInt32(); // 청크 생성 m_board.CreateChunkAt(chunkX, chunkY); var chunk = m_board.GetChunkAt(chunkX, chunkY); // 청크 크기 int chunkSize = br.ReadInt32(); // 타일 정보 for (int x = 0; x < chunkSize; ++x) { for (int y = 0; y < chunkSize; ++y) { // 타일 설정 var tile = chunk[x, y]; tile.ReadFromStream(br); // 설치된 것이 있다면 목록에 위치를 추가 if (tile.IsFactoryTile) { m_factoryList.Add(new Point( chunkX * this.Board.ChunkSize + x, chunkY * this.Board.ChunkSize + y)); } else if (tile.IsCompanyTile) { m_companyList.Add(new Point( chunkX * this.Board.ChunkSize + x, chunkY * this.Board.ChunkSize + y)); } else if (tile.IsChipTile) { m_chipList.Add(new Point( chunkX * this.Board.ChunkSize + x, chunkY * this.Board.ChunkSize + y)); } } } } } catch (FileNotFoundException) { } // 다음 파일로 넘어감 if (m_currentLoadChunk.MoveNext()) { return(true); } else { m_currentLoadChunk = null; return(false); } }
//##################################################################################### // 수신된 메세지 처리 private NetMessage WhenReqLogin(ServerVisitor client, NetMessageStream msg) { string userName = msg.ReadData <string>(); LoginResults loginResult = LoginResults.Success; // 로그인을 받을 수 있는 상태이면 if (this.CanLogin) { string password = msg.ReadData <string>(); string versionText = Utility.Version.Zero.ToString(); if (!msg.EndOfStream) { versionText = msg.ReadData <string>(); } Utility.Version clientVersion = new Utility.Version(versionText); // 클라이언트 버전이 서버버전과 같은지 확인 if (Application.ProductVersion == clientVersion) { // 회원여부 확인 및 비밀번호 얻기 bool isMember = m_accountList.ContainsKey(userName); string realPassword = ""; if (isMember) { realPassword = m_accountList[userName].Password; } // 회원이 아니면 실패 if (isMember == false) { loginResult = LoginResults.Fail_NotUser; } // 비밀번호가 틀리면 실패 else if (password != realPassword) { loginResult = LoginResults.Fail_WrongPassword; } // 이미 접속된 유저와 이름이 중복되면 실패 else if (m_loginUserList.Any((user) => user.Value.Name == userName)) { loginResult = LoginResults.Fail_AlreadyLogin; } // 로그인 성공시 if (loginResult == LoginResults.Success) { // 접속자 목록에 추가 m_loginUserList.Add(client.ID, new GamePlayer() { Name = userName }); // 로그인 사실을 모두에게 알림 NetMessageStream loginNotice = new NetMessageStream(); loginNotice.WriteData(userName); this.NoticeDelegate(loginNotice.CreateMessage((int)MessageTypes.Ntf_UserLogin)); } } else { // 클라이언트의 버전과 서버의 버전이 다르므로 접속불가 loginResult = LoginResults.Fail_DifferentVersion; } } else { // 로그인을 받을 수 없음 loginResult = LoginResults.Fail_ServerNotReady; } // 로그 Utility.Logger.GetInstance().Log(string.Format("\"{0}\"님이 로그인을 시도했습니다. 결과 : {1}", userName, loginResult.ToString())); // 로그인 결과 전송 NetMessageStream writer = new NetMessageStream(); writer.WriteData((int)loginResult); return(writer.CreateMessage((int)MessageTypes.Rsp_Login)); }