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 »

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).
SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

Re: Bug report: gadget handler skips frames

Post by SirMaverick »

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
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan »

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).
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Bug report: gadget handler skips frames

Post by jK »

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.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan »

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
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan »

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.
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Bug report: gadget handler skips frames

Post by jK »

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.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: Bug report: gadget handler skips frames

Post by trepan »

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.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: Bug report: gadget handler skips frames

Post by zwzsg »

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
Post Reply

Return to “Balanced Annihilation”