Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README16
-rw-r--r--src/core/application.cc25
-rw-r--r--src/core/commandbuffer.cc52
-rw-r--r--src/core/commandbuffer.h3
-rw-r--r--src/core/cvar.cc1
-rw-r--r--src/core/cvar.h1
-rw-r--r--src/core/gameserver.cc30
-rw-r--r--src/core/gameserver.h2
-rw-r--r--src/core/netserver.cc2
9 files changed, 98 insertions, 34 deletions
diff --git a/README b/README
index 4ab0dc0..0aefac6 100644
--- a/README
+++ b/README
@@ -210,10 +210,13 @@ Editing game data
Project contributors
- Thorn[mDc] - Canasta and Sharkan ship models
- Alpha testing
+ [mDc]Thorn - Canasta and Sharkan ship models, alpha testing
- Josky=KCT= - Shuttle ship model
+ Josky=KCT= - Shuttle ship model, alpha testing
+
+ [mDc]Minisori
+ Gareth - Alpha testing
+ DVSoftware
IRC
@@ -222,7 +225,7 @@ IRC
Web
Screenshots can be found at
- http://ingar.soliter.org/screenshots/osirion
+ http://ingar.satgnu.net/osirion
Acknowledgements
@@ -259,7 +262,8 @@ License
Trademarks
QUAKE and ID are registered trademarks of Id Software, Inc.
- LEGO is a reigstered trademark of the LEGO Group.
+ LEGO is a registered trademark of the LEGO Group.
The Osirion Project is an independent not-for-profit project
- and has no affiliation with these corporations.
+ and has no affiliation with these companies.
+
diff --git a/src/core/application.cc b/src/core/application.cc
index ac836df..09b3f61 100644
--- a/src/core/application.cc
+++ b/src/core/application.cc
@@ -16,6 +16,7 @@
#include "math/mathlib.h"
#include "filesystem/filesystem.h"
#include "core/application.h"
+#include "core/core.h"
#include "core/cvar.h"
#include "core/entity.h"
#include "core/func.h"
@@ -26,14 +27,15 @@ namespace core
{
// --------------- engine functions ------------------------------
-void func_print(std::string const &args)
-{
- con_print << args << "\n";
-}
-
void func_help(std::string const &args)
{
- con_print << "This is the help function\n";
+ std::istringstream argstream(args);
+ std::string topic;
+ if (!(argstream >> topic))
+ topic.assign("help");
+
+ topic.append(".txt");
+ CommandBuffer::print_file("help/" + topic);
}
void func_quit(std::string const &args)
@@ -140,6 +142,10 @@ void Application::init(int count, char **arguments)
Cvar::sv_framerate = Cvar::get("sv_framerate", "25");
Cvar::sv_framerate->set_info("[int] server framerate in frames/sec");
+ // server settings
+ Cvar::sv_name = Cvar::get("sv_name", "osirion server", Cvar::Archive);
+ Cvar::sv_name->set_info("[string] server name");
+
// network settings
Cvar::net_host = Cvar::get("net_host", "0.0.0.0", Cvar::Archive);
Cvar::net_host->set_info("[ip] IP address the network server binds to");
@@ -150,10 +156,10 @@ void Application::init(int count, char **arguments)
Cvar::net_maxclients = Cvar::get("net_maxclients", "16", Cvar::Archive);
Cvar::net_maxclients->set_info("[int] maximum number of network clients");
- Cvar::net_timeout = Cvar::get("net_timeout", "20", Cvar::Archive);
+ Cvar::net_timeout = Cvar::get("net_timeout", "20");
Cvar::net_timeout->set_info("[int] network timeout in seconds");
- Cvar::net_framerate = Cvar::get("net_framerate", "25", Cvar::Archive);
+ Cvar::net_framerate = Cvar::get("net_framerate", "25");
Cvar::net_framerate->set_info("[int] network framerate in frames/sec");
#ifdef _WIN32
@@ -175,9 +181,6 @@ void Application::init(int count, char **arguments)
// register our engine functions
Func *func = 0;
- func = Func::add("print", func_print);
- func->set_info("[str] print a message on the console");
-
func = Func::add("help", func_help);
func->set_info("dummy help function");
diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc
index d1c9451..40517e1 100644
--- a/src/core/commandbuffer.cc
+++ b/src/core/commandbuffer.cc
@@ -20,6 +20,21 @@
namespace core
{
+void func_print(std::string const &args)
+{
+ con_print << args << "\n";
+}
+
+void func_print_file(std::string const &args)
+{
+ std::istringstream argstream(args);
+ std::string filename;
+ if (!(argstream >> filename))
+ return;
+
+ CommandBuffer::print_file(filename);
+}
+
void func_list_func(std::string const &args)
{
Func::list();
@@ -75,7 +90,6 @@ std::stringstream CommandBuffer::cmdbuf(std::stringstream::in | std::stringstrea
void CommandBuffer::init()
{
//con_debug << "Initializing command buffer...\n";
-
Func *func = 0;
func = Func::add("list_ent", (FuncPtr)func_list_ent);
func->set_info("list entities");
@@ -89,6 +103,12 @@ void CommandBuffer::init()
func = Func::add("set", (FuncPtr)func_set);
func->set_info("[variable] [str] set variable value");
+ func = Func::add("print", func_print);
+ func->set_info("[str] print a message on the console");
+
+ func = Func::add("print_file", func_print_file);
+ func->set_info("[filename] print messages from file");
+
func = Func::add("exec", (FuncPtr)func_exec);
func->set_info("[filename] execute commands from file");
}
@@ -101,6 +121,9 @@ void CommandBuffer::shutdown()
Func::remove("list_var");
Func::remove("list_func");
Func::remove("list_ent");
+ Func::remove("print");
+ Func::remove("print_file");
+ Func::remove("exec");
}
void CommandBuffer::exec(std::string const &cmdline)
@@ -263,5 +286,32 @@ void CommandBuffer::exec_file(std::string const & filename)
ifs.close();
}
+void CommandBuffer::print_file(std::string const & filename)
+{
+ filesystem::File *f = filesystem::open(filename.c_str());
+ if (!f) {
+ con_warn << "Could not open " << filename << std::endl;
+ return;
+ }
+
+ std::string fn = f->path();
+ fn.append(f->name());
+ filesystem::close(f);
+
+ std::ifstream ifs;
+ ifs.open(fn.c_str());
+ if (!ifs.is_open()) {
+ con_warn << "Could not stream " << fn << "!\n";
+ return;
+ }
+
+ char line[MAXCMDSIZE];
+ while (ifs.getline(line, MAXCMDSIZE-1)) {
+ con_print << line << "\n";
+ }
+
+ ifs.close();
+}
+
}
diff --git a/src/core/commandbuffer.h b/src/core/commandbuffer.h
index 7b26211..9cd919b 100644
--- a/src/core/commandbuffer.h
+++ b/src/core/commandbuffer.h
@@ -31,6 +31,9 @@ public:
/// execute commands from a file
static void exec_file(std::string const & filename);
+ /// print messages from a file
+ static void print_file(std::string const & filename);
+
/// global buffer to hold the command stream
static std::stringstream cmd;
diff --git a/src/core/cvar.cc b/src/core/cvar.cc
index f8ea746..83ec5c4 100644
--- a/src/core/cvar.cc
+++ b/src/core/cvar.cc
@@ -21,6 +21,7 @@ Cvar *Cvar::con_ansi = 0;
Cvar *Cvar::sv_dedicated = 0;
Cvar *Cvar::sv_private = 0;
Cvar *Cvar::sv_framerate = 0;
+Cvar *Cvar::sv_name = 0;
Cvar *Cvar::net_host = 0;
Cvar *Cvar::net_port = 0;
diff --git a/src/core/cvar.h b/src/core/cvar.h
index 69fcae1..fceb79b 100644
--- a/src/core/cvar.h
+++ b/src/core/cvar.h
@@ -112,6 +112,7 @@ public:
static Cvar *sv_dedicated; // dedicated server
static Cvar *sv_private; // client with private server
static Cvar *sv_framerate; // server framerate
+ static Cvar *sv_name; // server name
static Cvar *con_ansi; // console ANSI colors
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 7e03c61..c18b1fa 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -104,6 +104,8 @@ GameServer::~GameServer()
Func::remove("who");
server_instance = 0;
+
+ players.clear();
}
void GameServer::abort()
@@ -114,26 +116,16 @@ void GameServer::abort()
void GameServer::list_players(Player *player)
{
using namespace std;
-
stringstream msgstr;
int count = 0;
- if (!Cvar::sv_dedicated->value()) {
- msgstr << setw(3) << localplayer()->id() << aux::spaces(localplayer()->name(), 24);
+ for (std::list<Player *>:: iterator it = players.begin(); it != players.end(); it++) {
+ msgstr.str("");
+ msgstr << setw(3) << (*it)->id() << aux::spaces((*it)->name(), 24);
send(player, msgstr.str());
count++;
}
- if (server_network) {
- std::list<NetClient *>:: iterator it;
- for (it = server_network->clients.begin(); it != server_network->clients.end(); it++) {
- msgstr.str("");
- msgstr << setw(3) << (*it)->player()->id() << aux::spaces((*it)->player()->name(), 24);
- send(player, msgstr.str());
- count++;
- }
- }
-
msgstr.str("");
msgstr << count << " connected " << aux::plural("player", count);
send(player, msgstr.str());
@@ -270,7 +262,8 @@ void GameServer::player_connect(Player *player)
// notify the game module
server_module->player_connect(player);
- // TODO manage player list
+ // manage player list
+ players.push_back(player);
}
void GameServer::player_disconnect(Player *player)
@@ -283,7 +276,14 @@ void GameServer::player_disconnect(Player *player)
// notify the game module
server_module->player_disconnect(player);
- // TODO manage player list
+ // manage player list
+ std::list<Player *>:: iterator it = players.begin();
+ while (((*it)->id() != player->id()) && (it != players.end())) {
+ it++;
+ }
+ if (it != players.end()) {
+ players.erase(it);
+ }
}
void GameServer::frame(float seconds)
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index c35ef74..d7d6eb8 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -64,6 +64,8 @@ public:
/// a player sends a command to the game server
void exec(Player *player, std::string const &cmdline);
+ std::list<Player *> players;
+
/*----- static ---------------------------------------------------- */
/// return the current game server
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 5334c6f..b604f47 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -278,7 +278,7 @@ void NetServer::client_initialize(NetClient *client) {
// send welcome message
std::ostringstream netmsg;
netmsg.str("");
- netmsg << "msg info Receiving data from remote server...\n";
+ netmsg << "msg info ^B" << Cvar::sv_name->str() << "\n";
client->send(netmsg.str());
client->transmit(fd());