Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-04-09 19:38:25 +0000
committerStijn Buys <ingar@osirion.org>2008-04-09 19:38:25 +0000
commit644479214119760394db18ec2488917ffb3a6c54 (patch)
tree0a485803e2c4f1a989fc1c444192ee3b3b2f3814 /src/core/application.cc
parent7a887f128d4da086ca7562779df5cefe53186aeb (diff)
parse command line arguments
Diffstat (limited to 'src/core/application.cc')
-rw-r--r--src/core/application.cc46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index ee0dd76..2ff7bb0 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -113,7 +113,7 @@ Application::~Application()
application_instance = 0;
}
-void Application::init()
+void Application::init(int count, char **arguments)
{
con_debug << "Debug messages enabled\n";
con_print << "Initializing core...\n";
@@ -121,6 +121,7 @@ void Application::init()
filesystem::init();
CommandBuffer::init();
+
// dedicated server has set this to 1
Cvar::sv_dedicated = Cvar::get("sv_dedicated", "0", Cvar::ReadOnly);
Cvar::sv_dedicated->set_info("[bool] indicates this is a dedicated server");
@@ -129,9 +130,12 @@ void Application::init()
Cvar::sv_private = Cvar::get("sv_private", "0");
Cvar::sv_private->set_info("[bool] indicates the client runs a networked server");
- // load save cvars
+ // load configuration
load_config();
+ // load command line
+ load_commandline(count, arguments);
+
// framerate settings
Cvar::sv_framerate = Cvar::get("sv_framerate", "25");
Cvar::sv_framerate->set_info("[int] server framerate in frames/sec");
@@ -289,8 +293,15 @@ void Application::save_config()
con_warn << "Could not write " << filename << std::endl;
return;
}
-
- std::map<std::string, Cvar*>::iterator it;
+
+ if (!Cvar::sv_dedicated->value())
+ ofs << "# client.cfg - osirion client configuration" << std::endl;
+ else
+ ofs << "# server.cfg - osiriond dedicated server configuration" << std::endl;
+
+ ofs << "# this file is automaticly generated" << std::endl;
+
+ Cvar::iterator it;
for (it = Cvar::registry.begin(); it != Cvar::registry.end(); it++) {
if (((*it).second->flags() & Cvar::Archive) == Cvar::Archive)
@@ -315,11 +326,34 @@ void Application::load_config()
char line[MAXCMDSIZE];
while (ifs.getline(line, MAXCMDSIZE-1)) {
- cmd() << line << "\n";
-
+ if (line[0] && line[0] != '#' && line[0] != ';')
+ cmd() << line << '\n';
}
// execute commands in the buffer
CommandBuffer::exec();
}
+
+void Application::load_commandline(int count, char **arguments)
+{
+ if (count < 2)
+ return;
+
+ for (int i=1; i < count; i++) {
+ if (arguments[i][0] == '+') {
+ if (i >1)
+ cmd() << '\n';
+
+ if (arguments[i][1])
+ cmd() << &arguments[i][1];
+ } else {
+ if (i > 1)
+ cmd() << ' ';
+ cmd() << arguments[i];
+ }
+ }
+
+ cmd() << '\n';
+}
+
}