Added safety checks for rendering, fixed crash in first level.

This commit is contained in:
Justin Marshall
2020-06-02 16:25:20 -07:00
parent e4b2ccf409
commit 22f3ea37de
4 changed files with 33 additions and 28 deletions
+20 -16
View File
@@ -571,14 +571,14 @@ void DisplayClass::Set_View_Dimensions(int x, int y, int width, int height)
// ST - 3/1/2019 12:05PM
// Made the below code more consistent with the width calculation. This is needed if we aren't going to draw the tabs at the top of the screen
//
if (height == -1) {
TacLeptonHeight = Pixel_To_Lepton(SeenBuff.Get_Height() - y);
//height = (SeenBuff.Get_Height()-y) / CELL_PIXEL_H;
}
else {
TacLeptonHeight = height * CELL_LEPTON_H;
}
//TacLeptonHeight = height * CELL_LEPTON_H;
//if (height == -1) {
// TacLeptonHeight = Pixel_To_Lepton(SeenBuff.Get_Height() - y);
// //height = (SeenBuff.Get_Height()-y) / CELL_PIXEL_H;
//}
//else {
// TacLeptonHeight = height * CELL_LEPTON_H;
//}
TacLeptonHeight = height * CELL_LEPTON_H;
/*
** Adjust the tactical cell if it is now in an invalid position
@@ -3096,13 +3096,17 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key)
** or release event, special mouse queuing storage variables are used. Other
** events must use the current mouse position globals.
*/
if (flags & (LEFTPRESS|LEFTRELEASE|RIGHTPRESS|RIGHTRELEASE)) {
x = Keyboard->MouseQX;
y = Keyboard->MouseQY;
} else {
x = Get_Mouse_X();
y = Get_Mouse_Y();
}
// jmarshall
//if (flags & (LEFTPRESS|LEFTRELEASE|RIGHTPRESS|RIGHTRELEASE)) {
// x = Keyboard->MouseQX;
// y = Keyboard->MouseQY;
//} else {
// x = Get_Mouse_X();
// y = Get_Mouse_Y();
//}
x = Get_Mouse_X();
y = Get_Mouse_Y();
// jmarshall end
bool edge = (y == 0 || x == 0 || x == SeenBuff.Get_Width()-1 || y == SeenBuff.Get_Height()-1);
COORDINATE coord = Map.Pixel_To_Coord(x, y);
CELL cell = Coord_Cell(coord);
@@ -3296,7 +3300,7 @@ int DisplayClass::TacticalClass::Action(unsigned flags, KeyNumType & key)
}
}
return(GadgetClass::Action(0, key));
return true; //(GadgetClass::Action(0, key));
}