mirror of
https://github.com/uprightbass360/AzerothCore-RealmMaster.git
synced 2026-01-13 00:58:34 +00:00
fix: mod-ale compiler patch
This commit is contained in:
@@ -33,6 +33,8 @@ if [ -z "${APPLY_SENDTRAINERLIST_PATCH:-}" ]; then
|
||||
else
|
||||
APPLY_SENDTRAINERLIST_PATCH="${APPLY_SENDTRAINERLIST_PATCH}"
|
||||
fi
|
||||
# Override keyword patch: always apply (C++11 best practice)
|
||||
APPLY_OVERRIDE_PATCH="${APPLY_OVERRIDE_PATCH:-1}"
|
||||
|
||||
if [ -z "$MODULE_DIR" ] || [ ! -d "$MODULE_DIR" ]; then
|
||||
echo "❌ mod-ale-patches: Invalid module directory: $MODULE_DIR"
|
||||
@@ -68,6 +70,44 @@ apply_movepath_patch() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Apply override keyword patch
|
||||
apply_override_patch() {
|
||||
local found_files=()
|
||||
|
||||
# Search for .cpp and .h files that need override keyword
|
||||
while IFS= read -r -d '' file; do
|
||||
if grep -l 'void OnPlayerLogin(Player\* player)' "$file" >/dev/null 2>&1; then
|
||||
found_files+=("$file")
|
||||
fi
|
||||
done < <(find "$MODULE_DIR" -name "*.cpp" -o -name "*.h" -print0)
|
||||
|
||||
if [ ${#found_files[@]} -eq 0 ]; then
|
||||
echo " ✅ No files need override keyword fix"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local patch_count=0
|
||||
for file in "${found_files[@]}"; do
|
||||
# Check if OnPlayerLogin exists without override keyword
|
||||
if grep -q 'void OnPlayerLogin(Player\* player) {' "$file" && ! grep -q 'void OnPlayerLogin(Player\* player) override {' "$file"; then
|
||||
if sed -i 's/void OnPlayerLogin(Player\* player) {/void OnPlayerLogin(Player* player) override {/' "$file"; then
|
||||
echo " ✅ Applied override keyword fix to $(basename "$file")"
|
||||
patch_count=$((patch_count + 1))
|
||||
else
|
||||
echo " ❌ Failed to apply override keyword fix to $(basename "$file")"
|
||||
return 2
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $patch_count -eq 0 ]; then
|
||||
echo " ✅ Override keyword fix already present"
|
||||
else
|
||||
echo " ✅ Applied override keyword fix to $patch_count file(s)"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Apply SendTrainerList compatibility patch
|
||||
apply_sendtrainerlist_patch() {
|
||||
local target_file="$MODULE_DIR/src/LuaEngine/methods/PlayerMethods.h"
|
||||
@@ -77,10 +117,10 @@ apply_sendtrainerlist_patch() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if the buggy code exists (without GetGUID())
|
||||
if grep -q 'player->GetSession()->SendTrainerList(obj);' "$target_file"; then
|
||||
# Apply the fix by adding ->GetGUID()
|
||||
if sed -i 's/player->GetSession()->SendTrainerList(obj);/player->GetSession()->SendTrainerList(obj->GetGUID());/' "$target_file"; then
|
||||
# Check if the buggy code exists (with ->GetGUID())
|
||||
if grep -q 'player->GetSession()->SendTrainerList(obj->GetGUID());' "$target_file"; then
|
||||
# Apply the fix by casting to Creature* instead of using GetGUID()
|
||||
if sed -i 's/player->GetSession()->SendTrainerList(obj->GetGUID());/if (Creature* creature = obj->ToCreature()) player->GetSession()->SendTrainerList(creature);/' "$target_file"; then
|
||||
echo " ✅ Applied SendTrainerList compatibility fix"
|
||||
return 0
|
||||
else
|
||||
@@ -95,6 +135,11 @@ apply_sendtrainerlist_patch() {
|
||||
|
||||
# Apply all patches
|
||||
patch_count=0
|
||||
if [ "$APPLY_OVERRIDE_PATCH" = "1" ]; then
|
||||
if apply_override_patch; then
|
||||
patch_count=$((patch_count + 1))
|
||||
fi
|
||||
fi
|
||||
if [ "$APPLY_MOVEPATH_PATCH" = "1" ]; then
|
||||
if apply_movepath_patch; then
|
||||
patch_count=$((patch_count + 1))
|
||||
|
||||
Reference in New Issue
Block a user