Thread: Instanced Area Design

Page 4 of 4 FirstFirst ... 234
Results 31 to 38 of 38
  1. #31  
    Registered Member
    A Wild Gengar's Avatar
    Join Date
    Apr 2016
    Posts
    96
    Thanks given
    63
    Thanks received
    49
    Rep Power
    101
    Allow me to educate, young grasshopper.

    It's pure intuition if you have have studied complexity analysis of algorithms which you can read about here.
    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? this might give you a bit more detail.
    Reply With Quote  
     

  2. Thankful users:


  3. #32  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by A Wild Gengar View Post
    Allow me to educate, young grasshopper.

    It's pure intuition if you have have studied complexity analysis of algorithms which you can read about here.
    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? this 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.
    Reply With Quote  
     

  4. #33  
    Registered Member Anan's Avatar
    Join Date
    Oct 2008
    Posts
    408
    Thanks given
    5
    Thanks received
    27
    Rep Power
    15
    ^ 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]
    Reply With Quote  
     

  5. #34  
    Registered Member
    Join Date
    Sep 2015
    Posts
    68
    Thanks given
    41
    Thanks received
    75
    Rep Power
    36
    Woah very nice, thanks for this!
    Reply With Quote  
     

  6. #35  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Quote Originally Posted by A Wild Gengar View Post
    Allow me to educate, young grasshopper.

    It's pure intuition if you have have studied complexity analysis of algorithms which you can read about here.
    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? this 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.
    Reply With Quote  
     

  7. Thankful user:


  8. #36  
    Registered Member
    Join Date
    Feb 2017
    Posts
    1
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by PasswordSucks View Post
    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): https://www.rune-server.ee/runescape...on-packet.html

    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.
    Reply With Quote  
     

  9. #37  
    Registered Member
    Join Date
    Jan 2014
    Posts
    13
    Thanks given
    0
    Thanks received
    2
    Rep Power
    11
    Quote Originally Posted by Eclipse View Post
    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

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

  10. #38  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Quote Originally Posted by Gaylord View Post
    You're making fun of a kid in your signature for not being a Java expert, but you, too, are asking a simple question

    OT: Code looks clean!! Good job and thanks for sharing!
    1. look at your username..
    2. that was a year ago, and i was confused and was asking for clarification.
    3. seriously wtf is w your username

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

Page 4 of 4 FirstFirst ... 234

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [718] Instanced Areas
    By Soulevoker in forum Help
    Replies: 2
    Last Post: 04-22-2015, 02:16 AM
  2. [718+] Adding music to designated area.
    By Grown in forum Requests
    Replies: 9
    Last Post: 08-26-2013, 09:12 AM
  3. Instanced Area
    By jacob34 in forum Help
    Replies: 2
    Last Post: 06-16-2013, 05:05 PM
  4. 718 Instanced Areas
    By jacob34 in forum Help
    Replies: 3
    Last Post: 06-10-2013, 09:04 AM
  5. [718] Player Instanced Areas
    By Arcanelights in forum Help
    Replies: 1
    Last Post: 05-22-2013, 12:00 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •