Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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