[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src ai.cpp
From: |
Jon Daniel |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src ai.cpp |
Date: |
Sat, 22 Jan 2005 01:27:17 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Jon Daniel <address@hidden> 05/01/22 06:27:17
Modified files:
src : ai.cpp
Log message:
Fixed a division by zero which appears if a unit has no attacks
and/or no damage at all.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/ai.cpp.diff?tr1=1.132&tr2=1.133&r1=text&r2=text
Patches:
Index: wesnoth/src/ai.cpp
diff -u wesnoth/src/ai.cpp:1.132 wesnoth/src/ai.cpp:1.133
--- wesnoth/src/ai.cpp:1.132 Fri Jan 21 23:17:15 2005
+++ wesnoth/src/ai.cpp Sat Jan 22 06:27:17 2005
@@ -1,4 +1,4 @@
-/* $Id: ai.cpp,v 1.132 2005/01/21 23:17:15 Sirp Exp $ */
+/* $Id: ai.cpp,v 1.133 2005/01/22 06:27:17 j_daniel Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1371,6 +1371,13 @@
weight_sum += weight;
}
+ // catch division by zero here if the attacking unit
+ // has zero attacks and/or zero damage
+ // if it has no attack at all the ai shouldn't prefer
+ // that unit anyway
+ if (weight_sum == 0) {
+ return 0;
+ }
return sum/weight_sum;
}
- [Wesnoth-cvs-commits] wesnoth/src ai.cpp,
Jon Daniel <=