Automatically apply RSA patch

This commit is contained in:
Thoronium
2023-02-27 17:15:21 -07:00
committed by GitHub
parent 55fa0a8d3c
commit 62a97d86cb
23 changed files with 184 additions and 468 deletions

View File

@@ -13,7 +13,7 @@ import Plus from '../../resources/icons/plus.svg'
import './ServerLaunchSection.css'
import { dataDir } from '@tauri-apps/api/path'
import { getGameExecutable, getGameVersion } from '../../utils/game'
import { patchGame, unpatchGame } from '../../utils/metadata'
import { patchGame, unpatchGame } from '../../utils/rsa'
interface IProps {
openExtras: (playGame: () => void) => void
@@ -109,7 +109,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
// Connect to proxy
if (config.toggle_grasscutter) {
if (config.patch_metadata) {
if (config.patch_rsa) {
const gameVersion = await getGameVersion()
console.log(gameVersion)
@@ -120,16 +120,16 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
return
}
if (gameVersion?.major == 2 && gameVersion?.minor < 8) {
if (gameVersion?.major == 2 && gameVersion?.minor < 9) {
alert(
'Game version is too old for metadata patching. Please disable metadata patching in the settings and try again.'
'Game version is too old for RSA patching. Please disable RSA patching in the settings and try again.'
)
return
}
if (gameVersion?.major == 3 && gameVersion?.minor >= 1) {
if (gameVersion?.major == 3 && gameVersion?.minor < 1) {
alert(
'Game version is too new for metadata patching. TO FIX: Please disable metadata patching in the settings menu to launch the game!! \nNOTE: You will require an RSA patch to play the game.'
'Game version is too old for RSA patching. Please disable RSA patching in the settings and try again.'
)
return
}
@@ -179,7 +179,7 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
if (!unpatched) {
alert(
`Could not unpatch game, aborting launch! (You can find your metadata backup in ${await dataDir()}\\cultivation\\)`
`Could not unpatch game, aborting launch! (You can unpatch in your game install folder, either remove version.dll or repair mhypbase.dll in launcher)`
)
return
}

View File

@@ -13,7 +13,7 @@ import * as server from '../../../utils/server'
import './Options.css'
import BigButton from '../common/BigButton'
import DownloadHandler from '../../../utils/download'
import * as meta from '../../../utils/metadata'
import * as meta from '../../../utils/rsa'
import HelpButton from '../common/HelpButton'
import TextInput from '../common/TextInput'
@@ -33,7 +33,7 @@ interface IState {
themes: string[]
theme: string
encryption: boolean
patch_metadata: boolean
patch_rsa: boolean
use_internal_proxy: boolean
wipe_login: boolean
horny_mode: boolean
@@ -61,7 +61,7 @@ export default class Options extends React.Component<IProps, IState> {
themes: ['default'],
theme: '',
encryption: false,
patch_metadata: false,
patch_rsa: false,
use_internal_proxy: false,
wipe_login: false,
horny_mode: false,
@@ -82,7 +82,7 @@ export default class Options extends React.Component<IProps, IState> {
this.toggleGrasscutterWithGame = this.toggleGrasscutterWithGame.bind(this)
this.setCustomBackground = this.setCustomBackground.bind(this)
this.toggleEncryption = this.toggleEncryption.bind(this)
this.restoreMetadata = this.restoreMetadata.bind(this)
this.removeRSA = this.removeRSA.bind(this)
}
async componentDidMount() {
@@ -108,7 +108,7 @@ export default class Options extends React.Component<IProps, IState> {
themes: (await getThemeList()).map((t) => t.name),
theme: config.theme || 'default',
encryption: await translate(encEnabled ? 'options.enabled' : 'options.disabled'),
patch_metadata: config.patch_metadata || false,
patch_rsa: config.patch_rsa || false,
use_internal_proxy: config.use_internal_proxy || false,
wipe_login: config.wipe_login || false,
horny_mode: config.horny_mode || false,
@@ -266,8 +266,8 @@ export default class Options extends React.Component<IProps, IState> {
})
}
async restoreMetadata() {
await meta.restoreMetadata(this.props.downloadManager)
async removeRSA() {
await meta.unpatchGame()
}
async installCert() {
@@ -311,24 +311,24 @@ export default class Options extends React.Component<IProps, IState> {
)}
<div className="OptionSection" id="menuOptionsContainermetaDownload">
<div className="OptionLabel" id="menuOptionsLabelmetaDownload">
<Tr text="options.recover_metadata" />
<HelpButton contents="help.emergency_metadata" />
<Tr text="options.recover_rsa" />
<HelpButton contents="help.emergency_rsa" />
</div>
<div className="OptionValue" id="menuOptionsButtonmetaDownload">
<BigButton onClick={this.restoreMetadata} id="metaDownload">
<BigButton onClick={this.removeRSA} id="metaDownload">
<Tr text="components.download" />
</BigButton>
</div>
</div>
<div className="OptionSection" id="menuOptionsContainerPatchMeta">
<div className="OptionLabel" id="menuOptionsLabelPatchMeta">
<Tr text="options.patch_metadata" />
<HelpButton contents="help.patch_metadata" />
<Tr text="options.patch_rsa" />
<HelpButton contents="help.patch_rsa" />
</div>
<div className="OptionValue" id="menuOptionsCheckboxPatchMeta">
<Checkbox
onChange={() => this.toggleOption('patch_metadata')}
checked={this.state?.patch_metadata}
onChange={() => this.toggleOption('patch_rsa')}
checked={this.state?.patch_rsa}
id="patchMeta"
/>
</div>