mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-02-19 20:02:35 +01:00
Potential issue in RoomTile removeUnit fixed.
This commit is contained in:
parent
419c3d07af
commit
23ae60119b
@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.rooms;
|
|||||||
|
|
||||||
import gnu.trove.set.hash.THashSet;
|
import gnu.trove.set.hash.THashSet;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ public class RoomTile
|
|||||||
private short gCosts;
|
private short gCosts;
|
||||||
private short hCosts;
|
private short hCosts;
|
||||||
|
|
||||||
private THashSet<RoomUnit> units;
|
private final THashSet<RoomUnit> units;
|
||||||
|
|
||||||
|
|
||||||
public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack)
|
public RoomTile(short x, short y, short z, RoomTileState state, boolean allowStack)
|
||||||
@ -210,20 +209,28 @@ public class RoomTile
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<RoomUnit> getUnits() {
|
public List<RoomUnit> getUnits() {
|
||||||
return new ArrayList<RoomUnit>(this.units);
|
synchronized (this.units) {
|
||||||
|
return new ArrayList<RoomUnit>(this.units);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUnit(RoomUnit unit) {
|
public void addUnit(RoomUnit unit) {
|
||||||
if(!this.units.contains(unit)) {
|
synchronized (this.units) {
|
||||||
this.units.add(unit);
|
if (!this.units.contains(unit)) {
|
||||||
|
this.units.add(unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUnit(RoomUnit unit) {
|
public void removeUnit(RoomUnit unit) {
|
||||||
this.units.remove(unit);
|
synchronized (this.units) {
|
||||||
|
this.units.remove(unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUnits() {
|
public boolean hasUnits() {
|
||||||
return this.units.size() > 0;
|
synchronized (this.units) {
|
||||||
|
return this.units.size() > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user