From c8fb85ae35825d6f705e43a1d8ac65d52f5fae31 Mon Sep 17 00:00:00 2001 From: Rick L Bird Date: Thu, 5 May 2011 20:53:22 -0400 Subject: [PATCH] PennMUSH 1.8.3p11 Author: talvo@talvo.com Date: Fri Nov 27 00:01:23 2009 +0000 Issue 140, @pemit = would show nospoof info to Author: talvo@talvo.com Date: Thu Nov 26 23:53:54 2009 +0000 Issue 142, @pemit/port and pemit(, ). Fixes #164 Fixes #129 --- hdrs/game.h | 1 + src/bsd.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/cmds.c | 8 +++++++- src/command.c | 2 +- src/funmisc.c | 7 +++++-- src/speech.c | 3 +++ 6 files changed, 58 insertions(+), 4 deletions(-) diff --git a/hdrs/game.h b/hdrs/game.h index 31cb229..59bff4f 100644 --- a/hdrs/game.h +++ b/hdrs/game.h @@ -135,6 +135,7 @@ extern void do_page(dbref player, const char *arg1, const char *arg2, dbref cause, int noeval, int multipage, int override, int has_eq); extern void do_page_port(dbref player, dbref cause, const char *arg1, const char *arg2, bool noeval_msg); +extern void do_pemit_port(dbref player, const char *pc, const char *msg, int flags); extern void do_think(dbref player, const char *message); #define PEMIT_SILENT 0x1 #define PEMIT_LIST 0x2 diff --git a/src/bsd.c b/src/bsd.c index edfb67f..7dc130f 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -3107,10 +3107,51 @@ player_desc(dbref player) return (DESC *) NULL; } + +/** Pemit to a specified socket. + * \param player the enactor. + * \param pc string containing port number to send message to. + * \param message message to send. + * \param flags PEMIT_* flags + */ +void +do_pemit_port(dbref player, const char *pc, const char *message, int flags) { + DESC *d; + int port; + + if (!Site(player)) { + notify(player, T("Permission denied.")); + return; + } + + port = atoi(pc); + if (port <= 0) { + notify(player, T("That's not a port number.")); + return; + } + + if (!*message) { + return; + } + + d = port_desc(port); + if (!d) { + notify(player, T("That port is not active.")); + return; + } + + if (!(flags & PEMIT_SILENT)) + notify_format(player, T("You pemit \"%s\" to %s."), message, (d->connected ? Name(d->player) : T("a connecting player"))); + queue_string_eol(d, message); + +} + /** Page a specified socket. * \param player the enactor. + * \param cause the cause * \param pc string containing port number to send message to. * \param message message to send. + * \param eval_msg Should message be evaluated? */ void do_page_port(dbref player, dbref cause, const char *pc, diff --git a/src/cmds.c b/src/cmds.c index 498c5f1..e3969e1 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -849,13 +849,19 @@ COMMAND(cmd_pemit) { int flags; - SPOOF(player, cause, sw); if (SW_ISSET(sw, SWITCH_SILENT)) flags = PEMIT_SILENT; else if (SW_ISSET(sw, SWITCH_NOISY)) flags = 0; else flags = SILENT_PEMIT ? PEMIT_SILENT : 0; + + if(SW_ISSET(sw, SWITCH_PORT)) { + do_pemit_port(player, arg_left, arg_right, flags); + return; + } + + SPOOF(player, cause, sw); if (!strcmp(cmd->name, "@NSPEMIT")) flags |= PEMIT_SPOOF; diff --git a/src/command.c b/src/command.c index 1b68689..f7a13ca 100644 --- a/src/command.c +++ b/src/command.c @@ -251,7 +251,7 @@ COMLIST commands[] = { | CMD_T_RS_NOPARSE | CMD_T_NOGUEST, NULL}, {"@PCREATE", NULL, cmd_pcreate, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_RS_ARGS, "!POWER^GUEST"}, - {"@PEMIT", "LIST CONTENTS SILENT NOISY NOEVAL SPOOF", cmd_pemit, + {"@PEMIT", "LIST CONTENTS SILENT NOISY NOEVAL PORT SPOOF", cmd_pemit, CMD_T_ANY | CMD_T_EQSPLIT | CMD_T_NOGAGGED, NULL}, {"@POLL", "CLEAR", cmd_poll, CMD_T_ANY, NULL}, {"@POOR", NULL, cmd_poor, CMD_T_ANY, NULL}, diff --git a/src/funmisc.c b/src/funmisc.c index 3770caf..98a0701 100644 --- a/src/funmisc.c +++ b/src/funmisc.c @@ -69,7 +69,7 @@ FUNCTION(fun_valid) FUNCTION(fun_pemit) { int ns = string_prefix(called_as, "NS"); - int flags = PEMIT_LIST; + int flags = PEMIT_LIST | PEMIT_SILENT; dbref saved_orator = orator; if (!command_check_byname(executor, ns ? "@nspemit" : "@pemit") || fun->flags & FN_NOSIDEFX) { @@ -79,7 +79,10 @@ FUNCTION(fun_pemit) orator = executor; if (ns) flags |= PEMIT_SPOOF; - do_pemit_list(executor, args[0], args[1], flags); + if (is_strict_integer(args[0])) + do_pemit_port(executor, args[0], args[1], flags); + else + do_pemit_list(executor, args[0], args[1], flags); orator = saved_orator; } diff --git a/src/speech.c b/src/speech.c index 69be7c6..0969a5f 100644 --- a/src/speech.c +++ b/src/speech.c @@ -533,6 +533,9 @@ do_pemit(dbref player, const char *arg1, const char *arg2, int flags) dbref who; int silent, nospoof; + if(!arg2 || !*arg2) + return; + silent = (flags & PEMIT_SILENT) ? 1 : 0; nospoof = (flags & PEMIT_SPOOF) ? 0 : 1; -- 2.30.2