25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

107 lines
2.4 KiB

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