diff --git a/src/servers/ZoneServer2016/classes/craftmanager.ts b/src/servers/ZoneServer2016/classes/craftmanager.ts index ebd8159bcb..024e8de83d 100644 --- a/src/servers/ZoneServer2016/classes/craftmanager.ts +++ b/src/servers/ZoneServer2016/classes/craftmanager.ts @@ -11,6 +11,7 @@ // Based on https://github.com/psemu/soe-network // ====================================================================== +import { Scheduler } from "../../../utils/utils"; import { ZoneServer2016 } from "../zoneserver"; import { ZoneClient2016 as Client } from "./zoneclient"; const debug = require("debug")("ZoneServer"); @@ -74,7 +75,7 @@ export class CraftManager { count: number ): Promise { // if craftItem gets stuck in an infinite loop somehow, setImmediate will prevent the server from crashing - server.pSetImmediate(); + Scheduler.yield() if (!count) return true; debug(`[CraftManager] Crafting ${count} of itemDefinitionId ${recipeId}`); const recipe = server._recipes[recipeId]; diff --git a/src/servers/ZoneServer2016/zoneserver.ts b/src/servers/ZoneServer2016/zoneserver.ts index 92fc47765c..adcc4df06c 100644 --- a/src/servers/ZoneServer2016/zoneserver.ts +++ b/src/servers/ZoneServer2016/zoneserver.ts @@ -37,6 +37,7 @@ import { isPosInRadius, getDistance, randomIntFromInterval, + Scheduler, } from "../../utils/utils"; import { Db, MongoClient } from "mongodb"; @@ -860,7 +861,7 @@ export class ZoneServer2016 extends ZoneServer2015 { if (isPosInRadius(5, vehicle.npcData.position, position)) { const distance = getDistance(position, vehicle.npcData.position); const damage = 250000 / distance; - await this.pSetTimeout(150); + await Scheduler.wait(150); this.damageVehicle(damage, vehicle); } } @@ -869,7 +870,7 @@ export class ZoneServer2016 extends ZoneServer2015 { const explosiveObj = this._explosives[explosive]; if (explosiveObj.characterId != npcTriggered) { if (getDistance(position, explosiveObj.position) < 2) { - await this.pSetTimeout(150); + await Scheduler.wait(150); this.explodeExplosive(explosiveObj); } } @@ -3745,8 +3746,6 @@ export class ZoneServer2016 extends ZoneServer2015 { ).zonePacketHandlers(); await this._packetHandlers.reloadCommandCache(); } - pSetImmediate = promisify(setImmediate); - pSetTimeout = promisify(setTimeout) } if (process.env.VSCODE_DEBUG === "true") {