Thread: [PI] ItemHandler process tick removal

Results 1 to 7 of 7
  1. #1 [PI] ItemHandler process tick removal 
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    okay got bored and started looking through other classes having things being processed through the main server tick and since i was in itemhandler already, i looked there first, this is the only thing ive found being processed in itemhandler

    Code:
    		for(GroundItem i : Server.itemHandler.items) {
    			if(i.hideTicks > 0) {
    				i.hideTicks--;
    			}
    			if(i.hideTicks == 1) { // item can now be seen by others
    				i.hideTicks = 0;
    				Server.itemHandler.createGlobalItem(i);
    				i.removeTicks = ItemHandler.HIDE_TICKS;
    			}
    			if(i.removeTicks > 0) {
    				i.removeTicks--;
    			}
    			if(i.removeTicks == 1) {
    				i.removeTicks = 0;
    				Server.itemHandler.removeGlobalItem(i, i.getItemId(), i.getItemX(), i.getItemY(), i.getItemAmount());
    				break;
    			}
    		}
    so i was like k.. i can really just turn this to a simple task. so here we go..

    Code:
    package rs2.main.cycle.event.impl;
    
    import rs2.main.Server;
    import rs2.main.cycle.event.CycleEvent;
    import rs2.main.cycle.event.CycleEventContainer;
    import rs2.main.model.items.GroundItem;
    import rs2.main.world.ItemHandler;
    
    /**
     * Starts the task for ground item removal and hide ticks after an item is dropped
     * @author Final Project
     *
     */
    public class GroundItemEvent extends CycleEvent {
    
    	@Override
    	public void execute(CycleEventContainer container) {
    		for(GroundItem i : Server.itemHandler.items) {
    			System.out.println(Integer.toString(i.hideTicks) + "hide");
    			System.out.println(Integer.toString(i.removeTicks) + "remove");
    			if(i.hideTicks > 0) {
    				i.hideTicks--;
    			}
    			if(i.hideTicks == 1) { // item can now be seen by others
    				i.hideTicks = 0;
    				Server.itemHandler.createGlobalItem(i);
    				i.removeTicks = ItemHandler.HIDE_TICKS;
    			}
    			if(i.removeTicks > 0) {
    				i.removeTicks--;
    			}
    			if(i.removeTicks == 1) {
    				i.removeTicks = 0;
    				Server.itemHandler.removeGlobalItem(i, i.getItemId(), i.getItemX(), i.getItemY(), i.getItemAmount());
    				container.stop();
    				break;
    			}
    		}
    	}
    
    	@Override
    	public void stop() {
    		// TODO Auto-generated method stub
    		
    	}
    	
    }
    Code:
    	/**
    	* Creates the ground item 
    	**/
    	
    	public void createGroundItem(Client c, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
    		if(itemId > 0) {
    			c.getItems().createGroundItem(itemId, itemX, itemY, itemAmount);
    			GroundItem item = new GroundItem(itemId, itemX, itemY, itemAmount, c.playerId, HIDE_TICKS);
    			CycleEventHandler.getSingleton().addEvent(c, new GroundItemEvent(), 1);
    			addItem(item);
    		}
    	}
    no more things being processed in my itemhandler

    Code:
    	public void process() {
    
    	}
    sorry if im annoying people with all my process removal threads, but at least im contributing. these shits shouldve been released years ago.
    Reply With Quote  
     

  2. #2  
    Banned Market Banned Market Banned


    Join Date
    Jan 2011
    Age
    23
    Posts
    3,115
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    this is the exact same thing as using the process method
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    Quote Originally Posted by lare96 View Post
    this is the exact same thing as using the process method
    how so? unless this method is called somewhere i dont know of? public void createGroundItem(Client c, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
    if(itemId > 0) {
    c.getItems().createGroundItem(itemId, itemX, itemY, itemAmount);
    GroundItem item = new GroundItem(itemId, itemX, itemY, itemAmount, c.playerId, HIDE_TICKS);
    CycleEventHandler.getSingleton().addEvent(c, new GroundItemEvent(), 1);
    addItem(item);
    }
    }
    Reply With Quote  
     

  4. #4  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,108
    Thanks given
    2,402
    Thanks received
    2,825
    Rep Power
    4604
    Quote Originally Posted by Our Promise View Post
    how so? unless this method is called somewhere i dont know of? &nbspublic void createGroundItem(Client c, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
    if(itemId > 0) {
    c.getItems().createGroundItem(itemId, itemX, itemY, itemAmount);
    GroundItem item = new GroundItem(itemId, itemX, itemY, itemAmount, c.playerId, HIDE_TICKS);
    CycleEventHandler.getSingleton().addEvent(c, new GroundItemEvent(), 1);
    addItem(item);
    }
    }
    Lares right, all you're doing is creating new tasks to handle these operations. You're better off creating sub functions for each of these operations and ultimately calling them in process.
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Banned Market Banned Market Banned


    Join Date
    Jan 2011
    Age
    23
    Posts
    3,115
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Our Promise View Post
    how so? unless this method is called somewhere i dont know of? public void createGroundItem(Client c, int itemId, int itemX, int itemY, int itemAmount, int playerId) {
    if(itemId > 0) {
    c.getItems().createGroundItem(itemId, itemX, itemY, itemAmount);
    GroundItem item = new GroundItem(itemId, itemX, itemY, itemAmount, c.playerId, HIDE_TICKS);
    CycleEventHandler.getSingleton().addEvent(c, new GroundItemEvent(), 1);
    addItem(item);
    }
    }
    actually after looking at it more this is worse lol if there are 600 ground items dropped, you have 600 tasks running every single tick looping through the list of active items... so basically you have 600 tasks each looping through 600 ground items 600x600 = 360 000 loops.......................

    ACTUALLY after looking at it more this doesn't even look like it would work properly? if you spawned 5 ground items that would create 5 tasks that are all processing those 5 items at the same time, meaning your ground items would be processing 5 times as fast as they normally should

    The way I did my system at first was I assigned every single ground item object a task and that task would perform processing for that individual item only when needed, there was no looping at all. After a while I realized that was dumb and just went back to the old way of doing it, I now process all ground items every 10 ticks. There's nothing wrong with ticking ground item events every 600ms
    Reply With Quote  
     

  7. Thankful user:


  8. #6  
    Registered Member
    Join Date
    Oct 2013
    Posts
    775
    Thanks given
    48
    Thanks received
    104
    Rep Power
    14
    Quote Originally Posted by lare96 View Post
    actually after looking at it more this is worse lol if there are 600 ground items dropped, you have 600 tasks running every single tick looping through the list of active items... so basically you have 600 tasks each looping through 600 ground items 600x600 = 360 000 loops.......................

    ACTUALLY after looking at it more this doesn't even look like it would work properly? if you spawned 5 ground items that would create 5 tasks that are all processing those 5 items at the same time, meaning your ground items would be processing 5 times as fast as they normally should

    The way I did my system at first was I assigned every single ground item object a task and that task would perform processing for that individual item only when needed, there was no looping at all. After a while I realized that was dumb and just went back to the old way of doing it, I now process all ground items every 10 ticks. There's nothing wrong with ticking ground item events every 600ms
    Aha, did not think of all that while doing this, was just eager to get it out. I suppose you're right
    Reply With Quote  
     

  9. #7  
    Banned Market Banned Market Banned


    Join Date
    Jan 2011
    Age
    23
    Posts
    3,115
    Thanks given
    1,198
    Thanks received
    1,479
    Rep Power
    0
    Quote Originally Posted by Our Promise View Post
    Aha, did not think of all that while doing this, was just eager to get it out. I suppose you're right
    you should fix it so people aren't adding broken code into their servers
    Reply With Quote  
     


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. [PI] Remove itemHandler process.
    By Rhubarb in forum Snippets
    Replies: 6
    Last Post: 03-14-2014, 09:11 PM
  2. [PI] Process Usage Removal
    By Arithium in forum Snippets
    Replies: 13
    Last Post: 12-31-2011, 01:23 AM
  3. [PI] New Defend Hitsplats, removing the "0" [PI]
    By IcEbLiTzMeHh in forum Help
    Replies: 12
    Last Post: 03-01-2011, 01:05 AM
  4. Replies: 0
    Last Post: 12-25-2010, 02:58 AM
  5. [PI] How Do i remove Walls????
    By addicted in forum Help
    Replies: 0
    Last Post: 07-21-2010, 03:19 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
  •