From 45e19fb82dbf49280c09574447b65520445be308 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 21 Jul 2008 22:57:35 +0000 Subject: load autoexec.cfg --- src/core/application.cc | 39 +++++++++++++++++++++++++++++++++++++++ src/core/application.h | 3 +++ 2 files changed, 42 insertions(+) (limited to 'src') 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(); -- cgit v1.2.3