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
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,
{
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;
| 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},
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) {
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;
}
dbref who;
int silent, nospoof;
+ if(!arg2 || !*arg2)
+ return;
+
silent = (flags & PEMIT_SILENT) ? 1 : 0;
nospoof = (flags & PEMIT_SPOOF) ? 0 : 1;