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 logger, improve support for ARM64 & Windows 7 #13

Merged
merged 5 commits into from
Dec 30, 2023

Conversation

modmuss50
Copy link
Member

@modmuss50 modmuss50 commented Dec 28, 2023

  • Add a simple log file in %temp%
  • Add proper ARM64 support, using the ARM64 JDK provided by the vanilla launcher. Previously it wouldn't use a native Java.
  • Fix possible issues where it may try to run an unsupported JDK (e.g an ARM64 JDK on x64, or x64 on x86), in practice I don't think this would have been an issue, but its fixed.
  • Fix crash on Windows 7 without the KB2533623 update.

@modmuss50 modmuss50 changed the title Add logger, improve support for ARM64, Add logger, improve support for ARM64 & Windows 7 Dec 28, 2023
Copy link
Member

@IMB11 IMB11 left a comment

Choose a reason for hiding this comment

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

Overall pretty okay.

src/main.cpp Outdated Show resolved Hide resolved
src/Logger.h Show resolved Hide resolved
Copy link

@Earthcomputer Earthcomputer left a comment

Choose a reason for hiding this comment

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

The braces are inconsistently on the same line and on the next line.

src/SystemHelper.cpp Outdated Show resolved Hide resolved
src/ISystemHelper.h Outdated Show resolved Hide resolved
src/ISystemHelper.h Outdated Show resolved Hide resolved

class Bootstrap {
public:
explicit Bootstrap(const std::shared_ptr<ISystemHelper>& systemHelper);
explicit Bootstrap(ISystemHelper& systemHelper, Logger& logger);

Choose a reason for hiding this comment

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

Suggested change
explicit Bootstrap(ISystemHelper& systemHelper, Logger& logger);
Bootstrap(const ISystemHelper& systemHelper, Logger& logger);

src/ISystemHelper.h Show resolved Hide resolved
private:
std::shared_ptr<ISystemHelper> systemHelper;
ISystemHelper& systemHelper;

Choose a reason for hiding this comment

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

Suggested change
ISystemHelper& systemHelper;
const ISystemHelper& systemHelper;

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for taking a look at this :) I have fixed the other points.

I was told a while back that you generally shouldn't have const refrences as member vars, ill be honest I didn't fully understand the reasoning. There seems to be a bit of litrature about this online such as: https://lesleylai.info/en/const-and-reference-member-variables/ And then other places seem to suggest having const is fine.

The orignal design around this is to allow a mock of ISystemHelper for unit tests (that dont exist atm), the formal name for this pattern seems to be "dependency injection via constructor".

Going back to using a shared_ptr seems like it might solve most of the possible problems? Either way I'm not too worried about being 100% correct as long as it works, but it is an intresting point of conversation.

Choose a reason for hiding this comment

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

It's generally bad practice to have (even non-const) references as member variables, as that article explains, because references cannot be rebound, i.e. are effectively const. There is no need to change back to shared_ptr, if you want you can use std::reference_wrapper instead, but I left this out of the review because I think the codebase is too simple for this to become a problem.

src/Bootstrap.h Show resolved Hide resolved
@modmuss50 modmuss50 merged commit 879c678 into FabricMC:main Dec 30, 2023
6 checks passed
@@ -44,92 +39,147 @@ void Bootstrap::launch() {
}

bool Bootstrap::launchMinecraftLauncher() {
if (auto minecraftLauncherPath = systemHelper->getRegValue(HKEY_CURRENT_USER, MC_LAUNCH_REG_PATH, MC_LAUNCH_REG_KEY); minecraftLauncherPath) {
const Architecture::Value hostArch = systemHelper.getHostArchitecture();
logger.log(L"Host archiecture: " + Architecture::AsString(hostArch));
Copy link

Choose a reason for hiding this comment

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

Misspelling :p

Copy link
Member Author

Choose a reason for hiding this comment

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

Opps, I will open an issue to remind myself to fix this in the next version. Not a major worry as it only shows in the log file 👍

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