Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
raviden
Novice


Joined: 02 Nov 2010
Posts: 45

PostPosted: Fri Jul 10, 2015 1:58 am   

Problem with GMCP
 
Hi,

I have a problem with GMCP, when the %gmcp variable is not assigned correctly by CMUD. I have no idea what could be the reason (if its mud-related, or cmud bug) - could someone help?

For example, when I move from room with exit E into room with no exits (visible or other), the exit value does not change:

For debug purposes, I made GMCP trigger:
Code:

#say %gmcp.module : main package name
#say %gmcp.package : actually the subpackage
#say %gmcp.message : the name of the message
#say %gmcp.data : the data received for this package as a database variable/string list
#say %gmcp.olddata : the previous data for this message
#say %0 : the raw string value received with the message. Should normally be a JSON string
#say ERRORS: %gmcp_errors
#say GMCP: %gmcp.room



In the first room:
Code:

room : main package name
 : actually the subpackage
info : the name of the message
exits=e: the data received for this package as a database variable/string list
exits=e: the previous data for this message
{"exits":["e"]} : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects="nums|data"
GMCP: info="exits=e"


#debugfile data:
Code:

<ESC>[0m<IAC><SB><201>room.info {"exits":["e"]}<IAC><SE>>


And when I move to second room:
Code:

room : main package name
 : actually the subpackage
info : the name of the message
exits=e: the data received for this package as a database variable/string list
exits=e: the previous data for this message
{} : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects="nums|data"
GMCP: info="exits=e"


#debugfile data:
Code:

<IAC><SB><201>room.info {}<IAC><SE>>


The same problem happens for example with objects package - it is not cleared every time new data appears, but the data is somehow appended to %gmcp instead. Can anyone think of any reason for this?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Jul 10, 2015 9:14 am   
 
This would appear to be a CMud bug. I would suggest making a Telnet trigger to capture the data yourself and using your own variable instead of the %gmcp predefined variable.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Fri Jul 10, 2015 11:13 am   
 
This is actually not a bug. If a particular field is not included in a GCMP message, CMUD will retain the previous value assigned to that field. This is to allow MUDs to selectively update fields. If only a single field has changed in a message that normally contains 10 fields, the MUD can send only that single field, rather than having to send everything that did not change along with it. The recommendation for MUD implementations is to send blank data (i.e. exits: []) in situations where clearing the previous data is required.
Reply with quote
raviden
Novice


Joined: 02 Nov 2010
Posts: 45

PostPosted: Fri Jul 10, 2015 4:34 pm   
 
Daern: that does not explain, why the same happens when I receive objects.nums data - I'll paste an example as soon as I'm back home from work, so you can see, but basicly:

Objects have two subpackages/messages - nums (that is an JSON array of ids) and data (that is JSON mapping of some data).

When I receive a larger package of object.nums f.e. [1000,2000] and then when I receive [1000], the %gmcp does not update accordingly and the %gmcp.object.nums is still 1000|2000, instead of just 1000. The same problem is with objects.data variable - it expands, but does not shrink. I'll post some raw data from MUD as soon as possible, but if you have some ideas why that could happen - please let me know so I can try to search for it.

It seems, that JSON message from MUD is proper - that's why I don't have an idea what can go wrong there.
Reply with quote
raviden
Novice


Joined: 02 Nov 2010
Posts: 45

PostPosted: Sat Jul 11, 2015 1:35 am   
 
GMCP trigger:
Code:

<trigger type="GMCP" priority="4040" newline="false" prompt="true" id="404">
  <pattern>objects</pattern>
  <value>#say Objects!
#say %gmcp.module : main package name
#say %gmcp.package : actually the subpackage
#say %gmcp.message : the name of the message
#say %gmcp.data : the data received for this package as a database variable/string list
#say %gmcp.olddata : the previous data for this message
#say %0 : the raw string value received with the message. Should normally be a JSON string
#say ERRORS: %gmcp_errors
#say GMCP_OBJECTS: %gmcp.objects</value>
</trigger>


Here's the data:

After clearing %gmcp (closing and opening session, so %gmcp is null), first info from objects:
Code:
in* (  153) 07-10-15 21:27:50:276 : <IAC><SB><201>objects.nums [1]<IAC><SE><IAC><SB><201>objects.data {"1":{"avatar":true,"attack_num":false,"defense_target":false,"team_leader":false,"living":true,"hp":6}}<IAC><SE>

Results in triggers
objects.nums:
Code:

objects : main package name
 : actually the subpackage
nums : the name of the message
1 : the data received for this package as a database variable/string list
 : the previous data for this message
[1] : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects=nums
GMCP_OBJECTS: nums=1


and objects.data:
Code:

objects : main package name
 : actually the subpackage
data : the name of the message
1="avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6" : the data received for this package as a database variable/string list
 : the previous data for this message
{"1":{"avatar":true,"attack_num":false,"defense_target":false,"team_leader":false,"living":true,"hp":6}} : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects="nums|data"
GMCP_OBJECTS: nums=1|data="1=""avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6"""


Then I go to second location, with additional object.
Code:
in* (  212) 07-10-15 21:28:00:570 : <IAC><SB><201>objects.nums [1,2]<IAC><SE><IAC><SB><201>objects.data {"2":{"desc":"Bear","defense_target":false,"attack_num":false,"attack_target":false,"team_leader":false,"team":false,"enemy":false,"living":true,"hp":6}}<IAC><SE>


GMCP triggers (objects.nums):
Code:

objects : main package name
 : actually the subpackage
nums : the name of the message
1|2 : the data received for this package as a database variable/string list
1 : the previous data for this message
[1,2] : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects="nums|data"
GMCP_OBJECTS: nums="1|2"|data="1=""avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6"""


and objects.data:
Code:

objects : main package name
 : actually the subpackage
data : the name of the message
1="avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6"|2="desc=Bear|defense_target=false|attack_num=false|attack_target=false|team_leader=false|team=false|enemy=false|living=true|hp=6" : the data received for this package as a database variable/string list
1="avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6" : the previous data for this message
{"2":{"desc":"Bear","defense_target":false,"attack_num":false,"attack_target":false,"team_leader":false,"team":false,"enemy":false,"living":true,"hp":6}} : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects="nums|data"
GMCP_OBJECTS: nums="1|2"|data="1=""avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6""|2=""desc=Bear|defense_target=false|attack_num=false|attack_target=false|team_leader=false|team=false|enemy=false|living=true|hp=6"""


Then I go back, to location with 1 object:
Code:
in* (   29) 07-10-15 21:28:09:911 : <IAC><SB><201>objects.nums [1]<IAC><SE><IAC><WILL><241>


GMCP trigger:
Code:

objects : main package name
 : actually the subpackage
nums : the name of the message
1|2 : the data received for this package as a database variable/string list
1|2 : the previous data for this message
[1] : the raw string value received with the message. Should normally be a JSON string
ERRORS: room=info|char="info|state"|objects="nums|data"
GMCP_OBJECTS: nums="1|2"|data="1=""avatar=true|attack_num=false|defense_target=false|team_leader=false|living=true|hp=6""|2=""desc=Bear|defense_target=false|attack_num=false|attack_target=false|team_leader=false|team=false|enemy=false|living=true|hp=6"""


As you can see, the %gmcp.objects.nums does not set to 1 as it should - it stays at 1|2 for some weird reason. Any idea? The same goes with gmcp.objects.data, you cant see that here, however when i go to room with 2 other objects, they'd append to existing %gmcp.objects.data instead of replacing them.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sat Jul 11, 2015 11:08 am   
 
The objects.data is exactly the same case that I described with exits above. The MUD did not send an updated value for the "2" field, so CMUD retained the previous value. If it did not do this, the data would be lost. I've never run into the objects.nums case as my MUD doesn't have any GMCP messages that are a single array... this one seems strange, but I assume it's a similar situation. As Vigilante suggested, your best bet might be to use telnet triggers on option 201, instead of GMCP triggers. You could use a pattern like this: ^([\w\.]+) (.+)$ to capture the module and data. The %json function can be used to parse the data into CMUD's variable format.

Edit: actually, looking at your examples more closely, it looks like %0 (the raw string value received with the message) is being set correctly. It would probably be simpler to use that, instead of a telnet trigger. You could set your own variables to the latest data using %0 in a GMCP trigger, then reference those variables in other triggers/aliases/etc instead of using %gmcp.
Reply with quote
raviden
Novice


Joined: 02 Nov 2010
Posts: 45

PostPosted: Sat Jul 11, 2015 2:27 pm   
 
Daern: that's what I was thinking about, however I do have the possibility to contact the mud creators and ask them to fix something with the mud output, if the error lies there - I do not see such thing though, so I don't know what to fix.

If you cant see the error either, I guess I'll just do everything based on %0 and %json function in gmcp trigger, as you mentioned.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Sun Jul 12, 2015 1:01 am   
 
I don't believe there is an error, just a misunderstanding of how GMCP works in CMUD. I think these two threads explain it pretty well:
http://forums.zuggsoft.com/forums/viewtopic.php?t=35695
http://forums.zuggsoft.com/forums/viewtopic.php?t=35773

As for changing the mud implementation, I would recommend sending an empty exits array in rooms with no exits (room.info {"exits":[]}) at the very least. I'll have to think more on the objects one.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net