Bug report: gadget handler skips frames

Bug report: gadget handler skips frames

Classic game design, maintained to please you...

Moderator: Content Developer

Post Reply
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Bug report: gadget handler skips frames

Post by quantum » 13 Nov 2010, 18:31

This is what I get if I print the frame number in GameFrame:

Code: Select all

[      0] Hello from frame 0
[      2] Hello from frame 2
[      3] Hello from frame 3
[      4] Hello from frame 4
[      5] Hello from frame 5
[      6] Hello from frame 6
[      7] Hello from frame 7
[      8] Hello from frame 8
[      9] Hello from frame 9
[     10] Hello from frame 10
...
Frame 1 is skipped. Other mods I've tested don't have this issue (The Cursed, S44, ZK).
0 x

SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: Bug report: gadget handler skips frames

Post by SirMaverick » 13 Nov 2010, 18:40

They can have this issue if there is a gadget that gets removed. I think that might be the reason here, too.

See http://springrts.com/mantis/view.php?id=1907
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan » 13 Nov 2010, 20:03

The problem has been known for a while. It's not only a
problem with the lua event handling, it's also present in
the C++ EventHandler.

For BZFlag, I rewrote both the C++ and lua event
handling to use lists instead of arrays. List iterators
are unaffected by insertions and deletions of other
iterators. The lua event list code is actually faster than
the code that SpringRTS is currently using (the lua list
implementation is surprising fast compared to array
iteration, and the BZFlag lua event handling code doesn't
have to do named function lookups).
0 x

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Bug report: gadget handler skips frames

Post by jK » 13 Nov 2010, 20:14

trepan wrote:the BZFlag lua event handling code doesn't
have to do named function lookups
How?
I thought Lua doesn't support `pointers` to lua_objects (note even a LUA_REGISTRYINDEX is a table lookup).

PS: I am working on the gadget-/widget handlers atm,
so the lua side will get fixed soon enough.
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan » 13 Nov 2010, 20:19

jK wrote:
trepan wrote:the BZFlag lua event handling code doesn't
have to do named function lookups
Instead of doing a widget["func_name"] lookup for each
function call, the functions are registered into the ordered
event lists.

simplified iteration example:

Code: Select all

local node = eventlist.start
while (node) do
  node.func(...)
  node = node.next
end
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan » 13 Nov 2010, 20:22

As you can see from the last commit date,
this hasn't been touched in a while. As a
matter of fact, almost all BZFlag development
has ceased 8^)

EventClientList.h
http://bzflag.svn.sourceforge.net/viewv ... iew=markup
Last edited by trepan on 13 Nov 2010, 20:24, edited 1 time in total.
0 x

User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Bug report: gadget handler skips frames

Post by jK » 13 Nov 2010, 20:23

trepan wrote:
jK wrote:
trepan wrote:the BZFlag lua event handling code doesn't
have to do named function lookups
Instead of doing a widget["func_name"] lookup for each
function call, the functions are registered into the ordered
event lists.

simplified iteration example:

Code: Select all

local node = eventlist.start
while (node) do
  node.func(...)
  node = node.next
end
ah,
I thought you were still talking about the engine eventhandler.
0 x

trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan » 13 Nov 2010, 20:32

One thing to note about the EventClientList.h example
is the "purify()" function (if anyone wants to take a shot
at fixing the C++ code). The reason for purify() is to
avoid problems when an EventClient is removed while
the list iterator pointing to it is active (being used to run
code).

One trick to solving this problem is shown in the following
header file (look for the CallbackList<F>::doIterate() method):
http://bzflag.svn.sourceforge.net/viewv ... iew=markup

That's seemed clunky to me, so instead I setup a dummy
EventClient instance, and replaced the EventClient pointer
in the list with the dummy instance (which has member
functions that don't do anything). A 'purify' flag is set on any
EventClientList with a removal, and you just have to clean
out the dummy instance pointers every once in a while.
0 x

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7017
Joined: 16 Nov 2004, 13:08

Re: Bug report: gadget handler skips frames

Post by zwzsg » 14 Nov 2010, 07:20

quantum wrote:Bug report: gadget handler skips frames

Frame 1 is skipped.
I encountered this problem as well. lurker wrote me a gadget handler patch to fix this. See my "hotfixes.lua" gadget (in KP for instance). Eh, I actually even have released a BA version with this fix: http://springrts.com/phpbb/viewtopic.php?f=44&t=24034
0 x

Post Reply

Return to “Balanced Annihilation”