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

console: use the new string functions #1459

Merged
merged 1 commit into from
Aug 30, 2024
Merged

console: use the new string functions #1459

merged 1 commit into from
Aug 30, 2024

Conversation

rr-
Copy link
Collaborator

@rr- rr- commented Aug 29, 2024

Checklist

  • I have read the coding conventions
  • I have added a changelog entry about what my pull request accomplishes, or it is an internal change

Description

A loose proposal how to refactor parsing the arguments of the console commands using LostArtefacts/libtrx#19. I refactored a few commands to showcase how this works.

I'm not sure if I like this, honestly, and I'm eager to hear your opinion. It works great for boolean commands, but might make string handling more cumbersome. For instance, the /play command accepts a level name, but the new argument parsing requires spaces to be enclosed in quotes (e.g., /play "great pyramid"). The problem is, the console does not support all characters, and it's actually impossible to type this.

@rr- rr- requested review from a team, lahm86 and walkawayy and removed request for a team August 29, 2024 13:31
@rr- rr- force-pushed the argparser branch 2 times, most recently from bfd59c1 to 2a8c7a3 Compare August 29, 2024 15:30
@rr-
Copy link
Collaborator Author

rr- commented Aug 29, 2024

I've simplified the proposal to use only argument parser primitives, restoring the previous behavior, and it looks acceptable. However, this still adds a lot of code to libtrx. I'm hesitant to introduce it since the code, while functional, is currently unused and likely will remain unused due to the intended flexibility of the command arguments.

Maybe the introduced functions should just become a couple of bool String_ParseBool(const char *input, bool *target); without introducing this new module at all.

LMK what you think.

@lahm86
Copy link
Collaborator

lahm86 commented Aug 29, 2024

It looks really good, but as you say maybe for now it's best to go with the simpler parsing functions for ease. No harm to leave it on a branch on libtrx for potential future integration?

@rr-
Copy link
Collaborator Author

rr- commented Aug 29, 2024

Gotcha – I'll open a new PR with String_Parse(…), use that to simplify existing commands, and rebase this on top of that one.

@rr- rr- marked this pull request as ready for review August 29, 2024 22:13
@rr-
Copy link
Collaborator Author

rr- commented Aug 29, 2024

Done

@rr- rr- self-assigned this Aug 29, 2024
@rr- rr- changed the title console: use the new argparser module console: use the new string functions Aug 29, 2024
@rr- rr- added this to the 4.4 milestone Aug 29, 2024
@rr- rr- added the Internal The invisible stuff label Aug 29, 2024
@walkawayy
Copy link
Collaborator

walkawayy commented Aug 30, 2024

It works really nice! Only odd thing I noticed was doing something like give 10 medi. I think it's fine to give both small and large medi with this command since it's ambiguous, but it looks like it happens twice for small and large. This console log screenshot is from one give command.

image

@rr-
Copy link
Collaborator Author

rr- commented Aug 30, 2024

That's a separate bug, which happens because Object_IdsFromName doesn't ensure that the matched objects are unique.

Logged as #1463.

@rr- rr- requested review from a team as code owners August 30, 2024 14:27
@rr- rr- requested review from aredfan and removed request for a team August 30, 2024 14:27
Copy link
Collaborator

@walkawayy walkawayy left a comment

Choose a reason for hiding this comment

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

lgtm

@rr- rr- merged commit dd1c277 into develop Aug 30, 2024
2 checks passed
@rr- rr- deleted the argparser branch August 30, 2024 18:58
@rr- rr- added the TR1 label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal The invisible stuff TR1
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants