From 6d1dc0f2b509f2e925698be20b023d2e4cfca7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= Date: Sat, 18 Mar 2006 13:17:59 +0000 Subject: [PATCH] prevent all AI from attacking twice with the same unit --- changelog | 1 + src/ai.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/changelog b/changelog index 56708f7bf25..b73201e58e6 100644 --- a/changelog +++ b/changelog @@ -160,6 +160,7 @@ SVN trunk (1.1.1+svn): * force a refresh after calls to ONSCREEN scrolls, to avoid refresh problems. * add sort_topics command to the WML of help + * check in ai code that ai doesn't use the same unit to attack twice Version 1.1.1: * campaigns diff --git a/src/ai.cpp b/src/ai.cpp index 7eeff0500d2..070223a8258 100644 --- a/src/ai.cpp +++ b/src/ai.cpp @@ -1006,6 +1006,10 @@ void ai_interface::attack_enemy(const location& u, const location& target, int w LOG_STREAM(err, ai) << "attempt to attack unit that is turned to stone\n"; return; } + if(!info_.units.find(u)->second.can_attack()) { + LOG_STREAM(err, ai) << "attempt to attack twice with the same unit\n"; + return; + } recorder.add_attack(u,target,weapon);