Compare commits

..

No commits in common. "73ce8d88bb760eba351eb970f033f8173a8de454" and "401499fa0e3f4e85ecb5918838b0999392e5b9a9" have entirely different histories.

5 changed files with 32 additions and 58 deletions

View File

@ -62,19 +62,6 @@ async function patchGameCode() {
const modUtils = new ModUtils(minifyCode(script));
/** @type {{ code: string, addToDictionary: string[] }[]} */
const codeSegments = [{
code: `player = aQ.eF(eR);
if (game.gIsReplay) { game.playerId = player; }
str = L(58, /* Player: {0} */ [b0.context.truncateAndFillText(playerData.rawPlayerNames[player], b0.qZ.sN(0, 10), 150)]) + " ";
str += L(59, /* Strength: {10} */ [b0.rY.formatNumber(playerData.playerBalances[player])]) + " ";
str += L(60, /* Territory: {10} */ [b0.rY.formatNumber(playerData.playerTerritories[player])]) + " ";
`, addToDictionary: ["game", "gIsReplay", "playerData", "rawPlayerNames", "playerBalances", "playerTerritories"]
}];
codeSegments.forEach(({ code, addToDictionary }) => {
modUtils.matchCode(code, { addToDictionary })
});
const { default: applyPatches } = await import('./patches/main.js');
console.log("Applying patches...");
applyPatches(modUtils);
@ -106,6 +93,7 @@ async function patchGameCode() {
].forEach(matchDictionaryExpression);
const rawCodeSegments = [
`aQ.eI(e0)?aQ.eE(e0)?a38=__L([a38]):(player=aQ.eF(e0),oq=__L([b0.uS.zG(@playerData.@rawPlayerNames[player],b0.p9.qQ(0,10),150)])+" ",oq=(oq+=__L([b0.wx.a07(playerData.@playerBalances[player])])+" ")+__L([b0.wx.a07(playerData.@playerTerritories[player])])+" ",`,
"1===a.b?this.@gLobbyMaxJoin=this.@gHumans:this.gLobbyMaxJoin=this.@data.@playerCount,this.tZ=this.gLobbyMaxJoin,this.@gBots=this.gLobbyMaxJoin-this.gHumans,this.sg=0,",
"[0]=__L(),@strs[1]=@game.@gIsSingleplayer?__L():__L(),",
"?(this.gB=Math.floor(.066*aK.fw),g5=aK.g5-4*@uiSizes.@gap-this.gB):",

View File

@ -1,38 +0,0 @@
import ModUtils from "../modUtils.js"
export default (/** @type {ModUtils} */ { insertCode, replaceRawCode, waitForMinification }) => {
insertCode(`/* here */
this.click = function(lK, lL, a1m) {
var gy = bL.gz(lK);
var h0 = bL.h1(lL);
var eV = bL.f7(gy, h0);
var eN = bL.eZ(eV);
if (!bL.isInMapBounds(gy, h0)) { return false; }
var a5C = (Device.a1.largeUIEnabled() ? 0.025 : 0.0144) * h___.hu;
var dp = performance.now();
if (Math.abs(lK - a4t) > a5C || Math.abs(lL - a4u) > a5C || dp > time + 500) { return false; }
time = dp;
if (a1m) { a5D(lK, lL, eN); return false; }
/*...*/}`,
`__fx.hoveringTooltip.display = function(mouseX, mouseY) {
var coordX = bL.gz(mouseX), coordY = bL.h1(mouseY),
coord = bL.f7(coordX, coordY), point = bL.eZ(coord);
// if (coordX < 0 || coordY < 0) return;
if (bL.isInMapBounds(coordX, coordY)) (function(lK, lL, eN) {
a5D(lK, lL, eN)
}(mouseX, mouseY, point))
}`)
insertCode(`player = aQ.eF(eR);
if (game.gIsReplay /* here */) { game.playerId = player; }
str = L(58, /* Player: {0} */ [b0.context.truncateAndFillText(playerData.rawPlayerNames[player], b0.qZ.sN(0, 10), 150)]) + " ";
str += L(59, /* Strength: {10} */ [b0.rY.formatNumber(playerData.playerBalances[player])]) + " ";
str += L(60, /* Territory: {10} */ [b0.rY.formatNumber(playerData.playerTerritories[player])]) + " ";`,
`&& __fx.hoveringTooltip.active === false`)
waitForMinification(() => {
replaceRawCode("aK.nH=(window.devicePixelRatio||1)*aEr,",
`aK.nH = (window.devicePixelRatio || 1) * aEr, __fx.hoveringTooltip.canvasPixelScale = aK.nH,`)
})
}

View File

@ -11,6 +11,29 @@ export default (/** @type {ModUtils} */ modUtils) => {
return alert("Error:\\n" + e.filename + " " + e.lineno + " " + e.colno + " " + e.message);`
)
// Hovering tooltip
modUtils.insertCode(`/* here */
this.click = function(lK, lL, a1m) {
var gy = bL.gz(lK);
var h0 = bL.h1(lL);
var eV = bL.f7(gy, h0);
var eN = bL.eZ(eV);
if (!bL.isInMapBounds(gy, h0)) { return false; }
var a5C = (Device.a1.largeUIEnabled() ? 0.025 : 0.0144) * h___.hu;
var dp = performance.now();
if (Math.abs(lK - a4t) > a5C || Math.abs(lL - a4u) > a5C || dp > time + 500) { return false; }
time = dp;
if (a1m) { a5D(lK, lL, eN); return false; }
/*...*/}`,
`__fx.hoveringTooltip.display = function(mouseX, mouseY) {
var coordX = bL.gz(mouseX), coordY = bL.h1(mouseY),
coord = bL.f7(coordX, coordY), point = bL.eZ(coord);
// if (coordX < 0 || coordY < 0) return;
if (bL.isInMapBounds(coordX, coordY)) (function(lK, lL, eN) {
a5D(lK, lL, eN)
}(mouseX, mouseY, point))
}`)
modUtils.waitForMinification(() => applyPatches(modUtils))
}
//export const requiredVariables = ["game", "playerId", "playerData", "rawPlayerNames", "gIsSingleplayer", "playerTerritories"];
@ -286,6 +309,11 @@ canvas.font=aY.g0.g1(1,fontSize),canvas.fillStyle="rgba("+gR+","+tD+","+hj+",0.6
`this.uI=function(username){var uK,uJ=username.indexOf("[");return!(uJ<0)&&1<(uK=username.indexOf("]"))-uJ&&uK-uJ<=8?username.substring(uJ+1,uK).toUpperCase().trim():null}, __fx.leaderboardFilter.parseClanFromPlayerName = this.uI;`);
}
{ // Hovering tooltip
replaceRawCode("aK.nH=(window.devicePixelRatio||1)*aEr,",
`aK.nH = (window.devicePixelRatio || 1) * aEr, __fx.hoveringTooltip.canvasPixelScale = aK.nH,`)
}
// Detailed team pie chart percentage
replaceRawCode(`qr=Math.floor(100*f0+.5)+"%"`,
`qr = (__fx.settings.detailedTeamPercentage ? (100*f0).toFixed(2) : Math.floor(100*f0+.5)) + "%"`)

View File

@ -4,7 +4,6 @@ import { getVar } from "./gameInterface.js";
const hoveringTooltip = new (function() {
let recentlyShown = false;
this.display = () => {}; // this gets populated by the modified game script
this.active = false;
this.canvasPixelScale = 1;
function handler(e) {
if (!getSettings().hoveringTooltip || !getVar("gameState") || recentlyShown) return;
@ -22,9 +21,7 @@ const hoveringTooltip = new (function() {
recentlyShown = true;
try {
this.active = true;
this.display(this.canvasPixelScale * x, this.canvasPixelScale * y);
this.active = false;
} catch (e) { console.error(e) }
// for better performance, reduce the tooltip display frequency to no more than once every 100 ms
setTimeout(() => recentlyShown = false, 100);

View File

@ -1,8 +1,7 @@
{
"version": "0.6.13",
"lastUpdated": "Jul 22",
"version": "0.6.12",
"lastUpdated": "Jul 15",
"changes": [
"Fix for game update 2.09.9",
"Fix to prevent the hovering tooltip from causing perspective switching during replays (a new feature was added to the base game where, in replays, you can switch to a different player/bot by right clicking on them)"
"Refactored the service worker code to (hopefully) fix a ton of relatively rare errors related to how the client's files are loaded (for example, code from earlier versions would sometimes be loaded along with code from newer versions, causing all kinds of issues). FX Client should be much more stable after this change."
]
}