diff --git a/audit/history.jsonl b/audit/history.jsonl index fd5f386c..9097feab 100644 --- a/audit/history.jsonl +++ b/audit/history.jsonl @@ -656,3 +656,4 @@ {"time": "2026-10-18T10:49:04.284335+00:00", "event": "platform_fix", "unit": "EterLib/GrpExpandedImageInstance.cpp", "result": "ADAPTED", "reason": "Preserve stage-0 U/V in UI command/sampler path instead of unconditional clamp; repeated Board backgrounds validated on macOS. Aggregate UI remains PARTIAL.", "evidence": ["audit/evidence/2026-10-18-ui-addressing.md", "tests/port/port_grp_resource_test.cpp", "tests/host/ui_sampler_capture_test.cpp"]} {"time": "2026-10-18T17:58:20.857552+00:00", "event": "lifecycle_investigation", "units": ["EterPythonLib/PythonWindow.cpp", "EterPythonLib/PythonWindowManager.cpp"], "finding": "Scripted reconnect during OnUpdate crashed; relevant window lifecycle group matches 40250. No code changes or status upgrades; use cold-start QA and retain reconnect finding.", "evidence": ["audit/evidence/2026-10-18-window-lifecycle-qa.md"]} {"time": "2026-10-18T23:43:15.072652+00:00", "event": "platform_endpoint_fix", "unit": "host/live_client + ScriptLib/LiveEndpointScript", "finding": "Preserve explicitly selected live endpoint across login reopen; execute optional local QA commands between parked script frames rather than from window traversal. No original CWindow/CWindowManager code changed.", "evidence": ["tests/wiki/test_live_endpoint.py", "tests/wiki/test_python_command_file.py", "audit/evidence/2026-10-18-window-lifecycle-qa.md", "docs/AVA2-SWITCHBOT.md"], "result": "Three same-process relogins and two cross-core map transfers verified on macOS/sbtest; native cross-channel switching remains pending; no global parity status upgraded."} +{"time": "2026-10-19T00:04:44.204859+00:00", "event": "authorized_ava2_extension", "unit": "ScriptLib/NativeChannelScript", "finding": "AVA2 MoveChannelDialog uses native server warp; map ownership/ports announced by trusted P2P peers. No original CWindow lifecycle algorithm or classic Warp packet changed.", "evidence": ["docs/AVA2-NATIVE-CHANNEL.md", "docs/AVA2-SWITCHBOT.md", "tests/wiki/test_native_channel.py"], "result": "macOS/sbtest CH5-CH6-CH5 active switchbot handover, locked attribute/targets, endpoint retention and disconnected target verified; Android offline build only; no global parity status upgrade."} diff --git a/docs/AVA2-NATIVE-CHANNEL.md b/docs/AVA2-NATIVE-CHANNEL.md new file mode 100644 index 00000000..a3734a40 --- /dev/null +++ b/docs/AVA2-NATIVE-CHANNEL.md @@ -0,0 +1,20 @@ +# AVA2 原生换线 + +客户端采用 AVA2 `root/uisystem.py::MoveChannelDialog` 和 `UIScript/MoveChannelDialog.py`。复用小地图原换线入口;收到服务端 `ChannelList` 后使用原生窗口,点击切换发送 `/move_channel N`。频道号按服务端列表绑定,支持不连续的测试频道5、6。资源由 `make_items.py` 放入 ava2items,包含原选择按钮及其 sub 引用纹理。 + +服务端按 AVA2 实际启用的 `do_cmd(SCMD_CHANGE_CHANNEL)` 执行3秒倒计时,重复命令取消。倒计时结束再次校验状态,然后 `MoveChannel` 使用现有 `WarpSet` 的保存、移除实体和 P2P 洗练状态转移。不会退出登录或清除洗练目标。服务端拒绝死亡、眩晕、交易/商店/强化等忙碌状态、运行中的任务、受限制地图、私人副本,以及未通告目标地图的频道。 + +原 AVA2 按100递增端口,不能直接用于203。适配通过同一DB集群的 P2P 核心通告真实游戏端口和 MAP_ALLOW,校验已连接对端的频道/P2P端口身份;5秒心跳、30秒过期,断开立即删除,同频道同地图出现重复归属时拒绝。没有修改经典 GC Warp 封包。 + +进入核心时服务端主动发送列表,覆盖首次登录和同地图换线。`UpdateServerInfo` 沿用原版命令更新当前频道和文字;扩展 `ChannelEndpoint` 保存目标游戏地址并保留原auth地址,避免换线后退出重登又回到之前频道。私人地图只列本频道;99频道保留只读窗口。没有原生列表的旧服务端继续用现有退出重登入口,该路径会停止洗练,不能视为原生续洗。 + +## 验证 + +- macOS/sbtest:CH5:13040→CH6:13050→CH5,洗练active保持1,两个备选目标与第4条锁定值不变,71084为1034→976→919;停止后退回物品并解锁。 +- 同频道、未开放频道、重复命令取消、任务选择中的拒绝均已验证;换到6后退出重登仍在6,auth仍11040;关闭6后列表只剩5且拒绝旧目标。 +- 客户端回归119项通过:`python3 -m unittest discover -s tests/wiki`,包括地址校验、auth保留、不连续频道、窗口替换、非法列表、99频道和原生按钮命令。 +- 服务端路由:`python3 tests/features/test_ava2_channel_registry.py`,覆盖对端身份、地图归属、过期、断开、歧义和原子拒绝非法快照。 +- macOS和Android原生编译;Android只离线编译,用户暂停手机验收。 +- 截图和联机测试记录在本机 `build/parity-acceptance-20261018`,不会打入客户端包。 + +正式服部署与验收仍需单独完成。 diff --git a/docs/AVA2-PARITY-PLAN.md b/docs/AVA2-PARITY-PLAN.md index 16a52dda..4b4bca2b 100644 --- a/docs/AVA2-PARITY-PLAN.md +++ b/docs/AVA2-PARITY-PLAN.md @@ -21,10 +21,12 @@ 仍未完成的边界:基础单堆仍为 200(请求上限 1000),稀有度物品系统未移植,物理快捷键和 Android 真机尚未验收,正式服未部署。下方旧实现描述保留作为迁移前基线,不能据此忽略本段状态,也不能把两项计为全量 AVA2 对齐完成。uitrack 已进入下述联机验收,战令、百科、宠物等仍待推进。 -原生 uitrack 双页窗口、五个世界首领刷新、地图 357 和原生门票兑换商店已接入 sbtest;已验证真实刷新/传送/实体、八项价格与实际道具兑换。旧副本增加真实冷却字段兼容,但八个副本的任务和入场条件尚未全部替换为 AVA2。提醒持久化冷启动已通过,Android 验收继续进行,详见 [AVA2-TRACK.md](AVA2-TRACK.md)。 +原生 uitrack 双页窗口、五个世界首领刷新、地图 357 和原生门票兑换商店已接入 sbtest;已验证真实刷新/传送/实体、八项价格与实际道具兑换。旧副本增加真实冷却字段兼容,但八个副本的任务和入场条件尚未全部替换为 AVA2。提醒持久化冷启动已通过,Android 真机验收按用户要求暂停,详见 [AVA2-TRACK.md](AVA2-TRACK.md)。 属性锁定已在 sbtest 验证:选第4条、实际消耗、洗练保留锁定值、重复操作拒绝、全测试集群冷重启后读回,以及取消和解锁。实现与边界见 [属性锁定说明](../tools/server/ava2-attr-lock/README.md)。进程内脚本重连的测试命令已移到帧间执行,另修复重新打开登录界面时丢失目标端点,同一进程三次重登通过;其他玩家/交易/商店锁定提示和物理触控仍未闭合。 +原生换线已接入 sbtest:AVA2 MoveChannelDialog、3秒倒计时和服务端传送,按真实端口/地图归属选核心。macOS验证CH5→CH6→CH5续洗、目标与锁定值保留、实际耗材、重登保留频道和离线目标拒绝;正式服尚未部署,Android仅离线编译。见 [原生换线](AVA2-NATIVE-CHANNEL.md)。 + ## 1. 对齐的含义 对每个系统都使用 AVA2 自己的实现,参考源码如下: @@ -70,7 +72,7 @@ AVA2 功能包头号在当前服务端基本空闲,可以直接沿用: | 副本信息 | `uiDungeonInfo` + `uiDungeonTimer`、CG 213 / GC 217、`dungeon_info`,含排名和传送 | 已有冰雪、船防、赤龙等副本和计时;原生信息页未完整移植 | 原生窗口、排名、完整协议与副本覆盖 | | 活动日历 | `uiEventCalendarNew` + CG 220 / GC 214、216,`char_event_calendar` | 只支持月光宝箱和圣诞袜两种活动 | 活动类型、窗口、GM 管理包 | | 显示开关 | 包括摆摊、宠物、坐骑的显示范围 | 没有这三项 | 补齐 | -| 换线 | 服务端把角色传送到目标频道(GC 121) | 客户端走 `/logout` 再重新登录 | AVA2 服务端源码在本机,可以移植服务端换线 | +| 换线 | 服务端 MoveChannel 以 GC Warp 传送到目标频道 | sbtest已使用原生窗口和服务端传送,旧服仍回退退出重登 | macOS原生跨频道续洗及重登已通过;正式服部署和Android真机待做 | | 模型预览 | `uiRenderTarget` | 已按 AVA2 实现(Vulkan) | 基本已对齐 | ### 2.3 `feature/ava2-unlock` P1–P8 @@ -105,7 +107,7 @@ AVA2 功能包头号在当前服务端基本空闲,可以直接沿用: 改动玩家正在用的系统,旧版和新版需要同时切换,并有回滚方案。 -1. 自动洗练(原生实现已部署,纯释放速度自然完成已通过;跨核心换地图续洗已通过;仍待原生跨频道换线和 Android 真机验收)+ 属性锁定(sbtest 已补选择流程和自有装备提示;其他容器/玩家提示待做):SWITCHBOT 窗口类型、CG/GC 171、`new_switchbot` 和 `PythonSwitchbot`、`uiswitchbot`;锁定改成拖 50348/50349 并在物品提示里显示,存储继续用独立表。 +1. 自动洗练(原生实现已部署,纯释放速度自然完成已通过;跨核心换地图及sbtest原生跨频道续洗已通过;正式服换线部署和 Android 真机验收待做)+ 属性锁定(sbtest 已补选择流程和自有装备提示;其他容器/玩家提示待做):SWITCHBOT 窗口类型、CG/GC 171、`new_switchbot` 和 `PythonSwitchbot`、`uiswitchbot`;锁定改成拖 50348/50349 并在物品提示里显示,存储继续用独立表。 2. 批量开箱:`/chest_drop`、滑块、Ctrl + Z、`AutoGiveItemChest`。 3. 批量拾取:CG 235、70002 自动拾取。 4. 世界 Boss / 副本追踪:uitrack。 diff --git a/docs/AVA2-SWITCHBOT.md b/docs/AVA2-SWITCHBOT.md index d9e8b45b..985b0dbb 100644 --- a/docs/AVA2-SWITCHBOT.md +++ b/docs/AVA2-SWITCHBOT.md @@ -94,4 +94,14 @@ Android APK 已构建并保留数据安装,用户于本轮明确选择“暂 开始配置为释放速度20、暴击10、穿透10、动物系20、不死系20,填入两个实际备选;武器第4条 (4,6) 已锁定。两个目标核心进入后 active 均为1,目标表一致,锁定值始终不变;71084总数2069→1811→1595,确认是持续真实洗练。最后主动停止、武器退回159格并解锁,测试集群重启后恢复原 MAP_ALLOW,临时核心关闭,QA位置恢复主城。证据:crosscore-{before,outbound,return,summary,cleanup}.json,以及远端 crosscore/primary-syslog、aux-syslog。 -这验证的是跨核心换地图。当前换线窗口仍使用退出重登,会按原注销路径停止洗练;不能把该证据计为“跨频道换线续洗”通过。AVA2 的实际 `ENABLE_CHANNEL_CHANGE` 实现在现已提取的 cmd_general.cpp/do_cmd、char.cpp/MoveChannel 和 uisystem.py/ChangeChannelWindow,后续需移植服务端换线及原生窗口。 +这验证的是跨核心换地图。该次测试时换线窗口仍使用退出重登,因此其证据只证明跨核心换地图;后续原生换线验收见下节。 + +## 2026-10-18 原生跨频道续洗 + +已按 AVA2 启用的 do_cmd→MoveChannel 和 MoveChannelDialog 接入,203端口布局通过P2P实际地图归属适配。sbtest仅临时加载地图1:频道5端口13040、频道6端口13050;详见 [原生换线](AVA2-NATIVE-CHANNEL.md)。 + +最终无需人工补发频道查询的自动验收完成5→6→5:active全程为1,两套目标表一致,锁定第4条 (4,6) 不变,71084总数1034→976→919。此轮特意使用持续不命中的目标检查交接,在往返完成后主动停止;不能将其称为自然完成测试。已退回武器到159格并解锁,数据库锁记录为0。 + +同频道、未开放频道、重复命令取消倒计时、真实任务选择窗口中的换线拒绝均通过。另一次5→6后正常退出重登仍在6,auth保持11040,再回5;关闭辅助核心后列表只剩5,旧目标6请求被拒绝。上述结果仅为macOS/sbtest;用户暂停Android真机验收,正式服未部署本轮换线改动。 + +证据:本机 build/parity-acceptance-20261018/native-channel-{before,outbound,return,cleanup,reconnect,unavailable}.json、native-channel-proof-final.log、native-channel-reconnect.log、native-channel-live-unavailable.png。首轮联机曾发现频道元数据不刷新,最终验收使用服务端EnterGame主动下发列表和原版UpdateServerInfo更新后的版本。 diff --git a/src/platform/ScriptLib/Ava2UICompatScript.inc b/src/platform/ScriptLib/Ava2UICompatScript.inc index 7f7a1a45..565a0de4 100644 --- a/src/platform/ScriptLib/Ava2UICompatScript.inc +++ b/src/platform/ScriptLib/Ava2UICompatScript.inc @@ -341,6 +341,11 @@ def LoadChildren(self, parent, dicChildren): parent.Children[Index].SetParent(parent) self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent) + elif Type == "thinboard_circle": + parent.Children[Index] = ThinBoardCircle() + parent.Children[Index].SetParent(parent) + self.LoadElementThinBoard(parent.Children[Index], ElementValue, parent) + elif Type == "box": parent.Children[Index] = Box() parent.Children[Index].SetParent(parent) diff --git a/src/platform/ScriptLib/NativeChannelScript.inc b/src/platform/ScriptLib/NativeChannelScript.inc new file mode 100644 index 00000000..c81b6cc7 --- /dev/null +++ b/src/platform/ScriptLib/NativeChannelScript.inc @@ -0,0 +1,213 @@ +// AVA2 uisystem.MoveChannelDialog; native server warp replaces logout/relogin switching. +static const char c_szNativeChannelScript[] = R"PY(# -*- coding: utf-8 -*- +import app,background,chat,game,localeInfo,mt_channel,mt_live_endpoint,net,serverInfo,ui +L=__import__('player').AutoHuntLocalize +for key,text in {'MOVE_CHANNEL_TITLE':'切换频道','MOVE_CHANNEL_SELECT':'切换','MOVE_CHANNEL_CANCEL':'取消'}.items():setattr(localeInfo,key,L(text)) +_channels=[] +_current=0 +_window=None +class MoveChannelDialog(ui.ScriptWindow): + def __init__(self): + ui.ScriptWindow.__init__(self) + self.Destroy() + self.__LoadDialog() + + def __del__(self): + ui.ScriptWindow.__del__(self) + + def Destroy(self): + self.ClearDictionary() + self.ParentBoard = 0 + self.ChildBoard = 0 + self.ChannelList = 0 + self.DlgWidht = 0 + self.channel = 0 + self.BlackBoardHeight = 0 + self.DlgHeight = 0 + self.AcceptBtn = 0 + self.CloseBtn = 0 + self.ChangeChannelNumber = 0 + + def __LoadDialog(self): + try: + pyScrLoader = ui.PythonScriptLoader() + pyScrLoader.LoadScriptFile(self, "UIScript/MoveChannelDialog.py") + except: + import exception + exception.Abort("MoveChannelDialog.__LoadDialog") + + self.ParentBoard = self.GetChild("MoveChannelBoard") + self.ChildBoard = self.GetChild("BlackBoard") + self.GetChild("MoveChannelTitle").SetCloseEvent(ui.__mem_func__(self.Close)) + + self.ChannelList = [] + cnt = len(_channels) + + self.DlgWidht = 190 + self.BlackBoardHeight = 23*cnt + 5*(cnt-1) + 13 + self.DlgHeight = self.BlackBoardHeight + 75 + + self.AcceptBtn = ui.MakeButton(self.ParentBoard, 13, self.DlgHeight - 33, "", "d:/ymir work/ui/public/", "middle_button_01.sub", "middle_button_02.sub", "middle_button_03.sub") + self.AcceptBtn.SetText( localeInfo.MOVE_CHANNEL_SELECT ) + self.AcceptBtn.SetEvent(ui.__mem_func__(self.AcceptButton)) + self.CloseBtn = ui.MakeButton(self.ParentBoard, self.DlgWidht - 73, self.DlgHeight - 33, "", "d:/ymir work/ui/public/", "middle_button_01.sub", "middle_button_02.sub", "middle_button_03.sub") + self.CloseBtn.SetText( localeInfo.MOVE_CHANNEL_CANCEL ) + self.CloseBtn.SetEvent(ui.__mem_func__(self.Close)) + + for i in xrange(cnt): + btn = ui.MakeButton(self.ChildBoard, 8, 6 + i*28, "", "d:/ymir work/ui/game/myshop_deco/", "select_btn_01.sub", "select_btn_02.sub", "select_btn_03.sub") + btn.SetText("CH %d"%(_channels[i])) + btn.SetEvent(ui.__mem_func__(self.__SelectChannel), _channels[i]) + self.ChannelList.append(btn) + + self.ParentBoard.SetSize(self.DlgWidht, self.DlgHeight) + self.ChildBoard.SetSize(self.DlgWidht - 26, self.BlackBoardHeight) + self.SetSize(self.DlgWidht, self.DlgHeight) + + self.UpdateRect() + + def __SelectChannel(self, idx): + self.ChangeChannelNumber = idx + if idx not in _channels:return + + if self.ChangeChannelNumber >= 8: + return + for btn in self.ChannelList: + btn.SetUp() + btn.Enable() + + self.ChannelList[_channels.index(idx)].Down() + self.ChannelList[_channels.index(idx)].Disable() + + def AcceptButton(self): + #if self.CheckIsBlockMap(): # already have in gamesrc. + # return + + if self.ChangeChannelNumber == self.StartChannelNumber: + return + + net.SendChatPacket("/move_channel %d" % self.ChangeChannelNumber) + self.__SaveChannelInfo() + self.StartChannelNumber = self.ChangeChannelNumber + self.Close() + + def Show(self): + ui.ScriptWindow.Show(self) + + self.StartChannelNumber = self.GetChannelNumber() + self.__SelectChannel(self.StartChannelNumber) + + def Close(self): + self.Hide() + + def OnPressEscapeKey(self): + self.Close() + return True + + def GetChannelNumber(self): + return _current + + def CheckIsBlockMap(self): + blockmapList = ["metin2_map_a1", "metin2_map_deviltower1", "metin2_map_b1","metin2_map_c1","metin2_map_wedding_01","metin2_map_oxevent","metin2_map_t3","metin2_map_t4","metin2_map_sungzi","metin2_map_sungzi_flame_hill_01","metin2_map_sungzi_flame_hill_02","metin2_map_sungzi_flame_hill_03","metin2_map_sungzi_snow","metin2_map_sungzi_snow_pass01","metin2_map_sungzi_snow_pass02","metin2_map_sungzi_snow_pass03","metin2_map_sungzi_desert_01","metin2_map_sungzi_desert_hill_01","metin2_map_sungzi_desert_hill_02","metin2_map_sungzi_desert_hill_03","metin2_map_empirewar01","metin2_map_empirewar02","metin2_map_empirewar03","metin2_map_guild_02","metin2_map_guild_03","metin2_map_kingdoomswar","metin2_map_duel"] + if background.GetCurrentMapName() in blockmapList: + #chat.AppendChat(1, localeInfo.CHANNEL_CHANGE_BLOCK) + return True + return False + + def IsShowWindow(self): + return self.IsShow() + + def __SaveChannelInfo(self): + if not any(self.ChangeChannelNumber in server.get("channel",{}) for region in serverInfo.REGION_DICT.values() for server in region.values()):return + loadRegionID, loadServerID, loadChannelID = self.__LoadChannelInfo() + try: + file = open("channel.inf", "w+") + file.write("%d %d %d" % (loadServerID, self.ChangeChannelNumber, loadRegionID)) + file.close() + except: + return + + def __LoadChannelInfo(self): + try: + file = open("channel.inf") + lines = file.readlines() + file.close() + if len(lines) > 0: + tokens = lines[0].split() + selServerID = int(tokens[0]) + selChannelID = int(tokens[1]) + if len(tokens) == 3: + regionID = int(tokens[2]) + return regionID, selServerID, selChannelID + except: + return -1, -1, -1 + +def RequestOpen(self): + self.Show() + net.SendChatPacket('/channel_list') +MoveChannelDialog.Open=RequestOpen +MoveChannelDialog.Refresh=lambda self:None +_oldOpen=game.GameWindow.Open +_oldClose=game.GameWindow.Close +_oldCommand=game.GameWindow.BINARY_ServerCommand_Run + +def Open(self): + result=_oldOpen(self) + net.SendChatPacket('/channel_list') + return result + +def Close(self): + global _window,_channels,_current + if _window:_window.Hide() + _window=None;_channels=[];_current=0 + return _oldClose(self) + +def Command(self,line): + global _window,_channels,_current + words=line.split() + if words and words[0]=='ChannelList': + if len(words)!=3:return 1 + try: + current=int(words[1]);channels=[int(v) for v in words[2].split(',')] + if (not 1<=current<=7 or any(not 1<=v<=7 for v in channels)) and not (current==99 and channels==[99]):return 1 + if len(channels)>7 or current not in channels:return 1 + except (ValueError,OverflowError):return 1 + _current=current;channels=sorted(set(channels)) + if _window and _channels==channels: + _window.channel=current + if _window.IsShow():_window.Show() + return 1 + shown=bool(mt_channel.g_window and mt_channel.g_window.IsShow()) + if mt_channel.g_window: + mt_channel.g_window.Hide();mt_channel.g_window.Destroy() + _channels=channels;_window=MoveChannelDialog();_window.channel=current + mt_channel.g_window=_window + if shown:_window.Show() + return 1 + if words and words[0]=='UpdateServerInfo': + if len(words)==2: + try: + channel=int(words[1]) + if 1<=channel<=7: + _current=channel + if _window:_window.channel=channel + net.SetServerInfo('Metin2, CH %d'%channel) + except (ValueError,OverflowError):pass + return 1 + if words and words[0]=='ChannelEndpoint': + if len(words)!=4:return 1 + try: + channel=int(words[1]);port=int(words[3]);octets=words[2].split('.') + if not 1<=channel<=7 or not 1<=port<=65535 or len(octets)!=4 or any(not v.isdigit() or not 0<=int(v)<=255 for v in octets):return 1 + mt_live_endpoint.Configure(self.stream,words[2],port,self.stream.account_addr,self.stream.account_port) + except (ValueError,OverflowError):pass + return 1 + if words and words[0]=='ChannelError': + chat.AppendChat(chat.CHAT_TYPE_INFO,L('当前位置或状态不能换线,或目标频道尚未开放。')) + return 1 + return _oldCommand(self,line) + +game.GameWindow.Open=Open +game.GameWindow.Close=Close +game.GameWindow.BINARY_ServerCommand_Run=Command +)PY"; diff --git a/src/platform/ScriptLib/PythonBoot.cpp b/src/platform/ScriptLib/PythonBoot.cpp index bcc5cbdb..c8dbabbd 100644 --- a/src/platform/ScriptLib/PythonBoot.cpp +++ b/src/platform/ScriptLib/PythonBoot.cpp @@ -1043,6 +1043,7 @@ namespace PythonBoot #include "ItemActionsScript.inc" #include "AttrLockScript.inc" #include "LiveEndpointScript.inc" +#include "NativeChannelScript.inc" #include "MinimapOuterRingScript.inc" #ifdef MT_HAS_MESHPORT #include "MeshPortScript.inc" @@ -1148,6 +1149,7 @@ bool RunMainScript(const char* lpCmdLine, std::string* error) install_script_module("mt_item_actions", c_szItemActionsScript); install_script_module("mt_attr_lock", c_szAttrLockScript); install_script_module("mt_live_endpoint", c_szLiveEndpointScript); + install_script_module("mt_native_channel", c_szNativeChannelScript); install_script_module("mt_minimap_buttons", c_szMinimapOuterRingScript); if (g_touch_input) install_script_module("mt_mobile_hud", c_szMobileHUDScript); diff --git a/tests/wiki/test_native_channel.py b/tests/wiki/test_native_channel.py new file mode 100644 index 00000000..7d048d5e --- /dev/null +++ b/tests/wiki/test_native_channel.py @@ -0,0 +1,68 @@ +"""Native channel commands validate the wire input and retain the auth endpoint.""" +import sys, types, unittest +from pathlib import Path + +class NativeChannelTest(unittest.TestCase): + def setUp(self): + names=('app','background','chat','game','localeInfo','mt_channel','mt_live_endpoint','net','serverInfo','ui','player') + self.previous={n:sys.modules.get(n) for n in names} + self.mods={n:types.ModuleType(n) for n in names} + sys.modules.update(self.mods);m=self.mods + m['ui'].ScriptWindow=type('ScriptWindow',(),{'__del__':lambda s:None}) + m['player'].AutoHuntLocalize=lambda s:s + m['game'].GameWindow=type('GameWindow',(),{'Open':lambda s:None,'Close':lambda s:None,'BINARY_ServerCommand_Run':lambda s,line:('old',line)}) + self.endpoint=[];self.messages=[];self.sent=[] + m['mt_live_endpoint'].Configure=lambda *args:self.endpoint.append(args) + m['chat'].CHAT_TYPE_INFO=1;m['chat'].AppendChat=lambda *a:self.messages.append(a) + m['net'].SendChatPacket=self.sent.append;m['net'].SetServerInfo=lambda s:None + m['mt_channel'].g_window=None + self.ns={};source=(Path(__file__).resolve().parents[2]/'src/platform/ScriptLib/NativeChannelScript.inc').read_text().split('R"PY(',1)[1].rsplit(')PY";',1)[0];exec(source,self.ns) + self.game=m['game'].GameWindow();self.game.stream=types.SimpleNamespace(account_addr='192.0.2.1',account_port=11040) + class Window: + def __init__(s):s.visible=False;s.destroyed=False + def IsShow(s):return s.visible + def Show(s):s.visible=True + def Hide(s):s.visible=False + def Destroy(s):s.destroyed=True + self.Window=Window;self.ns['MoveChannelDialog']=Window + def tearDown(self): + for n,old in self.previous.items(): + if old is None:sys.modules.pop(n,None) + else:sys.modules[n]=old + def command(self,line):return self.game.BINARY_ServerCommand_Run(line) + def test_endpoint_validation_and_auth_preservation(self): + for line in ('ChannelEndpoint 8 192.0.2.2 13050','ChannelEndpoint 6 hostname 13050','ChannelEndpoint 6 256.0.0.1 13050','ChannelEndpoint 6 192.0.2.2 0','ChannelEndpoint 6 192.0.2.2 65536','ChannelEndpoint 6 192.0.2.2 13050 trailing'): + self.command(line) + self.assertEqual(self.endpoint,[]) + self.command('ChannelEndpoint 6 192.0.2.2 13050') + self.assertEqual(self.endpoint,[(self.game.stream,'192.0.2.2',13050,'192.0.2.1',11040)]) + def test_roster_handles_noncontiguous_channels_and_replacement(self): + old=self.Window();old.Show();self.mods['mt_channel'].g_window=old + self.command('ChannelList 5 6,5,6');self.assertEqual(self.ns['_channels'],[5,6]) + window=self.ns['_window'];self.assertTrue(window.IsShow());self.assertTrue(old.destroyed);self.assertFalse(old.IsShow()) + self.command('ChannelList 6 5,6');self.assertIs(self.ns['_window'],window);self.assertEqual(window.channel,6) + for line in ('ChannelList 5 0','ChannelList 5 1,8','ChannelList invalid 5,6','ChannelList 5 5,6 extra','ChannelList 5 6'): + self.command(line);self.assertIs(self.ns['_window'],window) + def test_private_event_channel_keeps_native_readonly_dialog(self): + self.command('ChannelList 99 99');self.assertEqual(self.ns['_channels'],[99]) + self.assertEqual(self.ns['_current'],99) + def test_original_server_info_updates_current_channel(self): + self.command('ChannelList 5 5,6');self.command('UpdateServerInfo 6') + self.assertEqual(self.ns['_current'],6);self.assertEqual(self.ns['_window'].channel,6) + def test_close_hides_native_window_and_clears_roster(self): + self.command('ChannelList 5 5,6');window=self.ns['_window'];window.Show() + self.game.Close();self.assertFalse(window.IsShow());self.assertIsNone(self.ns['_window']) + self.assertEqual(self.ns['_channels'],[]);self.assertEqual(self.ns['_current'],0) + def test_native_accept_uses_warp_command(self): + source=(Path(__file__).resolve().parents[2]/'src/platform/ScriptLib/NativeChannelScript.inc').read_text().split('R"PY(',1)[1].rsplit(')PY";',1)[0] + namespace={};exec(source,namespace) + window=namespace['MoveChannelDialog'].__new__(namespace['MoveChannelDialog']);window.ChangeChannelNumber=6;window.StartChannelNumber=5 + saved=[];window._MoveChannelDialog__SaveChannelInfo=lambda:saved.append(True);window.Close=lambda:None + window.AcceptButton();self.assertEqual(self.sent,['/move_channel 6']);self.assertTrue(saved) + window.AcceptButton();self.assertEqual(len(self.sent),1) + def test_other_commands_delegate_and_open_requests_list(self): + self.game.Open();self.assertEqual(self.sent,['/channel_list']) + self.assertEqual(self.command('unrelated message'),('old','unrelated message')) + self.command('ChannelError unavailable');self.assertEqual(len(self.messages),1) + +if __name__=='__main__':unittest.main() diff --git a/tools/server/ava2-items/make_items.py b/tools/server/ava2-items/make_items.py index b0183ce6..de20a2c9 100644 --- a/tools/server/ava2-items/make_items.py +++ b/tools/server/ava2-items/make_items.py @@ -303,6 +303,12 @@ def prepare(ava,proto_reader,locale,output,tool,packer,wrap=lambda text:text): if q.startswith('d:/ymir work/ui/game/track/'): target=assets/q;target.parent.mkdir(parents=True,exist_ok=True) if not target.exists():shutil.copy2(files[q],target);copied+=1 + # AVA2 native channel dialog and its three selection-button states. + (assets/'uiscript/movechanneldialog.py').write_bytes((pack_maker/'uiscript/uiscript/movechanneldialog.py').read_bytes()) + for q in files: + if q.startswith('d:/ymir work/ui/game/myshop_deco/select_btn_'): + target=assets/q;target.parent.mkdir(parents=True,exist_ok=True) + if not target.exists():shutil.copy2(files[q],target);copied+=1 pack_ui_subimages(assets,files) (output/'items-server.tsv').write_bytes(b'\n'.join(server)+b'\n') (output/'items-client.tsv').write_bytes(b'\n'.join(client)+b'\n')