792 lines
47 KiB
Python
792 lines
47 KiB
Python
#!/usr/bin/env python3
|
|
"""Pinned original RealmList transformation; private candidates, no publication.
|
|
|
|
Uses the existing original-UI transformation pattern for the two pinned
|
|
consumers. The Source branch owns pending realm choice only; other screen and
|
|
error handling remains original, and Source realm-change/cancel stays held.
|
|
"""
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from functools import lru_cache
|
|
from pathlib import Path
|
|
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
SOURCE_SHA256='1486be22772e638b4a302083def941c9514a651287420bad1b3f43d35922c084'
|
|
SOURCE_REFERENCE='interface/addons/blizzard_gluexml/mainline/realmlist.lua'
|
|
GLUE_SHA256='3f7d06f7801f8a8eb47f700d735ca083ed920004b106bdb1d888b10706d4c986'
|
|
GLUE_REFERENCE='interface/addons/blizzard_glueparent/mainline/glueparent.lua'
|
|
PROVIDER=ROOT/'compat/glue/source_realm_provider.lua'
|
|
ADAPTER=ROOT/'compat/glue/source_realm_list_adapter.lua'
|
|
GLUE_ADAPTER=ROOT/'compat/glue/source_realm_glue_adapter.lua'
|
|
LOGIN_DIAGNOSTIC=ROOT/'compat/glue/source_login_diagnostic.lua'
|
|
LOGIN_INPUT_PARITY=ROOT/'compat/glue/source_login_input_parity.lua'
|
|
VISUAL_GLUE_PARENT_SHA256='3a0c80630f83773f2dcac0afef11d2f55584691e5279c660fc22c1514a1042ad'
|
|
LOCAL_TEST_LOGIN_INPUT_SHA256='9095b930d40d6207d105284c771b17dfe33466033ba31969cf0046eaec280209'
|
|
LOCAL_TEST_LOGIN_XML_SHA256='f0f7497293b037c0db5043bc6598e7ab007d1be25f47f067f33390ea9e5a56d3'
|
|
LOCAL_TEST_NOGATE_LUA_SHA256='2992a6e8e5d560a269403c20ae3f3102b36a955db3fe7af886fceced2eca8985'
|
|
LOCAL_TEST_NOGATE_XML_SHA256='df52c2946140161995131c980127322d1a4f46020039cd03c5be8eaad472df32'
|
|
CLEAN_LOCAL_GLUE_PARENT_SHA256='44be9c8d82b1c0777f3b2556d42e5ec62c9fa020fd0f5bae6112660a9ab1f8db'
|
|
|
|
|
|
def transform_local_test_account_login(source,source_xml):
|
|
"""Prepare a private local-only login experiment from the pinned Source UI.
|
|
|
|
The caller must separately establish local endpoint confinement before any
|
|
client adoption. This transformation neither authenticates nor publishes.
|
|
"""
|
|
if not isinstance(source,bytes) or hashlib.sha256(source).hexdigest()!=LOCAL_TEST_LOGIN_INPUT_SHA256:
|
|
raise ValueError('Pinned Source AccountLogin input differs')
|
|
if not isinstance(source_xml,bytes) or hashlib.sha256(source_xml).hexdigest()!=LOCAL_TEST_LOGIN_XML_SHA256:
|
|
raise ValueError('Pinned Source AccountLogin XML differs')
|
|
newline='\r\n' if b'\r\n' in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
replacements=[
|
|
('local function GW_SourceLoginMessage(button, message)\n',
|
|
'local function GW_SourceLoginMessage(button, message)\n\tif not GW_SourceLoginSubmitted then return; end\n'),
|
|
('''function GW_SourceLoginPoll(nativeReady)
|
|
if not nativeReady and not GW_SourceLoginSubmitted then return false; end
|
|
return GW_SourceLoginIsReady();
|
|
end''',
|
|
'''function GW_SourceLoginPoll(nativeReady)
|
|
if not GW_SourceLoginSubmitted then
|
|
if nativeReady then GW_SourceLoginIsReady(); end -- optional Source preflight
|
|
return true; -- permit an attempt; native Login still reports its own result
|
|
end
|
|
return GW_SourceLoginIsReady();
|
|
end'''),
|
|
('function AccountLogin_Login()\n\tif not GW_SourceLoginIsReady() then return; end\n',
|
|
'function AccountLogin_Login()\n'),
|
|
('''function AccountLogin_OnEnterPressed()
|
|
\tif C_Login.IsLoginReady() and GW_SourceLoginIsReady() then
|
|
\t\tAccountLogin_Login();
|
|
\tend
|
|
end''',
|
|
'''function AccountLogin_OnEnterPressed()
|
|
\tAccountLogin_Login();
|
|
end'''),
|
|
]
|
|
for before,after in replacements:
|
|
if text.count(before)!=1:raise ValueError('Pinned local test login anchor differs')
|
|
text=text.replace(before,after,1)
|
|
xml_newline='\r\n' if b'\r\n' in source_xml else '\n'
|
|
xml=source_xml.decode('utf-8').replace('\r\n','\n')
|
|
before='local sourceReady = GW_SourceLoginPoll(nativeReady);\n\t\t\t\t\t\t\t\tif ( nativeReady and sourceReady ) then'
|
|
after='local allowSubmit = GW_SourceLoginPoll(nativeReady);\n\t\t\t\t\t\t\t\tif ( allowSubmit ) then'
|
|
if xml.count(before)!=1:raise ValueError('Pinned local test login XML anchor differs')
|
|
xml=xml.replace(before,after,1)
|
|
return text.replace('\n',newline).encode('utf-8'),xml.replace('\n',xml_newline).encode('utf-8')
|
|
|
|
|
|
def transform_local_test_no_preflight(source,source_xml):
|
|
"""Remove pre-submit Source preflight from the pinned private no-gate UI.
|
|
|
|
Caller must establish genuine local-only routing independently. No expected
|
|
Source generation is inferred; real Source realm refresh remains held.
|
|
"""
|
|
if not isinstance(source,bytes) or hashlib.sha256(source).hexdigest()!=LOCAL_TEST_NOGATE_LUA_SHA256:
|
|
raise ValueError('Pinned no-gate Source AccountLogin input differs')
|
|
if not isinstance(source_xml,bytes) or hashlib.sha256(source_xml).hexdigest()!=LOCAL_TEST_NOGATE_XML_SHA256:
|
|
raise ValueError('Pinned no-gate Source AccountLogin XML differs')
|
|
newline='\r\n' if b'\r\n' in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
before=' if nativeReady then GW_SourceLoginIsReady(); end -- optional Source preflight\n'
|
|
if text.count(before)!=1:raise ValueError('Pinned no-gate preflight anchor differs')
|
|
text=text.replace(before,'',1)
|
|
return text.replace('\n',newline).encode('utf-8'),source_xml
|
|
|
|
|
|
@lru_cache(maxsize=3)
|
|
def owned_lua(path):
|
|
return path.read_text()
|
|
|
|
|
|
def transform(source,*,enable_source_pending=False):
|
|
if type(enable_source_pending)is not bool:raise ValueError('Explicit Source UI boolean required')
|
|
if not isinstance(source,bytes)or len(source)>2*1024*1024 or hashlib.sha256(source).hexdigest()!=SOURCE_SHA256:
|
|
raise ValueError('Pinned original RealmList input differs')
|
|
newline='\r\n'if b'\r\n'in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
def once(before,after,count=1):
|
|
nonlocal text
|
|
if text.count(before)!=count:raise ValueError('Original RealmList consumer anchor differs: '+repr(before[:96]))
|
|
text=text.replace(before,after,count)
|
|
# All substitutions are file-local. C_RealmList and C_Login stay untouched.
|
|
text=text.replace('C_RealmList.','RealmListProvider.')
|
|
once('function RealmList_Update(retainScrollPosition)',
|
|
'function RealmList_Update(retainScrollPosition)\n\tRealmListProvider.Refresh();')
|
|
once('button.populationState = realmInfo.populationState;',
|
|
'button.populationState = realmInfo.populationState;\n\tbutton.sourcePopulation = realmInfo.sourcePopulation;\n\tbutton.sourceSelectable = realmInfo.sourceSelectable;')
|
|
once('return button.populationState ~= "OFFLINE";',
|
|
'return button.populationState ~= "OFFLINE" and button.sourceSelectable ~= false;')
|
|
once('button:SetEnabled(realmInfo.populationState ~= "OFFLINE");',
|
|
'button:SetEnabled(realmInfo.populationState ~= "OFFLINE" and realmInfo.sourceSelectable ~= false);')
|
|
once('RealmListOkButton:SetEnabled(populationState and populationState ~= "OFFLINE");',
|
|
'RealmListOkButton:SetEnabled(populationState and populationState ~= "OFFLINE" and realmInfo.sourceSelectable ~= false);')
|
|
once('if ( populationState == "OFFLINE" ) then\n\t\tbutton.Load:SetText(REALM_DOWN);',
|
|
'if ( populationState == "SOURCE" ) then\n\t\tbutton.Load:SetText(button.sourcePopulation);\n\t\tbutton.Load:SetTextColor(NORMAL_FONT_COLOR:GetRGB());\n\telseif ( populationState == "OFFLINE" ) then\n\t\tbutton.Load:SetText(REALM_DOWN);')
|
|
once('local population1 = RealmListProvider.GetRealmInfo(realm1).populationState;',
|
|
'local sourceOrder = RealmListProvider.ComparePopulation(realm1, realm2);\n\tif sourceOrder ~= nil then return sourceOrder; end\n\tlocal population1 = RealmListProvider.GetRealmInfo(realm1).populationState;')
|
|
once('local realmInfo = RealmListProvider.GetRealmInfo(RealmList.selectedRealm);\n\n\t\tif (realmInfo.populationState',
|
|
'local realmInfo = RealmListProvider.GetRealmInfo(RealmList.selectedRealm);\n\n\t\tif RealmListProvider.IsSource() and (not realmInfo or realmInfo.populationState == "OFFLINE" or realmInfo.sourceSelectable == false) then\n\t\t\tRealmList_UpdateOKButton();\n\t\t\treturn false, "selection-not-available";\n\t\tend\n\n\t\tif (realmInfo.populationState')
|
|
once('RealmListProvider.ConnectToRealm(RealmList.selectedRealm);',
|
|
'RealmListProvider.ConnectToRealm(RealmList.selectedRealm);\n\t\tif RealmListProvider.IsSource() then RealmList_UpdateOKButton(); end')
|
|
once('function RealmList_OnCancel()',
|
|
'function RealmList_OnCancel()\n\tif RealmListProvider.IsSource() then\n\t\tStaticPopup_Show("OKAY", "Returning to the login screen is not available yet.");\n\t\treturn false, "account-realm-transition-unverified";\n\tend')
|
|
prefix='''-- Owned local Source realm data adapter; original controls below remain authoritative.
|
|
local SourceRealmFactory = (function()
|
|
'''+owned_lua(PROVIDER)+'''
|
|
end)();
|
|
local SourceRealmListAdapter = (function()
|
|
'''+owned_lua(ADAPTER)+'''
|
|
end)();
|
|
local SourceRealmData = SourceRealmFactory({
|
|
GetSnapshot = function()
|
|
if type(C_Login.GetTurtleRealmSnapshot) ~= "function" then error("snapshot-unavailable"); end
|
|
return C_Login.GetTurtleRealmSnapshot();
|
|
end,
|
|
RequestRealm = function(index, generation)
|
|
if type(C_Login.RequestTurtleRealm) ~= "function" then return -4001; end
|
|
return C_Login.RequestTurtleRealm(index, generation);
|
|
end,
|
|
});
|
|
local SourceRealmPreference;
|
|
if '''+str(enable_source_pending).lower()+''' and type(RegisterCVar) == "function"
|
|
and type(GetCVar) == "function" and type(SetCVar) == "function" then
|
|
local registered, result = pcall(RegisterCVar, "octoLastRealmIdentity");
|
|
if registered and result ~= false then
|
|
SourceRealmPreference = {
|
|
Read = function() return GetCVar("octoLastRealmIdentity"); end,
|
|
Write = function(value) return SetCVar("octoLastRealmIdentity", value); end,
|
|
};
|
|
end
|
|
end
|
|
local RealmListProvider = SourceRealmListAdapter(SourceRealmData, C_RealmList, '''+str(enable_source_pending).lower()+''', SourceRealmPreference);
|
|
'''
|
|
return (prefix+text).replace('\n',newline).encode('utf-8')
|
|
|
|
|
|
def transform_glue(source,*,enable_source_pending=False,enable_login_diagnostics=False):
|
|
if type(enable_source_pending)is not bool:raise ValueError('Explicit Source UI boolean required')
|
|
if type(enable_login_diagnostics)is not bool:raise ValueError('Explicit login diagnostics boolean required')
|
|
if not isinstance(source,bytes)or len(source)>2*1024*1024 or hashlib.sha256(source).hexdigest()!=GLUE_SHA256:
|
|
raise ValueError('Pinned original GlueParent input differs')
|
|
newline='\r\n'if b'\r\n'in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
replacements=[
|
|
('function GlueParent_EnsureValidScreen()',
|
|
'function GlueParent_EnsureValidScreen()\n\tSourceRealmGlue.Refresh();'),
|
|
('function GlueParent_IsScreenValid(screen)',
|
|
'function GlueParent_IsScreenValid(screen)\n\tif SourceRealmGlue.IsPending() then return screen == "realmlist"; end'),
|
|
('function GlueParent_GetBestScreen()',
|
|
'function GlueParent_GetBestScreen()\n\tif SourceRealmGlue.IsPending() then return "realmlist"; end'),
|
|
]
|
|
for before,after in replacements:
|
|
if text.count(before)!=1:raise ValueError('Original GlueParent consumer anchor differs: '+before)
|
|
text=text.replace(before,after,1)
|
|
if enable_login_diagnostics:
|
|
for before,after in [
|
|
('errorCategory, errorID, localizedString, debugString, errorCodeString = C_Login.GetLastError();',
|
|
'errorCategory, errorID, localizedString, debugString, errorCodeString = C_Login.GetLastError();\n\t\tpcall(SourceLoginDiagnostic, "native-error", loginState, GlueParent.currentScreen, SourceRealmGlue.GetSourceStatus, errorCategory, errorID, errorCodeString);')]:
|
|
if text.count(before)!=1:raise ValueError('Original diagnostic anchor differs: '+before)
|
|
text=text.replace(before,after,1)
|
|
prefix='''-- Owned Source realm-choice branch; original show/error mechanisms below.
|
|
local SourceRealmFactory = (function()
|
|
'''+owned_lua(PROVIDER)+'''
|
|
end)();
|
|
local SourceRealmGlueFactory = (function()
|
|
'''+owned_lua(GLUE_ADAPTER)+'''
|
|
end)();
|
|
local SourceRealmGlue = SourceRealmGlueFactory(SourceRealmFactory({
|
|
GetSnapshot = function()
|
|
if type(C_Login.GetTurtleRealmSnapshot) ~= "function" then error("snapshot-unavailable"); end
|
|
return C_Login.GetTurtleRealmSnapshot();
|
|
end,
|
|
RequestRealm = function(index, generation)
|
|
if type(C_Login.RequestTurtleRealm) ~= "function" then return -4001; end
|
|
return C_Login.RequestTurtleRealm(index, generation);
|
|
end,
|
|
}), '''+str(enable_source_pending).lower()+''');
|
|
'''
|
|
if enable_login_diagnostics:
|
|
prefix+='''local SourceLoginDiagnostic = (function()
|
|
'''+owned_lua(LOGIN_DIAGNOSTIC)+'''
|
|
end)();
|
|
'''
|
|
result=(prefix+text).replace('\n',newline).encode('utf-8')
|
|
return _add_source_login_input_parity(result, enable_source_pending)
|
|
|
|
|
|
def remove_login_visual_diagnostic(source):
|
|
"""Remove only the known temporary visual diagnostic from the adopted UI."""
|
|
if not isinstance(source,bytes) or hashlib.sha256(source).hexdigest()!=VISUAL_GLUE_PARENT_SHA256:
|
|
raise ValueError('Pinned adopted GlueParent input differs')
|
|
newline=b'\r\n' if b'\r\n' in source else b'\n'
|
|
declaration=b'local GW_LoginDiagnosticFrame;'+newline
|
|
start=b' if phase == "native-error" then'+newline+b' pcall(function()'+newline+b' if type(CreateFrame) ~= "function" then return; end'+newline
|
|
end=b' C_Log.LogMessage(table.concat(parts, " "));'
|
|
if source.count(declaration)!=1 or source.count(start)!=1 or source.count(end)!=1:
|
|
raise ValueError('Adopted visual diagnostic anchors differ')
|
|
before,tail=source.split(start,1)
|
|
overlay,after=tail.split(end,1)
|
|
if overlay.count(b'GW_LoginDiagnosticFrame:Show();')!=1 or b'GW_LOGIN_ERROR ' not in overlay:
|
|
raise ValueError('Adopted visual diagnostic block differs')
|
|
return (before+end+after).replace(declaration,b'',1)
|
|
|
|
|
|
def defer_bnet_1016_during_preset(source):
|
|
"""Defer the local front's 1016 dialog while the native preset is open.
|
|
|
|
The error is left in C_Login for the original handler after that screen.
|
|
"""
|
|
if not isinstance(source, bytes):
|
|
raise TypeError('GlueParent input must be bytes')
|
|
before = b'\tlocal errorID;\r\n\tif ( loginState.auroraState == LE_AURORA_STATE_WAITING_FOR_NETWORK ) then'
|
|
after = (b'\tlocal errorID;\r\n'
|
|
b'\tlocal gwErrorCategory, gwErrorID = C_Login.GetLastError();\r\n'
|
|
b'\tlocal gwDeferBnetPresetError = loginState.connectedToWoW and GlueParent.currentScreen == "experiencepreset" and gwErrorCategory == "BNET" and gwErrorID == 1016;\r\n'
|
|
b'\tif ( loginState.auroraState == LE_AURORA_STATE_WAITING_FOR_NETWORK ) then')
|
|
if source.count(before) != 1:
|
|
raise ValueError('Pinned original dialog-entry anchor differs')
|
|
source = source.replace(before, after, 1)
|
|
before = b'elseif ( loginState.auroraState == LE_AURORA_STATE_NONE and C_Login.GetLastError() ) then'
|
|
after = b'elseif ( loginState.auroraState == LE_AURORA_STATE_NONE and C_Login.GetLastError() and not gwDeferBnetPresetError ) then'
|
|
if source.count(before) != 1:
|
|
raise ValueError('Pinned original native-error branch differs')
|
|
return source.replace(before, after, 1)
|
|
|
|
|
|
def clear_proven_local_bnet_front_error(source):
|
|
"""Clear the stale BNET 1016 record after an authenticated local realm join.
|
|
|
|
Keep the existing preset deferral. Other error categories and unproved
|
|
local sessions continue through the original Glue error handler.
|
|
"""
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest() != CLEAN_LOCAL_GLUE_PARENT_SHA256:
|
|
raise ValueError('Pinned clean local GlueParent input differs')
|
|
before = (b'\tlocal gwDeferBnetPresetError = loginState.connectedToWoW and GlueParent.currentScreen == "experiencepreset" '
|
|
b'and gwErrorCategory == "BNET" and gwErrorID == 1016;\r\n')
|
|
after = (before +
|
|
b'\tif loginState.connectedToWoW and gwErrorCategory == "BNET" and gwErrorID == 1016 '
|
|
b'and (GlueParent.currentScreen == "experiencepreset" or GlueParent.currentScreen == "charselect" '
|
|
b'or GlueParent.currentScreen == "charcreate") and type(C_Login.GetTurtleRealmSnapshot) == "function" then\r\n'
|
|
b'\t\tlocal ok, source = pcall(C_Login.GetTurtleRealmSnapshot);\r\n'
|
|
b'\t\tif ok and type(source) == "table" and source.state == 2 and source.error == 0 '
|
|
b'and source.auth_result == 0 and source.server_proof_verified == 1 '
|
|
b'and source.transport_prepared == 1 and source.cancel == 0 '
|
|
b'and type(source.selected_index) == "number" and source.selected_index >= 0 then\r\n'
|
|
b'\t\t\tC_Login.ClearLastError();\r\n'
|
|
b'\t\t\tC_Log.LogMessage("GW_LOCAL_FRONT_ERROR_IGNORED category=BNET id=1016 source_proof=1");\r\n'
|
|
b'\t\tend\r\n'
|
|
b'\tend\r\n')
|
|
if source.count(before) != 1:
|
|
raise ValueError('Pinned clean local BNET deferral anchor differs')
|
|
return source.replace(before, after, 1)
|
|
|
|
|
|
def stage(original,output,*,enable_source_pending=False,consumer='realm-list',enable_login_diagnostics=False):
|
|
original=Path(original);output=Path(output)
|
|
if not output.resolve().is_relative_to((ROOT/'runtime').resolve()):raise ValueError('Use a private runtime candidate path')
|
|
if consumer=='glue-parent-no-visual':
|
|
if enable_source_pending or enable_login_diagnostics:raise ValueError('Existing GlueParent already contains its qualified options')
|
|
qualification=output.with_suffix('.qualification.private.json')
|
|
if output.exists() or qualification.exists():raise ValueError('Existing candidate or qualification preserved')
|
|
candidate=remove_login_visual_diagnostic(original.read_bytes())
|
|
output.parent.mkdir(parents=True,exist_ok=True);output.write_bytes(candidate)
|
|
report=dict(kind='existing-GlueParent-remove-login-visual-v1',consumer=consumer,
|
|
source_reference=GLUE_REFERENCE,original=dict(path=str(original),sha256=VISUAL_GLUE_PARENT_SHA256),
|
|
candidate=dict(path=str(output),sha256=hashlib.sha256(candidate).hexdigest()),
|
|
native_popup_help_and_logging_preserved=True,installed=False,native_acceptance=False)
|
|
qualification.write_text(json.dumps(report,indent=2)+'\n')
|
|
return report
|
|
if consumer not in ('realm-list','glue-parent'):raise ValueError('Unknown qualified original UI consumer')
|
|
transform_function=transform if consumer=='realm-list'else transform_glue
|
|
if enable_login_diagnostics and consumer!='glue-parent':raise ValueError('Login diagnostics require glue-parent consumer')
|
|
options=dict(enable_source_pending=enable_source_pending)
|
|
if consumer=='glue-parent':options['enable_login_diagnostics']=enable_login_diagnostics
|
|
raw=original.read_bytes();candidate=transform_function(raw,**options)
|
|
output.parent.mkdir(parents=True,exist_ok=True);output.write_bytes(candidate)
|
|
report=dict(kind='original-Glue-Source-realm-adapter-v1',consumer=consumer,
|
|
source_reference=SOURCE_REFERENCE if consumer=='realm-list'else GLUE_REFERENCE,
|
|
original=dict(path=str(original),sha256=SOURCE_SHA256 if consumer=='realm-list'else GLUE_SHA256),
|
|
candidate=dict(path=str(output),sha256=hashlib.sha256(candidate).hexdigest()),
|
|
source_pending_enabled=enable_source_pending,global_native_APIs_overridden=False,
|
|
original_controls_and_style_preserved=True,new_original_UI_assets=False,
|
|
owned_support=[dict(path=str(path),sha256=hashlib.sha256(owned_lua(path).encode()).hexdigest())
|
|
for path in (PROVIDER,ADAPTER if consumer=='realm-list'else GLUE_ADAPTER)],
|
|
screen_and_auth_error_routing='Owned genuine pending-choice branch; native fallback and all other native errors preserved',
|
|
Source_cancel_or_realm_change='HELD',installed=False,native_acceptance=False)
|
|
if enable_login_diagnostics:
|
|
report['login_diagnostics_enabled']=True
|
|
report['owned_support'].append(dict(path=str(LOGIN_DIAGNOSTIC),sha256=hashlib.sha256(owned_lua(LOGIN_DIAGNOSTIC).encode()).hexdigest()))
|
|
output.with_suffix('.qualification.private.json').write_text(json.dumps(report,indent=2)+'\n')
|
|
return report
|
|
|
|
|
|
SUPER_DISTRICT_SHA256='fe18531198c6216b308a509dfd474c3c174f91b823f538f0c02eb03535177b9f'
|
|
SUPER_DISTRICT_REFERENCE='interface/addons/blizzard_gluexml/mainline/superdistrict.lua'
|
|
SUPER_DISTRICT_FDI=8199120
|
|
INSTALLED_SUPER_DISTRICT_SHA256='0a7b90f1efbce66bd39d048f90a0242b03e2b3f827424d1f90b5051452d254e0'
|
|
INSTALLED_MACHINE_SUPER_DISTRICT_SHA256='4321b35f4c58fe585b6451264bd0ecd4b715346ebb286973bf5975a6db39e785'
|
|
INSTALLED_MACHINE_DISTRICT_ADAPTER_SHA256='a5e1d3cd8a42f9567d4ea62b0f92ef178c479cafce9484f71111661962a296c2'
|
|
INSTALLED_ACCOUNT_LOGIN_SHA256='3a3c7fee791a6cf688a81cccbc6e2fe085f3343b2972834d4da7fae7fdbdff5b'
|
|
INSTALLED_ACCOUNT_LOGIN_BROWSER_COPY_SHA256='30682e6a87f868080b15b8aaa526944b462a3410408184d5b6285d0b7b28d106'
|
|
INSTALLED_ACCOUNT_LOGIN_TWO_PRESS_SHA256='9a0a0dfeb596d73289aaeea4e38034b0afd09e4374ed3e73dc68fbea4358d84a'
|
|
GLUE_SAVEDVARS_TOC_SHA256='bc7e03d75b3a2fe4f92f37e013a0626c457e80b08538bf96762c6be2b47b016d'
|
|
GLUE_SAVEDVARS_TOC_FDI=5362155
|
|
CURRENT_GLUE_PARENT_SHA256='787d977a8fd395860530f06aee26b70e5657941918112cbabf81db40ef4fd91c'
|
|
DISTRICT_ADAPTER=ROOT/'compat/glue/source_realm_district_adapter.lua'
|
|
|
|
_CVAR_REALM_PREFERENCE=('local SourceRealmPreference;\n'
|
|
'if type(RegisterCVar) == "function" and type(GetCVar) == "function"\n'
|
|
' and type(SetCVar) == "function" then\n'
|
|
' local registered, result = pcall(RegisterCVar, "octoLastRealmIdentity");\n'
|
|
' if registered and result ~= false then\n'
|
|
' SourceRealmPreference = {\n'
|
|
' Read = function() return GetCVar("octoLastRealmIdentity"); end,\n'
|
|
' Write = function(value) return SetCVar("octoLastRealmIdentity", value); end,\n'
|
|
' };\n'
|
|
' end\n'
|
|
'end\n')
|
|
_MACHINE_REALM_PREFERENCE=('local SourceRealmPreference = {\n'
|
|
' Read = function() return g_octoLastRealmIdentity; end,\n'
|
|
' Write = function(value) g_octoLastRealmIdentity = value; end,\n'
|
|
'};\n')
|
|
|
|
|
|
_SCOPED_REALM_PREFERENCE = """local SourceRealmPreference = {
|
|
Read = function(accountKey)
|
|
if type(g_octoLastRealmIdentity) == "table" then
|
|
return g_octoLastRealmIdentity[accountKey];
|
|
end
|
|
end,
|
|
Write = function(accountKey, realm)
|
|
if type(g_octoLastRealmIdentity) ~= "table" then g_octoLastRealmIdentity = {}; end
|
|
g_octoLastRealmIdentity[accountKey] = realm;
|
|
end,
|
|
};
|
|
"""
|
|
|
|
|
|
def _register_realm_character_list(source):
|
|
source = _replace_once(source, 'self:RegisterEvent("SUPER_DISTRICT_LIST_UPDATED");',
|
|
'self:RegisterEvent("SUPER_DISTRICT_LIST_UPDATED");\n\tself:RegisterEvent("CHARACTER_LIST_UPDATE");',
|
|
'Realm preference character-list event')
|
|
return _replace_once(source, 'function SuperDistrictMixin:OnEvent(event)\n',
|
|
'function SuperDistrictMixin:OnEvent(event)\n'
|
|
'\tif event == "CHARACTER_LIST_UPDATE" then SourceRealmDistrict.CharacterListReceived(); return; end\n',
|
|
'Realm preference character-list handler')
|
|
|
|
|
|
def upgrade_final7_realm_preference(source):
|
|
"""Regenerate the owned chooser modules on the installed faf3 FDID 8199120."""
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest() != "0454afc28e5128c66d77197e825a20bbe39953c01069090cfd108d57fa91e138":
|
|
raise ValueError("Installed faf3 SuperDistrict input differs")
|
|
text = source.decode("utf-8").replace("\r\n", "\n")
|
|
begin = "local SourceRealmDistrict = (function()\n"
|
|
join = "\nend)()((function()\n"
|
|
end = "\nend)()({\n GetSnapshot = function()"
|
|
prefix, body = text.split(begin)
|
|
old_adapter, provider_and_tail = body.split(join)
|
|
old_provider, tail = provider_and_tail.split(end)
|
|
prefix = _replace_once(prefix, _MACHINE_REALM_PREFERENCE, _SCOPED_REALM_PREFERENCE, "Realm preference store")
|
|
# Regenerate the numeric data decoder together with the two owned Lua modules.
|
|
old_backend, trailing = (end + tail).split("), SourceRealmPreference);", 1)
|
|
result = (prefix + begin + owned_lua(DISTRICT_ADAPTER) + join + owned_lua(PROVIDER)
|
|
+ "\nend)()(" + _source_backend_lua() + "), SourceRealmPreference);" + trailing)
|
|
return _register_realm_character_list(result).replace("\n", "\r\n").encode("utf-8")
|
|
|
|
|
|
def transform_glue_savedvars_toc(source):
|
|
"""Register the realm identity in the engine's machine-scoped Glue save file."""
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest()!=GLUE_SAVEDVARS_TOC_SHA256:
|
|
raise ValueError('Pinned Glue saved-variables TOC input differs')
|
|
before=(b'## SavedVariablesMachine: g_collapsedServerAlert, '
|
|
b'g_characterSelectToolTrayCollapsed, g_newGameModeAvailableAcknowledged')
|
|
if source.count(before)!=1 or b'g_octoLastRealmIdentity' in source:
|
|
raise ValueError('Glue saved-variables declaration differs')
|
|
return source.replace(before, before+b', g_octoLastRealmIdentity', 1)
|
|
|
|
|
|
def rebind_installed_super_district_machine_preference(source):
|
|
"""Replace only final6's failed custom-CVar storage binding."""
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest()!=INSTALLED_SUPER_DISTRICT_SHA256:
|
|
raise ValueError('Pinned installed SuperDistrict input differs')
|
|
newline='\r\n' if b'\r\n' in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
if text.count(_CVAR_REALM_PREFERENCE)!=1:
|
|
raise ValueError('Installed SuperDistrict preference binding differs')
|
|
return text.replace(_CVAR_REALM_PREFERENCE,_MACHINE_REALM_PREFERENCE,1).replace('\n',newline).encode('utf-8')
|
|
|
|
|
|
def upgrade_installed_super_district_stable_identity(source):
|
|
"""Rebase only the realm adapter embedded in exact installed 05d7 Glue."""
|
|
return _replace_installed_district_adapter(source, INSTALLED_MACHINE_SUPER_DISTRICT_SHA256,
|
|
INSTALLED_MACHINE_DISTRICT_ADAPTER_SHA256)
|
|
|
|
|
|
def refresh_release_district_adapter(source):
|
|
"""Update the owned adapter in the 70334 ec5d release copy of FDID 8199120."""
|
|
return _replace_installed_district_adapter(
|
|
source, '540cf0579d1ec9f66b4f0e37fa59efa667ab5ddc9db2f669da5ade0e01a2d8bc',
|
|
'f4cbb940d2c1b2d1ebc6a284fd570c77a99ccee9286d53dbc0fde1565b48ab8f')
|
|
|
|
|
|
def _replace_installed_district_adapter(source, file_hash, adapter_hash):
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest() != file_hash:
|
|
raise ValueError('Pinned installed SuperDistrict input differs')
|
|
newline='\r\n' if b'\r\n' in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
before='local SourceRealmDistrict = (function()\n'
|
|
after='\nend)()((function()\n'
|
|
if text.count(before)!=1 or text.count(after)!=1:
|
|
raise ValueError('Installed realm adapter boundaries differ')
|
|
head, remaining=text.split(before,1)
|
|
old_adapter, tail=remaining.split(after,1)
|
|
if hashlib.sha256(old_adapter.encode('utf-8')).hexdigest()!=adapter_hash:
|
|
raise ValueError('Installed realm adapter differs')
|
|
rebased=head+before+owned_lua(DISTRICT_ADAPTER)+after+tail
|
|
return rebased.replace('\n',newline).encode('utf-8')
|
|
|
|
|
|
def correct_installed_priority_wait_copy(source):
|
|
"""Align the final6 login popup with its client-owned browser sign-in."""
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest()!=INSTALLED_ACCOUNT_LOGIN_SHA256:
|
|
raise ValueError('Pinned installed AccountLogin input differs')
|
|
before=(b'Checking the saved Octo priority session in the background. '
|
|
b'If it has expired, sign in with OctoLauncher once and reopen the game, '
|
|
b'or use the public Octo route.')
|
|
after=(b'Checking Octo priority access in the background. '
|
|
b'If a browser sign-in opens, approve it there. '
|
|
b'You can also use the public Octo route.')
|
|
if source.count(before)!=1:
|
|
raise ValueError('Installed priority wait popup differs')
|
|
return source.replace(before, after, 1)
|
|
|
|
|
|
def prepare_installed_priority_first_press(source):
|
|
"""Keep credentials in Glue until the client-owned priority worker is ready."""
|
|
if (not isinstance(source, bytes) or
|
|
hashlib.sha256(source).hexdigest()!=INSTALLED_ACCOUNT_LOGIN_BROWSER_COPY_SHA256):
|
|
raise ValueError('Pinned browser-copy AccountLogin input differs')
|
|
newline=b'\r\n' if b'\r\n' in source else b'\n'
|
|
before=b'\tif route == 1 then'+newline
|
|
after=(b'\tif route == 0 then'+newline+
|
|
b'\t\t-- The first owned input can arm the native login frame before that frame'+newline+
|
|
b'\t\t-- starts the priority worker. Keep both fields intact for a second press.'+newline+
|
|
b'\t\tStaticPopup_Show("OKAY", "Octo sign-in is initializing in the background. Please press Log In again shortly.");'+newline+
|
|
b'\t\treturn;'+newline+
|
|
b'\telseif route == 1 then'+newline)
|
|
if source.count(before)!=1:
|
|
raise ValueError('Installed priority first-press branch differs')
|
|
result=source.replace(before,after,1)
|
|
if hashlib.sha256(result).hexdigest()!=INSTALLED_ACCOUNT_LOGIN_TWO_PRESS_SHA256:
|
|
raise ValueError('Installed priority first-press output differs')
|
|
return result
|
|
|
|
|
|
def _source_backend_lua():
|
|
# The helper-free Bridge cannot allocate Lua objects (foreign-DLL
|
|
# allocations do not return), so it exposes a numeric query API:
|
|
# (0,0) captures one Wire snapshot; (0,i) header fields; (1,row,f) row
|
|
# fields; (2|3,row,c) name/address bytes packed three per integer.
|
|
return '''{
|
|
GetSnapshot = function()
|
|
local api = C_Login.GetTurtleRealmSnapshot;
|
|
if type(api) ~= "function" then error("snapshot-unavailable"); end
|
|
local captured = api(0, 0, 0);
|
|
if captured ~= 0 then return captured; end
|
|
local snapshot = {};
|
|
for index, key in ipairs({"abi", "size", "generation", "endpoint_kind", "state", "error",
|
|
"auth_result", "discovery_result", "server_proof_verified", "realm_count",
|
|
"selected_index", "transport_prepared", "cancel", "auth_port", "copied_realms",
|
|
"genuine_discovery", "source_login_readiness"}) do
|
|
local value = api(0, index, 0);
|
|
if type(value) ~= "number" then return -4003; end
|
|
snapshot[key] = value;
|
|
end
|
|
if snapshot.server_proof_verified == 1 and snapshot.genuine_discovery == 1 and snapshot.cancel == 0 then
|
|
local chunks = {};
|
|
for field = 18, 33 do
|
|
local word = api(0, field, 0);
|
|
if type(word) ~= "number" or word < 0 or word > 65535 or word ~= math.floor(word) then break; end
|
|
chunks[#chunks + 1] = string.format("%04x", word);
|
|
end
|
|
if #chunks == 16 and api(0, 3, 0) == snapshot.generation then
|
|
snapshot.account_preference_key = table.concat(chunks);
|
|
end
|
|
end
|
|
local function text(query, row)
|
|
local parts = {};
|
|
for chunk = 0, 85 do
|
|
local packed = api(query, row, chunk);
|
|
if type(packed) ~= "number" or packed <= 0 then break; end
|
|
for _ = 1, 3 do
|
|
local byte = packed % 256;
|
|
if byte == 0 then return table.concat(parts); end
|
|
parts[#parts + 1] = string.char(byte);
|
|
packed = (packed - byte) / 256;
|
|
end
|
|
end
|
|
return table.concat(parts);
|
|
end
|
|
for row = 0, (snapshot.copied_realms or 0) - 1 do
|
|
local fields = {};
|
|
for index, key in ipairs({"type", "flags", "characters", "category", "wire_id", "population_bits"}) do
|
|
fields[key] = api(1, row, index - 1);
|
|
end
|
|
fields.name = text(2, row);
|
|
fields.address = text(3, row);
|
|
snapshot["r" .. row] = fields;
|
|
end
|
|
return snapshot;
|
|
end,
|
|
Cancel = function()
|
|
local api = C_Login.GetTurtleRealmSnapshot;
|
|
if type(api) ~= "function" then return -4001; end
|
|
return api(4, 0, 0);
|
|
end,
|
|
RequestRealm = function(index, generation)
|
|
if type(C_Login.RequestTurtleRealm) ~= "function" then return -4001; end
|
|
return C_Login.RequestTurtleRealm(index, generation);
|
|
end,
|
|
}'''
|
|
|
|
|
|
def _replace_once(text,before,after,label):
|
|
if text.count(before)!=1:raise ValueError(label+' anchor differs: '+repr(before[:96]))
|
|
return text.replace(before,after,1)
|
|
|
|
|
|
def transform_super_district(source):
|
|
"""Present pending Source realms in the original SuperDistrict (ruleset) screen."""
|
|
if not isinstance(source,bytes)or hashlib.sha256(source).hexdigest()!=SUPER_DISTRICT_SHA256:
|
|
raise ValueError('Pinned original SuperDistrict input differs')
|
|
newline='\r\n'if b'\r\n'in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
for before,after in [
|
|
('\tself:RefreshSuperDistrictButtons();\n\tself:UpdateSelection(self.selectedSuperDistrictID);\nend',
|
|
'\tself:HookScript("OnUpdate", function(frame, delta) SourceRealmDistrict.OnUpdate(frame, delta); end);\n'
|
|
'\tself:RefreshSuperDistrictButtons();\n\tself:UpdateSelection(self.selectedSuperDistrictID);\nend'),
|
|
('function SuperDistrictMixin:RefreshSuperDistrictButtons()\n',
|
|
'function SuperDistrictMixin:RefreshSuperDistrictButtons()\n\tif SourceRealmDistrict.Refresh(self) then return; end\n'),
|
|
('function SuperDistrictMixin:OnCancel()\n',
|
|
'function SuperDistrictMixin:OnCancel()\n\tSourceRealmDistrict.Cancel(self);\n'),
|
|
('function SuperDistrictMixin:ConfirmSuperDistrict()\n',
|
|
'function SuperDistrictMixin:ConfirmSuperDistrict()\n\tif SourceRealmDistrict.Confirm(self, self.selectedSuperDistrictID) then return; end\n'),
|
|
('\tself.SubRegionDropdown:SetShown(#C_Login.GetSubRegions() > 1);',
|
|
'\tself.SubRegionDropdown:SetShown(#C_Login.GetSubRegions() > 1 and not SourceRealmDistrict.IsActive());'),
|
|
]:text=_replace_once(text,before,after,'SuperDistrict')
|
|
prefix=('-- Owned Source realm choice in the original SuperDistrict screen.\n'
|
|
+_SCOPED_REALM_PREFERENCE
|
|
+'local SourceRealmDistrict = (function()\n'+owned_lua(DISTRICT_ADAPTER)+'\nend)()((function()\n'
|
|
+owned_lua(PROVIDER)+'\nend)()('+_source_backend_lua()+'), SourceRealmPreference);\n')
|
|
return _register_realm_character_list(prefix+text).replace('\n',newline).encode('utf-8')
|
|
|
|
|
|
def _expose_account_back(text):
|
|
anchor = 'function GlueParent_EnsureValidScreen()'
|
|
return _replace_once(text, anchor,
|
|
'GlueParent_SourceAccountBack = SourceRealmGlue.OnAccountBack;\n\n' + anchor,
|
|
'Source account Back notification')
|
|
|
|
|
|
def add_source_choice_to_current_glue(source):
|
|
"""Route a pending Source realm choice to the SuperDistrict screen."""
|
|
if not isinstance(source,bytes)or hashlib.sha256(source).hexdigest()!=CURRENT_GLUE_PARENT_SHA256:
|
|
raise ValueError('Pinned current GlueParent input differs')
|
|
newline='\r\n'if b'\r\n'in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
for before,after in [
|
|
('function GlueParent_EnsureValidScreen()','function GlueParent_EnsureValidScreen()\n\tSourceRealmGlue.Refresh();'),
|
|
('function GlueParent_UpdateDialogs()', 'function GlueParent_UpdateDialogs()\n\tif SourceRealmGlue.HandleFailure() then return; end'),
|
|
('function GlueParent_IsScreenValid(screen)','function GlueParent_IsScreenValid(screen)\n\tif SourceRealmGlue.IsHolding() then return screen == "superdistrict"; end'),
|
|
('function GlueParent_GetBestScreen()','function GlueParent_GetBestScreen()\n\tif SourceRealmGlue.IsHolding() then return "superdistrict"; end'),
|
|
('C_Login.GetLastError() and not gwDeferBnetPresetError ) then',
|
|
'C_Login.GetLastError() and not gwDeferBnetPresetError and not SourceRealmGlue.IsPending() ) then'),
|
|
# Native login stays "connecting" while Source waits for the choice;
|
|
# the realm screen replaces the Connecting popup only in that state.
|
|
('\tif ( loginState.auroraState == LE_AURORA_STATE_WAITING_FOR_NETWORK ) then',
|
|
'\tif ( SourceRealmGlue.IsPending() ) then\n\t\tStaticPopup_Hide("CANCEL");\n'
|
|
'\telseif ( loginState.auroraState == LE_AURORA_STATE_WAITING_FOR_NETWORK ) then'),
|
|
# The numeric snapshot API returns no table; reuse the adapter status.
|
|
('local ok, source = pcall(C_Login.GetTurtleRealmSnapshot);',
|
|
'local ok, source = pcall(SourceRealmGlue.GetSourceStatus);'),
|
|
]:text=_replace_once(text,before,after,'GlueParent')
|
|
# The Source snapshot raises no glue event: poll gently and re-run the
|
|
# original screen/dialog decisions only when the pending state flips.
|
|
text+=('\n-- Owned Source realm-choice poll.\n'
|
|
'do\n\tlocal poll, elapsed = CreateFrame("Frame"), 0;\n'
|
|
'\tpoll:SetScript("OnUpdate", function(_, delta)\n'
|
|
'\t\telapsed = elapsed + (delta or 0);\n\t\tif elapsed < 0.5 then return; end\n\t\telapsed = 0;\n'
|
|
'\t\tlocal was, failed = SourceRealmGlue.IsHolding(), SourceRealmGlue.GetFailureGeneration();\n'
|
|
'\t\tSourceRealmGlue.Refresh();\n'
|
|
'\t\tif SourceRealmGlue.IsHolding() ~= was or SourceRealmGlue.GetFailureGeneration() ~= failed then\n'
|
|
'\t\t\tGlueParent_EnsureValidScreen();\n\t\t\tGlueParent_UpdateDialogs();\n\t\tend\n'
|
|
'\tend);\nend\n')
|
|
prefix=('-- Owned Source realm-choice routing; original screens and errors otherwise.\n'
|
|
'local SourceRealmGlue = (function()\n'+owned_lua(GLUE_ADAPTER)+'\nend)()((function()\n'
|
|
+owned_lua(PROVIDER)+'\nend)()('+_source_backend_lua()+'), true);\n')
|
|
return _add_source_login_input_parity((prefix+_expose_account_back(text)).replace('\n',newline).encode('utf-8'), True)
|
|
|
|
|
|
def _add_source_login_input_parity(source, enabled):
|
|
"""Configure only the enabled Source login widgets before original Show.
|
|
|
|
The original AccountLogin OnShow remains responsible for saved account
|
|
data, focus and login. Never inspect or rewrite either widget's text.
|
|
"""
|
|
if type(enabled) is not bool:
|
|
raise ValueError('Explicit Source UI boolean required')
|
|
if not enabled:
|
|
return source
|
|
newline='\r\n' if b'\r\n' in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
if 'local SourceLoginInputParity = ' in text:
|
|
raise ValueError('Source login input parity already present')
|
|
before='\tlocal frameToShow = _G[screenInfo.frame];\n\tframeToShow:Show();'
|
|
after=('\tlocal frameToShow = _G[screenInfo.frame];\n'
|
|
'\tif screenInfo.frame == "AccountLogin" then SourceLoginInputParity(frameToShow); end\n'
|
|
'\tframeToShow:Show();')
|
|
text=_replace_once(text,before,after,'Source login input pre-Show')
|
|
prefix=('local SourceLoginInputParity = (function()\n'
|
|
+owned_lua(LOGIN_INPUT_PARITY)+'\nend)()(true);\n')
|
|
return (prefix+text).replace('\n',newline).encode('utf-8')
|
|
|
|
|
|
def upgrade_source_login_input_parity_glue(source):
|
|
"""Add input parity to the accepted Source-failure Glue child only."""
|
|
if not isinstance(source,bytes) or hashlib.sha256(source).hexdigest() != 'cf3a368797ea812cc0841043588385bb2e242a266fd3f54d552158a0f12eef45':
|
|
raise ValueError('Pinned Source failure GlueParent input differs')
|
|
return _add_source_login_input_parity(source, True)
|
|
|
|
|
|
def upgrade_source_failure_glue(source):
|
|
"""Upgrade only the established owned Source wrapper, preserving its body.
|
|
|
|
The installed Store/character UI child can contain later unrelated Glue
|
|
edits. Require the exact previous adapter and poll scaffolding rather than
|
|
regenerating that child from an older whole-file baseline.
|
|
"""
|
|
if not isinstance(source,bytes) or len(source)>2*1024*1024:
|
|
raise ValueError('Bounded owned GlueParent bytes required')
|
|
newline='\r\n' if b'\r\n' in source else '\n'
|
|
text=source.decode('utf-8').replace('\r\n','\n')
|
|
before='local SourceRealmGlue = (function()\n'
|
|
after='\nend)()((function()\n'
|
|
if text.count(before)!=1 or text.count(after)!=1:
|
|
raise ValueError('Owned Source Glue adapter wrapper differs')
|
|
start=text.index(before)+len(before);end=text.index(after,start)
|
|
old=text[start:end]
|
|
if hashlib.sha256(old.encode('utf-8')).hexdigest()!='d9efc1aadc5fc8bd5f6644d475345069c885c7fb253b1bf56e7e9a431ca93800':
|
|
raise ValueError('Owned Source Glue adapter pin differs')
|
|
text=text[:start]+owned_lua(GLUE_ADAPTER)+text[end:]
|
|
text=_replace_once(text,'function GlueParent_UpdateDialogs()',
|
|
'function GlueParent_UpdateDialogs()\n\tif SourceRealmGlue.HandleFailure() then return; end','Source failure dialog')
|
|
text=_replace_once(text,'\t\tlocal was = SourceRealmGlue.IsHolding();\n',
|
|
'\t\tlocal was, failed = SourceRealmGlue.IsHolding(), SourceRealmGlue.GetFailureGeneration();\n','Source failure poll capture')
|
|
text=_replace_once(text,'\t\tif SourceRealmGlue.IsHolding() ~= was then\n',
|
|
'\t\tif SourceRealmGlue.IsHolding() ~= was or SourceRealmGlue.GetFailureGeneration() ~= failed then\n','Source failure poll transition')
|
|
return _expose_account_back(text).replace('\n',newline).encode('utf-8')
|
|
|
|
def main():
|
|
parser=argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--original',type=Path,required=True)
|
|
parser.add_argument('--output',type=Path,required=True)
|
|
parser.add_argument('--enable-source-pending',action='store_true')
|
|
parser.add_argument('--enable-login-diagnostics',action='store_true')
|
|
parser.add_argument('--consumer',choices=('realm-list','glue-parent','glue-parent-no-visual'),default='realm-list')
|
|
args=parser.parse_args()
|
|
report=stage(args.original,args.output,enable_source_pending=args.enable_source_pending,consumer=args.consumer,enable_login_diagnostics=args.enable_login_diagnostics)
|
|
print(json.dumps({'candidate':report['candidate'],'installed':False},separators=(',',':')))
|
|
|
|
|
|
if __name__=='__main__':main()
|
|
|
|
# Selected Q97 inputs; Q86 changes only customization FDID 8068384.
|
|
REALM_EXIT_INPUTS = {
|
|
'back': ('2b44044db558ba8753925f394e83acfdede075384d715d7d87ce70aa1bba150e',
|
|
'function CharacterSelectBackButtonMixin:OnClick()\n',
|
|
'\tSourceRealmExit();\n'),
|
|
'character': ('5bed4b18394dbd9b33c1fa556f92f3fb5cc135a8a3b6a5a43664717083bb9e1d',
|
|
'function CharacterSelectUtil.ChangeRealm()\n',
|
|
'\tif SourceRealmExit() then CharacterSelect_Exit(); return; end\n'),
|
|
'realm': ('f76eb2ae171a92eb348cff2b775f7b7e0166425fbb116b98c9fb93bbf9b13e51',
|
|
'function RealmList_OnCancel()\n',
|
|
'\tif SourceRealmExit() then\n'
|
|
'\t\tif type(GlueParent_SourceAccountBack) == "function" then GlueParent_SourceAccountBack(); end\n'
|
|
'\t\tC_Login.DisconnectFromServer();\n'
|
|
'\t\tEventRegistry:TriggerEvent("RealmList.Cancel");\n\t\treturn;\n\tend\n'),
|
|
'district': ('08e9d8cbb2ba4c1a7d5cf9a100e6a66bb3b5cf0e0156ddba208d46b8ebeda6fb',
|
|
'function SuperDistrictMixin:OnCancel()\n',
|
|
'\tif SourceRealmExit() then\n\t\tSourceRealmDistrict.Cancel(self);\n'
|
|
'\t\tif type(GlueParent_SourceAccountBack) == "function" then GlueParent_SourceAccountBack(); end\n'
|
|
'\t\tC_Login.DisconnectFromServer();\n\t\treturn;\n\tend\n'),
|
|
}
|
|
|
|
|
|
def transform_realm_exit(source, *, consumer):
|
|
"""Clear explicit realm-choice intent and use the existing disconnect path.
|
|
|
|
Selected account-scoped Glue storage is authoritative, not the retired
|
|
custom CVar. The latter is cleared only for migration compatibility.
|
|
No native API or callback is replaced at runtime.
|
|
"""
|
|
if consumer not in REALM_EXIT_INPUTS:
|
|
raise ValueError('Unknown realm exit consumer')
|
|
digest, anchor, addition = REALM_EXIT_INPUTS[consumer]
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest() != digest:
|
|
raise ValueError('Pinned realm exit input differs')
|
|
newline = '\r\n' if b'\r\n' in source else '\n'
|
|
text = source.decode('utf-8').replace('\r\n', '\n')
|
|
text = _replace_once(text, anchor, anchor + addition, 'Explicit realm exit')
|
|
prefix = ('-- Owned explicit Source realm exit; native API identities remain intact.\n'
|
|
'local SourceRealmExit = (function()\n' + _SCOPED_REALM_PREFERENCE +
|
|
'local provider = (function()\n' + owned_lua(PROVIDER) + '\nend)()(' +
|
|
_source_backend_lua() + ');\nreturn (function()\n' +
|
|
owned_lua(ROOT/'compat/glue/source_realm_exit.lua') +
|
|
'\nend)()(provider, SourceRealmPreference, function()\n'
|
|
' if type(SetCVar) == "function" then SetCVar("octoLastRealmIdentity", ""); end\n'
|
|
'end);\nend)();\n')
|
|
return (prefix + text).replace('\n', newline).encode('utf-8')
|
|
|
|
|
|
REALM_NAV_INPUT_SHA256 = 'ccac714c59d56c5007fe1f8da7c8e145b171b3aee137e9eb8cbc83e6a288d270'
|
|
|
|
|
|
def transform_realm_nav(source):
|
|
"""Choose the character-select buttons constructed by the stock Camelot navigation bar."""
|
|
if not isinstance(source, bytes) or hashlib.sha256(source).hexdigest() != REALM_NAV_INPUT_SHA256:
|
|
raise ValueError('Pinned realm navigation template differs')
|
|
realm_flag = b'<KeyValue key="realmsButtonAvailable" value="false" type="boolean"/>'
|
|
ruleset_flag = b'<KeyValue key="superDistrictsButtonAvailable" value="true" type="boolean"/>'
|
|
indent = b'\r\n\t\t\t'
|
|
stock = indent.join((realm_flag, ruleset_flag))
|
|
if source.count(stock) != 1:
|
|
raise ValueError('Selected Camelot navigation flags differ')
|
|
buttons = (
|
|
realm_flag.replace(b'"false"', b'"true"'),
|
|
ruleset_flag.replace(b'"true"', b'"false"'),
|
|
b'<KeyValue key="storeButtonAvailable" value="false" type="boolean"/>',
|
|
)
|
|
return source.replace(stock, indent.join(buttons))
|
|
|
|
|
|
def prepare_priority_login_timeout(source):
|
|
"""Bound the owned priority gate; preserve the original credential/login body."""
|
|
if not isinstance(source, bytes):
|
|
raise ValueError('AccountLogin input must be bytes')
|
|
newline = '\r\n' if b'\r\n' in source else '\n'
|
|
text = source.decode('utf-8').replace('\r\n', '\n')
|
|
before = 'local function OctoPriorityWaitDialog()\n'
|
|
after = '\tC_Login.ClearLastError();'
|
|
if text.count(before) != 1 or text.count(after) != 1:
|
|
raise ValueError('Priority login boundaries differ')
|
|
start, end = text.index(before), text.index(after)
|
|
if hashlib.sha256(text[start:end].encode()).hexdigest() != '3b43224da33bb7b925e4b1722dada3b956ccf81203efa5dc2ca6fced3fecc378':
|
|
raise ValueError('Priority login gate differs; review before replacing')
|
|
gate = (ROOT / 'compat/glue/priority_login_timeout.lua').read_text()
|
|
replacement = ('local OctoPriorityLoginGate = (function()\n' + gate + '\nend)();\n\n'
|
|
'function AccountLogin_Login()\n\tif not OctoPriorityLoginGate() then return; end\n')
|
|
return (text[:start] + replacement + text[end:]).replace('\n', newline).encode('utf-8')
|