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

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