Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/gameserver.cc')
-rw-r--r--src/core/gameserver.cc57
1 files changed, 54 insertions, 3 deletions
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);