фикс muthic+ и магазина

This commit is contained in:
2026-03-09 21:26:55 +04:00
parent 65ec263dd0
commit da97c45702
2 changed files with 142 additions and 32 deletions
+5
View File
@@ -125,6 +125,11 @@ ACORE_PLAYERBOTS_FORCE=0
# Скрипт импортирует только отсутствующие таблицы и world-объекты, не перезатирая уже созданные данные. # Скрипт импортирует только отсутствующие таблицы и world-объекты, не перезатирая уже созданные данные.
ACORE_IMPORT_MYTHICPLUS_SQL=1 ACORE_IMPORT_MYTHICPLUS_SQL=1
# 1 = импортировать SQL для lua_scripts/Store_System в отдельную базу `store`.
# Скрипт создаст схему `store`, недостающие таблицы и стартовые записи магазина.
# Демонстрационные старые логи покупок из исходного дампа не импортируются.
ACORE_IMPORT_STORE_SQL=1
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# worldserver.conf: управляемые override-настройки # worldserver.conf: управляемые override-настройки
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
+132 -27
View File
@@ -13,13 +13,14 @@ if [[ -f "$ENV_FILE" ]]; then
fi fi
IMPORT_MYTHICPLUS_SQL="${ACORE_IMPORT_MYTHICPLUS_SQL:-1}" IMPORT_MYTHICPLUS_SQL="${ACORE_IMPORT_MYTHICPLUS_SQL:-1}"
IMPORT_STORE_SQL="${ACORE_IMPORT_STORE_SQL:-1}"
usage() { usage() {
cat <<EOF cat <<EOF
Usage: $(basename "$0") Usage: $(basename "$0")
Imports required custom SQL that lives outside the normal AzerothCore module paths. Imports required custom SQL that lives outside the normal AzerothCore module paths.
Currently this bootstraps the MythicPlus Lua package. Currently this bootstraps the MythicPlus and Store Lua packages.
EOF EOF
} }
@@ -35,6 +36,19 @@ mysql_query() {
"mysql -N -s -uroot -p\"\$MYSQL_ROOT_PASSWORD\" \"$database\"" <<<"$sql" "mysql -N -s -uroot -p\"\$MYSQL_ROOT_PASSWORD\" \"$database\"" <<<"$sql"
} }
mysql_exec() {
local database="${1:-}"
local sql="$2"
if [[ -n "$database" ]]; then
docker compose exec -T ac-database bash -lc \
"mysql -uroot -p\"\$MYSQL_ROOT_PASSWORD\" \"$database\"" <<<"$sql"
else
docker compose exec -T ac-database bash -lc \
"mysql -uroot -p\"\$MYSQL_ROOT_PASSWORD\"" <<<"$sql"
fi
}
table_exists() { table_exists() {
local database="$1" local database="$1"
local table_name="$2" local table_name="$2"
@@ -46,6 +60,16 @@ table_exists() {
[[ "$result" == "1" ]] [[ "$result" == "1" ]]
} }
database_exists() {
local database="$1"
local result
result="$(mysql_query "information_schema" \
"SELECT COUNT(*) FROM schemata WHERE schema_name = '${database}';")"
[[ "$result" == "1" ]]
}
import_sql_file() { import_sql_file() {
local database="$1" local database="$1"
local file_path="$2" local file_path="$2"
@@ -83,37 +107,15 @@ maybe_import_table() {
import_sql_file "$database" "$file_path" import_sql_file "$database" "$file_path"
} }
if (($# > 0)); then import_mythicplus_sql() {
case "$1" in
-h|--help)
usage
exit 0
;;
*)
printf 'Unknown option: %s\n\n' "$1" >&2
usage >&2
exit 1
;;
esac
fi
require_integer_flag "ACORE_IMPORT_MYTHICPLUS_SQL" "$IMPORT_MYTHICPLUS_SQL"
cd "$ROOT_DIR"
if ! docker compose ps --status running --services | grep -qx 'ac-database'; then
printf 'ac-database is not running. Start the database first.\n' >&2
exit 1
fi
if [[ "$IMPORT_MYTHICPLUS_SQL" == "0" ]]; then if [[ "$IMPORT_MYTHICPLUS_SQL" == "0" ]]; then
log "MythicPlus SQL import disabled, skipped" log "MythicPlus SQL import disabled, skipped"
exit 0 return 0
fi fi
if [[ ! -d "$ROOT_DIR/sql/Mythic+" ]]; then if [[ ! -d "$ROOT_DIR/sql/Mythic+" ]]; then
log "sql/Mythic+ directory not found, skipped" log "sql/Mythic+ directory not found, skipped"
exit 0 return 0
fi fi
maybe_import_table "acore_characters" "character_mythic_history" \ maybe_import_table "acore_characters" "character_mythic_history" \
@@ -132,10 +134,113 @@ maybe_import_table "acore_world" "world_mythic_loot" \
maybe_import_table "acore_world" "world_vault_loot" \ maybe_import_table "acore_world" "world_vault_loot" \
"$ROOT_DIR/sql/Mythic+/world/world_vault_loot.sql" "$ROOT_DIR/sql/Mythic+/world/world_vault_loot.sql"
if [[ "$(mysql_query "acore_world" "SELECT COUNT(*) FROM creature_template WHERE entry = 900001;")" == "0" ]]; then if [[ "$(mysql_query "acore_world" "
SELECT
CASE
WHEN EXISTS (SELECT 1 FROM creature_template WHERE entry = 900001)
AND EXISTS (SELECT 1 FROM item_template WHERE entry = 900100)
AND EXISTS (SELECT 1 FROM gameobject_template WHERE entry = 900000)
AND EXISTS (SELECT 1 FROM creature WHERE id1 = 900001 OR id2 = 900001 OR id3 = 900001)
AND EXISTS (SELECT 1 FROM gameobject WHERE id = 900000)
THEN 1
ELSE 0
END;
")" == "0" ]]; then
log "repairing MythicPlus world bootstrap entries"
mysql_exec "acore_world" "
DELETE FROM creature WHERE id1 = 900001 OR id2 = 900001 OR id3 = 900001;
DELETE FROM gameobject WHERE id = 900000;
DELETE FROM creature_template_locale WHERE entry = 900001;
DELETE FROM item_template_locale WHERE ID = 900100;
DELETE FROM creature_template_model WHERE CreatureID = 900001;
DELETE FROM creature_template WHERE entry = 900001;
DELETE FROM item_template WHERE entry = 900100;
DELETE FROM gameobject_template WHERE entry = 900000;
"
import_sql_file "acore_world" "$ROOT_DIR/sql/Mythic+/world/creature_and_keystones.sql" import_sql_file "acore_world" "$ROOT_DIR/sql/Mythic+/world/creature_and_keystones.sql"
else else
log "MythicPlus creature bootstrap already exists, skipping" log "MythicPlus creature bootstrap already exists, skipping"
fi fi
}
import_store_sql() {
local store_sql_file="$ROOT_DIR/sql/Store.sql"
local temp_sql=""
if [[ "$IMPORT_STORE_SQL" == "0" ]]; then
log "Store SQL import disabled, skipped"
return 0
fi
if [[ ! -d "$ROOT_DIR/lua_scripts/Store_System" ]]; then
log "lua_scripts/Store_System directory not found, skipped"
return 0
fi
if [[ ! -f "$store_sql_file" ]]; then
log "sql/Store.sql not found, skipped"
return 0
fi
if ! database_exists "store"; then
log "creating database store"
mysql_exec "" "CREATE DATABASE IF NOT EXISTS \`store\` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
fi
temp_sql="$(mktemp)"
{
printf 'CREATE DATABASE IF NOT EXISTS `store` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;\n'
printf 'USE `store`;\n'
awk '
BEGIN { skip = 0 }
skip {
if ($0 ~ /;[[:space:]]*$/) {
skip = 0
}
next
}
$0 ~ /^INSERT INTO `store_logs` / {
skip = 1
next
}
{
sub(/^INSERT INTO /, "INSERT IGNORE INTO ")
print
}
' "$store_sql_file"
} > "$temp_sql"
log "bootstrapping store database"
mysql_exec "" "$(cat "$temp_sql")"
rm -f "$temp_sql"
}
if (($# > 0)); then
case "$1" in
-h|--help)
usage
exit 0
;;
*)
printf 'Unknown option: %s\n\n' "$1" >&2
usage >&2
exit 1
;;
esac
fi
require_integer_flag "ACORE_IMPORT_MYTHICPLUS_SQL" "$IMPORT_MYTHICPLUS_SQL"
require_integer_flag "ACORE_IMPORT_STORE_SQL" "$IMPORT_STORE_SQL"
cd "$ROOT_DIR"
if ! docker compose ps --status running --services | grep -qx 'ac-database'; then
printf 'ac-database is not running. Start the database first.\n' >&2
exit 1
fi
import_mythicplus_sql
import_store_sql
log "custom SQL bootstrap completed" log "custom SQL bootstrap completed"