After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 516992 - Lose life on pressing "backwards" when in network game
Lose life on pressing "backwards" when in network game
Status: RESOLVED FIXED
Product: gnome-games-superseded
Classification: Deprecated
Component: gnibbles
2.21.x
Other All
: Normal minor
: ---
Assigned To: GNOME Games maintainers
GNOME Games maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-17 13:16 UTC by Roger Light
Modified: 2009-04-13 16:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (806 bytes, patch)
2008-11-23 15:48 UTC, Roger Light
committed Details | Review

Description Roger Light 2008-02-17 13:16:09 UTC
Please describe the problem:
In a non-network game of gnibbles, pressing the key for the opposite direction that the worm is travelling (ie. backwards) does nothing.

In a network game, pressing backwards kills the worm - but only for three directions. The fourth direction functions the same as in a non-network game.

Steps to reproduce:
1. Start a network game of gnibbles.
2. Press the key for the opposite direction to which you are travelling.
3. Repeat for all directions.


Actual results:
Worm dies when going backwards for three of the directions and not for the other.

Expected results:
Either the worm should die when going backwards for all four directions or it should die on non of them (which would be consistent with the non-network game mode).

Does this happen every time?


Other information:
Comment 1 Roger Light 2008-11-23 15:48:19 UTC
Created attachment 123266 [details] [review]
Proposed patch
Comment 2 Andreas Røsdal 2008-12-08 20:02:19 UTC
I've just had a quick look at the patch, but here are some questions that might be useful when testing it:

-Does this change break network compatibility with older gnibbles clients?
-Is the correct worm moved to the new direction as specified by the keypress event? 
-Does the patch work correctly for both network and single player games?

For example, why do you always modify the first worm, like this  "worms[0]" ?

Other than that, it's great that someone is improving the network support in gnibbles. Note that there is a lot that can be improved in this area.
Comment 3 Roger Light 2008-12-09 00:26:45 UTC
This is a client side only patch that occasionally prevents data being sent to the server that is forbidden during non-networked play. As all that is happening is that we aren't sending a move that is invalid anyway, it doesn't break compatibility with older gnibbles clients as far as I can tell. It just amounts to the player not having pressed backwards.

The patch only affects networked play.

Looking at the rest of the code, it seems that during network mode the local player is always worms[0]. The other players still exist as worms[n]. The patch modifies the client so that it only considers the state of the local player when comparing it to the keyboard input. When pressing backwards without the patch, the client will look at worms[0] and conclude that nothing should be done because it is an invalid move. The loop will then iterate and consider worm[1], which may or may not be travelling in the same direction as worm[0]. If it is not travelling in the same direction then "backwards" will be a valid move and get transmitted to the server, and worm[0] will die. With the patch only worms[0] is considered just the same as with the rest of the code when in networked mode.
Comment 4 Thomas Andersen 2009-03-30 16:06:50 UTC
Patch committed to trunk as r8960:
http://svn.gnome.org/viewvc/gnome-games?view=revision&revision=8960

Potential patch for 2.26.x

Thanks for the patch Roger. I will make sure to spell you name correctly in the NEWS/announce mail this time :)
Comment 5 Jason Clinton 2009-04-13 16:24:48 UTC
Cherry picked to 2.26