mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Fix not applying patches correctly
This commit is contained in:
parent
a5b77ae8c0
commit
049e65429a
@ -4310,15 +4310,16 @@ class Patcher {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
funcStr = funcStr.replace('onServerDisconnectMessage(e){', `onServerDisconnectMessage (e) {
|
funcStr = funcStr.replace('onServerDisconnectMessage(e){', `onServerDisconnectMessage(e) {
|
||||||
const msg = JSON.parse(e);
|
const msg = JSON.parse(e);
|
||||||
if (msg.reason === 'WarningForBeingIdle') {
|
if (msg.reason === 'WarningForBeingIdle') {
|
||||||
try {
|
try {
|
||||||
this.sendKeepAlive();
|
this.sendKeepAlive();
|
||||||
return;
|
return;
|
||||||
} catch (ex) {}
|
} catch (ex) { console.log(ex); }
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
|
||||||
return funcStr;
|
return funcStr;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -4435,19 +4436,26 @@ class Patcher {
|
|||||||
|
|
||||||
static patch(item) {
|
static patch(item) {
|
||||||
let patchName;
|
let patchName;
|
||||||
|
let appliedPatches;
|
||||||
|
|
||||||
for (let id in item[1]) {
|
for (let id in item[1]) {
|
||||||
if (Patcher.#PATCH_ORDERS.length <= 0) {
|
if (Patcher.#PATCH_ORDERS.length <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appliedPatches = [];
|
||||||
const func = item[1][id];
|
const func = item[1][id];
|
||||||
const funcStr = func.toString();
|
let funcStr = func.toString();
|
||||||
|
|
||||||
for (let groupIndex = 0; groupIndex < Patcher.#PATCH_ORDERS.length; groupIndex++) {
|
for (let groupIndex = 0; groupIndex < Patcher.#PATCH_ORDERS.length; groupIndex++) {
|
||||||
const group = Patcher.#PATCH_ORDERS[groupIndex];
|
const group = Patcher.#PATCH_ORDERS[groupIndex];
|
||||||
|
|
||||||
for (let patchIndex = 0; patchIndex < group.length; patchIndex++) {
|
for (let patchIndex = 0; patchIndex < group.length; patchIndex++) {
|
||||||
const patchName = group[patchIndex];
|
const patchName = group[patchIndex];
|
||||||
|
if (appliedPatches.indexOf(patchName) > -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const patchedFuncStr = Patcher.#PATCHES[patchName].call(null, funcStr);
|
const patchedFuncStr = Patcher.#PATCHES[patchName].call(null, funcStr);
|
||||||
if (!patchedFuncStr) {
|
if (!patchedFuncStr) {
|
||||||
// Only stop if the first patch is failed
|
// Only stop if the first patch is failed
|
||||||
@ -4458,9 +4466,12 @@ class Patcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funcStr = patchedFuncStr;
|
||||||
|
|
||||||
console.log(`[Better xCloud] Applied "${patchName}" patch`);
|
console.log(`[Better xCloud] Applied "${patchName}" patch`);
|
||||||
// Apply patched function
|
// Apply patched function
|
||||||
item[1][id] = eval(patchedFuncStr);
|
item[1][id] = eval(patchedFuncStr);
|
||||||
|
appliedPatches.push(patchName);
|
||||||
|
|
||||||
// Remove patch from group
|
// Remove patch from group
|
||||||
group.splice(patchIndex, 1);
|
group.splice(patchIndex, 1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user