fix: mod-ale compiler patch

This commit is contained in:
uprightbass360
2026-01-05 19:25:34 -05:00
parent b6b37f37c9
commit fe410a6d4d

View File

@@ -33,6 +33,8 @@ if [ -z "${APPLY_SENDTRAINERLIST_PATCH:-}" ]; then
else else
APPLY_SENDTRAINERLIST_PATCH="${APPLY_SENDTRAINERLIST_PATCH}" APPLY_SENDTRAINERLIST_PATCH="${APPLY_SENDTRAINERLIST_PATCH}"
fi 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 if [ -z "$MODULE_DIR" ] || [ ! -d "$MODULE_DIR" ]; then
echo "❌ mod-ale-patches: Invalid module directory: $MODULE_DIR" echo "❌ mod-ale-patches: Invalid module directory: $MODULE_DIR"
@@ -68,6 +70,44 @@ apply_movepath_patch() {
fi 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 compatibility patch
apply_sendtrainerlist_patch() { apply_sendtrainerlist_patch() {
local target_file="$MODULE_DIR/src/LuaEngine/methods/PlayerMethods.h" local target_file="$MODULE_DIR/src/LuaEngine/methods/PlayerMethods.h"
@@ -77,10 +117,10 @@ apply_sendtrainerlist_patch() {
return 1 return 1
fi fi
# Check if the buggy code exists (without GetGUID()) # Check if the buggy code exists (with ->GetGUID())
if grep -q 'player->GetSession()->SendTrainerList(obj);' "$target_file"; then if grep -q 'player->GetSession()->SendTrainerList(obj->GetGUID());' "$target_file"; then
# Apply the fix by adding ->GetGUID() # Apply the fix by casting to Creature* instead of using GetGUID()
if sed -i 's/player->GetSession()->SendTrainerList(obj);/player->GetSession()->SendTrainerList(obj->GetGUID());/' "$target_file"; then 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" echo " ✅ Applied SendTrainerList compatibility fix"
return 0 return 0
else else
@@ -95,6 +135,11 @@ apply_sendtrainerlist_patch() {
# Apply all patches # Apply all patches
patch_count=0 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" = "1" ]; then
if apply_movepath_patch; then if apply_movepath_patch; then
patch_count=$((patch_count + 1)) patch_count=$((patch_count + 1))