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 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/core/application.cc') 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) -- cgit v1.2.3