Forum: PogamutUT2004

Raytracing Bug

There seems to be a bug with raytracing. I was using the RaycastingBot to learn about rays, and I noticed that although this bot defines 5 AutoTraceRays, it only references 3 of them in the flagChanged method of the listener that checks the rays. If you change the body of that method from:
-----------
left = raycasting.getRay(LEFT45);
front = raycasting.getRay(FRONT);
right = raycasting.getRay(RIGHT45);
------------
to
------------
System.out.println("traces");
AutoTraceRay temp = raycasting.getRay(LEFT90);
left = raycasting.getRay(LEFT45);
front = raycasting.getRay(FRONT);
right = raycasting.getRay(RIGHT45);
temp = raycasting.getRay(RIGHT90);
System.out.println("finished");
------------

Then the method hangs forever. I know this because the "finished" at the end never gets printed. Finding this bug was pretty annoying. This was all in 3.0.11 by the way.

On a related note, why isn't there a method like getAutoTraces() anymore that simply returns the current state of all previously defined autotraces?
Hi.
I've look into in quickly - it is a problem of the last ray that is added (RIGHT90), for some reason, if you query the last ray added by raycasting.createRay in flagChanged method, it will freeze there.
If you add another ray that will be added after RIGHT90, the code above will work.

I do not know where the bug is yet (I am suspecting GameBots2004), I'll look into this later.

Thx for bug report,
Michal
Still working on the issue. Seems it is not at the GameBots2004 side. If you want ray tracing to work properly, do not use flagChanged method and instead make a listener to AutoTraceRay objects. E.g.:

IWorldObjectListener<AutoTraceRay> myObjList = new IWorldObjectListener<AutoTraceRay>() {

        public void notify(IWorldObjectEventr<AutoTraceRay> event) {
            user.severe("Event: " + event.toString() + "; Id: " + event.getObject().getId().getStringId());
        }
    };


Do not forget to register this listener with worldview through:

getWorldView().addObjectListener(AutoTraceRay.class, myObjList);


Best,
Michal
Hi!

I'll look at this issue as well (this Friday).

Best!
Jimmy
It is fixed in the SVN. It was my fault ... wrong order of two method calls, one of them was latch.countDown() :-)
R
Great! Thanks Ruda :-)

Jakub