From 9ff5cf6184b9c5183c1f55cfa6c0d08586eb02c9 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 10 Feb 2011 18:07:24 +0000 Subject: Added a local chat channel. The say command defaults to zone chat, global messages can be send with the shout command. Removed NonSolid flag fro race objects, have race use the local chat channel. Updated to network protocol version 22. Updated developer documentation. --- src/core/gameserver.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 3 deletions(-) (limited to 'src/core/gameserver.cc') diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 1bd0dbe..d6f9029 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -255,7 +255,8 @@ Inventory *GameServer::request_inventory(Entity *entity) } -void GameServer::say(Player *player, std::string const &message) +// global chat message +void GameServer::shout(Player *player, std::string const &message) { if (!message.size()) return; @@ -265,14 +266,39 @@ void GameServer::say(Player *player, std::string const &message) return; } + // TODO strip color codes if requested std::string notification("^B"); notification.append(player->name()); - notification.append("^F:^N "); + notification.append("^B: "); notification.append(message); broadcast(Message::Public, notification); } +// local chat message +void GameServer::say(Player *player, std::string const &message) +{ + if (!message.size()) + return; + + if(!player->zone()) + return; + + if (player->mute()) { + player->send("^WYou have been muted"); + return; + } + + // TODO strip color codes if requested + std::string notification("^B"); + notification.append(player->name()); + notification.append("^B:^N "); + notification.append(message); + + broadcast(player->zone(), notification); +} + +// player-to-player chat messages void GameServer::private_message(Player *player, std::string const &args) { if (!args.size()) @@ -346,6 +372,29 @@ void GameServer::broadcast(const Message::Channel channel, const std::string tex } } +// broadcast a message to all players in a particular zone +void GameServer::broadcast(Zone *zone, std::string const text, Player *ignore_player) +{ + if (!text.size()) + return; + + for (Players::iterator it = players().begin(); it != players().end(); it++) { + Player *player = (*it); + if ((player->zone() == zone) && (player != ignore_player)) { + Player *player = (*it); + player->message(Message::Local, text); + } + } + + // console is not in the player list + if (Cvar::sv_dedicated->value()) { + std::string notification(zone->label()); + notification += ' '; + notification.append(text); + localplayer()->message(Message::Local, notification); + } +} + // broadcast a sound event to all players void GameServer::broadcast_sound(const std::string name, Player *ignore_player) { @@ -418,11 +467,13 @@ void GameServer::player_connect(Player *player) player->player_id = server_maxplayerid++; + /* std::string message("^B"); message.append(player->name()); message.append("^B connects."); broadcast(message, player); - + */ + // notify the game module server_module->player_connect(player); -- cgit v1.2.3