Metin2 game client (P0–P11) + mobile asset pipeline
Networked client on the existing Godot 4.7 + libgr2 renderer:
- net: m2dev wire protocol (libsodium KX + XChaCha20), auth/select/game
phases, EntityStore world model, ~all GC/CG headers. char create/delete,
private shop / mall / cube, SHOP_GC_START_EX, guild, party (+ CG_PARTY_SET_STATE),
quests, dragon soul, refine, safebox, exchange.
- UI: in-game windows migrated 1:1 from the reference uiscript/root .py —
char status (/stat), inventory+equipment, select-item ([SELECT_ITEM] quest
token), system-option + game-option + ESC system menu, private-shop 39-grid,
party info board, shop tabs, atlas, minimap, quickbar, chat, …
- EterGrnLib polish: GR2 material blend/two-sided, LOD crossfade, motion-event
dispatch, contact shadow, ray-AABB picking, weapon grip pre-transform.
Portable asset IO (A1) — all extension/libgr2/formats/mtproto reads routed
through godot::FileAccess (res:// PCK works on iOS/Android); standalone-lib
*_path() kept for the non-Godot CTests. AssetResolver + PropertyRegistry
switched to a baked index (bake_asset_index.gd) instead of std::filesystem.
Mobile builds: build-{android,ios}.sh, export-android.sh, pack-assets.sh,
gen-debug-keystore.sh. Assets ship as a zip mounted at runtime by
project/asset_pack.gd (adb push now; HTTP download is a drop-in later).
ctest 10/10, 34 GDScript suites, macOS/iOS/Android all build.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013EJxkHiNKS4kybHS3XKyAJ
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
# ServerInfo (P10) —— 服务器列表 + 频道 → (host, port)。
|
||||
#
|
||||
# var si := ServerInfo.new()
|
||||
# si.load_file("res://serverlist.txt") # 可选;没有就用内置默认
|
||||
# for s in si.servers(): ...
|
||||
# var addr := si.address(server_index, channel) # {auth_host,auth_port,game_host,game_port}
|
||||
#
|
||||
# 文件格式(TSV,# 注释):
|
||||
# name auth_host auth_port game_host game_port channels(csv) [port_step] [mark_port]
|
||||
# 测试服 192.168.21.203 11000 192.168.21.203 11011 1,2,3 1 0
|
||||
#
|
||||
# 频道 N 的 game 端口 = game_port + (N-1)*port_step。
|
||||
# 联调服实测端口是 11011/11012/11013(step=1);不同服可在文件第 7 列覆盖。
|
||||
# 第 8 列 mark_port = 公会会徽服端口(0 = 不下载会徽)。
|
||||
class_name ServerInfo
|
||||
extends RefCounted
|
||||
|
||||
const DEFAULT_PORT_STEP := 1
|
||||
|
||||
var _servers: Array = []
|
||||
|
||||
func _init() -> void:
|
||||
# 内置默认:当前联调服(CServerStateChecker 实测频道口 11011/12/13)
|
||||
_servers = [{
|
||||
"name": "测试服",
|
||||
"auth_host": "192.168.21.203", "auth_port": 11000,
|
||||
"game_host": "192.168.21.203", "game_port": 11011,
|
||||
"channels": [1, 2, 3], "port_step": 1, "mark_port": 0,
|
||||
}]
|
||||
|
||||
func load_file(path: String) -> bool:
|
||||
if not FileAccess.file_exists(path):
|
||||
return false
|
||||
var f := FileAccess.open(path, FileAccess.READ)
|
||||
if f == null:
|
||||
return false
|
||||
var out: Array = []
|
||||
while not f.eof_reached():
|
||||
var line := f.get_line().strip_edges()
|
||||
if line == "" or line.begins_with("#"):
|
||||
continue
|
||||
var c := line.split("\t", false)
|
||||
if c.size() < 5:
|
||||
c = line.split(" ", false) # 容忍空格分隔
|
||||
if c.size() < 5:
|
||||
continue
|
||||
var chans: Array = []
|
||||
if c.size() >= 6:
|
||||
for t in String(c[5]).split(",", false):
|
||||
chans.append(int(t))
|
||||
if chans.is_empty():
|
||||
chans = [1]
|
||||
var step := DEFAULT_PORT_STEP
|
||||
if c.size() >= 7 and int(c[6]) > 0:
|
||||
step = int(c[6])
|
||||
var mark_port := 0
|
||||
if c.size() >= 8 and int(c[7]) > 0:
|
||||
mark_port = int(c[7])
|
||||
out.append({
|
||||
"name": String(c[0]),
|
||||
"auth_host": String(c[1]), "auth_port": int(c[2]),
|
||||
"game_host": String(c[3]), "game_port": int(c[4]),
|
||||
"channels": chans, "port_step": step, "mark_port": mark_port,
|
||||
})
|
||||
if out.is_empty():
|
||||
return false
|
||||
_servers = out
|
||||
return true
|
||||
|
||||
func servers() -> Array:
|
||||
return _servers
|
||||
|
||||
func count() -> int:
|
||||
return _servers.size()
|
||||
|
||||
func server(idx: int) -> Dictionary:
|
||||
return _servers[idx] if idx >= 0 and idx < _servers.size() else {}
|
||||
|
||||
# 返回 {auth_host, auth_port, game_host, game_port},game_port 已按频道偏移。
|
||||
func address(server_idx: int, channel: int = 1) -> Dictionary:
|
||||
var s := server(server_idx)
|
||||
if s.is_empty():
|
||||
return {}
|
||||
var ch: int = maxi(1, channel)
|
||||
var step: int = int(s.get("port_step", DEFAULT_PORT_STEP))
|
||||
return {
|
||||
"auth_host": s["auth_host"], "auth_port": s["auth_port"],
|
||||
"game_host": s["game_host"],
|
||||
"game_port": int(s["game_port"]) + (ch - 1) * step,
|
||||
"mark_host": s["game_host"], "mark_port": int(s.get("mark_port", 0)),
|
||||
}
|
||||
Reference in New Issue
Block a user