Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Fixed minimap crash when items were on the ground.

- Fixed broken savegame when craft is saved with invalid speed.
- Fixed battlescape crash when
- Added option to disable mouse in engine (mainly for Battlescape).
  • Loading branch information...
commit 2614234b60ce8cf952bc632d94d1fe96bceab736 1 parent c68a6a3
@SupSuper authored
View
12 src/Battlescape/BattlescapeGame.cpp
@@ -542,7 +542,17 @@ void BattlescapeGame::handleState()
{
if (!_states.empty())
{
- _states.front()->think();
+ // end turn request?
+ if (_states.front() == 0)
+ {
+ _states.pop_front();
+ endTurn();
+ return;
+ }
+ else
+ {
+ _states.front()->think();
+ }
getMap()->draw(); // redraw map
}
}
View
20 src/Battlescape/MiniMapView.cpp
@@ -113,22 +113,12 @@ void MiniMapView::draw()
Surface * s = _set->getFrame(frame);
s->blitNShade(this, x, y, 0);
}
- else
+ // perhaps (at least one) item on this tile?
+ if (!t->getInventory()->empty())
{
- // or perhaps (at least one) corpse on this tile?
- for (std::vector<BattleItem*>::iterator it = t->getInventory()->begin(); it != t->getInventory()->end(); ++it)
- {
- if ((*it)->getUnit())
- {
- int frame = t->getUnit()->getMiniMapSpriteIndex();
- int size = t->getUnit()->getArmor()->getSize();
- frame += (t->getPosition().y - t->getUnit()->getPosition().y) * size;
- frame += t->getPosition().x - t->getUnit()->getPosition().x;
- frame += _frame * size * size;
- Surface * s = _set->getFrame(frame);
- s->blitNShade(this, x, y, 0);
- }
- }
+ int frame = 9 + _frame;
+ Surface * s = _set->getFrame(frame);
+ s->blitNShade(this, x, y, 0);
}
px++;
View
23 src/Engine/Game.cpp
@@ -48,7 +48,7 @@ namespace OpenXcom
* @warning Currently the game is designed for 8bpp, so there's no telling what'll
* happen if you use a different value.
*/
-Game::Game(const std::string &title, int width, int height, int bpp) : _screen(0), _cursor(0), _lang(0), _states(), _deleted(), _res(0), _save(0), _rules(0), _quit(false), _init(false)
+Game::Game(const std::string &title, int width, int height, int bpp) : _screen(0), _cursor(0), _lang(0), _states(), _deleted(), _res(0), _save(0), _rules(0), _quit(false), _init(false), _mouseActive(true)
{
// Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0)
@@ -163,6 +163,15 @@ void Game::run()
// Process events
while (SDL_PollEvent(&_event))
{
+ // Skip mouse events if they're disabled
+ if (!_mouseActive &&
+ (_event.type == SDL_MOUSEMOTION ||
+ _event.type == SDL_MOUSEBUTTONDOWN ||
+ _event.type == SDL_MOUSEBUTTONUP))
+ {
+ continue;
+ }
+
if (_event.type == SDL_QUIT)
{
_quit = true;
@@ -412,4 +421,16 @@ void Game::setRuleset(Ruleset *rules)
_rules = rules;
}
+/**
+ * Sets whether the mouse is activated.
+ * If it is, mouse events are processed, otherwise
+ * they are ignored and the cursor is hidden.
+ * @param active Is mouse activated?
+ */
+void Game::setMouseActive(bool active)
+{
+ _mouseActive = active;
+ _cursor->setVisible(active);
+}
+
}
View
9 src/Engine/Game.h
@@ -54,6 +54,7 @@ class Game
Ruleset *_rules;
bool _quit, _init;
FpsCounter *_fpsCounter;
+ bool _mouseActive;
public:
/// Creates a new game and initializes SDL.
Game(const std::string &title, int width, int height, int bpp);
@@ -89,12 +90,14 @@ class Game
void setResourcePack(ResourcePack *res);
/// Gets the currently loaded saved game.
SavedGame *const getSavedGame() const;
- /// Sets a new saved game for the game
+ /// Sets a new saved game for the game.
void setSavedGame(SavedGame *save);
- /// Gets the currently loaded ruleset
+ /// Gets the currently loaded ruleset.
Ruleset *const getRuleset() const;
- /// Sets a new ruleset for the game
+ /// Sets a new ruleset for the game.
void setRuleset(Ruleset *rules);
+ /// Sets whether the mouse cursor is activated.
+ void setMouseActive(bool active);
};
}
View
2  src/Engine/Options.h
@@ -28,7 +28,7 @@ namespace OpenXcom
/**
* Enumeration for the battlescape scrolling types.
*/
-enum ScrollType { SCROLL_TRIGGER, SCROLL_AUTO, SCROLL_RMB };
+enum ScrollType { SCROLL_TRIGGER, SCROLL_AUTO };
/**
* Container for all the various global game options
View
2  src/Savegame/BattleUnit.cpp
@@ -1581,7 +1581,7 @@ int BattleUnit::getMiniMapSpriteIndex () const
// * 0-2 : Xcom soldier
// * 3-5 : Alien
// * 6-8 : Civilian
- // * 9-11 : Dead unit
+ // * 9-11 : Item
// * 12-23 : Xcom HWP
// * 24-35 : Alien big terror unit(cyberdisk, ...)
if (isOut())
View
6 src/Savegame/MovingTarget.cpp
@@ -140,6 +140,12 @@ void MovingTarget::calculateSpeed()
length = sqrt(dLon * dLon + dLat * dLat);
_speedLon = dLon / length * _speedRadian / cos(_lat + _speedLat);
_speedLat = dLat / length * _speedRadian;
+ // Check for invalid speeds
+ if (!(_speedLon == _speedLon) || !(_speedLat == _speedLat))
+ {
+ _speedLon = 0;
+ _speedLat = 0;
+ }
}
else
{
Please sign in to comment.
Something went wrong with that request. Please try again.