Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-02-10 18:07:24 +0000
committerStijn Buys <ingar@osirion.org>2011-02-10 18:07:24 +0000
commit9ff5cf6184b9c5183c1f55cfa6c0d08586eb02c9 (patch)
treed50dd2d8ed48acfbb7063d4c073f77cb195106f7 /src/core/gameserver.cc
parenta255dbc032d15a4f5024bc60baa19c45ebceecc6 (diff)
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.
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);