#!/bin/sh # Installs quest support_skills_max (README.md): run on the server from this directory, then restart game. # Adds the quest (GBK) to the locale's quest directory and locale_list, pc.set_skill_level to quest_functions, # and recompiles all quests. set -eu SERVER=${SERVER:-/usr/metin2/server} LOCALE=${LOCALE:-newcibn} QUEST="$SERVER/share/locale/$LOCALE/quest" HERE=$(cd "$(dirname "$0")" && pwd) BACKUP=/root/backup-support-skills/$(date +%Y%m%d-%H%M%S) export LC_ALL=C mkdir -p "$BACKUP" cp -p "$QUEST/locale_list" "$QUEST/quest_functions" "$BACKUP/" echo "backup: $BACKUP" iconv -f UTF-8 -t GBK "$HERE/support_skills_max.quest" > "$BACKUP/support_skills_max.gbk" # A GBK trail byte 0x5C would be a backslash to qc. if grep -q '\\' "$BACKUP/support_skills_max.gbk"; then echo "backslash byte in GBK" >&2; exit 1; fi cat "$BACKUP/support_skills_max.gbk" > "$QUEST/support_skills_max.quest" # qc only accepts functions listed in quest_functions; game registers pc.set_skill_level (questlua_pc.cpp) # but the list does not have it. grep -qx pc.set_skill_level "$QUEST/quest_functions" || echo pc.set_skill_level >> "$QUEST/quest_functions" # make.py strips only the LF of a locale_list line (203's has no newline after the last line). sed -i '' '/^support_skills_max\.quest/d' "$QUEST/locale_list" [ -z "$(tail -c 1 "$QUEST/locale_list")" ] || echo >> "$QUEST/locale_list" echo support_skills_max.quest >> "$QUEST/locale_list" # make.py's shebang (/usr/local/bin/python) does not exist on 203. cd "$QUEST" && /usr/local/bin/python2.7 make.py > "$BACKUP/make.log" 2>&1 || { tail "$BACKUP/make.log" >&2; exit 1; } ls object/notarget/login 2>/dev/null | grep support_skills_max || ls -R object | grep support_skills_max echo "done; restart game"