# HG changeset patch # User Thinker K.F. Li # Date 1292762843 -28800 # Node ID 45fcbd54e873dfd5d843a6e5e5ce66bf5995ddbf # Parent bd0cfb8666b8914bb9457e46e9c3a03d1800721a Fix issue of divided by zero for tank diff -r bd0cfb8666b8 -r 45fcbd54e873 examples/tank/enemy.c --- 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;