Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-07-21 22:57:35 +0000
committerStijn Buys <ingar@osirion.org>2008-07-21 22:57:35 +0000
commit45e19fb82dbf49280c09574447b65520445be308 (patch)
tree3317fea0526ba4f11486aadcdb994db338d796a0 /src/core
parent2c7c599647773221fceacc1633b95e4b614b8af3 (diff)
load autoexec.cfg
Diffstat (limited to 'src/core')
-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();