#39 Command prompts

open
nobody
None
5
2011-12-26
2011-12-26
Ron Lovis
No

KC v2.11.1 (definitely), build 1199 (probably). The mud text shown below is from a standard installation of the Dead Souls mudlib.

1. I have been trying to write a gag trigger to stop KC displaying empty lines. (My laptop's monitor is small.)

Pattern:
'^\s*$'
Action:
''
Omit (gag) from output:
checked

2. This is the output:

You are on the shore, at the far eastern end of town. A road travels west into the heart of town. A
great sea stretches out into the eastern horizon.
There is a sign here you can read.
Obvious exits: east, west
hp: 390/390 mp: 850/850 sp: 441/441 >
hp: 390/390 mp: 850/850 sp: 441/441 >
hp: 390/390 mp: 850/850 sp: 441/441 > A soft breeze cools your brow.

3. The command prompt is displayed three times (two empty lines were removed). I only want to see it once. Is it a bug that KC keeps re-displaying the command prompt? I have tried thousands of different regexs in the trigger pattern/action, but I always see the same thing.

4. The gag trigger is still enabled. I set up a hook event 'OnReceivedText'.

Action:
'/myPlugin->myFunc("$hookdata")'

5. KC sends my script this line:

'Obvious exits: east, west hp: 390/390 mp: 850/850 sp: 441/441 >'

This is pretty bad. My script now thinks that 'hp', '390/390', 'mp' etc are exits in the current room.

6. If I send several commands at once (e.g. 'west%;west%;west'), KC sends me lines like this:

'Obvious exits: east, west hp: 390/390 mp: 850/850 sp: 441/441 > You are standing in the town centre'

Now two lines have been joined to become one. This is definitely some kind of error!

7. By the way, I found a small error in the KC manual, v2.11.1, chapter C2:

$world->alias("pattern", "action", { attribute1 => value1,
attribute2 => value2, ... })

...'action' should be 'substitution', yes?

Discussion

  • Ron Lovis
    Ron Lovis
    2011-12-27

    Update - please ignore 4-6. They are nothing to do with KildClient.

     
  • Cycy
    Cycy
    2012-04-18

    I regrettably suggest that your MUD is sending the same prompt 3 times, and attempting to conceal this with a trailing carriage return. Things do that for a "updatable line" hack, returning to the beginning and overwriting the line with new characters (or in this case, the exact same characters).

    I don't know why kildclient would treat that lone carriage return as a line by itself (gagging it) but it probably has something to do with src/net.c:data_ready_cb reading lines wrong. A line should either be a newline, or a carriage return followed by a newline, never a carriage return by itself, which doesn't designate any sort of new line and is part of the same line. data_ready_cb:962 correctly delineates lines by \n and not \r, so a line like "hp: 390/390 mp: 850/850 sp: 441/441 >\rhp: 390/390 mp: 850/850 sp: 441/441 >\rhp: 390/390 mp: 850/850 sp: 441/441 >\n A soft breeze cools your brow." should only produce two non-empty lines with non-whitespace, neither of them gagged. Instead it produces 8 lines, each \r as its own line (gagged), and also the last \n for some reason, then reduced to 3 lines with the last \n discarded entirely.

    ideally you would contact your MUD administrators and tell them to stop updating the prompt when your hp, mp, and sp haven't changed at all, and they would get right working on that because you don't pay them to do things half assed, right?

     
  • Actually older Macs (up to OS-X) did use only \r to mark line end. I don't know if any server used that convention.

    According to the telnet RFC, only \r\n should be used. But KildClient tries to accept any valid newline marker (and even some invalid ones, such as \n\r - sent by some Smaug-based servers).

    Even if \r were not treated as a newline, it still wouldn't erase the previous line (unless I specifically added code to do that, which I do not intend to). I'm afraid the problem is in the server and its non-standard line handling.

     
  • By the way, in "hp: 390/390 mp: 850/850 sp: 441/441 >\rhp: 390/390 mp: 850/850 sp: 441/441 >\rhp: 390/390 mp: 850/850 sp: 441/441 >\n A soft breeze cools your brow." the \r are treated as \n, so four lines are produced. The gag would not fire as there are no empty lines.