Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set/getPlayerScriptDebugLevel #826

Merged
merged 11 commits into from Sep 2, 2019

Conversation

knitz12
Copy link
Contributor

@knitz12 knitz12 commented Feb 18, 2019

While i was making a new account system (MySQL) i found out i couldn't use /debugscript without creating an account in MTA's database AND adding it to the ACL, that was a problem because when i logged in my system i also had to login in MTA's system using /login to be able to view script errors, that's why i created this pull request, with this i could add a /debug command which would simulate /debugscript.

This PR adds two new functions, setPlayerScriptDebugLevel and getPlayerScriptDebugLevel, I'm fairly new to the MTA's codebase so i don't know if i made any mistake.

@botder botder added the enhancement New feature or request label Feb 18, 2019
@botder botder added this to the Backlog milestone Feb 18, 2019
@Citizen01
Copy link
Member

Thanks for your PR.

I have a question: Why not setPlayerDebuggerVisible and setPlayerDebuggerLevel ? (this needs other feedbacks than mine before renaming anything).

Also we dropped the hungarian notation for new devs (even though I prefer when the code is consistant).

Would be great if we could give root as element so it does for everyone. I don't have any valid use case though but I see SetPlayerDebuggerVisible was ready for it:

bool CStaticFunctionDefinitions::SetPlayerDebuggerVisible(CElement* pElement, bool bVisible)
{
assert(pElement);
RUN_CHILDREN(SetPlayerDebuggerVisible(*iter, bVisible))
if (IS_PLAYER(pElement))
{
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);

@knitz12
Copy link
Contributor Author

knitz12 commented Feb 19, 2019

@Citizen01 I modified the functions to work with the root element, i didn't changed the hungarian notation as i don't know what to replace them with.

About the naming: I used setPlayerDebugView* instead of setPlayerDebugger* because of the existing (clientside) function named setDebugViewActive but i'm open to change it if others think its better 😃.

Thanks for the review.

@qaisjp
Copy link
Contributor

qaisjp commented Feb 19, 2019

You can also enable debugscript for "Everyone" in the ACL to get around this

@knitz12
Copy link
Contributor Author

knitz12 commented Feb 19, 2019

@qaisjp Then everyone would have access to /debugscript, which is something i don't want, Or am i missing something?

@CrosRoad95 I fixed some things you mentioned, i also tried to fix the others whitespace changes but git didn't picked them (i don't know why) but i don't think they are relevant as they don't change anything visually.

@qaisjp
Copy link
Contributor

qaisjp commented Feb 19, 2019

Oh, now I understand your problem.

How about setPlayerScriptDebugLevel(player, boolean/int). Pass false to hide, and pass an integer for the level.

There should be a getter.

@knitz12
Copy link
Contributor Author

knitz12 commented Feb 20, 2019

@qaisjp Wouldn't it be better to pass 0 to setPlayerScriptDebugLevel to hide the debugger? In a similar way the getter (getPlayerScriptDebugLevel?) would return 0 if the player had the debugger closed.

This is the current behaviour of /debugscript.

@qaisjp
Copy link
Contributor

qaisjp commented Feb 21, 2019

I thought about that but don't want to conflict with 0: custom message in https://wiki.multitheftauto.com/wiki/OutputDebugString

Also remove setPlayerDebugView* functions
@knitz12
Copy link
Contributor Author

knitz12 commented Feb 21, 2019

@qaisjp Ok, i added set/getPlayerScriptDebugLevel, passing false to setPlayerScriptDebugLevel hides the debugger and passing an integer shows it.

@knitz12 knitz12 changed the title Add setPlayerDebugViewActive and setPlayerDebugViewMode Add set/getPlayerScriptDebugLevel Feb 21, 2019
Copy link
Contributor

@patrikjuvonen patrikjuvonen left a comment

Choose a reason for hiding this comment

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

I believe it is better to match these function names as well.

@knitz12
Copy link
Contributor Author

knitz12 commented Feb 22, 2019

@patrikjuvonen Done :)

@patrikjuvonen
Copy link
Contributor

Thanks for the changes. This PR is ready to be merged but I'd wait for #821 so we can make returns right for this from the start.

@botder
Copy link
Member

botder commented Aug 17, 2019

The decision in pull request #821 (Pin down return value on failure) is now settled.

@patrikjuvonen patrikjuvonen self-assigned this Aug 17, 2019
@knitz12
Copy link
Contributor Author

knitz12 commented Aug 21, 2019

Done @patrikjuvonen :)

Copy link
Contributor

@patrikjuvonen patrikjuvonen left a comment

Choose a reason for hiding this comment

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

Thank you!
Good job. This PR is ready to be merged afrer 1.5.7 is released.

@patrikjuvonen patrikjuvonen modified the milestones: Backlog, 1.6 Aug 21, 2019
@patrikjuvonen patrikjuvonen merged commit ded201f into multitheftauto:master Sep 2, 2019
@ccw808
Copy link
Member

ccw808 commented Sep 13, 2019

Sorry about late review, but does function.setPlayerScriptDebugLevel really need to be restricted to Admin ACL by default?

@knitz12
Copy link
Contributor Author

knitz12 commented Sep 16, 2019

@ccw808 Well, my thought for doing this was that a malicious resource could make a backdoor command which would allow the attacker to read all the debug messages, gaining knowledge on the internals of the server or observing how a specific system reacts to certain inputs etc depending on how the server uses the logging functions.

With that scenario in mind i put it in the admin ACL, also to conform with /debugscript.

@qaisjp
Copy link
Contributor

qaisjp commented Jun 3, 2020

No, you're right, 0 is better for closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants