diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-02 19:18:44 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-02 19:18:44 +0000 |
commit | 89de2efebc22b3754c18ede10dc07bfc397fc2d0 (patch) | |
tree | 1d005c4b0ad66333235ecfbea03089bb31015b48 /src/core | |
parent | fd6f22924fd0d85ee20fb1d5e4588ac441675ea9 (diff) |
initial server ncurses console
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/application.cc | 23 | ||||
-rw-r--r-- | src/core/commandbuffer.cc | 1 | ||||
-rw-r--r-- | src/core/core.cc | 2 | ||||
-rw-r--r-- | src/core/cvar.cc | 2 | ||||
-rw-r--r-- | src/core/cvar.h | 3 | ||||
-rw-r--r-- | src/core/gameserver.cc | 4 | ||||
-rw-r--r-- | src/core/netconnection.cc | 2 | ||||
-rw-r--r-- | src/core/netserver.cc | 15 | ||||
-rw-r--r-- | src/core/netserver.h | 3 | ||||
-rw-r--r-- | src/core/player.cc | 1 | ||||
-rw-r--r-- | src/core/player.h | 13 |
11 files changed, 52 insertions, 17 deletions
diff --git a/src/core/application.cc b/src/core/application.cc index 738a071..cd6d278 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -61,9 +61,9 @@ void func_disconnect(std::string const &args) // --------------- signal_handler ----------------------------------- +#ifndef _WIN32 extern "C" void signal_handler(int signum) { -#ifndef _WIN32 switch (signum) { case SIGHUP: case SIGINT: @@ -78,13 +78,18 @@ extern "C" void signal_handler(int signum) application()->quit(1); } break; +#ifdef HAVE_CURSES + case SIGWINCH: + sys::ConsoleInterface::instance()->resize(); + break; +#endif default: std::cerr << "Received signal " << signum << ", terminated...\n"; application()->quit(1); break; } -#endif } +#endif // --------------- Application ----------------------------- @@ -106,6 +111,9 @@ Application::Application() sys::signal(SIGINT, signal_handler); sys::signal(SIGQUIT, signal_handler); sys::signal(SIGTERM, signal_handler); +#ifdef HAVE_CURSES + sys::signal(SIGWINCH, signal_handler); +#endif #endif } @@ -165,6 +173,10 @@ void Application::init(int count, char **arguments) Cvar::net_framerate = Cvar::get("net_framerate", "25"); Cvar::net_framerate->set_info("[int] network framerate in frames/sec"); + // passwords + Cvar::rconpassword = Cvar::get("rconpassword", "", Cvar::Archive); + Cvar::rconpassword->set_info("[string] password for remote console access"); + #ifdef _WIN32 Cvar::con_ansi = Cvar::get("con_ansi", "0", Cvar::Archive); #else @@ -185,7 +197,7 @@ void Application::init(int count, char **arguments) // register our engine functions Func *func = 0; func = Func::add("help", func_help); - func->set_info("dummy help function"); + func->set_info("help function"); func = Func::add("quit", func_quit); func->set_info("exit the application"); @@ -212,7 +224,6 @@ void Application::shutdown() save_config(); // remove our engine functions - Func::remove("print"); Func::remove("help"); Func::remove("quit"); @@ -280,8 +291,6 @@ void Application::disconnect() void Application::frame(float seconds) { - console()->flush(); - // execute commands in the buffer CommandBuffer::exec(); @@ -299,8 +308,6 @@ void Application::frame(float seconds) if (!application_game->running()) disconnect(); - - console()->flush(); } void Application::save_config() diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc index 0d02e6b..b34b04b 100644 --- a/src/core/commandbuffer.cc +++ b/src/core/commandbuffer.cc @@ -93,6 +93,7 @@ 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"); diff --git a/src/core/core.cc b/src/core/core.cc index c77087e..0f68ab3 100644 --- a/src/core/core.cc +++ b/src/core/core.cc @@ -12,7 +12,7 @@ namespace core { std::string core_name("The Osirion Project"); -std::string core_version("0.1"); +std::string core_version(VERSION); const std::string &name() { diff --git a/src/core/cvar.cc b/src/core/cvar.cc index 9d90afd..772144f 100644 --- a/src/core/cvar.cc +++ b/src/core/cvar.cc @@ -31,6 +31,8 @@ Cvar *Cvar::net_maxclients = 0; Cvar *Cvar::net_timeout = 0; Cvar *Cvar::net_framerate = 0; +Cvar *Cvar::rconpassword = 0; + std::map<std::string, Cvar*> Cvar::registry; Cvar::Cvar(const char *name, unsigned int flags) diff --git a/src/core/cvar.h b/src/core/cvar.h index 620096b..7aab5d3 100644 --- a/src/core/cvar.h +++ b/src/core/cvar.h @@ -123,6 +123,9 @@ public: static Cvar *net_maxclients;// maximum number of connected clients static Cvar *net_timeout; // network timeout in seconds static Cvar *net_framerate; // client network send framerate + + static Cvar *rconpassword; // rcon password + private: std::string cvar_name; std::string cvar_info; diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 3bcc4fe..cddddff 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -298,6 +298,10 @@ void GameServer::exec(Player *player, std::string const & cmdline) void GameServer::player_connect(Player *player) { + if (Cvar::sv_dedicated->value() && (player == localplayer())) { + return; + } + player->player_id = server_maxplayerid++; std::string message("^B"); diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index fc2e5d0..b89887c 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -348,7 +348,7 @@ void NetConnection::parse_incoming_message(const std::string & message) // FIXME - separate sender nickname if (message.size() > 11) { application()->notify_message(message.substr(11)); - application()->notify_sound("com/chat.wav"); + application()->notify_sound("com/chat"); } } else if (level == "snd") { diff --git a/src/core/netserver.cc b/src/core/netserver.cc index b604f47..2859006 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -126,6 +126,10 @@ NetServer::~NetServer() } } +void NetServer::abort() { + netserver_error = true; +} + // remove disconnected clients void NetServer::reap() { @@ -185,9 +189,14 @@ void NetServer::receive() int nb = select(fd()+1, &readset, NULL, NULL, &timeout); if (nb == -1) { +#ifndef _WIN32 + // ncurses needs SIGWINCH catched + if (errno == EINTR) { + return; + } +#endif con_error << "Network error on select()" << std::endl; - //perror("select"); - abort(); + this->abort(); return; } @@ -200,7 +209,7 @@ void NetServer::receive() ssize_t bytes_received = ::recvfrom(fd(), recbuf, FRAMESIZE-1, 0, (struct sockaddr *)&client_addr, &client_addr_len); if (bytes_received == -1) { con_error << "Network error on recvfrom()!" << std::endl; - abort(); + this->abort(); return; } else { //con_debug << "Incoming data '" << recbuf << "'"<< bytes_received << " bytes" << std::endl; diff --git a/src/core/netserver.h b/src/core/netserver.h index 5850b29..a83229c 100644 --- a/src/core/netserver.h +++ b/src/core/netserver.h @@ -64,6 +64,9 @@ public: std::list<NetClient *> clients; protected: + /// set the error state + void abort(); + /// called when a new client connects NetClient *client_connect(std::string const host, int const port); diff --git a/src/core/player.cc b/src/core/player.cc index 71ac8de..97b6944 100644 --- a/src/core/player.cc +++ b/src/core/player.cc @@ -28,6 +28,7 @@ void Player::clear() player_id = 0; player_name.clear(); player_dirty = false; + player_rcon = false; clear_assets(); } diff --git a/src/core/player.h b/src/core/player.h index 08abac2..b8dd100 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -25,7 +25,9 @@ namespace core class Player { public: + /// default constructor Player(); + /// default destructor ~Player(); /*----- inspectors ------------------------------------------------ */ @@ -79,19 +81,22 @@ public: /* -- should actually not be public --*/ - // dirty state + /// dirty state bool player_dirty; - // id of the player + /// indicates rcon access + bool player_rcon; + + /// id of the player int player_id; // name of the player std::string player_name; - // color + /// player color math::Color player_color; - // the entity the Player is currently controling + /// the entity the Player is currently controling EntityControlable *player_control; std::list<EntityControlable*> assets; |