Closed JTM-rootstorm closed 6 years ago
Thanks for letting me know. Actually that block from MiniJSON is perfect. The bug is in CMProtocols.java, where the packet is constructed like so: doc.append("\"name\":\"").append(MiniJSON.toJSONString(I.Name())).append("\","); final String attribs = makeGMCPAttribs(I); if(attribs.length()>0) doc.append("\"attrib\":\"").append(attribs.toString()).append("\",");
--- see the problem? If there are no attributes, then it ends in a comma.
The fix is below. It is in several places, however, so you might just want to pull the latest rev.
doc.append("\"id\":").append(I.hashCode()).append(","); doc.append("\"name\":\"").append(MiniJSON.toJSONString(I.Name())).append("\""); final String attribs = makeGMCPAttribs(I); if(attribs.length()>0) doc.append(",\"attrib\":\"").append(attribs.toString()).append("\"");
Yeah, just a couple minutes more after enabling GMCP debug text and I would've had the right spot. So (not) close
I'll give the latest commit a spin!
Fun one: error still happens because a comma is missing between the } and {
<Lua error:InvalidJSONInput: parse error: after array element, I expect ',' or ']'
36131,"name":"a ration pack"}{"id":2110729899,"name":"a wate
(right here) ------^
at ..\3rdparty\lua_yajl\lua_yajl.c line 345>
my sloppy fix to that is
if (i == mob.numItems() - 1) {
doc.append("}");
} else {
doc.append("},");
}
though that's char.items.list specific, dont quite know if it'll be needed elsewhere just yet.
Using Mudlet 3.9.0 as client and this package for GMCP stuff.
Error:
Digging around the scripts from the package show no sign of doing anything but parsing whatever data it's given from the server, so I'm left thinking that a bit of code somewhere is adding in a comma where it shouldn't be; The toString functions for the MiniJSON.java classes under both core and siplet.support are really the only places I can find where this would happen, specifically
I feel like k.hasNext() is causing it to toss another comma in there before the closing brace, but I'm not sure as to why
I guess I'll be poking at it until it either turns out my hunch is wrong (or is not the lib's fault) or someone beats me to the solution