Skip to content

Commit

Permalink
Allow debug messages in on(Client)DebugMessage (fixes #639)
Browse files Browse the repository at this point in the history
  • Loading branch information
botder committed Oct 7, 2018
1 parent 7a06605 commit 81b64e3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Shared/mods/deathmatch/logic/CScriptDebugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void CScriptDebugging::LogString(const char* szPrePend, const SLuaDebugInfo& lua
}

// Check whether on(Client)DebugMessage is currently being triggered
bool notCancelled = false;
bool notCancelled = true;
if (!m_bTriggeringMessageEvent)
{
// Make sure the state of on(Client)DebugMessage being triggered can be retrieved later
Expand Down

5 comments on commit 81b64e3

@ArranTuna
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will fix it because it did not trigger at all. My example used outputDebugString but I also tested it with outputChatBox and it does not show up.

@qaisjp
Copy link
Contributor

@qaisjp qaisjp commented on 81b64e3 Oct 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does wasEventCancelled() say before this fix?

@ArranTuna
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually on further testing, it did output to chatbox, but I didn't notice it because I did:

addEventHandler("onDebugMessage", root, function(msg, lvl, file, line) outputChatBox(msg..", "..lvl..", "..file..", "..line) end)

And file and line are both nil so there was an error in that line but it wouldn't show up until I used tostring:

srun addEventHandler("onDebugMessage", root, function(msg, lvl, file, line) outputChatBox(tostring(msg)..", "..tostring(lvl)..", "..tostring(file)..", "..tostring(line)) end)

So I guess this fix would work.

@ArranTuna
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so the problem that caused me to think this was bugged was because the arguments passed must have changed when a script fails to load or I made an edit to my script and broke it not handling when file argument is nil. My script was passing this nil variable to a function that returns an error when it gets nil and I never knew this because debugs don't show up that are occuring inside onDebugMessage, so yeah if this fix allows debug messages to show up inside the debug message event, it should avoid any confusion for scripters when they have errors inside their debug handler.

@botder
Copy link
Member Author

@botder botder commented on 81b64e3 Oct 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit only fixes usage of outputDebugString/iprint in the on(Client)DebugMessage handler, before this commit, these functions wouldn't show anything there, when called inside the event handler. Also, outputDebugString/iprint won't trigger on(Client)DebugMessage again, when called from that event handler.

Please sign in to comment.