This INI works with vanilla Gothic II and G2MDK 2.6a installed.
Could a time parameter be added to OpenGothic to allow the game to start at a specific time?
Currently, the time can be changed through Marvin Mode using the "set time 0 0" option.
diff --git a/game/game/gamesession.cpp b/game/game/gamesession.cpp
index 6f5c549..a954ae6 100644
--- a/game/game/gamesession.cpp
+++ b/game/game/gamesession.cpp
@@ -71,7 +71,7 @@ GameSession::GameSession(std::string file) {
Gothic::inst().setLoadingProgress(0);
setupSettings();
- setTime(gtime(8,0));
+ setTime(Gothic::inst().hasStartTime() ? Gothic::inst().startTime() : gtime(8,0));
vm.reset(new GameScript(*this));
initPerceptions();
diff --git a/game/gothic.cpp b/game/gothic.cpp
index e795b80..2aa01ba 100644
--- a/game/gothic.cpp
+++ b/game/gothic.cpp
@@ -6,6 +6,7 @@
#include <cstring>
#include <cctype>
#include <cassert>
+#include <cstdio>
#include <zenkit/addon/daedalus.hh>
@@ -212,6 +213,20 @@ Gothic::Gothic() {
if(!mod.empty())
modvdfs.emplace_back(std::move(mod));
}
+
+ if(modFile->has("OPTIONS","force_Parameters")) {
+ const std::string params(modFile->getS("OPTIONS","force_Parameters"));
+ const size_t tPos = params.find("-time:");
+ if(tPos!=std::string::npos) {
+ int hh=0, mm=0;
+ if(std::sscanf(params.c_str()+tPos, "-time:%d:%d", &hh, &mm)==2) {
+ startTimeVal = gtime(hh,mm);
+ startTimeSet = true;
+ } else {
+ Log::e("failed to parse -time from force_Parameters: \"",params,"\"");
+ }
+ }
+ }
}
/*
'/work' seem to have lowest priority
diff --git a/game/gothic.h b/game/gothic.h
index 00003a2..5ea19c7 100644
--- a/game/gothic.h
+++ b/game/gothic.h
@@ -75,6 +75,8 @@ class Gothic final {
std::string_view defaultWorld() const;
std::string_view defaultPlayer() const;
+ bool hasStartTime() const { return startTimeSet; }
+ gtime startTime() const { return startTimeVal; }
std::string_view defaultSave() const;
std::string_view defaultGameDatFile() const;
std::string_view defaultOutputUnits() const;
@@ -229,6 +231,8 @@ class Gothic final {
Benchmark isBenchmark = Benchmark::None;
std::string wrldDef, plDef, gameDatDef, ouDef;
+ bool startTimeSet = false;
+ gtime startTimeVal;
std::unique_ptr<IniFile> defaults;
std::unique_ptr<IniFile> baseIniFile;
I am trying to use an INI file which contains the following section:
This INI works with vanilla Gothic II and G2MDK 2.6a installed.
Could a time parameter be added to OpenGothic to allow the game to start at a specific time?
Currently, the time can be changed through Marvin Mode using the "set time 0 0" option.
Parsing can be added with following diff: