mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Living: Do not use spl_object_id() for identifying effects
it's possible for these to have different IDs if they were cloned, serialized or copied between threads.
This commit is contained in:
parent
fe98b6c765
commit
20f092a685
@ -64,7 +64,6 @@ use function max;
|
|||||||
use function min;
|
use function min;
|
||||||
use function mt_getrandmax;
|
use function mt_getrandmax;
|
||||||
use function mt_rand;
|
use function mt_rand;
|
||||||
use function spl_object_id;
|
|
||||||
use function sqrt;
|
use function sqrt;
|
||||||
use const M_PI;
|
use const M_PI;
|
||||||
|
|
||||||
@ -219,7 +218,7 @@ abstract class Living extends Entity implements Damageable{
|
|||||||
* @param Effect $effectType
|
* @param Effect $effectType
|
||||||
*/
|
*/
|
||||||
public function removeEffect(Effect $effectType) : void{
|
public function removeEffect(Effect $effectType) : void{
|
||||||
$index = spl_object_id($effectType);
|
$index = $effectType->getId();
|
||||||
if(isset($this->effects[$index])){
|
if(isset($this->effects[$index])){
|
||||||
$effect = $this->effects[$index];
|
$effect = $this->effects[$index];
|
||||||
$hasExpired = $effect->hasExpired();
|
$hasExpired = $effect->hasExpired();
|
||||||
@ -249,7 +248,7 @@ abstract class Living extends Entity implements Damageable{
|
|||||||
* @return EffectInstance|null
|
* @return EffectInstance|null
|
||||||
*/
|
*/
|
||||||
public function getEffect(Effect $effect) : ?EffectInstance{
|
public function getEffect(Effect $effect) : ?EffectInstance{
|
||||||
return $this->effects[spl_object_id($effect)] ?? null;
|
return $this->effects[$effect->getId()] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -260,7 +259,7 @@ abstract class Living extends Entity implements Damageable{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasEffect(Effect $effect) : bool{
|
public function hasEffect(Effect $effect) : bool{
|
||||||
return isset($this->effects[spl_object_id($effect)]);
|
return isset($this->effects[$effect->getId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -284,8 +283,7 @@ abstract class Living extends Entity implements Damageable{
|
|||||||
$oldEffect = null;
|
$oldEffect = null;
|
||||||
$cancelled = false;
|
$cancelled = false;
|
||||||
|
|
||||||
$type = $effect->getType();
|
$index = $effect->getType()->getId();
|
||||||
$index = spl_object_id($type);
|
|
||||||
if(isset($this->effects[$index])){
|
if(isset($this->effects[$index])){
|
||||||
$oldEffect = $this->effects[$index];
|
$oldEffect = $this->effects[$index];
|
||||||
if(
|
if(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user