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 simple name auto-completion for the chat #37

Merged
merged 11 commits into from
Jun 5, 2020

Conversation

MoonPadUSer
Copy link
Contributor

No description provided.

@MoonPadUSer MoonPadUSer marked this pull request as draft June 3, 2020 21:18
@MoonPadUSer
Copy link
Contributor Author

Todo: exclude bots from the auto-completion

@MoonPadUSer MoonPadUSer marked this pull request as ready for review June 4, 2020 11:22
@ghost
Copy link

ghost commented Jun 4, 2020

Things that would block me accept this:

  • no sanity check on s: there is no certainty you don't write out of memory thus I consider this code unsafe and not acceptable.

Now, general coding sanity:

  • Instead of using if/else that takes the whole function and change indentation, just return at end of if.
  • Indentation change found in 2nd patch near like 824, easy to see with a diff.
  • lines ending with spaces found
  • what is the printf( "start" ...) meant to do in a part of the code you don't touch?
  • strlen( foo ) in a loop that never changes foo is slow
  • strlen is slow anyway, avoid calling it for nothing (I see at least 1 useless call)

More specific to that current code:

  • avoid using the loop macros, use for( auto const& foo : foobar ) or normal macros.
  • please stop having for loops and if condition on same line to then use misleading indentation.
  • complete() is used only once in the whole code. Take the occasion to have the architecture safer, for example by using an std::string (there are other methods, too)
  • for the same reason, there's no point in keeping it's declaration extern or in a header anyway
  • avoid using an external structure's variables and literal constants. Instead, add it a method with a name that describes what it does (for example here: 'bool clientstate::is_player(void) const;' and 'char const* clientstate::name(void) const;'

@MoonPadUSer MoonPadUSer marked this pull request as draft June 4, 2020 12:05
@MoonPadUSer MoonPadUSer marked this pull request as ready for review June 4, 2020 14:03
@MoonPadUSer

This comment has been minimized.

Copy link
Member

@TheAssassin TheAssassin left a comment

Choose a reason for hiding this comment

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

I couldn't spot any apparent potential overflows any more. Good work! Please change these inline comments, I'll try the PR in the meantime.


char* name = strrchr(s, '@');

if (name) // autocomplete name
Copy link
Member

Choose a reason for hiding this comment

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

Inline comments. Please avoid.

@TheAssassin TheAssassin merged commit 763a60e into master Jun 5, 2020
@TheAssassin TheAssassin deleted the chat-name-auto-completion branch June 5, 2020 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants