From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19160 invoked by alias); 17 Aug 2004 21:55:38 -0000 Mailing-List: contact xconq7-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: xconq7-owner@sources.redhat.com Received: (qmail 19151 invoked from network); 17 Aug 2004 21:55:36 -0000 Received: from unknown (HELO av6-1-sn2.hy.skanova.net) (81.228.8.106) by sourceware.org with SMTP; 17 Aug 2004 21:55:36 -0000 Received: by av6-1-sn2.hy.skanova.net (Postfix, from userid 502) id 2E70C37E66; Tue, 17 Aug 2004 23:55:36 +0200 (CEST) Received: from smtp2-2-sn2.hy.skanova.net (smtp2-2-sn2.hy.skanova.net [81.228.8.178]) by av6-1-sn2.hy.skanova.net (Postfix) with ESMTP id 1B57337E43 for ; Tue, 17 Aug 2004 23:55:36 +0200 (CEST) Received: from [212.181.162.155] (h155n1fls24o1048.bredband.comhem.se [212.181.162.155]) by smtp2-2-sn2.hy.skanova.net (Postfix) with ESMTP id A310937E44 for ; Tue, 17 Aug 2004 23:55:35 +0200 (CEST) X-Sender: u22611592@m1.226.comhem.se Message-Id: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Tue, 17 Aug 2004 22:15:00 -0000 To: xconq7@sources.redhat.com From: Hans Ronne Subject: The selective fire-at command X-SW-Source: 2004/txt/msg00937.txt.bz2 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