Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/application.cc39
-rw-r--r--src/core/application.h3
2 files changed, 42 insertions, 0 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index f92a0fe..8234b8f 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -156,6 +156,7 @@ void Application::init(int count, char **arguments)
// load configuration
load_config();
+ load_autoexec();
// load command line
load_commandline(count, arguments);
@@ -383,6 +384,44 @@ void Application::load_config()
CommandBuffer::exec();
}
+void Application::load_autoexec()
+{
+ if (Cvar::sv_dedicated->value())
+ return;
+
+ std::string filename(filesystem::writedir);
+ filename.append("autoexec.cfg");
+ std::ifstream ifs(filename.c_str(), std::ifstream::in);
+
+ if (!ifs.is_open()) {
+ con_warn << "Could not read " << filename << std::endl;
+
+ std::ofstream ofs(filename.c_str());
+
+ if (!ofs.is_open()) {
+ con_warn << "Could not write " << filename << std::endl;
+ return;
+ }
+
+ ofs << "# autoexec.cfg - osirion client custom settings" << std::endl;
+ ofs << "# put your custom settings here" << std::endl;
+ ofs.close();
+
+ return;
+ } else {
+
+ con_print << " reading configuration from " << filename << std::endl;
+
+ char line[MAXCMDSIZE];
+ while (ifs.getline(line, MAXCMDSIZE-1)) {
+ if (line[0] && line[0] != '#' && line[0] != ';')
+ cmd() << line << '\n';
+ }
+
+ CommandBuffer::exec();
+ }
+}
+
void Application::load_commandline(int count, char **arguments)
{
if (count < 2)
diff --git a/src/core/application.h b/src/core/application.h
index 8f69720..0e5c9c0 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -78,6 +78,9 @@ protected:
/// load cvar config
void load_config();
+
+ /// load exra config
+ void load_autoexec();
/// save cvar config
void save_config();