1. 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,
Code:
``````int i = 0;
i += 2;``````
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.

Given the matrix a[x][y], a comparison would be O(n^2) since you are essentially saying
Code:
``````for (int i = 0; i < x; i++) {
for(int j = 0; j < y; j++) {
a[i][j] = some arbitrary value;
}
}``````
because it is obviously a nested loop. n being the number of times being looped.

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.

2. Thankful users:

3. Originally Posted by A Wild Gengar
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,
Code:
``````int i = 0;
i += 2;``````
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.

Given the matrix a[x][y], a comparison would be O(n^2) since you are essentially saying
Code:
``````for (int i = 0; i < x; i++) {
for(int j = 0; j < y; j++) {
a[i][j] = some arbitrary value;
}
}``````
because it is obviously a nested loop. n being the number of times being looped.

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.
Let me just say that I've only read the first sentence, made me chuckle. I'll edit this shortly once I read, sensei.

Edit; Thank you that was a good read. No I have no prior knoweldge of this subject however I will give the link(s) you've provided a thorough read.

4. ^ 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]

5. Woah very nice, thanks for this!

6. Originally Posted by A Wild Gengar
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,
Code:
``````int i = 0;
i += 2;``````
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.

Given the matrix a[x][y], a comparison would be O(n^2) since you are essentially saying
Code:
``````for (int i = 0; i < x; i++) {
for(int j = 0; j < y; j++) {
a[i][j] = some arbitrary value;
}
}``````
because it is obviously a nested loop. n being the number of times being looped.

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.
Thank you again for this. Just re-read it and have considered re-writing the original post. I appreciate the time put into this response.

7. Thankful user:

Now this is some well documented code and well writted, however not to critisize, but there is a Packet to do this.

So packet 241 (or known on RSPS Wiki as 'Construct map region') creates and 8 x 8 'dynamic' map region of a specified, map. As 317 didn't have construction this was formely used for purposes like Tzaar based minigames, where it would be 'one-player'. This prevents other players games from intefering with your own. Research it, I think using the framework you have here for it with the Packet would make an awesome feature. Better than the +4 cheephax used years ago. I think it was Graham who documented the use of this packet im sure you'll find it on here somewhere. An people have used this im sure in the past to cheephax Construction onto Clients which never had it.

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:

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;
}``````
It's not abundantly clear to me how this works, or how to use it.

9. Originally Posted by Eclipse
so each time one player creates one instance, you need to create a whole class? kinda confused on if im looking at this correctly
You're making fun of a kid in your signature for not being a Java expert, but you, too, are asking a simple question :P

OT: Code looks clean!! Good job and thanks for sharing!

10. Originally Posted by Gaylord
You're making fun of a kid in your signature for not being a Java expert, but you, too, are asking a simple question :P

OT: Code looks clean!! Good job and thanks for sharing!
2. that was a year ago, and i was confused and was asking for clarification.