In the swing version of BoardView1, there are two places that draw the sprites related to artillery (auto-hit sprites, the incoming artillery arrow). The first is in the drawArtilleryHex(1) method. This appears to be new functionality in the swing version of the BoardView1.
The second is this chunk of code:
:::java
//draw special stuff for the hex
final Collection<SpecialHexDisplay> shdList = game.getBoard().getSpecialHexDisplay(c);
if(shdList != null) {
for(SpecialHexDisplay shd : shdList)
{
if (shd.drawNow(game.getPhase(), game.getRoundCount(),localPlayer.getName())) {
scaledImage = getScaledImage(shd.getType().getDefaultImage());
if(scaledImage != null) {
boardGraph.drawImage(scaledImage, drawX, drawY, this);
}
}
}
}
This "specialhexdisplay" version appears to be from the AWT version of BoardView1.
The result of this is that some of the swing code doesn't function properly. Looking at the swing code, it's clear that the intent is to only draw the auto-hit sprite when an artillery weapon is actually selected. Because the sprite is drawn twice, this behavior gets overwritten.
Additionally, the tooltip that is displayed for the sprite only works when an artillery weapon is selected, meaning that the sprite sometimes has a tooltip and sometimes doesn't.
Fixed in [r9628].
The first step was to remove the "specialhexdisplay" version that was from the AWT version of BoardView1. However, there were some bugs in drawArtilleryHex, plus the code wasn't very efficient. It would iterate through all of visible hexes and see if they needed to be drawn on.
A better way is to iterate through the cases that would cause hexes to be updated. That is, iterate through the auto-hit designated hexes and the hexes with incoming artillery attacks. Since the number of these is generally going to be very low, this is a better way to do it. I rewrote the drawArtilleryHexes function to work this way.
There was still a bug after this: incoming artillery strikes wouldn't be displayed right away. This was because the server didn't update the artillery attacks stored in the game object until after the offboard firing phase. I added an update in the server code at the end of the targeting phase as well.
From what I can tell, the code related to SpecialHexDisplay in Board and in weapon handlers is now only required for the AWT gui. When we remove the AWT gui, this code should be removed as well.
Related
Commit: [r9628]
Ticket [#4001] and [r10385] are related to this ticket.
Related
Bugs:
#4001Commit: [r10385]