Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-29 18:01:35 +0000
committerStijn Buys <ingar@osirion.org>2008-09-29 18:01:35 +0000
commit381c729e777b50771626703e60b422aafc791513 (patch)
tree856b9467dda75daaa1d78f6dce9dfb746dc338ce /src/core
parent5b64ecbd39307d17acd8815187f6cd211c384029 (diff)
adds introduction screen to the client
Diffstat (limited to 'src/core')
-rw-r--r--src/core/application.cc37
-rw-r--r--src/core/application.h7
-rw-r--r--src/core/gameconnection.h4
-rw-r--r--src/core/gameinterface.h3
-rw-r--r--src/core/gameserver.cc11
-rw-r--r--src/core/gameserver.h3
-rw-r--r--src/core/module.cc1
-rw-r--r--src/core/module.h4
8 files changed, 60 insertions, 10 deletions
diff --git a/src/core/application.cc b/src/core/application.cc
index 2b3f41f..c02db9b 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -98,15 +98,9 @@ void func_load(std::string const &args)
return;
}
- if (game()) {
- con_warn << "Connected. Disconnect first.\n";
- return;
- }
-
std::string name(args);
aux::to_label(name);
-
- Module::load(name.c_str());
+ application()->load(name);
}
// --------------- signal_handler -----------------------------------
@@ -156,6 +150,8 @@ Application::Application()
application_time = 0;
application_game = 0;
+ module_interactive = 0;
+
#ifndef _WIN32
sys::signal(SIGHUP, signal_handler);
sys::signal(SIGINT, signal_handler);
@@ -312,11 +308,33 @@ void Application::quit(int status)
}
+Module *Application::load(std::string const &module_name)
+{
+ if (game()) {
+ con_warn << "Connected. Disconnect first.\n";
+ return 0;
+ }
+
+ if (Module::current() && Module::current()->interactive()) {
+ module_interactive = Module::current();
+ }
+ return Module::load(module_name.c_str());
+}
+
void Application::connect(std::string const &host)
{
if (connected()) {
- con_warn << "Connected. Disconnect first.\n";
- return;
+ if (!Module::current()->interactive() && module_interactive) {
+ /* if the current running module is non-interactive,
+ disconnect, and load the last interactive module_interactive
+ */
+ disconnect();
+ Module::load(module_interactive->label().c_str());
+
+ } else {
+ con_warn << "Connected. Disconnect first.\n";
+ return;
+ }
}
if (application_game) {
@@ -350,6 +368,7 @@ void Application::disconnect()
notify_disconnect();
delete application_game;
application_game = 0;
+ notify_zoneclear(0);
con_print << "^BDisconnected.\n";
}
}
diff --git a/src/core/application.h b/src/core/application.h
index 0dfa652..3769941 100644
--- a/src/core/application.h
+++ b/src/core/application.h
@@ -13,6 +13,7 @@
#include "core/netserver.h"
#include "core/netconnection.h"
#include "core/gameinterface.h"
+#include "core/module.h"
namespace core
{
@@ -46,6 +47,9 @@ public:
/// disconnect from the game module
void disconnect();
+ /// load a module
+ Module *load(std::string const &module_name);
+
/*----- virtual mutators ------------------------------------------ */
/// initialize the application
@@ -100,6 +104,9 @@ private:
float application_time;
GameInterface *application_game;
static Application *application_instance;
+
+ /// last loaded interactive module
+ Module *module_interactive;
};
/// pointer to the current Application
diff --git a/src/core/gameconnection.h b/src/core/gameconnection.h
index ecf50f2..973d96f 100644
--- a/src/core/gameconnection.h
+++ b/src/core/gameconnection.h
@@ -28,6 +28,10 @@ public:
/// returns true if the game connection can not run a time frime
inline bool error() { return !connection_running; }
+ /// returns true if the game is running an interactive module
+ inline bool interactive() { return true; }
+
+
/*----- mutators -------------------------------------------------- */
/// run a game connection time frame
diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h
index 69cd588..b6d7cb6 100644
--- a/src/core/gameinterface.h
+++ b/src/core/gameinterface.h
@@ -54,6 +54,9 @@ public:
/// returns true if the game server can run a time frime
virtual bool running() = 0;
+ /// returns true if the game is running an interactive module
+ virtual bool interactive() = 0;
+
/*----- mutators ------------------------------------------------- */
/// clear all game variables, game functions and entities
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 70786af..4037c70 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -135,7 +135,7 @@ GameServer::GameServer() : GameInterface()
con_print << " module '^B" << server_module->name() << "^N'\n";
- if ((Cvar::sv_dedicated->value() || Cvar::sv_private->value())) {
+ if (server_module->interactive() && (Cvar::sv_dedicated->value() || Cvar::sv_private->value())) {
server_network = new NetServer(Cvar::net_host->str(), (unsigned int) Cvar::net_port->value());
if (!server_network->valid()) {
delete server_network;
@@ -220,6 +220,15 @@ void GameServer::abort()
server_running = false;
}
+bool GameServer::interactive()
+{
+ if (!server_module) {
+ return false;
+ } else {
+ return server_module->interactive();
+ }
+}
+
void GameServer::showtime()
{
using namespace std;
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index b25f1a0..0dfdd9d 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -33,6 +33,9 @@ public:
/// returns true if the game server can not run a time frime
inline bool error() { return !server_running; }
+ /// returns true if the game is running an interactive module
+ bool interactive();
+
/// show the current time
void showtime();
diff --git a/src/core/module.cc b/src/core/module.cc
index 29c9eb8..ae78260 100644
--- a/src/core/module.cc
+++ b/src/core/module.cc
@@ -76,6 +76,7 @@ Module::Module(const char *name) :
module_name(name)
{
module_running = false;
+ module_interactive = true;
}
Module::~Module()
diff --git a/src/core/module.h b/src/core/module.h
index b46c296..20029cf 100644
--- a/src/core/module.h
+++ b/src/core/module.h
@@ -33,6 +33,9 @@ public:
/// label of the module
inline std::string const & label() const { return module_label; }
+ /// indicates if this is an interactive module or not
+ inline bool interactive() const { return module_interactive; }
+
/*----- mutators -------------------------------------------------- */
/// initialize the game module
@@ -80,6 +83,7 @@ protected:
void abort();
bool module_running;
+ bool module_interactive;
private:
std::string module_name;