Skip to content
Dirk Krause edited this page Nov 27, 2013 · 1 revision

lordofpomelo code organizations

The lordofpomelo code includes two parts, the back-end server code for the game-server and front-end code for the web-server. Game-server is the server side of lordofpomelo, including all the game logic code and game server code. Web-server is the client of lordofpomelo, including the web pages and user login and registration codes. In addition to these two parts, there is a shared directory used to store shared code and configuration.

As a distributed game server, lordofpomelo includes different instances of game servers, and these servers will use the same code. Different server instances will load their own code separately, according to the configuration files. The following figure is the code structure:

lordofpomelo_arch

Game-server-side code analysis

![Game-server] (http://pomelo.netease.com/resource/documentImage/lordofpomelo/code/game-server.png)

The app.js is the entrance of the server code, the descriptions of the directories are as follows:

  • /app: Server-side js, the including different game servers and game logic.
  • /config: The configuration file of lordofpomelo.
  • /logs: The log files generated by the game server.
  • /scripts: The local script of statistics module.
  • /test: lordofpomelo's test case.

Logic code

The logic code used to accomplish specific business logic, such as AI which drives the monsters, or path which calculates the shortest path in game map. All the logic code is located in /app/domain directory.

![Logic] (http://pomelo.netease.com/resource/documentImage/lordofpomelo/code/logic.png)

  • /action: responsible for handling long term client requests. Since the scene logic is tick driven, and the tick interval is short (by default 100ms), the long term job that needs ticks to finish will be packaged as an action.
  • /aoi: AOI (areas of interest) logic, including AOI message package, and the handling of AOI message.
  • /area: The scenes related logic, including entities management, message broadcast, and other logic modules such as AOI, AI, etc.
  • /entity: Abstraction for the entities in the scene, including player, monster, npc, treasure, equipment and so on.
  • /event: Deals with various events produced by game scene, including player message, monster message and so on.
  • /map: Loads and parses the map data in order to construct a map object.
  • /task: Task-related code, responsible for task execution and cancelation.

Server code.

![Servers] (http://pomelo.netease.com/resource/documentImage/lordofpomelo/code/servers.png)

Server code is located in the /servers directory. The code provides a public RPC interface for other services. These interfaces are used to process requests of servers and clients, and return the result. The servers in lordofpomelo include:

  • /area: The scene server, used to maintain all the scene information, deals with the game logics, such as add or delete a player, attack mob and so on.
  • /chat: The chat server is responsible for processing all the chat messages.
  • /connector: The connector servers, responsible for maintaining all online players' sessions, accept players' data, and pushes message to clients.
  • /auth: The login server is used to verify user login information
  • /path: The pathfinding server is used to move objects in game scene.
  • /gate: The gate server is the entrance of lordofpomelo.

Web-server code architecture

![Web server] (http://pomelo.netease.com/resource/documentImage/lordofpomelo/code/web_server.png)

The web code of lordofpomelo is mainly divided into two parts: the UI code use html5 and use game logic code use colorbox library (link). The UI includes the login and register page, and all the options and menus in the game. These codes are developed in html5/css3 to render.

The web-server also includes user registration and OAuth validation logic: the relavant code is in the /lib directory.

The following figure is the content of web-server:

![Client & html] (http://pomelo.netease.com/resource/documentImage/lordofpomelo/code/client_html.png)

  • /animation_json: The description of all the animation in json format.
  • /css: The css code.
  • /image: The image resources.
  • /js: All the js files used in the game client.
  • /index.html: lordofpomelo's index page.

The following figure is the game logic code in the client:

![Client & html] (http://pomelo.netease.com/resource/documentImage/lordofpomelo/code/game_client.png)

  • /config: client-side configuration.
  • /handler: The handle in client side, designed to handle server-side messages.
  • /lib: colorbox and pomelo client communication library code
  • /model: The logic code of the game client.
  • /ui: UI code in client.
  • /utils: The tools used by the client.
  • /app.js: The client initialization entry, responsible for initializing the game client.
Clone this wiki locally