Skip to content

Commit a796461

Browse files
committed
- Fixed crash when SDL can't get resolution list.
- Fixed missing IDs in old savegames.
1 parent d11594e commit a796461

4 files changed

Lines changed: 27 additions & 14 deletions

File tree

src/Menu/OptionsState.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "OptionsControlsState.h"
3535
#include "AdvancedOptionsState.h"
3636
#include "../Engine/CrossPlatform.h"
37+
#include "../Engine/Logger.h"
3738

3839
namespace OpenXcom
3940
{
@@ -88,8 +89,8 @@ OptionsState::OptionsState(Game *game) : State(game)
8889
_btnSoundVolume4 = new TextButton(22, 26, 246, 82);
8990
_btnSoundVolume5 = new TextButton(22, 30, 270, 82);
9091

91-
/* Get available fullscreen/hardware modes */
92-
_res = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWPALETTE);
92+
/* Get available fullscreen modes */
93+
_res = SDL_ListModes(NULL, SDL_FULLSCREEN);
9394
if (_res > (SDL_Rect**)0)
9495
{
9596
int i;
@@ -105,7 +106,15 @@ OptionsState::OptionsState(Game *game) : State(game)
105106
}
106107
_resAmount = i;
107108
}
108-
109+
else
110+
{
111+
_resCurrent = -1;
112+
_resAmount = 0;
113+
_btnDisplayDown->setVisible(false);
114+
_btnDisplayUp->setVisible(false);
115+
Log(LOG_WARNING) << "Couldn't get display resolutions";
116+
}
117+
109118
if (Options::getBool("fullscreen"))
110119
_displayMode = _btnDisplayFullscreen;
111120
else

src/Ruleset/Ruleset.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -638,14 +638,6 @@ SavedGame *Ruleset::newSave() const
638638
{
639639
ids[*i] = 1;
640640
}
641-
ids["STR_UFO"] = 1;
642-
ids["STR_LANDING_SITE"] = 1;
643-
ids["STR_CRASH_SITE"] = 1;
644-
ids["STR_WAYPOINT"] = 1;
645-
ids["STR_TERROR_SITE"] = 1;
646-
ids["STR_ALIEN_BASE"] = 1;
647-
ids["STR_SOLDIER"] = 1;
648-
ids["ALIEN_MISSIONS"] = 1;
649641
save->initIds(ids);
650642

651643
// Set up starting base

src/Savegame/SavedGame.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void SavedGame::load(const std::string &filename, Ruleset *rule)
227227
_globeLon = doc["globeLon"].as<double>(_globeLon);
228228
_globeLat = doc["globeLat"].as<double>(_globeLat);
229229
_globeZoom = doc["globeZoom"].as<int>(_globeZoom);
230-
_ids = doc["ids"].as< std::map<std::string, int> >(_ids);
230+
initIds(doc["ids"].as< std::map<std::string, int> >(_ids));
231231

232232
for (YAML::const_iterator i = doc["countries"].begin(); i != doc["countries"].end(); ++i)
233233
{
@@ -332,6 +332,7 @@ void SavedGame::save(const std::string &filename) const
332332
// Saves the brief game info used in the saves list
333333
YAML::Node brief;
334334
brief["version"] = OPENXCOM_VERSION_SHORT;
335+
brief["build"] = OPENXCOM_VERSION_GIT;
335336
brief["time"] = _time->save();
336337
out << brief;
337338
// Saves the full game data to the save
@@ -563,7 +564,18 @@ int SavedGame::getId(const std::string &name)
563564
*/
564565
void SavedGame::initIds(const std::map<std::string, int> &ids)
565566
{
566-
_ids = ids;
567+
_ids["STR_UFO"] = 1;
568+
_ids["STR_LANDING_SITE"] = 1;
569+
_ids["STR_CRASH_SITE"] = 1;
570+
_ids["STR_WAYPOINT"] = 1;
571+
_ids["STR_TERROR_SITE"] = 1;
572+
_ids["STR_ALIEN_BASE"] = 1;
573+
_ids["STR_SOLDIER"] = 1;
574+
_ids["ALIEN_MISSIONS"] = 1;
575+
for (std::map<std::string, int>::const_iterator i = ids.begin(); i != ids.end(); ++i)
576+
{
577+
_ids[i->first] = i->second;
578+
}
567579
}
568580

569581
/**

src/Savegame/Ufo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class matchMissionID: public std::unary_function<const AlienMission *, bool>
103103
void Ufo::load(const YAML::Node &node, const Ruleset &ruleset, SavedGame &game)
104104
{
105105
MovingTarget::load(node);
106-
_id = node["id"].as<int>(_id);
106+
_id = _crashId = _landId = node["id"].as<int>(_id);
107107
_crashId = node["crashId"].as<int>(_crashId);
108108
_landId = node["landId"].as<int>(_landId);
109109
_damage = node["damage"].as<int>(_damage);

0 commit comments

Comments
 (0)