From 5ceb4694a05ec68b5cfba18b0f25ba804be88a80 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 12 May 2008 18:32:15 +0000 Subject: console colors --- src/core/Makefile.am | 2 +- src/core/application.cc | 8 ++++---- src/core/commandbuffer.cc | 10 ++++++---- src/core/gameserver.cc | 30 +++++++++++++++--------------- src/core/netserver.cc | 22 ++++++++++------------ 5 files changed, 36 insertions(+), 36 deletions(-) (limited to 'src/core') diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 8b99c72..fb32450 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -12,5 +12,5 @@ libcore_la_LIBADD = $(top_builddir)/src/model/libmodel.la \ noinst_LTLIBRARIES = libcore.la noinst_HEADERS = application.h commandbuffer.h clientstate.h core.h cvar.h entity.h func.h \ gameconnection.h gameinterface.h gameserver.h module.h net.h \ - netclient.h netconnection.h netserver.cc player.h stats.h + netclient.h netconnection.h netserver.h player.h stats.h diff --git a/src/core/application.cc b/src/core/application.cc index be1dcac..2f8cc54 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -116,7 +116,7 @@ Application::~Application() void Application::init(int count, char **arguments) { con_debug << "Debug messages enabled\n"; - con_print << "Initializing core...\n"; + con_print << "^BInitializing core...\n"; filesystem::init(); @@ -182,7 +182,7 @@ void Application::init(int count, char **arguments) void Application::shutdown() { - con_print << "Shutting down core...\n"; + con_print << "^BShutting down core...\n"; if (connected()) disconnect(); @@ -241,7 +241,7 @@ void Application::connect(std::string const &host) application_game = new GameServer(); if (application_game->running()) { - con_print << "Connected to local game.\n"; + con_print << "^BConnected to local game.\n"; } else { delete application_game; application_game = 0; @@ -255,7 +255,7 @@ void Application::disconnect() if(application_game) { delete application_game; application_game = 0; - con_print << "Disconnected.\n"; + con_print << "^BDisconnected.\n"; } } diff --git a/src/core/commandbuffer.cc b/src/core/commandbuffer.cc index 56aba16..e97a00e 100644 --- a/src/core/commandbuffer.cc +++ b/src/core/commandbuffer.cc @@ -90,7 +90,7 @@ void CommandBuffer::init() func = Func::add("set", (FuncPtr)func_set); func->set_info("[variable] [str] set variable value"); - func = Func::add("exec", (FuncPtr)exec); + func = Func::add("exec", (FuncPtr)func_exec); func->set_info("[filename] execute commands from file"); } @@ -153,7 +153,7 @@ void CommandBuffer::exec(std::string const &cmdline) } } - con_print << command << " " << cvar->str() << " " << cvar->info() << "\n"; + con_print << command << " " << cvar->str() << " ^N" << cvar->info() << "\n"; return; } @@ -161,7 +161,7 @@ void CommandBuffer::exec(std::string const &cmdline) if (connection()) connection()->forward(cmdline); else - con_print << "Unknown command '" << command << "'\n"; + con_print << "Unknown command '" << command << "^N'\n"; } void CommandBuffer::exec() @@ -252,7 +252,9 @@ void CommandBuffer::exec_file(std::string const & filename) con_warn << "Could not stream " << fn << "!\n"; return; } - + + con_debug << "Executing " << fn.c_str() << std::endl; + char line[MAXCMDSIZE]; while (ifs.getline(line, MAXCMDSIZE-1)) { if (line[0] && line[0] != '#' && line[0] != ';') diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 98823e0..11a8b13 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -30,7 +30,7 @@ GameServer *GameServer::server_instance = 0; GameServer::GameServer() : GameInterface() { - con_print << "Initializing game server...\n"; + con_print << "^BInitializing game server...\n"; server_instance = this; server_network = 0; server_time = 0; @@ -51,7 +51,7 @@ GameServer::GameServer() : GameInterface() return; } - con_print << " module '" << server_module->name() << "'\n"; + con_print << " module '^B" << server_module->name() << "^N'\n"; if ((Cvar::sv_dedicated->value() || Cvar::sv_private->value())) { server_network = new NetServer(Cvar::net_host->str(), (unsigned int) Cvar::net_port->value()); @@ -63,7 +63,7 @@ GameServer::GameServer() : GameInterface() return; } } else { - con_debug << "Network server disabled.\n"; + con_print << " network server disabled.\n"; server_network = 0; } @@ -81,7 +81,7 @@ GameServer::~GameServer() { server_running = false; - con_print << "Shutting down game server...\n"; + con_print << "^BShutting down game server...\n"; if (server_network) { delete server_network; @@ -143,13 +143,13 @@ void GameServer::say(Player *player, std::string const &message) return; // send to console - con_print <name() << ": " << message << "\n"; + con_print << "^B" << player->name() << "^F:^B " << message << std::endl; // broadcast to remote clients if (server_network) { - std::string netmessage("msg public "); + std::string netmessage("msg public ^B"); netmessage.append(player->name()); - netmessage.append(": "); + netmessage.append("^F:^B "); netmessage.append(message); netmessage += '\n'; server_network->broadcast(netmessage); @@ -214,7 +214,7 @@ void GameServer::exec(Player *player, std::string const & cmdline) std::string message("Unknown command '"); message.append(command); - message.append("'"); + message.append("^N'"); send(player, message); } @@ -222,8 +222,9 @@ void GameServer::player_connect(Player *player) { player->player_id = server_maxplayerid++; - std::string message(player->name()); - message.append(" connects."); + std::string message("^B"); + message.append(player->name()); + message.append("^B connects."); broadcast(message, player); // notify the game module @@ -232,8 +233,9 @@ void GameServer::player_connect(Player *player) void GameServer::player_disconnect(Player *player) { - std::string message(player->name()); - message.append(" disconnects."); + std::string message("^B"); + message.append(player->name()); + message.append("^B disconnects."); broadcast(message, player); // notify the game module @@ -303,7 +305,7 @@ void GameServer::frame(float seconds) // transmit buffered sends server_network->transmit(); - // TODO - start server frame + // start server frame std::ostringstream framehdr; framehdr.str(""); framehdr << "frame " << server_time << "\n"; @@ -355,8 +357,6 @@ void GameServer::frame(float seconds) client->player()->player_dirty = false; } } - // TODO - end server frame - // transmit buffered sends server_network->transmit(); diff --git a/src/core/netserver.cc b/src/core/netserver.cc index e66f63d..5334c6f 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -39,7 +39,7 @@ namespace core NetServer::NetServer(std::string const host, unsigned int const port) { - con_print << "Initializing network server..." << std::endl; + con_print << "^BInitializing network server..." << std::endl; // initialize variables netserver_fd = -1; @@ -84,7 +84,7 @@ NetServer::NetServer(std::string const host, unsigned int const port) return; } - con_print << " Listening on " << inet_ntoa(netserver_addr.sin_addr) << ":" << ntohs(netserver_addr.sin_port) << std::endl; + con_print << " listening on " << inet_ntoa(netserver_addr.sin_addr) << ":" << ntohs(netserver_addr.sin_port) << std::endl; // add the listening socket to the file descriptor set FD_ZERO(&serverset); @@ -98,7 +98,7 @@ NetServer::NetServer(std::string const host, unsigned int const port) NetServer::~NetServer() { - con_print << "Shutting down network server..." << std::endl; + con_print << "^BShutting down network server..." << std::endl; std::string netmsg("disconnect\n"); @@ -140,8 +140,9 @@ void NetServer::reap() (*it)->abort(); // print a message - std::string message(client->player()->name()); - message.append(" timed out."); + std::string message("^B"); + message.append(client->player()->name()); + message.append(" ^Btimed out."); if (client->state() == NetClient::Connected) { server()->broadcast(message, client->player()); @@ -252,7 +253,6 @@ void NetServer::receive() } // remove dead connections - // FIXME timeout reap(); } @@ -365,8 +365,9 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me } else if ((client->state() == NetClient::Connected) && (client->player()->name() != oldname)) { - std::string netmsg(oldname); - netmsg.append(" renamed to "); + std::string netmsg("^B"); + netmsg.append(oldname); + netmsg.append(" ^Brenamed to "); netmsg.append(client->player()->name()); server()->broadcast(netmsg); } @@ -409,10 +410,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me // say if (command == "say") { if (message.size() > command.size()+1) { - std::ostringstream osstream; - osstream << "msg public " << client->player()->name() << " " << message.substr(command.size()+1) << "\n"; - broadcast(osstream.str()); - con_print << client->player()->name() << " " << message.substr(command.size()+1) << std::endl; + server()->say(client->player(), message.substr(command.size()+1)); } return; } -- cgit v1.2.3