Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/application.cc46
-rw-r--r--src/core/application.h5
-rw-r--r--src/core/cvar.h3
3 files changed, 47 insertions, 7 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';
+}
+
}
diff --git a/src/core/application.h b/src/core/application.h
index f0f03b5..01f34cf 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -47,7 +47,7 @@ public:
/*----- virtual mutators ------------------------------------------ */
/// initialize the application
- virtual void init();
+ virtual void init(int count, char **arguments);
/// shutdown the application
virtual void shutdown();
@@ -70,6 +70,9 @@ protected:
/// save cvar config
void save_config();
+ /// load command line arguments
+ void load_commandline(int count, char **argments);
+
private:
/// time the core has been running
float application_time;
diff --git a/src/core/cvar.h b/src/core/cvar.h
index 06b7f2a..e45839f 100644
--- a/src/core/cvar.h
+++ b/src/core/cvar.h
@@ -106,6 +106,9 @@ public:
/// the Cvar registry
static std::map<std::string, Cvar*> registry;
+ /// an iterator for the Cvar registry
+ typedef std::map<std::string, Cvar*>::iterator iterator;
+
static Cvar *sv_dedicated; // dedicated server
static Cvar *sv_private; // client with private server
static Cvar *sv_framerate; // server framerate