Page 1 of 2

GMCP and ANSI Escape

Posted: Tue Apr 03, 2018 10:56 am
by Aconite
[ LUA ] - object:<JSON decoder error:> function:<json_to_value>
<Lua error:InvalidJSONInput: lexical error: invalid character inside string.
name": "'Captain Dieme's Saber[0;32m'[0;32m", "type": "wea
(right here) ------^
at ..\3rdparty\lua_yajl\lua_yajl.c line 345>


Im just a hobby programmer and not familiar with QT.

However i looked at the mudlet source code and looks like string being send to gmcp data is not filtered from Ansi Escape Characters
causing both error and not adding that line to the gmcp table itself.

So i propose a solution, dunno if it works but suggesting anyway.

in TLuaInterpreter.cpp

function void TLuaInterpreter::parseJSON(QString& key, const QString& string_data, const QString& protocol)

line 11162 auto dataInUtf8 = string_data.toUtf8();
Is it Possible to use QTextStream or QTextCodec to strip ansi from the json data?

Thank you.

Re: GMCP and ANSI Escape

Posted: Tue Apr 03, 2018 1:24 pm
by Vadi
Mudlet could strip it out but that wouldn't solve the real problem: the game sending ANSI escapes in out of band data where they don't make sense. Could you file a bug with the game about this?

Re: GMCP and ANSI Escape

Posted: Tue Apr 03, 2018 3:35 pm
by Aconite
Thank you for your fast response,

This error only happens on GMCP events and causing some of the major triggers stop working in the middle of script.
Posted a note on Bug board about this error. Unfortunately, game is not maintained as well as it used to be.
I thought this would be a good alternative solution.

Thank you.

Re: GMCP and ANSI Escape

Posted: Tue Apr 03, 2018 4:16 pm
by Vadi
We'll have a look. You are using Mudlet 3.7.1?

Re: GMCP and ANSI Escape

Posted: Tue Apr 03, 2018 4:34 pm
by Aconite
Thank you again for your fast response,

Yes I downloaded the latest version from mudlets Website "3.7.1"

Re: GMCP and ANSI Escape

Posted: Tue Apr 03, 2018 9:51 pm
by SlySven
Which MUD is doing this?

Re: GMCP and ANSI Escape

Posted: Wed Apr 04, 2018 8:33 am
by Aconite
It a very good family mud actually, Been playing for like 23+ years,
Not glorious as used to be but we have still have some numbers. Its called avatar

Re: GMCP and ANSI Escape

Posted: Wed Apr 04, 2018 4:34 pm
by SlySven
Given that sending out ANSI ESC codes in the main text is something that should be at the client/user's control (not all Telnet NVTs can handle them) is there any controls to frob on the Server?

Re: GMCP and ANSI Escape

Posted: Thu Apr 05, 2018 9:45 am
by Aconite
There is only one option for it. To turn all the colors off from the game. But thats not practical. Tried to color the text from mudlet but there are
some things that cant be colored or even it is being colored it will add too many trigger check which eventually will slow response time or give
errors which will be hard to debug.
I posted some notes to the bug forums about this that GMCP should be completely filtered from ANSI or any color in the game However, i dont think it will be solved in close future.

Re: GMCP and ANSI Escape

Posted: Thu Apr 05, 2018 2:31 pm
by Aconite
Regarding This problem,

I added the following code to the TLuaInterpreter.cpp to the Headers

Code: Select all

#include <QRegExp>
around line 11168:

Code: Select all

QString buf_string = string_data;
buf_string.remove(QRegExp("'\\x001B\\[\\d+;\\d+m"));
// auto dataInUtf8 = string_data.toUtf8();
auto dataInUtf8 = buf_string.toUtf8();
it works (able to compile Mudlet using ubuntu but couldn't manage to compile it in Windows.)
Moderator (SlySven) Edit: add code formatting to make it a bit clearer