diff --git a/patches/customLobby.js b/patches/customLobby.js index 8582b52..997034d 100644 --- a/patches/customLobby.js +++ b/patches/customLobby.js @@ -1,7 +1,7 @@ import ModUtils from '../modUtils.js'; // Custom lobby patches -export default (/** @type {ModUtils} */ { insertCode, replaceRawCode, dictionary: dict, waitForMinification }) => { +export default (/** @type {ModUtils} */ { insertCode, replaceCode, replaceRawCode, dictionary: dict, waitForMinification }) => { // set player id correctly insertCode(`function aBG(aBE) { @@ -13,13 +13,20 @@ export default (/** @type {ModUtils} */ { insertCode, replaceRawCode, dictionary return -1; }`, `if (__fx.customLobby.isActive()) return __fx.customLobby.getPlayerId();`); + insertCode(`this.y___ = function() { s___.t(5, 5); }; + this.a3a = function() { s___.w___(); aY.init(); }; /* here */`, + `__fx.customLobby.setJoinFunction(() => { s___.w___(); aY.init(); });`) + replaceCode(`var url = aQt[0] + Sockets.a.b[socketId] + aQt[1 + dg]; socket = new WebSocket(url);`, + `var url = aQt[0] + Sockets.a.b[socketId] + aQt[1 + dg]; + socket = new WebSocket(__fx.customLobby.isActive() && socketId === 1 ? __fx.customLobby.getSocketURL() : url);`) + // if the server is unreachable + insertCode(`if (socketId === 0) { q.a08(3249); return; } /* here */`, + `if (socketId === 1 && __fx.customLobby.isActive()) { + q.a08(3249); + return __fx.customLobby.setActive(false); + }`) + waitForMinification(() => { - replaceRawCode("this.aHm=function(){i___.rX(),aM.a7U(0),aM.init()}", - `this.aHm=function(){i___.rX(),aM.a7U(0),aM.init()}, - __fx.customLobby.setJoinFunction(() => { i___.rX(); aM.a7U(0); aM.init(); })` - ) - replaceRawCode(`(socketId-aq.kt.a82)+"/",(socket=new WebSocket(url)`, - `(socketId-aq.kt.a82)+"/",(socket=new WebSocket(__fx.customLobby.isActive() && socketId === 1 ? __fx.customLobby.getSocketURL() : url)`) replaceRawCode("this.send=function(socketId,data){aJE(socketId),aJ4[socketId].send(data)}", "this.send=function(socketId,data){aJE(socketId),aJ4[socketId].send(data)},__fx.customLobby.setSendFunction(this.send)") replaceRawCode("b7.dH(a0),0===b7.size?aq.kt.aJJ(wR,3205):", @@ -47,8 +54,6 @@ export default (/** @type {ModUtils} */ { insertCode, replaceRawCode, dictionary __fx.customLobby.isActive() && (sV.style.display = "none"),`); // allow games with one player replaceRawCode("if((t3=bk.t1.t3[e0])<2)return!1;", "if((t3=bk.t1.t3[e0])<2 && !__fx.customLobby.isActive())return!1;") - // if the server is unreachable - replaceRawCode("{g.wc(3249)}", "{__fx.customLobby.isActive()?(g.wc(3249),__fx.customLobby.setActive(false)):g.wc(3249)}") // error descriptions const errors = { 3249: "No servers found", 4705: "Lobby not found", 4730: "Kicked from lobby" }; replaceRawCode(`m.n___(4,5,new o(__L(),xT(e),!0))`, diff --git a/patches/highlightSpawnpoints.js b/patches/highlightSpawnpoints.js new file mode 100644 index 0000000..1e5f117 --- /dev/null +++ b/patches/highlightSpawnpoints.js @@ -0,0 +1,26 @@ +import ModUtils from "../modUtils.js"; + +// Highlight clan spawnpoints +export default (/** @type {ModUtils} */ { replaceCode, waitForMinification, replaceRawCode }) => { + // when rendered on game start + replaceCode( + `var x = (d.minX[i] + d.maxX[i] + 1 - hQ - 2) >> 1; + var y = (d.minY[i] + d.maxY[i] + 1 - hQ - 2) >> 1; + ctx.drawImage(a1e[game.gIsTeamGame ? ((game.gGameType === 9 && aD.a[i] === 5) ? 3 : t.ids[i]) : (i < game.gHumans ? 1 : 0)], x, y);`, + `var highlight = __fx.settings.highlightClanSpawns && __fx.clanFilter.inOwnClan[i]; + if (highlight) hQ *= 2; + var x = (d.minX[i] + d.maxX[i] + 1 - hQ - 2) >> 1; + var y = (d.minY[i] + d.maxY[i] + 1 - hQ - 2) >> 1; + if (highlight) ctx.drawImage(a1e[game.gIsTeamGame ? ((game.gGameType === 9 && aD.a[i] === 5) ? 3 : t.ids[i]) : (i < game.gHumans ? 1 : 0)], x, y, hQ, hQ); + else ctx.drawImage(a1e[game.gIsTeamGame ? ((game.gGameType === 9 && aD.a[i] === 5) ? 3 : t.ids[i]) : (i < game.gHumans ? 1 : 0)], x, y);`, + ) + waitForMinification(() => { + // when rendered during spawn selection + replaceRawCode("function(a6,es,bK,hP,hQ,hR,ov){0===dV.eg[a6]||0===dV.ev[a6]||(hQ=ay.ak*((dV.nu[a6]+dV.nw[a6]+1)/2-bK)/(hQ-bK)-.5*es,bK=ay.al*((dV.nv[a6]+dV.nx[a6]+1)/2-hP)/(hR-hP)-.5*es,hQ>ay.ak)||bK>ay.al||hQ<-es||bK<-es||(bI.setTransform(cz,0,0,cz,hQ,bK),", + `function(a6,es,bK,hP,hQ,hR,ov){ + var highlight = __fx.settings.highlightClanSpawns && __fx.clanFilter.inOwnClan[a6]; + if (highlight) es *= 2; + 0===dV.eg[a6]||0===dV.ev[a6]||(hQ=ay.ak*((dV.nu[a6]+dV.nw[a6]+1)/2-bK)/(hQ-bK)-.5*es,bK=ay.al*((dV.nv[a6]+dV.nx[a6]+1)/2-hP)/(hR-hP)-.5*es,hQ>ay.ak)||bK>ay.al||hQ<-es||bK<-es||(bI.setTransform(highlight?cz*2:cz,0,0,highlight?cz*2:cz,hQ,bK),` + ) + }) +} \ No newline at end of file diff --git a/patches/patches.js b/patches/patches.js index 3ddc594..1e50d4d 100644 --- a/patches/patches.js +++ b/patches/patches.js @@ -292,23 +292,6 @@ canvas.font=aY.g0.g1(1,fontSize),canvas.fillStyle="rgba("+gR+","+tD+","+hj+",0.6 `aK.nH = (window.devicePixelRatio || 1) * aEr, __fx.hoveringTooltip.canvasPixelScale = aK.nH,`) } - { // Highlight clan spawnpoints - // when rendered on game start - replaceRawCode("var x;0!==playerData.eg[i]&&0!==playerData.playerTerritories[i]&&(x=playerData.nu[i]+playerData.nw[i]+1-gv-2>>1,gv=playerData.nv[i]+playerData.nx[i]+1-gv-2>>1,ctx.drawImage(km[game.gIsTeamGame?lV.i6[i]:i>1,y=playerData.nv[i]+playerData.nx[i]+1-gv-2>>1, - highlight ? ctx.drawImage(km[game.gIsTeamGame?lV.i6[i]:iay.ak)||bK>ay.al||hQ<-es||bK<-es||(bI.setTransform(cz,0,0,cz,hQ,bK),", - `function(a6,es,bK,hP,hQ,hR,ov){ - var highlight = __fx.settings.highlightClanSpawns && __fx.clanFilter.inOwnClan[a6]; - if (highlight) es *= 2; - 0===dV.eg[a6]||0===dV.ev[a6]||(hQ=ay.ak*((dV.nu[a6]+dV.nw[a6]+1)/2-bK)/(hQ-bK)-.5*es,bK=ay.al*((dV.nv[a6]+dV.nx[a6]+1)/2-hP)/(hR-hP)-.5*es,hQ>ay.ak)||bK>ay.al||hQ<-es||bK<-es||(bI.setTransform(highlight?cz*2:cz,0,0,highlight?cz*2:cz,hQ,bK),` - ) - } - // 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)) + "%"`)