/* core/gameinterface.cc This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #include #include class GameInterface; #include "core/application.h" #include "core/gameinterface.h" #include "core/player.h" #include "sys/sys.h" namespace core { GameInterface *game() { return GameInterface::instance(); } GameInterface *GameInterface::gameinterface_instance = 0; GameInterface::GameInterface(const char *gamename) { gameinterface_instance = this; connected = false; if (gamename) game_name.assign(gamename); else game_name.clear(); } GameInterface::~GameInterface() { gameinterface_instance = 0; } GameInterface *GameInterface::instance() { return gameinterface_instance; } std::string const &GameInterface::name() { return game_name; } void message_broadcast(std::string const & message, int ignoreplayer) { // send to console con_print << message << std::endl; // broadcast to remote clients if (application()->netserver) { std::string netmessage("msg info "); netmessage.append(message); netmessage += '\n'; application()->netserver->broadcast(netmessage, ignoreplayer); } } void message_send(Player const &player, const char *protohdr, std::string message) { // send to console if (&player == &localplayer) { con_print << message << std::endl; } // send to remote clients if (application()->netserver) { NetClient *client = application()->netserver->find_client(player); if (client) { std::string netmessage("msg info "); netmessage.append(message); netmessage += '\n'; application()->netserver->send(client, message); } } } } // namespace core