changeset 1135:45fcbd54e873

Fix issue of divided by zero for tank
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 19 Dec 2010 20:47:23 +0800
parents bd0cfb8666b8
children 950076863b7e
files examples/tank/enemy.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/examples/tank/enemy.c	Sun Dec 19 17:56:23 2010 +0800
+++ b/examples/tank/enemy.c	Sun Dec 19 20:47:23 2010 +0800
@@ -234,6 +234,9 @@
 	return;
     }
     
+    if(all_interest == 0)	/* all nearby places are occupied */
+	return;
+
     interest_dir = (rand() % all_interest) + 1;
     for(i = 0; i < 3; i++) {
 	chk_dir = (dir + 3  + i) % 4;