|
Each time you mine an ore with a replacement object id, the server adds a new object to be spawned, however it does not remove existing objects before spawning a new one. This results in a huge pile up of objects being spawned for the player mining and new players entering the region, in worst case scenarios it crashes the client entirely. This will also obviously cause an unwanted memory leak as the "active" object list will grow indefinitely whilst players are mining.
Where both the depleted rock and normal rock are spawned add this above.
Code:GameObject gameObject = ObjectManager.getGameObject(object.getX(), object.getY(), object.getZ()); if(gameObject != null) { ObjectManager.removeFromList(gameObject); }
Thanks for the contribution
would that be in the mining class above this:
and this:Code:ObjectManager.spawnWithObject(ore.getReplacement(), object.getX(), object.getY(), object.getZ(), object.getType(), object.getFace());
Code:ObjectManager.spawnWithObject(object.getId(), object.getX(), object.getY(), object.getZ(), object.getType(), object.getFace());
I'm trying to implement this, I'm cannot find symbol error pointing at object.getY(). Any help, should I be able to paste this code in with no other changes and it works?
It's alright, I found the problem. Everything was fine except i didn't import GameOblect class. Do everything Mystic Maze does above and make sure you havefor future people.Code:import com.vencillio.rs2.entity.object.GameObject;
Good job Stuart, recently solved this for Figgatt's OS-Fidelity. Here is a bit more detail. The ObjectManager#spawnWithObject was changed to return the object being spawned for later use.
Code:GameObject removeExisting = ObjectManager.getGameObject(new Location(object.getX(), object.getY(), object.getZ())); if (removeExisting != null) { ObjectManager.removeFromList(removeExisting); } final GameObject replace = ObjectManager.spawnWithObject(ore.getReplacement(), object.getX(), object.getY(), object.getZ(), object.getType(), object.getFace()); TaskQueue.queue(new Task(player, ore.getRespawn(), false, StackType.STACK, BreakType.NEVER, TaskIdentifier.MINING_ROCK) { @Override public void execute() { stop(); } @Override public void onStop() { ObjectManager.removeFromList(replace); ObjectManager.spawnWithObject(object.getId(), object.getX(), object.getY(), object.getZ(), object.getType(), object.getFace()); } });
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |