public inbox for xconq7@sourceware.org
 help / color / mirror / Atom feed
* The selective fire-at command
@ 2004-08-17 22:15 Hans Ronne
  2004-08-17 22:59 ` Eric McDonald
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Ronne @ 2004-08-17 22:15 UTC (permalink / raw)
  To: xconq7

We have been arguing the merits of the selective fire-at command for the
last two days. Well, I've got news that will surprise some of you. The
selective fire-at command doesn't work in the tcltk interface. An as far as
I can tell from the CVS sources, it never worked.

First let me explain what I mean by a selective fire-at command, and until
now assumed that everybody else who was talking about it also meant. We
have two enemy units in the same cell, A and B. If I do a fire-into action,
one, both or neither unit will be hit, depending on the outcome. In
contrast, if I do a fire-at command ('f') with the cursor on top of A, I
will always hit A, never B. If I do the same thing with the cursor on top
of B, I will always hit B, never A. This is the whole point of the
selective command. You get to pick what unit to hit.

This is also how things work in the Mac interface. However, it is not how
the tcltk interface works. In the tcltk interface, I will always hit the
same unit (A) even if I target B. In fact, the unit that is hit (A) is
always the first unit in the stack. So the tcltk interface doesn't care one
iota about what unit I am trying to hit.

This is perhaps hard to believe, given the discussion we just had, but
there is a simple test that any of you can do to convince yourself that
what I am saying is true:

1. Launch the Magnuszew game.
2. Switch on see-all and sequential play.
3. Switch off both AIs and switch player to the German side.
4. Switch to survey mode and select one of the German mortars.

We are now ready for action. At the front of the Russian column, there are
two tanks, 1st SU85 and 2nd SU85. The 1st SU85 carries the 9th infantry
platoon inside.

5. Put the cursor on top of 1st SU85 and press 'f'. You will then hit 1st
SU85 and perhaps also the platoon inside. So far so good.

6. Now pick another mortar and target 2nd SU85. Amazingly, you will hit 1st
SU85 instead! In fact, no matter what other unit in the cell you try to
target, you will always hit 1st SU85 (since it is the first unit in the
stack).

Looking at the code, we can immediately understand why this is so (in fact
it was because I couldn't make sense of the code that I discovered the
whole thing). Here are the relevant lines from do_fire in tkcmd.c:

	sx = map->inpsx;  sy = map->inpsy;

	if (nearest_cell(widget_vp(map), sx, sy, &x, &y, NULL, NULL)) {
	    common_fire_at(unit, x, y);
	} else {
	    cmd_error(dside, "Cannot fire outside the world!");
	}

You will notice that the pixel coordinates are converted to (x, y) by
nearest_cell, and these cell coordinates are then passed on to
common_fire_at. What this means is that all information about what unit
within the cell you were trying to target is lost.

Looking further at common_fire_at we find:

    for_all_view_stack_with_occs(unit->side, x, y, uview) {
        /* And which are not on our side. Note that we are allowed to
           hit other trusted sides, though doing so may make them not
           trusted for long. :-) */
        if (unit->side != side_n(uview->siden)) {
            other = uview->unit;
            /* Assume we have the right target. (Bad assumption,
               but what else can one do with the info presently available?) */
            break;
        }

The code iterates through the stack and always selects the first enemy unit
it finds as "other". Which is then passed on to the kernel. QED.

Now, two comments. First, the fire-at command does work in the Mac
interface since the pixel coordinates are passed on and the unit under the
cursor is identified. Second, the tcltk (and Mac) attack commands also work
as expected. I won't give you the deatils, but you can check out the
sources and try for yourself.

I will try to fix the fire-at command since I am hacking the tcltk sources
anyway. It should not be too difficult given the fact that we have a
working command in the Mac interface.

Hans


















^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: The selective fire-at command
  2004-08-17 22:15 The selective fire-at command Hans Ronne
@ 2004-08-17 22:59 ` Eric McDonald
  2004-08-17 23:25   ` Hans Ronne
  0 siblings, 1 reply; 6+ messages in thread
From: Eric McDonald @ 2004-08-17 22:59 UTC (permalink / raw)
  To: Hans Ronne; +Cc: xconq7

On Tue, 17 Aug 2004, Hans Ronne wrote:

> You will notice that the pixel coordinates are converted to (x, y) by
> nearest_cell, and these cell coordinates are then passed on to
> common_fire_at. What this means is that all information about what unit
> within the cell you were trying to target is lost.

Right, and that caused problems later on when one needed more 
information in the 'common_fire_at' routine.

>         if (unit->side != side_n(uview->siden)) {
>             other = uview->unit;
>             /* Assume we have the right target. (Bad assumption,
>                but what else can one do with the info presently available?) */

I think the comment says it all. The function did what it could 
with the info available.

> Now, two comments. First, the fire-at command does work in the Mac
> interface since the pixel coordinates are passed on and the unit under the
> cursor is identified. 

I think that when I was working on the Dec 29 fix, I wanted to fix 
this as well, but wasn't sure how to go about it because I didn't 
know the Tcl/Tk interface code all that well. In retrospect, I 
should have looked at the attack code for guidance.

Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: The selective fire-at command
  2004-08-17 22:59 ` Eric McDonald
@ 2004-08-17 23:25   ` Hans Ronne
  2004-08-17 23:36     ` Eric McDonald
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Ronne @ 2004-08-17 23:25 UTC (permalink / raw)
  To: Eric McDonald; +Cc: xconq7

>I think that when I was working on the Dec 29 fix, I wanted to fix
>this as well, but wasn't sure how to go about it because I didn't
>know the Tcl/Tk interface code all that well. In retrospect, I
>should have looked at the attack code for guidance.

It's not your fault that the command doesn't work. As I said, the previous
version didn't work either, as far as I can tell from the CVS sources, and
your December hack was certainly a major improvement with respect to other
problems. The fact that nobody discovered that the command doesn't work for
many years shows that it's a very subtle bug (or a seldomly used command).

I found it paradoxical, though, that those who argued that this is a very
useful command which should be kept at all costs have never been able to
use it, while I, who do have a selective fire-at command on my Mac don't
find it particularly useful :-).

Hans


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: The selective fire-at command
  2004-08-17 23:25   ` Hans Ronne
@ 2004-08-17 23:36     ` Eric McDonald
  2004-08-18  0:48       ` Hans Ronne
  0 siblings, 1 reply; 6+ messages in thread
From: Eric McDonald @ 2004-08-17 23:36 UTC (permalink / raw)
  To: Hans Ronne; +Cc: xconq7

On Wed, 18 Aug 2004, Hans Ronne wrote:

> problems. The fact that nobody discovered that the command doesn't work for
> many years shows that it's a very subtle bug (or a seldomly used command).

I would say the former and not the latter. I have, in fact, used 
this command to fire at a single unit so that a mouse click does 
not accidentally advance into a cell (when the opponent exerts a 
ZOC range of -1, for example).

I have also thought that I was firing at a select unit when more 
than one unit was present in a cell before. Of course, I was 
obviously under the delusion that my choice of target was being 
hit, and did not pay close attention to where the firing lines 
where being drawn. Mea culpa, I guess. But, the fact that I 
thought I was using something, but was not, does not mean that it 
is not useful.

Of course, when an unit with a large image is occupied, then it 
obscures the entire cell, and so it is not possible to even click 
on the edge of the cell to enter it. (Or this is my recollection 
anyway.)

> I found it paradoxical, though, that those who argued that this is a very
> useful command which should be kept at all costs have never been able to
> use it, while I, who do have a selective fire-at command on my Mac don't
> find it particularly useful :-).

The sarcasm was not lost on me. However, I do not think we should 
let it detract from the good arguments about the usefulness of the 
command and its corresponding action. Nor should we let it derail 
the 'fire-into' semantics debate, until that is all straightened 
out. Also, as you pointed out, the attack command and 
corresponding action did work as advertized, and so it cannot be 
claimed that those who advocated it were using it under a 
delusion in the way that I was using fire under a delusion.

These are important changes that are being discussed, and it 
would be a pity if the arguments were swept under the rug because 
someone was cast as a hypocrite of sorts.

Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: The selective fire-at command
  2004-08-17 23:36     ` Eric McDonald
@ 2004-08-18  0:48       ` Hans Ronne
  2004-08-18  3:00         ` Eric McDonald
  0 siblings, 1 reply; 6+ messages in thread
From: Hans Ronne @ 2004-08-18  0:48 UTC (permalink / raw)
  To: Eric McDonald; +Cc: xconq7

>out. Also, as you pointed out, the attack command and
>corresponding action did work as advertized, and so it cannot be
>claimed that those who advocated it were using it under a
>delusion in the way that I was using fire under a delusion.

Indeed, and as I also stated I can appreciate the potential usefulness of
both commands, even if I rarely use them myself. Keeping them is on my
revised agenda, and I am even trying to fix the tcltk fire-at command so
that it finally will work.

Hans


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: The selective fire-at command
  2004-08-18  0:48       ` Hans Ronne
@ 2004-08-18  3:00         ` Eric McDonald
  0 siblings, 0 replies; 6+ messages in thread
From: Eric McDonald @ 2004-08-18  3:00 UTC (permalink / raw)
  To: Hans Ronne; +Cc: xconq7

Hans Ronne wrote:

> Indeed, and as I also stated I can appreciate the potential usefulness of
> both commands, even if I rarely use them myself. Keeping them is on my
> revised agenda, and I am even trying to fix the tcltk fire-at command so
> that it finally will work.

Excellent.

Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-18  0:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-17 22:15 The selective fire-at command Hans Ronne
2004-08-17 22:59 ` Eric McDonald
2004-08-17 23:25   ` Hans Ronne
2004-08-17 23:36     ` Eric McDonald
2004-08-18  0:48       ` Hans Ronne
2004-08-18  3:00         ` Eric McDonald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).