Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Bug Game Event Handlers - Loop Delay

Joined
Mar 26, 2014
Messages
33
The performance of some of the game event handlers validates is having an impact on the loop delay.

Code:
import com.runemate.game.api.hybrid.GameEvents;
import com.runemate.game.api.script.framework.LoopingBot;

import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;


/**
* Created by Tom (Overflow).
*/
public class EventHandlerDebug extends LoopingBot {

    long b = System.currentTimeMillis();
    int count = 0;
    Deque<GameEvents.GameEvent> events = new LinkedList<>();
    GameEvents.GameEvent current;

    @Override
    public void onStart(String... strings) {
        super.onStart(strings);
        this.setLoopDelay(100);
        Collections.addAll(events, GameEvents.RS3.values());
    }

    public void onLoop() {
        System.out.printf("With %s enabled loop took %s\n", current != null ? current.getName() : "NA", (System.currentTimeMillis() - b));
        if (current == null || count++ > 5) {
            if (current != null) {
                events.addLast(current);
            }
            events.forEach(GameEvents.GameEvent::disable);
            current = events.pollFirst();
            current.enable();
            count = 0;
        }
        b = System.currentTimeMillis();
    }
}

On my system running the above the interface closer takes 800 - 900ms and the grim reaper around 100ms to validate. The reaper isn't a massive problem, 100ms could be accounted for within the specified delay of each loop but the interface closer is an issue.
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
This issue is acknowledged by myself. I ran some genuine profiling and as expected they were understandably expensive. I'll come up with a solution in th near future.
 
Top