25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

107 satır
2.5 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. const components = require('../components/components');
  9. const mods = require('../misc/mods');
  10. const animations = require('../config/animations');
  11. const skins = require('../config/skins');
  12. const factions = require('../config/factions');
  13. const classes = require('../config/spirits');
  14. const spellsConfig = require('../config/spellsConfig');
  15. const spells = require('../config/spells');
  16. const recipes = require('../config/recipes/recipes');
  17. const itemTypes = require('../items/config/types');
  18. const mapList = require('../config/maps/mapList');
  19. const itemEffects = require('../items/itemEffects');
  20. const profanities = require('../misc/profanities');
  21. const eventEmitter = require('../misc/events');
  22. let onCpnsReady = async function () {
  23. factions.init();
  24. skins.init();
  25. animations.init();
  26. classes.init();
  27. spellsConfig.init();
  28. spells.init();
  29. itemTypes.init();
  30. mapList.init();
  31. recipes.init();
  32. itemEffects.init();
  33. profanities.init();
  34. await clientConfig.init();
  35. process.send({
  36. method: 'onReady'
  37. });
  38. };
  39. let onModsReady = function () {
  40. components.init(onCpnsReady);
  41. };
  42. const onCrash = async e => {
  43. if (e.toString().indexOf('ERR_IPC_CHANNEL_CLOSED') > -1)
  44. return;
  45. _.log('Error Logged: ' + e.toString());
  46. _.log(e.stack);
  47. await io.setAsync({
  48. key: new Date(),
  49. table: 'error',
  50. value: e.toString() + ' | ' + e.stack.toString()
  51. });
  52. process.send({
  53. event: 'onCrashed'
  54. });
  55. };
  56. let onDbReady = async function () {
  57. require('../misc/random');
  58. process.on('uncaughtException', onCrash);
  59. process.on('unhandledRejection', onCrash);
  60. await mods.init();
  61. onModsReady();
  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. else if (m.event)
  89. eventEmitter.emit(m.event, m.data);
  90. });