refactor(server): use cpp target instead of neko
This commit is contained in:
@@ -9,7 +9,7 @@ deploy_repo_version: develop
|
|||||||
deploy_npm: yes
|
deploy_npm: yes
|
||||||
|
|
||||||
service_name: "{{ project_name }}"
|
service_name: "{{ project_name }}"
|
||||||
service_work_dir: "{{ deploy_current_dir }}/target/server/neko"
|
service_work_dir: "{{ deploy_current_dir }}/target/server/cpp"
|
||||||
service_command: "/usr/bin/neko {{ service_work_dir }}/{{ project_name }}.n {{ service_host }}"
|
service_command: "{{ service_work_dir }}/{{ project_name }} {{ service_host }}"
|
||||||
service_user: www-data
|
service_user: www-data
|
||||||
service_control_user: "{{ project_user }}"
|
service_control_user: "{{ project_user }}"
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ const editor = new Project(
|
|||||||
*/
|
*/
|
||||||
const server = new Project(
|
const server = new Project(
|
||||||
Project.BuildSystem.HAXE,
|
Project.BuildSystem.HAXE,
|
||||||
Project.Platform.NEKO,
|
Project.Platform.CPP,
|
||||||
config.branch({
|
config.branch({
|
||||||
name: 'server',
|
name: 'server',
|
||||||
sources: ['src/server/haxe'],
|
sources: ['src/server/haxe'],
|
||||||
@@ -172,7 +172,7 @@ const defaultSeries = [
|
|||||||
module.exports['editor:flash:html'],
|
module.exports['editor:flash:html'],
|
||||||
module.exports['editor:html5:build'],
|
module.exports['editor:html5:build'],
|
||||||
|
|
||||||
module.exports['server:neko:build'],
|
module.exports['server:cpp:build'],
|
||||||
];
|
];
|
||||||
|
|
||||||
if (System.isLinux) {
|
if (System.isLinux) {
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -12,7 +12,7 @@
|
|||||||
"gulp": "^4.0.0",
|
"gulp": "^4.0.0",
|
||||||
"gulp-add": "0.0.2",
|
"gulp-add": "0.0.2",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-haxetool": "0.1.3",
|
"gulp-haxetool": "^0.1.9",
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3296,9 +3296,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/gulp-haxetool": {
|
"node_modules/gulp-haxetool": {
|
||||||
"version": "0.1.3",
|
"version": "0.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.1.9.tgz",
|
||||||
"integrity": "sha512-oaJIOHc1TGBsFEjuVV6ON1050umCZbpy61ph1Qt6/p+f5NO2WWnbVFhoH+0dL2GedCHEiuihbzpVzV1DT9jsXg==",
|
"integrity": "sha512-ABS3nWVrGMA0iLnIoOHl06zp6OOB9BCE5Nda0cpuaKVX2LGMPnJMhxPJNDQXvMhYTDnX90z2EpyIFDH6Pyv37A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ansi-colors": "^1.1.0",
|
"ansi-colors": "^1.1.0",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"gulp": "^4.0.0",
|
"gulp": "^4.0.0",
|
||||||
"gulp-add": "0.0.2",
|
"gulp-add": "0.0.2",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-haxetool": "0.1.3",
|
"gulp-haxetool": "^0.1.9",
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"haxeDependencies": {
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package ru.m.tankz.server;
|
|||||||
|
|
||||||
import haxe.io.Bytes;
|
import haxe.io.Bytes;
|
||||||
import haxework.log.TraceLogger;
|
import haxework.log.TraceLogger;
|
||||||
import neko.net.ThreadServer;
|
import cpp.net.ThreadServer;
|
||||||
import ru.m.tankz.bundle.CachedLevelBundle;
|
import ru.m.tankz.bundle.CachedLevelBundle;
|
||||||
import ru.m.tankz.bundle.IConfigBundle;
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
import ru.m.tankz.bundle.ILevelBundle;
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
import ru.m.tankz.server.bundle.ServerConfigBundle;
|
import ru.m.tankz.server.bundle.AssetConfigBundle;
|
||||||
import ru.m.tankz.server.bundle.ServerLevelSource;
|
import ru.m.tankz.server.bundle.AssetLevelSource;
|
||||||
import ru.m.tankz.server.game.GameManager;
|
import ru.m.tankz.server.game.GameManager;
|
||||||
import ru.m.tankz.server.game.IGameManager;
|
import ru.m.tankz.server.game.IGameManager;
|
||||||
import ru.m.tankz.server.session.GameSession;
|
import ru.m.tankz.server.session.GameSession;
|
||||||
@@ -48,8 +48,8 @@ class Server extends ThreadServer<GameSession, Bytes> {
|
|||||||
#end
|
#end
|
||||||
L.d(TAG, 'Running');
|
L.d(TAG, 'Running');
|
||||||
L.i(TAG, 'Build: ${CompilationOption.get("build")}');
|
L.i(TAG, 'Build: ${CompilationOption.get("build")}');
|
||||||
configBundle = new ServerConfigBundle();
|
configBundle = new AssetConfigBundle();
|
||||||
levelBundle = new CachedLevelBundle(new ServerLevelSource());
|
levelBundle = new CachedLevelBundle(new AssetLevelSource());
|
||||||
levelBundle.load();
|
levelBundle.load();
|
||||||
gameManager = new GameManager();
|
gameManager = new GameManager();
|
||||||
var host:String = Sys.args().length > 0 ? Sys.args()[0] : "0.0.0.0";
|
var host:String = Sys.args().length > 0 ? Sys.args()[0] : "0.0.0.0";
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.m.tankz.server.bundle;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import yaml.Parser;
|
||||||
|
import yaml.Yaml;
|
||||||
|
|
||||||
|
class AssetConfigBundle implements IConfigBundle {
|
||||||
|
|
||||||
|
private var _cache:Map<GameType, Config> = new Map();
|
||||||
|
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function get(type:GameType):Config {
|
||||||
|
if (!_cache.exists(type)) {
|
||||||
|
var source:ConfigSource = Yaml.parse(Assets.getText('config/${type}.yaml'), Parser.options().useObjects());
|
||||||
|
_cache.set(type, Config.fromSource(type, source));
|
||||||
|
}
|
||||||
|
return _cache.get(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/server/haxe/ru/m/tankz/server/bundle/AssetLevelSource.hx
Normal file
33
src/server/haxe/ru/m/tankz/server/bundle/AssetLevelSource.hx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package ru.m.tankz.server.bundle;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import openfl.utils.AssetType;
|
||||||
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import ru.m.tankz.util.LevelUtil;
|
||||||
|
|
||||||
|
class AssetLevelSource implements ILevelSource {
|
||||||
|
|
||||||
|
public function new() {}
|
||||||
|
|
||||||
|
public function resolveMeta(id:PackId):LevelPackMeta {
|
||||||
|
var bytes = Assets.getBytes('level/${id}.zip');
|
||||||
|
return LevelUtil.getMeta(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(id:PackId):LevelPack {
|
||||||
|
var bytes = Assets.getBytes('level/${id}.zip');
|
||||||
|
return LevelUtil.unpack(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list():Array<PackId> {
|
||||||
|
var result = [];
|
||||||
|
for (path in Assets.list(AssetType.BINARY)) {
|
||||||
|
if (StringTools.startsWith(path, "level")) {
|
||||||
|
result.push(PackId.fromString(path.split("/").pop().split(".").shift()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user