瀏覽代碼

use new path property of maps in maplist for relative folder loading

tags/v0.3.1
notme 5 年之前
committed by Big Bad Waffle
父節點
當前提交
aae090339d
共有 6 個文件被更改,包括 41 次插入15 次删除
  1. +20
    -5
      src/server/config/maps/mapList.js
  2. +3
    -1
      src/server/config/quests/questBuilder.js
  3. +5
    -2
      src/server/events/events.js
  4. +4
    -2
      src/server/world/atlas.js
  5. +7
    -5
      src/server/world/map.js
  6. +2
    -0
      src/server/world/worker.js

+ 20
- 5
src/server/config/maps/mapList.js 查看文件

@@ -1,11 +1,26 @@
let events = require('../../misc/events');

let config = [
'cave',
'estuary',
'sewer',
'fjolarok',
'dungeon'
{
name: 'cave',
path: 'config/maps'
},
{
name: 'estuary',
path: 'config/maps'
},
{
name: 'sewer',
path: 'config/maps'
},
{
name: 'fjolarok',
path: 'config/maps'
},
{
name: 'dungeon',
path: 'config/maps'
}
];

module.exports = {


+ 3
- 1
src/server/config/quests/questBuilder.js 查看文件

@@ -1,5 +1,6 @@
let questTemplate = require('./templates/questTemplate');
let globalQuests = require('../questsBase');
let mapList = require('../maps/mapList');

module.exports = {
instance: null,
@@ -9,6 +10,7 @@ module.exports = {
},
obtain: function (obj, template) {
let zoneName = template ? template.zoneName : obj.zoneName;
let zonePath = mapList.mapList.find(m => m.name === zoneName);
let oQuests = obj.quests;
if (oQuests.quests.filter(q => q.zoneName === zoneName).length > 0)
return;
@@ -16,7 +18,7 @@ module.exports = {
let zoneTemplate = null;

try {
zoneTemplate = require('../../config/maps/' + zoneName + '/quests.js');
zoneTemplate = require('../../' + zonePath + '/' + zoneName + '/quests.js');
} catch (e) {
zoneTemplate = globalQuests;
}


+ 5
- 2
src/server/events/events.js 查看文件

@@ -1,5 +1,6 @@
let phaseTemplate = require('../config/eventPhases/phaseTemplate');
let fs = require('fs');
let mapList = require('../config/maps/mapList');

module.exports = {
configs: [],
@@ -8,14 +9,16 @@ module.exports = {
init: function (instance) {
this.instance = instance;

let path = 'config/maps/' + this.instance.map.name + '/events';
let zoneName = this.instance.map.name;
let zonePath = mapList.mapList.find(z => z.name === zoneName).path;
let path = zonePath + '/' + zoneName + '/events';
if (!fs.existsSync(path))
return;

let files = fs.readdirSync(path)
.map(f => ('../' + path + '/' + f));

this.instance.eventEmitter.emit('onBeforeGetEventList', this.instance.map.name, files);
this.instance.eventEmitter.emit('onBeforeGetEventList', zoneName, files);

files.forEach(function (f) {
let e = require(f);


+ 4
- 2
src/server/world/atlas.js 查看文件

@@ -122,11 +122,12 @@ module.exports = {
getMapFiles: function () {
mapList.mapList.forEach(m => this.spawnMap(m));
},
spawnMap: function (name) {
spawnMap: function (map) {
let worker = childProcess.fork('./world/worker');
let thread = {
id: this.nextId++,
name: name.replace('.json', ''),
name: map.name,
path: map.path,
worker: worker
};

@@ -152,6 +153,7 @@ module.exports = {
method: 'init',
args: {
name: thread.name,
path: thread.path,
zoneId: thread.id
}
});


+ 7
- 5
src/server/world/map.js 查看文件

@@ -12,6 +12,7 @@ let padding = null;

module.exports = {
name: null,
path: null,
layers: [],

mapFile: null,
@@ -49,9 +50,10 @@ module.exports = {

init: function (args) {
this.name = args.name;

this.path = args.path;
try {
this.zone = require('../config/maps/' + this.name + '/zone');
this.zone = require('../' + this.path + '/' + this.name + '/zone');
} catch (e) {
this.zone = globalZone;
}
@@ -59,14 +61,14 @@ module.exports = {

let chats = null;
try {
chats = require('../config/maps/' + this.name + '/chats');
chats = require('../' + this.path + '/' + this.name + '/chats');
} catch (e) {}
if (chats)
this.zone.chats = chats;

let dialogues = null;
try {
dialogues = require('../config/maps/' + this.name + '/dialogues');
dialogues = require('../' + this.path + '/' + this.name + '/dialogues');
} catch (e) {}
events.emit('onBeforeGetDialogue', this.name, dialogues);
if (dialogues)
@@ -78,7 +80,7 @@ module.exports = {
for (let r in resources)
resourceSpawner.register(r, resources[r]);

mapFile = require('../config/maps/' + this.name + '/map');
mapFile = require('../' + this.path + '/' + this.name + '/map');
this.mapFile = mapFile;
this.mapFile.properties = this.mapFile.properties || {};
mapScale = mapFile.tilesets[0].tileheight;


+ 2
- 0
src/server/world/worker.js 查看文件

@@ -15,6 +15,7 @@ let spellsConfig = require('../config/spellsConfig');
let spells = require('../config/spells');
let recipes = require('../config/recipes/recipes');
let itemTypes = require('../items/config/types');
let mapList = require('../config/maps/mapList');
let sheets = require('../security/sheets');

let onCpnsReady = function () {
@@ -26,6 +27,7 @@ let onCpnsReady = function () {
spellsConfig.init();
spells.init();
itemTypes.init();
mapList.init();
recipes.init();
sheets.init();



Loading…
取消
儲存