-
Notifications
You must be signed in to change notification settings - Fork 4
/
engine.js
63 lines (43 loc) · 1.53 KB
/
engine.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"use strict";
const path = require("path");
// Load the configuration
global.CONFIG = require("./config");
// Create some useful global functions
global.getDataFile = function() {
/*
* Function global.getDataFile
* Returns a file from the base data directory
*/
return path.join(__dirname, "data", CONFIG.SERVER.CLIENT_VERSION, ...arguments);
}
global.requireModule = function() {
/*
* Function global.requireModule
* Requires a module from the base source directory
*/
return require(path.join(__dirname, "src", ...arguments));
}
// Load constants
global.CONST = require(getDataFile("constants.json"));
// Requires the prototype modifications
requireModule("__proto__");
if(require.main === module) {
/*
* Function __main__
* Function called when the initialization script is executed
*/
// Check the NodeJS version
let [ major, minor, patch ] = process.versions.node.split(".");
// Confirm major version
if(major < 16) {
console.log("Could not launch gameserver: required version: %s and current version: %s.".format("16.0.0", process.versions.node));
return process.exit(1);
}
console.log("Starting NodeJS Forby Open Tibia Server.");
console.log("Creating server with version [[ %s ]].".format(CONFIG.SERVER.CLIENT_VERSION));
console.log("Setting data directory to [[ %s ]].".format(getDataFile("")));
const GameServer = requireModule("gameserver");
// Attach the gameserver to the process and initialize
process.gameServer = new GameServer();
process.gameServer.initialize();
}