Skip to content
mike edited this page Dec 25, 2017 · 2 revisions

lordofpinus code organizations

The lordofpinus 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 lordofpinus, including all the game logic code and game server code. Web-server is the client of lordofpinus, 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, lordofpinus 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:

lordofpinus_arch

Game-server-side code analysis

![Game-server] (http://pomelo.netease.com/resource/documentImage/lordofpinus/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 lordofpinus.
  • /logs: The log files generated by the game server.
  • /scripts: The local script of statistics module.
  • /test: lordofpinus'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/lordofpinus/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/lordofpinus/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 lordofpinus 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 lordofpinus.

Web-server code architecture

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

The web code of lordofpinus 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/lordofpinus/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: lordofpinus's index page.

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

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

  • /config: client-side configuration.
  • /handler: The handle in client side, designed to handle server-side messages.
  • /lib: colorbox and pinus 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