Skip to content

Commit

Permalink
Added incremental component to version number.
Browse files Browse the repository at this point in the history
  • Loading branch information
SockPuppet8 committed Nov 2, 2018
1 parent 5b72574 commit 1438d14
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
13 changes: 6 additions & 7 deletions src/Console/Interface/Title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,16 @@ void Title::draw( AOutputWindow& window, AGameModel& in_model ) const

console.draw(atx, aty, '@', Console::Green);

static const char * border0 = "..................";
static const char * border0 = "....................";
std::string version = " Version " + std::string(GAMEMODEL_VERSION_STR) + std::string(" ");
static const char * border1 = "..................";
console.drawText(atx+4, title_base+10, border1, floor_col);
console.drawText(atx+4, title_base+11, version.c_str(), Console::Green);
console.drawText(atx+4, title_base+12, border1, floor_col);
console.drawText(atx+2, title_base+10, border0, floor_col);
console.drawText(atx+2, title_base+11, version.c_str(), Console::Green);
console.drawText(atx+2, title_base+12, border0, floor_col);

static const char * press_enter = " Press Enter ";
static const char * border2 = ".............";
static const char * border1 = ".............";
console.drawText(atx+9, title_base+13, press_enter, Console::BrightYellow);
console.drawText(atx+9, title_base+14, border2 , floor_col);
console.drawText(atx+9, title_base+14, border1 , floor_col);
}

bool Title::drawsWholeWindow(void) const
Expand Down
18 changes: 13 additions & 5 deletions src/Model/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@ bool isSaveFile(const char * filename)
std::getline(ifs, firstline);
if (0 == firstline.compare(0, 18, "AlienHack savefile")) {

int ver_maj, ver_min;
if (std::sscanf(firstline.c_str(), "AlienHack savefile %d %d", &ver_maj, &ver_min) != 2)
int ver_maj, ver_min, ver_incr;
if (std::sscanf(firstline.c_str(), "AlienHack savefile %d %d %d", &ver_maj, &ver_min, &ver_incr) != 3)
return false;

if (ver_maj < GAMEMODEL_SAVE_LAST_COMPATIBLE_MAJOR)
return false;

if (ver_maj == GAMEMODEL_SAVE_LAST_COMPATIBLE_MAJOR && ver_min < GAMEMODEL_SAVE_LAST_COMPATIBLE_MINOR)
return false;
if (ver_maj == GAMEMODEL_SAVE_LAST_COMPATIBLE_MAJOR)
{
if (ver_min < GAMEMODEL_SAVE_LAST_COMPATIBLE_MINOR)
return false;

if (ver_min == GAMEMODEL_SAVE_LAST_COMPATIBLE_MINOR)
if (ver_incr < GAMEMODEL_SAVE_LAST_COMPATIBLE_INCREMENTAL)
return false;
}

return true;
}
Expand All @@ -61,7 +68,8 @@ bool saveGame(AHGameModel& model, const char * filename)
{
ofs << "AlienHack savefile " <<
boost::lexical_cast<std::string>(GAMEMODEL_VERSION_MAJOR) << " " <<
boost::lexical_cast<std::string>(GAMEMODEL_VERSION_MINOR) << " ##\n";
boost::lexical_cast<std::string>(GAMEMODEL_VERSION_MINOR) << " " <<
boost::lexical_cast<std::string>(GAMEMODEL_VERSION_INCREMENTAL) << " ##\n";

boost::archive::text_oarchive oa(ofs);

Expand Down
14 changes: 8 additions & 6 deletions src/Model/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#define ALIENHACK_MODEL_VERSION_HPP


#define GAMEMODEL_VERSION_MAJOR 0
#define GAMEMODEL_VERSION_MINOR 9
#define GAMEMODEL_VERSION_STR "0.9 beta"

#define GAMEMODEL_SAVE_LAST_COMPATIBLE_MAJOR 0
#define GAMEMODEL_SAVE_LAST_COMPATIBLE_MINOR 9
#define GAMEMODEL_VERSION_MAJOR 0
#define GAMEMODEL_VERSION_MINOR 9
#define GAMEMODEL_VERSION_INCREMENTAL 1
#define GAMEMODEL_VERSION_STR "0.9.1 beta"

#define GAMEMODEL_SAVE_LAST_COMPATIBLE_MAJOR 0
#define GAMEMODEL_SAVE_LAST_COMPATIBLE_MINOR 9
#define GAMEMODEL_SAVE_LAST_COMPATIBLE_INCREMENTAL 1

#endif

0 comments on commit 1438d14

Please sign in to comment.