Permalink
Browse files

Added some tracking of what engine version a particular module supports.

  • Loading branch information...
1 parent 60e68eb commit 85393ce84bb42568b03cb90a816cd31a4bd70daf @sweetkristas sweetkristas committed Aug 1, 2012
@@ -1,4 +1,5 @@
{
id: "aritest",
+min_engine_version: 1.2,
"dependencies": "frogatto",
}
@@ -1,5 +1,6 @@
{
id: "cellular",
"dependencies": "frogatto",
+min_engine_version: 1.2,
arguments: ["--native"]
}
@@ -1,6 +1,7 @@
{
id: "cube_trains",
name: "Cube Trains",
+min_engine_version: 1.2,
arguments: ["--width", "1000", "--height", "775", "--bigscreen", "--proportional-resize", "--no-iphone-controls"]
//arguments: []
}
@@ -1,5 +1,6 @@
{
id: "frogatto",
name: "Frogatto & Friends",
+min_engine_version: 1.2,
arguments: []
}
@@ -1,5 +1,6 @@
{
id: "rpg",
name: "rpg",
+min_engine_version: 1.2,
"dependencies": "frogatto",
}
@@ -1,4 +1,5 @@
{
id: "secluded-isle",
+ min_engine_version: 1.2,
"dependencies": "frogatto",
}
@@ -1,6 +1,7 @@
{
- "abbreviation": "xo",
- "id": "tictactoe",
- "name": "Noughts & Crosses",
+ abbreviation: "xo",
+ id: "tictactoe",
+ name: "Noughts & Crosses",
+ min_engine_version: 1.2,
arguments: ["--width", "700", "--height", "700", "--bigscreen"],
}
@@ -1,5 +1,6 @@
{
id: "tileciv",
"dependencies": "frogatto",
+min_engine_version: 1.2,
version: [1, 0, 0]
}
@@ -1,5 +1,6 @@
{
id: "vgi",
name: "VGI",
+ min_engine_version: 1.2,
"dependencies": ["elisa", "frogatto"],
}
@@ -1,6 +1,7 @@
{
id: "weregild",
name: "Weregild",
+min_engine_version: 1.2,
"dependencies": "frogatto",
#arguments: ["--width", "1050", "--height", "845", "--native"]
}
View
@@ -6,6 +6,7 @@
#include "json_parser.hpp"
#include "md5.hpp"
#include "module.hpp"
+#include "preferences.hpp"
#include "unit_test.hpp"
namespace module {
@@ -179,6 +180,10 @@ void load(const std::string& mod_file_name, bool initial)
variant v = json::parse_from_file(fname);
if(v.is_map()) {
+ ASSERT_LOG(v["min_engine_version"].is_null() == false, "A min_engine_version field in the module.cfg file must be specified.");
+ ASSERT_LOG(v["min_engine_version"] <= preferences::version_decimal(), "The engine version being used (" << preferences::version_decimal()
+ << ") to run the module is older than required by the module (" << v["min_engine_version"] << ").");
+
if(v["name"].is_null() == false) {
pretty_name = v["name"].as_string();
} else if(v["id"].is_null() == false) {
@@ -217,6 +222,10 @@ void load_module_from_file(const std::string& modname, modules* mod_) {
variant v = json::parse_from_file("./modules/" + modname + "/module.cfg");
ASSERT_LOG(mod_ != NULL, "Invalid module pointer passed.");
if(v.is_map()) {
+ ASSERT_LOG(v["min_engine_version"].is_null() == false, "A min_engine_version field in the module.cfg file must be specified.");
+ ASSERT_LOG(v["min_engine_version"] <= preferences::version_decimal(), "The engine version being used (" << preferences::version_decimal()
+ << ") to run the module is older than required by the module (" << v["min_engine_version"] << ").");
+
if(v["id"].is_null() == false) {
mod_->name_= v["id"].as_string();
}
View
@@ -104,13 +104,17 @@ void WindowsPrefs::CleanUp()
WindowsPrefs winPrefs;
#endif // _WINDOWS
-
namespace preferences {
const std::string& version() {
static const std::string Version = "1.2";
return Version;
}
+ const variant& version_decimal() {
+ static const variant versiond = variant(decimal::from_string(version()));
+ return versiond;
+ }
+
namespace {
int unique_user_id = 0;
View
@@ -21,6 +21,7 @@ std::string GetAppDataPath();
namespace preferences {
const std::string& version();
+ const variant& version_decimal();
int get_unique_user_id();
bool parse_arg(const char* arg);

0 comments on commit 85393ce

Please sign in to comment.