[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnubg] Scratching a couple of itches ...
From: |
Nis Jorgensen |
Subject: |
Re: [Bug-gnubg] Scratching a couple of itches ... |
Date: |
Tue, 29 Jun 2004 11:08:41 +0200 |
User-agent: |
Mozilla Thunderbird 0.6 (Windows/20040502) |
Nis Jorgensen wrote:
>Jon Kinsey wrote:
>
>>Pos: xsYBAF+27S0AAA
>>Match: cIl4AAAAAAAA
>>
>>Click on 6 point - illegal move and chequer on bar disappears.
>>
>>Pos: W9sLABDzDgAAAA
>>Match: QgmxAAAAAAAA
>>
>>Click on 4 point - hits on 2 point, also can't take chequer off board.
>>
>>
>Confirmed. I wasn't aware that this function was used for placing
>checkers when clicking, as well as drag-n-dropping. That does make
>things more complicated (and explains part of the procedure which I did
>not understand the reason for before).
>
>I will aim to have a fix ready tomorrow.
>
>
Attached.
(someone with cvs write access please apply this)
/Nis
Index: gtkboard.c
===================================================================
RCS file: /cvsroot/gnubg/gnubg/gtkboard.c,v
retrieving revision 1.185
diff -u -r1.185 gtkboard.c
--- gtkboard.c 27 Jun 2004 10:51:28 -0000 1.185
+++ gtkboard.c 29 Jun 2004 08:55:18 -0000
@@ -1226,7 +1226,7 @@
* list of valid destination points (since we have the code for that
available
*
* Known problems:
-
+ *
* Not tested for "allow dragging to illegal points". Unlikely to work,
might crash
* It is not possible to drag checkers from the bearoff tray. This must be
corrected in
* the pick-up code - this proc should be ready for it.
@@ -1277,29 +1277,31 @@
bd->points[ bar ] -= bd->drag_colour;
board_invalidate_point( bd, bar );
}
+
if ( bd->diceRoll[0] == bd->diceRoll[1] ) {
for (i = 1; i <= 3; i++) {
passpoint = source - i * bd->diceRoll[0] * bd->drag_colour;
- if ((dest2 - passpoint) * bd->drag_colour > 0 ) break;
- if (bd->points[ passpoint ] == - bd->drag_colour) {
+ if ((dest2 - passpoint) * bd->drag_colour >= 0 ) break;
+ if (bd->points[ passpoint ] == -bd->drag_colour) {
hit++;
hitCheckers[ i ] = passpoint;
- bd->points[ passpoint ] = 0;
+ bd->points[ passpoint ] += bd->drag_colour;
bd->points[ bar ] -= bd->drag_colour;
board_invalidate_point( bd, bar );
board_invalidate_point( bd, passpoint );
}
}
} else {
- if (ABS(source - dest2) == bd->diceRoll [ 0 ] + bd->diceRoll [ 1 ]
- || dest > 25 )
+ if (ABS(source - dest2) == bd->diceRoll [ 0 ] + bd->diceRoll [ 1 ]
|| (
+ dest > 25 && ABS (source - dest2) > MAX (bd->diceRoll[ 0 ],
bd->diceRoll[ 1 ]))
+ )
for (i = 0; i < 2; i++) {
passpoint = source - bd->diceRoll[ i ] * bd->drag_colour;
- if ((dest2 - passpoint) * bd->drag_colour > 0 ) continue;
+ if ((dest2 - passpoint) * bd->drag_colour >= 0 ) continue;
if (bd->points[ passpoint ] == - bd->drag_colour) {
hit++;
hitCheckers[ i + 1 ] = passpoint;
- bd->points[ passpoint ] = 0;
+ bd->points[ passpoint ] += bd->drag_colour;
bd->points[ bar ] -= bd->drag_colour;
board_invalidate_point( bd, bar );
board_invalidate_point( bd, passpoint );
@@ -1308,7 +1310,7 @@
}
}
}
- } else {
+ } else if ( (source - dest2) * bd->drag_colour < 0 ) {
/*
* Check for taking chequer off point where we hit
@@ -1366,12 +1368,9 @@
bd->points[ dest ] += bd->drag_colour;
board_invalidate_point( bd, dest );
-/* Not sure why this was made conditional on dest != source
- * I encountered at least one case where it was needed anyway (when we tried
- * to unhit on that point so commenting out */
-/* if( source != dest ) { */
- if( update_move( bd ) && !fGUIIllegal ) {
+ if( source != dest ) {
+ if( update_move( bd ) && !fGUIIllegal ) {
/* the move was illegal; undo it */
bd->points[ source ] += bd->drag_colour;
board_invalidate_point( bd, source );
@@ -1387,7 +1386,7 @@
}
}
- if ( unhit > 0 ) {
+ if ( unhit > 0 ) {
bd->points[ bar ] -= unhit * bd->drag_colour;
board_invalidate_point( bd, bar );
for (i = 0; i < 4; i++)
@@ -1399,10 +1398,10 @@
update_move( bd );
placed = FALSE;
- }
-/* } */
+ }
+ }
- board_invalidate_point( bd, placed ? dest : bd->drag_point );
+ board_invalidate_point( bd, placed ? dest : source );
#if USE_BOARD3D
if (bd->rd->fDisplayType == DT_3D && bd->rd->quickDraw)