# [igor@linguist.dartmouth.edu: Re: Modifying player properties based entering any command]

"Robert J. Brown" (rj@eli.wariat.org)
Thu, 27 Mar 1997 12:31:29 -0600

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    ------- Start of forwarded message -------
    Return-Path: nop@ccs.neu.edu
    Mime-Version: 1.0
    Content-Type: text/plain; charset="us-ascii"
    X-NS-Transport-ID: 0800207424C500FBB36A
    Date: Wed, 19 Mar 1997 23:34:44 PST
    From: Jeff Dubrule <igor@linguist.dartmouth.edu>
    Subject: Re: Modifying player properties based entering any command
    To: MOO-cows wizards list <moo-cows@xerox.com>
    Sender: MOO-Cows-Errors@parc.xerox.com
    Precedence: bulk
    X-Filter: mailagent [version 3.0 PL44] for fox@ares.mars.org
    Resent-From: clue-cows <nop@nop.com>
    Errors-To: clue-cows <nop@nop.com>

    At 11:07 PM -0800 3/19/97, Christopher Unkel wrote:
    >On Wed, 19 Mar 1997, Kipp the Kidd wrote:
    >
    >> At 05:27 PM 3/19/97 PST, Scott Robinson wrote:
    >> >Ok, you will have to set your connection to "binary".
    >> >(set_connection_option(player,"binary",1);) and have your :do_command
    >> >understand the "binary" representations in-Server (encode_binary,
    >> >decode_binary) because your server will error up with a "binary"
    >> >connection. I'll send in example code in a bit. =)
    >>
    >> I don't think Henry was looking for this... he said anything a player types,
    >> and players can't "type" binary.  The <CR> is really just enter, which makes
    >> $do_command()'s argstr to "".  Also, this eliminates any chances of using
    >> default parsing, if do_command wants to use it.  I can't imagine why you
    >> would want this done on the main login port.
    >
    >Yes, putting an incoming connection into binary mode has unpleasant side
    >effects.
    >
    >But if you want the server to respond to empty lines -- that is, just a
    >CR, it is necessary.  The server ignores "blank" lines, so $do_command
    >will *not* be called with an argstr of "" when a CR by itself is entered.
    >
    >Try it -- program $do_command with something like "notify(player,
    >"$do_command); return 0;" and try some blank lines, either just a CR or
    >some spaces and then a CR.  You won't get any output.

    I've managed to solve this problem by stripping off the lines, then
    force_input()ing them to be the next command processed, and then letting
    them pass through.  I checked to see whether the entire text was a blank
    line and, if so, shoved "CRLF" into the buffer instead.

    Here's the code for anyone interested:

    .program #333:do_command
    if (caller != #-1)
      raise(E_PERM);
    elseif (!connection_option(player, "binary"))
      set_connection_option(player, "binary", 1);
      force_input(player, argstr, 1);
      return 1;
    elseif (length(decode_binary(argstr)) == 1)
      return 0;
      "parse it normally";
    else
      while (i = min(index(argstr, "~0A~0D") || index(argstr, "~0D~0A"),
    index(argstr, "~0D~0A") || index(argstr, "~0A~0D")))
        if (i == 1)
          force_input(player, "CRLF");
          argstr[0..6] = "";
        else
          force_input(player, strsub(argstr[1..i - 1], "~7E", "~"));
          argstr[0..i + 5] = "";
        endif
        suspend(0); /* suspend OK here because we won't be passing this on
    anyway */
      endwhile
    endif
    return 1;
    .

    - -manta
    ------- End of forwarded message -------