
Allow me to educate, young grasshopper.
It's pure intuition if you have have studied complexity analysis of algorithms which you can read about [Only registered and activated users can see links. ].
Assuming you don't...
An operation is either an addition/subtraction, multiplication/division/modulus , comparison, or an assignment.
For instance,has a time complexity of O(2) i.e. an upper bound of 2 units of time (which is processor dependent). 1 for the += operation and another for assigning the value of 2.Code:int i = 0; i += 2;
Given the matrix a[x][y], a comparison would be O(n^2) since you are essentially sayingbecause it is obviously a nested loop. n being the number of times being looped.Code:for (int i = 0; i < x; i++) { for(int j = 0; j < y; j++) { a[i][j] = some arbitrary value; } }
In your case, you are using a[z][y][z] which is O(n^3). This means for a matrix of [1000][1000][1000] it would take 1000^3 units of time just to initialize.
The client does this all the time and it's no problem since it does it only for the region you are cureently in.
But for the server, where it handles 1000's of other things simultaneously, it can have severe memory costs.
You have to keep track of all regions, not just the one you are in.
Still not satisfied? [Only registered and activated users can see links. ] might give you a bit more detail.
^ just do it as graham suggested 3rd way which is adding another dimension in the location class , means when checking for location in all over the server it will not match the current dimension so basically here what happens in the main part you want : playerupdating, and npcupdating you check the player or npc location as usual and the new dimension thus making the server determined which players are in the same region and which are not according to all the [x][y][z][instanceId]
Woah very nice, thanks for this!
Graham's thread (which was mentioned previously in this thread): [Only registered and activated users can see links. ]
and his code from hyperion or apollo:
It's not abundantly clear to me how this works, or how to use it.Code:/** * Sends the packet to construct a map region. * @param palette The palette of map regions, int[13][13] array. * @return The action sender instance, for chaining. */ public ActionSender sendConstructMapRegion(int[][] palette) { player.setLastKnownRegion(player.getLocation()); PacketBuilder bldr = new PacketBuilder(241, Type.VARIABLE_SHORT); bldr.putShortA(player.getLocation().getRegionY() + 6); bldr.startBitAccess(); for(int z = 0; z < 4; z++) { for(int x = 0; x < 13; x++) { for(int y = 0; y < 13; y++) { boolean flag = z == player.getLocation().getZ(); bldr.putBits(1, flag ? 1 : 0); if(flag) { bldr.putBits(26, palette[x][y] << 14  palette[x][y] << 3); } } } } bldr.finishBitAccess(); bldr.putShort(player.getLocation().getRegionX() + 6); player.getSession().write(bldr.toPacket()); return this; }
« How to set your environmental variables  [RUSE] Whitelist system » 
Thread Information 
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) 