HomeWildfire Games

Support creating lobby GUI messages with arbitrary arguments instead of forcing…


Support creating lobby GUI messages with arbitrary arguments instead of forcing every message type into the same struct type, refs #4877 / rP19514 / D339.

Creates the GUI messages directly as JS::Values and removes the intermediary rigid struct.
Implementation similar to ScriptInterface::CreateObject from D2080.

Differential Revision: https://code.wildfiregames.com/D2264
Tested on: clang 8.0.1, Jenkins

Event Timeline

elexis added inline comments.Mon, Sep 9, 10:23 AM


This removes wstring_from_utf8 for all GUI messages.

For some its unneeded, but the gloox strings are UTF encoded and must be decoded before creation of the JS value.

Reproduce for example by posting ä into the chat.

elexis added inline comments.Mon, Sep 9, 3:38 PM

The banal fix would be to add wstring_from_utf8 in every string property of every CreateObject call.

That would make the code longer, but the alternative is to make the code even shorter, by specializing ToJSVal<glooxwrapper::string>, i.e. the to_string() would be removed in every line instead of adding a new call in every line.

Notice that ToJSVal specializations were already proposed in D1667 for other instances and we can use it for the other gloox properties that are converted to strings as well.

elexis added inline comments.Wed, Sep 11, 11:59 AM

It seemed cleaner to only set "historic" for historic messages, furthermore it seemed to work since JS interprets it as false for chat messages, but JS complains about this being undefined for the kick messages. So it seems cleaner to always set this boolean as it was before rather than dealing with undefined or true in JS. Fix at D2282.