Author Topic: Cancel Display Bug  (Read 2455 times)

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
Cancel Display Bug
« on: 26 April 2008, 09:29:39 »
I tried fixing the cancel bug in GAE.

1. Where the info text is set when hovering on a 'phantom' cell below the image.
ie.

| 00 | 01 | 02 | 03
| 04 | 05 | 06 | 07
| 08 | 09 | 10 | 11
| 12 | 13 | 14 | 15
-------------------
| 16 | 17| 18 | 19    Invalid Pos


When selecting the worker, 12 is the autorepair and 15 is the cancel button. 16 will show autorepair and 19 will show cancel info text even though it is invalid.

Here is a screenshot of it. Note that the worker has stopped moving but the cancel button remains.



Code: [Select]
void Gui::mouseMoveDisplay(int x, int y){
computeInfoString(computePosDisplay(x, y));
}

void Gui::computeInfoString(int posDisplay){
...
                        if(posDisplay==cancelPos){
display.setInfoText(lang.get("Cancel"));
}
...
}

int Gui::computePosDisplay(int x, int y){
int posDisplay= display.computeDownIndex(x, y);

        if(posDisplay<0 || posDisplay>=Display::downCellCount){
posDisplay= invalidPos;
}
else if(selection.isComandable()){
if(posDisplay == cancelPos) {
//check cancel button
if(!selection.isCancelable() && !selectingBuilding){
posDisplay= invalidPos;
}
...
        return posDisplay;
}


In display.cpp/h
Code: [Select]
// definitions
        static const int cellSideCount= 4;
static const int upCellCount= cellSideCount*cellSideCount;
static const int downCellCount= cellSideCount*cellSideCount;
static const int colorCount= 4;
static const int imageSize= 32;
static const int invalidPos= -1;
static const int downY = imageSize*9;
static const int infoStringY= imageSize*4;

int Display::computeDownIndex(int x, int y){
y= y-(downY-cellSideCount*imageSize);

if(y>imageSize*cellSideCount){
return invalidPos;
}

int cellX= x/imageSize;
int cellY= (y/imageSize) % cellSideCount;
int index= (cellSideCount-cellY-1)*cellSideCount+cellX;;

if(index<0 || index>=downCellCount || downImages[index]==NULL){
index= invalidPos;
}

return index;
}

Therefore I think the problem lies in computeDownIndex but there is no commenting so I have no idea what is happening.

2. The cancel button doesn't disappear when the unit stops the command.

From selection.cpp/h
Code: [Select]
bool isCancelable() const {return cancelable;}
From gui.cpp
Code: [Select]
void Gui::computeDisplay(){
...
if(selection.isCancelable()){
display.setDownImage(cancelPos, ut->getCancelImage());
display.setDownLighted(cancelPos, true);
}
...
}

From selection.cpp
Code: [Select]
void Selection::update() {
...
cancelable = cancelable || ((*i)->anyCommand()
&& (*i)->getCurrCommand()->getCommandType()->getClass() != ccStop);
...
}


That is the only place that cancelable is modified therefore I think that is where the problem lies. Possibly the command is not being removed and anyCommand() is returning true when it should be false.
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

 

anything