mirror of
https://github.com/maierfelix/POGOserver.git
synced 2026-03-23 18:34:16 -05:00
Update
- Avoid usage of setTimeout in hot functions
This commit is contained in:
parent
00588b2d72
commit
1522fa1709
|
|
@ -22,6 +22,7 @@ export default class WildPokemon extends Pokemon {
|
|||
|
||||
this.encounterId = this.getEncounterId();
|
||||
|
||||
this.despawnIn = -1;
|
||||
this.isDespawned = false;
|
||||
|
||||
this.minExpire = obj.minExpire;
|
||||
|
|
|
|||
|
|
@ -60,9 +60,12 @@ export default class SpawnPoint extends MapObject {
|
|||
this.activeSpawns.map((pkmn) => {
|
||||
if (pkmn.isExpired() && !pkmn.isDespawned) {
|
||||
pkmn.isDespawned = true;
|
||||
setTimeout(() => {
|
||||
pkmn.despawnIn = +new Date() + ((MAP_REFRESH_RATE * 1e3) + pkmn.expiration);
|
||||
}
|
||||
else if (pkmn.isDespawned) {
|
||||
if (+new Date() >= pkmn.despawnIn) {
|
||||
this.despawnPkmn(pkmn);
|
||||
}, (MAP_REFRESH_RATE * 1e3) * 2);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user