-
-
Notifications
You must be signed in to change notification settings - Fork 311
Integrate Steamworks #797
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
Integrate Steamworks #797
Conversation
Summary of ChangesHello @MakinoharaShoko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates Steamworks functionality into the application, allowing game scripts to interact with the Steam API. The core purpose is to enable the unlocking of Steam achievements through a new Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request integrates Steamworks functionality, allowing the game to unlock Steam achievements. It introduces a new callSteam script command, a SteamIntegration class to bridge with Electron, and necessary configuration updates. The implementation is solid, but I've found a couple of areas for improvement: one is a logic bug in the lazy initialization of the Steam integration, and the other is an inefficient and potentially buggy loop in the callSteam script handler. My review includes suggestions to fix these issues.
| if (!this.initialized) { | ||
| if (this.appId) { | ||
| await this.initialize(this.appId); | ||
| } else { | ||
| logger.warn('Steam integration unlock call skipped: AppID not set'); | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In unlockAchievement, if the integration is not initialized, you attempt to initialize it. However, you don't check if this initialization was successful before proceeding. If await this.initialize(this.appId) fails (returns false), this.initialized will remain false, but the function will continue and attempt to call bridge.unlockAchievement, which is not what's intended. You should check the initialization status again after the attempt and return early if it failed.
if (!this.initialized) {
if (this.appId) {
await this.initialize(this.appId);
if (!this.initialized) {
logger.warn(`Steam integration unlock call skipped for ${achievementId}: initialization failed`);
return false;
}
} else {
logger.warn('Steam integration unlock call skipped: AppID not set');
return false;
}
}| for (const arg of sentence.args) { | ||
| if (arg.key === 'achievementId') { | ||
| const achievementId = getStringArgByKey(sentence, 'achievementId'); | ||
| if (achievementId) { | ||
| WebGAL.steam | ||
| .unlockAchievement(achievementId) | ||
| .then((result) => { | ||
| logger.info(`callSteam: achievement ${achievementId} unlock ${result ? 'succeeded' : 'failed'}`); | ||
| }) | ||
| .catch((error) => { | ||
| logger.error(`callSteam: achievement ${achievementId} unlock threw`, error); | ||
| }); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The for...of loop is unnecessary and potentially incorrect. You iterate over all arguments, and for each one with the key achievementId, you call getStringArgByKey. getStringArgByKey itself finds the first argument with the given key. This means if you have multiple arguments, you might be re-evaluating getStringArgByKey unnecessarily. If there are multiple arguments with key: 'achievementId', you'll be trying to unlock the same (first) achievement multiple times. It's more efficient and correct to call getStringArgByKey once.
const achievementId = getStringArgByKey(sentence, 'achievementId');
if (achievementId) {
WebGAL.steam
.unlockAchievement(achievementId)
.then((result) => {
logger.info(`callSteam: achievement ${achievementId} unlock ${result ? 'succeeded' : 'failed'}`);
})
.catch((error) => {
logger.error(`callSteam: achievement ${achievementId} unlock threw`, error);
});
}|
this pr closes #796 |
Deploying webgal-dev with
|
| Latest commit: |
5110cbf
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e265bb31.webgal-dev.pages.dev |
| Branch Preview URL: | https://steamworks.webgal-dev.pages.dev |
No description provided.