From fe410a6d4dcd9c05fbb39152472daf78260c09e2 Mon Sep 17 00:00:00 2001 From: uprightbass360 Date: Mon, 5 Jan 2026 19:25:34 -0500 Subject: [PATCH] fix: mod-ale compiler patch --- scripts/hooks/mod-ale-patches | 53 ++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/scripts/hooks/mod-ale-patches b/scripts/hooks/mod-ale-patches index aa5530a..45e9e2e 100755 --- a/scripts/hooks/mod-ale-patches +++ b/scripts/hooks/mod-ale-patches @@ -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))