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

Refactor the packet generator #2070

Merged
merged 39 commits into from
Dec 10, 2023

Conversation

lmoureaux
Copy link
Contributor

@lmoureaux lmoureaux commented Dec 3, 2023

I went "a bit" overboard while fixing #2062 and ended up rewriting half of the file. The result is still far from perfect, but the pylint score went up to 8.5/10 (from 1.5/10 initially). So I would say it's about one order of magnitude more maintainable.

The parts I reorganized are mostly related to parsing the input file and writing the output. The core business logic behind the code generation is mostly unchanged. The main exceptions are large-scale replacements of obsolete syntax (%-based string formatting, x += 1 instead of x = x + 1, etc).

I also removed unused functions and parameters in dataio_raw.h/cpp. I encountered them while trying to go even deeper with the refactoring (which I won't do just yet).

I tested this PR on the client side by connecting to a game and doing some basic moves. I didn't spawn a server, but everything is quite symmetric so I'm optimistic.

I can this huge thing if you prefer, really just wanted to push it somewhere so I won't forget it.

Closes #2062.

Remove the -v option since it wasn't really doing anything useful.
Using ccache works better to avoid recompiling everything.
* Use f-strings everywhere, removing usage of % self.__dict
* Remove "struct" where possible (C++ification)
* Use += where possible
* Move comments to docstrings
* A few more trivial simplifications
* escaped strings
* native int vector handling
Simplifies generate_packets as well
@lmoureaux lmoureaux requested a review from jwrober December 3, 2023 22:09
Copy link
Collaborator

@jwrober jwrober left a comment

Choose a reason for hiding this comment

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

That is a big PR. The python code you changed was ancient syntax. I'm kinda surprised it took till v3.12 to throw errors. Good job on this refactor.

@lmoureaux lmoureaux merged commit 7e32e44 into longturn:master Dec 10, 2023
20 checks passed
@lmoureaux lmoureaux deleted the refactor/generate-packets branch December 10, 2023 00:02
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.

Warnings in generate_packets.py
2 participants