Details
test
Diff Detail
- Repository
- rP 0 A.D. Public Repository
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
binaries/data/mods/public/gui/lobby/lobby.js | ||
---|---|---|
366 ↗ | (On Diff #3247) | some JS comment stating what that call is good for |
369 ↗ | (On Diff #3247) | for (let msg of Engine....) |
source/lobby/XmppClient.cpp | ||
590 ↗ | (On Diff #3247) | const & |
603 ↗ | (On Diff #3247) | Remove duplication by using a new helper function |
624 ↗ | (On Diff #3247) | JS_NewArrayObject, JS_SetElement |
source/lobby/XmppClient.h | ||
172 ↗ | (On Diff #3247) | comment explaining what that is used for |
source/lobby/XmppClient.cpp | ||
---|---|---|
582 ↗ | (On Diff #3247) | lines before i actualy want to use the function SetJSMessageProperties() also but i cannot get it to work cause the JS::RootedValue ret variable is another than the JS::MutableHandleValue from the GuiPollMessage function. if someone get this figured out would be nice. it works in either way now its just to get some doubled code reduced. |
Please upload your patches with 9999 lines of context from now on. It says "context not available" everywhere, while we could read the surrounding code if you did.
svn diff --diff-cmd diff -x "-p -U9999" .
source/lobby/XmppClient.cpp | ||
---|---|---|
624 ↗ | (On Diff #3247) | is this bad cause i take this from GUIGetPlayerList |
Thanks for the context. Has helped already.
Patch looks ok mostly. Didn't test it yet.
source/lobby/IXmppClient.h | ||
---|---|---|
59 ↗ | (On Diff #3256) | Weird that GuiPollMessage and GuiPollAllMessages have a different number of arguments and different return types. |
source/lobby/XmppClient.cpp | ||
568 ↗ | (On Diff #3256) | Why isn't scriptInterface.Eval("({})", ret); done in the helper? |
581 ↗ | (On Diff #3256) | Probably ok to not call JSAutoRequest, as we're not registering new variables. Actually this function should be deleted altogether in a separate patch: #4482. |
598 ↗ | (On Diff #3256) | commented code |
606 ↗ | (On Diff #3256) | reference instead of copy, i.e. missing & |
613 ↗ | (On Diff #3256) | ++i |
source/lobby/XmppClient.cpp | ||
---|---|---|
613 ↗ | (On Diff #3256) | L235 visualreplay.cpp JS_SetElement(cx, replaysWithoutNullEntries, i++, replay); xD |
Can't wait to see this committed, after the renames, two comment changes and someone having checked the reference.
binaries/data/mods/public/gui/lobby/lobby.js | ||
---|---|---|
366 ↗ | (On Diff #3247) | // Display chat messages when returning from a game ? |
369 ↗ | (On Diff #3263) | Correct in all cases called (when registering an account, logging in, logging in + receiving historic messages, returning from a game,), because LobbyGuiPollAllMessages covers all these cases. |
source/lobby/XmppClient.cpp | ||
561 ↗ | (On Diff #3263) | Mh, don't we miss a reference here (as in doing an unneeded copy)? Is that the reason why the pop was done after reading from it? |
564 ↗ | (On Diff #3263) | comment unneeded IMO as the code below is self-evident |
565 ↗ | (On Diff #3263) | In the future we might want to extend this, so that people can also follow bans/kicks and error messages. Perhaps we can just remember all messages, but there was a huge performance problem at the time when processing too many state changes after returning from a long game, which was the introduction of ClearPresenceUpdates. I wonder how we filter those. Perhaps we should push a <std::pair<std::string, JS::Heap<JS::Value>>, so that the first` element of the pair shows us the type to filter. |
566 ↗ | (On Diff #3263) | I'll never understand whether to use push_back or emplace_back, since everyone says something different on the topic. |
573 ↗ | (On Diff #3263) | (Actually this function looks like it should go into GUIScriptConversions.cpp, but deleting it will be better.) |
591 ↗ | (On Diff #3263) | No need to rename ret |
601 ↗ | (On Diff #3263) | ret -> messages? |
603 ↗ | (On Diff #3263) | uint32_t is what JS_SetElement takes: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_SetElement Then we can start at 0 and are exempt from the CodingConventions and must use i++. (didn't consider it the first time) |
610 ↗ | (On Diff #3263) | (The entire array to JS::Value conversion can be avoided if we would have added it to GUIConversions.cpp, but.... deletion is better) |
source/lobby/XmppClient.cpp | ||
---|---|---|
561 ↗ | (On Diff #3263) | actualy it says front() returns reference to front |
source/lobby/XmppClient.cpp | ||
---|---|---|
601 ↗ | (On Diff #3263) | yes |
source/lobby/XmppClient.cpp | ||
---|---|---|
565 ↗ | (On Diff #3263) | kick ban are chat messages type |
source/lobby/XmppClient.cpp | ||
---|---|---|
565 ↗ | (On Diff #3263) | its just game and system network message that are being not saved. these are errors disconnect/connect and update messages for the panel. |
set history flag for saved messages, that has been poped out of messages queue and shown to user, so they can be seen as history messages.
msg.saved flag instead of msg.history flag to say its saved (and though has been shown before in queue)
Every message received from LobbyGuiPollAllMessages is a historic message. So there is no need to add that saved flag in C++.
So that SetJSMessageProperties doesn't have to be added.
Can just set msg.historic = true in the for (let msg of Engine.LobbyGuiPollAllMessages()) loop.
Since there are a bunch of merge conflicts already, I'll commit D835 so that we don't have to spend even more time on this.
if (message.type == L"chat") -> Ah, that does actually include kick,, ban, role, nick as wanted. But including join and leave sounds wrong, because they cost too much performance in case hundreds of them accumulate while playing a game (which is the reason why we have added ClearPresenceUpdates)
source/lobby/XmppClient.cpp | ||
---|---|---|
611 ↗ | (On Diff #3286) | Is JS::ObjectValue needed? |
(Actually if were already creating a copy when converting the struct to a JSval, might want to set the property there instead of JS, so nevermind what I recommended)
GuiMessageToJSVal is a better name for that new helper function.
Trying to avoid the copy by popping after the conversion to JS val just gets us funny segfaults:
+ const GUIMessage message = m_GuiMessageQueue.front(); + m_GuiMessageQueue.pop_front();
Another way to get funny results is by using a std::move in the std::push statement of historic messages, so not doing that.
Patch is good and correct as is (and complete), given rebase, renames and the presence-change ignoring for historic messages.
Thanks!
source/lobby/IXmppClient.h | ||
---|---|---|
59 ↗ | (On Diff #3286) | const ScriptInterface ref |
source/lobby/XmppClient.cpp | ||
565 ↗ | (On Diff #3263) | if (message.type == L"chat") should do the same as ClearPresenceUpdates |
source/lobby/XmppClient.h | ||
150 ↗ | (On Diff #3286) | going for GuiPollNewMessage and GuiPollHistoricMessages |