HomeWildfire Games

Fix missing wstring_from_utf8 for multi-user-chat messages and translated…

Description

Fix missing wstring_from_utf8 for multi-user-chat messages and translated strings following rP22856 / D2264.

The commit introduced support for arbitrary lobby CreateGUIMessage JS::Value arguments but didn't transfer wstring_from_utf8 appropriately.
Instead of enlengthening the code by reintroducing utf8_from_wstring everyhwere, shorten the code and specialize ToJSVal for glooxwrapper::string and gloox enums.

Avoid string copies for XmppClient getters, refs D1668:
Change GetPresence() and GetRole() to return the pointer to the string literal instead of copy constructing a std::string each call.
Don't reintroduce the unneeded utf8_from_wstring conversions for the untranslatable ASCII identifiers returned by GetPresence() and GetRole().
Change GetSubject() to return a const ref to the member instead of copy assigning the std::string to an output value.
Change m_Subject to std::wstring to avoid constructing a copy using wstring_from_utf8 each GetSubject() call.
Change gloox enum to translatable string functions to be static, so as to use them in the new ToJSVal functions (enabled by not calling CertificateErrorToString from ConnectionErrorToString anyymore in rP22880/D2274).

Avoid per-player string copies in m_PlayerMap:
Change m_PlayerMap value type from std::vector<std::string> to a new PlayerMap struct with named members for readability.
Use gloox enums as PlayerMap values to avoid constructing (performance) and storing (memory footprint) std::strings.
The JS String is created from the pointer to the ASCII string literal without intermediaries.
Use glooxwrapper::string for nickname and m_Rating since it's the data source type received in relevant places, but that might be improved for performance with std::wstring.

Construct map values in place where possible and post error instead of silently inserting if an existing value is to be modified.
Avoid repeated std::map lookups on string keys by caching the PlayerMap::iterator where available.

Remove some glooxwrapper::string to_string() calls redundant with its operator<< and improve DbgXMPP gloox enum output.
Transfer rating too upon nickchange.

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