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

Auto-generate configuration based on config.json #1052

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

royfalk
Copy link
Contributor

@royfalk royfalk commented Mar 4, 2025

This uses my https://github.com/royfalk/JsonStruct project to auto-generate configuration.h/cpp based on config.json.

Please answer the following:

Code Changes:

Issues:

  • When launching, map opens automatically
  • Crosshair is different

@@ -1,8 +1,8 @@
/*
* configuration.cpp
* configuration.h
Copy link
Contributor

Choose a reason for hiding this comment

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

Incorrect

Copy link
Contributor

Choose a reason for hiding this comment

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

My vote would be to get rid of all those, that's just useless cruft, IMHO.

*
* Copyright (C) 2021-2022 Daniel Horn, Roy Falk, ministerofinformation,
* David Wales, Stephen G. Tuggy, and other Vega Strike contributors
* Copyright (C) 2021-2023 Daniel Horn, Roy Falk, ministerofinformation,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the end year be 2025?

Comment on lines +418 to +419
std::shared_ptr<Configuration> configuration() {
static std::shared_ptr<Configuration> kConfiguration = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I was the one who introduced this form of singleton for holding the Configuration object. Unfortunately, I don't think my code was quite correct. At least, I don't think it's a true Meyers singleton if it uses a pointer instead of a reference for the static variable.

Hopefully this won't be too difficult to fix in your Json Struct generation code, @royfalk . The Vega Strike Logger class should demonstrate how to implement a Meyers singleton properly. (At least I think I have it right finally.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I was the one who introduced this

Yes.

Hopefully this won't be too difficult to fix in your Json Struct generation code, @royfalk . The Vega Strike Logger class should demonstrate how to implement a Meyers singleton properly. (At least I think I have it right finally.)

I'll take a look.

return kConfiguration;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing LF at end of file

@@ -1,8 +1,8 @@
/*
* configuration.h
* configuration.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the .cpp and .h files got their headers switched around.

*
* Copyright (C) 2021-2023 Daniel Horn, Roy Falk, ministerofinformation,
* David Wales, Stephen G. Tuggy, Benjamen R. Meyer, and other Vega Strike contributors
* Copyright (C) 2021-2022 Daniel Horn, Roy Falk, ministerofinformation,
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the end year here should also be 2025.

};

extern std::shared_ptr<Configuration> configuration();

#endif //VEGA_STRIKE_ENGINE_CONFIG_CONFIGURATION_H
#endif //VEGA_STRIKE_ENGINE_CONFIG_CONFIGURATION_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing LF at end of file

@stephengtuggy
Copy link
Contributor

Looks pretty good for the most part. Thanks, @royfalk


const float max = diamond_size * r_size * 0.75f * configuration()->graphics_config.hud.min_missile_bracket_size;
const float coord = configuration()->graphics_config.hud.min_missile_bracket_size + (configuration()->graphics_config.hud.max_missile_bracket_size - configuration()->graphics_config.hud.min_missile_bracket_size) * lock_percent;
const float max = diamond_size * r_size * 0.75f * configuration()->hud.min_missile_bracket_size;

Check failure

Code scanning / CodeQL

Multiplication result converted to larger type High

Multiplication result may overflow 'float' before it is converted to 'double'.
Copy link
Member

Choose a reason for hiding this comment

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

please ensure this is fixed

@royfalk royfalk mentioned this pull request Mar 4, 2025
1 task
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.

4 participants