Files
AzerothCore-RealmMaster/scripts/hooks/fix-statbooster-api
2025-11-02 21:03:05 -05:00

46 lines
1.3 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Post-install hook to fix StatBooster API compatibility
set -e
MODULE_DIR="${MODULE_DIR:-}"
MODULE_NAME="${MODULE_NAME:-}"
if [ -z "$MODULE_DIR" ] || [ ! -d "$MODULE_DIR" ]; then
echo "❌ fix-statbooster-api: Invalid module directory: $MODULE_DIR"
exit 2
fi
echo "🔧 fix-statbooster-api: Patching API compatibility for $MODULE_NAME"
HEADER_FILE="$MODULE_DIR/src/StatBoost.h"
CPP_FILE="$MODULE_DIR/src/StatBoost.cpp"
if [ ! -f "$HEADER_FILE" ]; then
echo " Header file not found, skipping: $HEADER_FILE"
exit 0
fi
# Check if already patched
if grep -q "OnPlayerLogin" "$HEADER_FILE" 2>/dev/null; then
echo " ✅ Module already patched"
exit 0
fi
# Apply API compatibility patches
echo " 📝 Patching OnLogin -> OnPlayerLogin"
# Patch header file
if [ -f "$HEADER_FILE" ]; then
sed -i 's/void OnLogin(Player\* player) override;/void OnPlayerLogin(Player* player) override;/g' "$HEADER_FILE" && \
echo " ✅ Patched $HEADER_FILE"
fi
# Patch cpp file
if [ -f "$CPP_FILE" ]; then
sed -i 's/void StatBoosterPlayer::OnLogin(Player\* player)/void StatBoosterPlayer::OnPlayerLogin(Player* player)/g' "$CPP_FILE" && \
echo " ✅ Patched $CPP_FILE"
fi
echo " ✅ API compatibility patches applied"
exit 0