Files
metin2-client/tools/server/vip-card/install.sh
T
shenleiandClaude Opus 5.5 32372c2a73 vip-card: back up the proto rows as REPLACE statements only
A plain mysqldump --where also writes DROP/CREATE TABLE, so restoring the
backup would have emptied item_proto down to the two cards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 03:40:50 +09:00

37 lines
2.0 KiB
Bash

#!/bin/sh
# Installs the VIP cards (README.md): run on the server from this directory with a game built from
# metin2-server feature/vip-card (port_premium.h), then restart db + game. 40250 ships 38001/38002 as unused
# ITEM_NONE rows of size 0, which the inventory cannot hold (two of them share a cell, neither can move): this
# gives them one cell, stacking, an item log and no NPC sale, and names them on the server (item_names.txt and
# item_proto.locale_name; the client has its own names and the same size/flags, data/zh_40250).
set -eu
SERVER=${SERVER:-/usr/metin2/server}
PROTO="$SERVER/share/conf/item_proto.txt"
NAMES="$SERVER/share/conf/item_names.txt"
BACKUP=/root/backup-vip-card/$(date +%Y%m%d-%H%M%S)
export LC_ALL=C
mkdir -p "$BACKUP"
cp -p "$PROTO" "$NAMES" "$BACKUP/"
mysqldump -uroot --no-create-info --replace player item_proto --where="vnum in (38001,38002)" > "$BACKUP/item_proto-rows.sql"
echo "backup: $BACKUP"
# item_proto.txt: column 5 size, 6 anti flags, 7 flags.
awk -F'\t' -v OFS='\t' '$1 == 38001 || $1 == 38002 { $5 = 1; $6 = "ANTI_SELL"; $7 = "ITEM_STACKABLE | LOG"; n++ } { print }
END { if (n != 2) { print "item_proto.txt: " n " of 2 cards found" > "/dev/stderr"; exit 1 } }' \
"$PROTO" > "$BACKUP/item_proto.new"
cat "$BACKUP/item_proto.new" > "$PROTO"
week=$(printf 'VIP会员卡(7天)' | iconv -f UTF-8 -t GB2312)
month=$(printf 'VIP会员卡(30天)' | iconv -f UTF-8 -t GB2312)
awk -F'\t' -v OFS='\t' -v week="$week" -v month="$month" '$1 == 38001 { $2 = week; n++ } $1 == 38002 { $2 = month; n++ } { print }
END { if (n != 2) { print "item_names.txt: " n " of 2 cards found" > "/dev/stderr"; exit 1 } }' \
"$NAMES" > "$BACKUP/item_names.new"
cat "$BACKUP/item_names.new" > "$NAMES"
# ITEM_STACKABLE | ITEM_LOG = 4 | 8192, ITEM_ANTIFLAG_SELL = 256.
mysql -uroot player -e "UPDATE item_proto SET size = 1, flag = 8196, antiflag = 256, locale_name = '$week' WHERE vnum = 38001;
UPDATE item_proto SET size = 1, flag = 8196, antiflag = 256, locale_name = '$month' WHERE vnum = 38002"
echo "done; restart db and game"