Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/camera.cc2
-rw-r--r--src/client/client.cc8
-rw-r--r--src/core/application.cc46
-rw-r--r--src/core/application.h5
-rw-r--r--src/core/cvar.h3
-rw-r--r--src/server/server.cc8
6 files changed, 56 insertions, 16 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc
index c7982f4..754cbad 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -54,7 +54,7 @@ float x_offset;
float z_offset;
// default pitch in mode::Track
-const float pitch_track = 15.0f;
+const float pitch_track = 0.0f; // 15.0f;
// default rotate offset increase/decrease
float rotate_offset_inc;
// default translate offset increase/decrease
diff --git a/src/client/client.cc b/src/client/client.cc
index ab27d0f..2079c71 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -31,7 +31,7 @@ class Client : public core::Application
{
public:
/// initialize the client Client
- virtual void init();
+ virtual void init(int count, char **arguments);
/// run the client Client
virtual void run();
@@ -68,7 +68,7 @@ void client_main(int count, char **arguments)
std::cout << arguments[i] << " ";
std::cout << std::endl;
- app.init();
+ app.init(count, arguments);
app.run();
app.shutdown();
}
@@ -81,13 +81,13 @@ void Client::quit(int status)
core::Application::quit(status);
}
-void Client::init()
+void Client::init(int count, char **arguments)
{
con_print << "Initializing client..." << std::endl;
// initialize core
core::Cvar::sv_dedicated = core::Cvar::set("sv_private", "0");
- core::Application::init();
+ core::Application::init(count, arguments);
// client variables
core::Cvar *cvar = 0;
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
diff --git a/src/server/server.cc b/src/server/server.cc
index 49af573..c4c0b88 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -17,7 +17,7 @@ namespace server {
class Server : public core::Application {
public:
/// initialize the server Application
- virtual void init();
+ virtual void init(int count, char **arguments);
/// run the server Application
virtual void run();
@@ -42,19 +42,19 @@ void main(int count, char **arguments)
std::cout << arguments[i] << " ";
std::cout << std::endl;
- app.init();
+ app.init(count, arguments);
app.run();
app.shutdown();
}
//--- private -----------------------------------------------------
-void Server::init()
+void Server::init(int count, char **arguments)
{
con_print << "Initializing server..." << std::endl;
core::Cvar::sv_private = core::Cvar::set("sv_dedicated", "1", core::Cvar::ReadOnly);
- core::Application::init();
+ core::Application::init(count, arguments);
console::init();