您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

97 行
2.1 KiB

  1. global.io = true;
  2. global.extend = require('extend');
  3. let helpers = require('../misc/helpers');
  4. let components = require('../components/components');
  5. let instancer = require('./instancer');
  6. let io = require('../security/io');
  7. let mods = require('../misc/mods');
  8. let mtx = require('../mtx/mtx');
  9. let animations = require('../config/animations');
  10. let skins = require('../config/skins');
  11. let factions = require('../config/factions');
  12. let classes = require('../config/spirits');
  13. let spellsConfig = require('../config/spellsConfig');
  14. let spells = require('../config/spells');
  15. let itemTypes = require('../items/config/types');
  16. let sheets = require('../security/sheets');
  17. let onCpnsReady = function () {
  18. factions.init();
  19. skins.init();
  20. mtx.init();
  21. animations.init();
  22. classes.init();
  23. spellsConfig.init();
  24. spells.init();
  25. itemTypes.init();
  26. sheets.init();
  27. process.send({
  28. method: 'onReady'
  29. });
  30. };
  31. let onModsReady = function () {
  32. components.init(onCpnsReady);
  33. };
  34. let onDbReady = function () {
  35. global._ = helpers;
  36. global.instancer = instancer;
  37. require('../misc/random');
  38. mods.init(onModsReady);
  39. setInterval(function () {
  40. global.gc();
  41. }, 60000);
  42. process.on('uncaughtException', function (e) {
  43. if (e.toString().indexOf('ERR_IPC_CHANNEL_CLOSED') > -1)
  44. return;
  45. console.log('Error Logged: ' + e.toString());
  46. console.log(e.stack);
  47. io.set({
  48. ent: new Date(),
  49. field: 'error',
  50. value: e.toString() + ' | ' + e.stack.toString(),
  51. callback: function () {
  52. process.send({
  53. event: 'onCrashed'
  54. });
  55. }
  56. });
  57. });
  58. };
  59. io.init(onDbReady);
  60. process.on('message', m => {
  61. if (m.module) {
  62. let instances = instancer.instances;
  63. let iLen = instances.length;
  64. for (let i = 0; i < iLen; i++) {
  65. let objects = instances[i].objects.objects;
  66. let oLen = objects.length;
  67. let found = false;
  68. for (let j = 0; j < oLen; j++) {
  69. let object = objects[j];
  70. if (object.name === m.args[0]) {
  71. let mod = object.instance[m.module];
  72. mod[m.method].apply(mod, m.args);
  73. found = true;
  74. break;
  75. }
  76. }
  77. if (found)
  78. break;
  79. }
  80. } else if (m.method)
  81. instancer[m.method](m.args);
  82. });