GNOME Bugzilla – Bug 516992
Lose life on pressing "backwards" when in network game
Last modified: 2009-04-13 16:24:48 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:
Created attachment 123266 [details] [review] Proposed patch
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.
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.
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 :)
Cherry picked to 2.26