TIL-sparta

스파르타) Node.js 5기 게임 서버 최종 프로젝트 (D-6)

Megadr0ne 2024. 8. 22. 04:04

 

학습 키워드: C#, .NET, Recast & Detour, DotRecast

 

1. Progress

1) 메인 서버와 Dedi 서버 정보 동기화 및 클라이언트 전송:

 

GitHub - donkim1212/PathfindingDediServer: (WIP) 내배캠 스파르타 Node.js 5기 Team 12 최종 프로젝트 The Last Rollba

(WIP) 내배캠 스파르타 Node.js 5기 Team 12 최종 프로젝트 The Last Rollback에서 사용될 길찾기 전용 서버 입니다. - donkim1212/PathfindingDediServer

github.com

(24-08-21 일자 'dev' branch commit history 참고)

 

전용 서버 주요 변경점

- 통신 구조 오류 수정

- 필수 기능 구현 마무리

 

 

GitHub - eliotjang/the-last-rollback-server: MORPG + Defense

MORPG + Defense. Contribute to eliotjang/the-last-rollback-server development by creating an account on GitHub.

github.com

(24-08-21 일자 '90-update-데디-서버-통신-구조-작성' branch commit history 참고)

 

메인 서버 주요 변경점

- 통신 구조 오류 수정

- 이동 및 회전 방향 동기화

 

2. Troubleshooting

1) Proto 컴파일 시 MapField 의 MergeFrom 이 없는 문제 (해결):

// protocol.proto
...
message S_PlayersLocationUpdate {
  map<string, TransformInfo> positions = 1;
}

message TransformInfo {
  float posX = 1; // 기본값 : -9 ~ 9
  float posY = 2; // 기본값 : 1
  float posZ = 3; // 기본값 : -8 ~ 8
  float rot = 4; // 기본값 : 0~360
}
...

 

 위와 같이 작성한 proto파일을 protoc를 통해 컴파일하면 Unity에서 아래와 같은 에러가 발생한다.

 

'MergeFrom' 관련 오류

 

 proto 파일의 map 구조를 컴파일할 때 MergeFrom이 사라져서 컴파일러 에러가 발생하는데, 정확한 원인은 모르지만 github 이슈 을 읽어보니 중복 키 이름을 사용할 때 발생하는 문제와 연관이 있는 것 같다. 일단 어차피 map으로 보내더라도 클라이언트에서 key 배열을 찾아 순회해야하기 때문에 아래와 같이 새 구조를 정의한 뒤 repeated 로 전송하도록 변경했다.

 

// protocol.proto
...
message S_PlayersTransformUpdate {
  repeated PlayerTransformInfo transformInfo = 1;
}

message PlayerTransformInfo {
  string accountId = 1;
  TransformInfo transformInfo = 2;
}
...

 

 

--


REFERENCES:

 

https://github.com/eliotjang/the-last-rollback-server

 > The Last Rollback - 메인 서버 repo

https://github.com/donkim1212/PathfindingDediServer

 > The Last Rollback - Pathfinding Dedicated Server repo

728x90