|
|




!!!![]()
gl






Thanks,
This was the way it was done in Apollo, however I did check over this and the RegionCoordinates have a specific hash code:
Doing stuff like HashSet.Contains(regionCoords) is a O(1) operation due to this. Compared to a list where the worst time could be O(N) where N is the size of the list.Code:public override int GetHashCode() { return X << 16 | Y; }
Also the HashSet prevents duplicates fairly quickly as opposed to a list where you have to check every item for a duplicate O(N) again.
If you do have any alternatives which may be better please do let me know.
Edit also i forgot:
will create a new HashSet of the already existing one. Like a shallow copy.Code:.ToHashSet()
Awesome, best of luck.

Woah good fucking luck with this project brother!




Haha. Whoops. Checking the github, there has been quite a few changes to the [Only registered and activated users can see links. ] class
Checking the local copy of Apollo that I had checked the other day it had
So yeah, big difference haha.Code:package org.apollo.game.sync.task; import org.apollo.game.event.impl.RegionChangeEvent; import org.apollo.game.model.Player; import org.apollo.game.model.Position; /** * A {@link SynchronizationTask} which does pre-synchronization work for the specified {@link Player}. * * @author Graham */ public final class PrePlayerSynchronizationTask extends SynchronizationTask { /** * The player. */ private final Player player; /** * Creates the {@link PrePlayerSynchronizationTask} for the specified player. * * @[Only registered and activated users can see links. ] player The player. */ public PrePlayerSynchronizationTask(Player player) { this.player = player; } /** * Checks if a region update is required. * * @[Only registered and activated users can see links. ] {@code true} if so, {@code false} otherwise. */ private boolean isRegionUpdateRequired() { Position current = player.getPosition(); Position last = player.getLastKnownRegion(); int deltaX = current.getLocalX(last); int deltaY = current.getLocalY(last); return deltaX < 16 || deltaX >= 88 || deltaY < 16 || deltaY >= 88; } @Override public void run() { player.getWalkingQueue().pulse(); if (player.isTeleporting()) { player.resetViewingDistance(); } if (!player.hasLastKnownRegion() || isRegionUpdateRequired()) { player.setRegionChanged(true); Position position = player.getPosition(); player.setLastKnownRegion(position); player.send(new RegionChangeEvent(position)); } } }

Yeah quite a lot of branches for apollo easy to get mixed up. I do think how I combined the pre, update and post update stuff looks ugly as f, I will be separating it properly later on.

wow, very very nice ill follow this

| « 🧙Phantasm🧙 - The Destination of your Imagination | Torva - A Pre-EoC Only Experience » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |