CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Jon Daniel <[EMAIL PROTECTED]>  05/01/23 14:25:34

Modified files:
        src            : pathfind.cpp 

Log message:
        fixed a division by zero if a unit remaining_movement but total 
movement is zero

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/pathfind.cpp.diff?tr1=1.55&tr2=1.56&r1=text&r2=text

Patches:
Index: wesnoth/src/pathfind.cpp
diff -u wesnoth/src/pathfind.cpp:1.55 wesnoth/src/pathfind.cpp:1.56
--- wesnoth/src/pathfind.cpp:1.55       Fri Jan 21 23:17:15 2005
+++ wesnoth/src/pathfind.cpp    Sun Jan 23 14:25:34 2005
@@ -1,4 +1,4 @@
-/* $Id: pathfind.cpp,v 1.55 2005/01/21 23:17:15 Sirp Exp $ */
+/* $Id: pathfind.cpp,v 1.56 2005/01/23 14:25:34 j_daniel Exp $ */
 /*
 Copyright (C) 2003 by David White <[EMAIL PROTECTED]>
 Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -629,9 +629,13 @@
 
        const int starting_movement = unit_.movement_left();
        int remaining_movement = starting_movement - current_cost;
-       if (remaining_movement < 0) {
-               int total = unit_.total_movement();
+       int total = unit_.total_movement();
+       if (total != 0) {
+               if (remaining_movement < 0) {
                remaining_movement = total - (-remaining_movement) % total;
+               }
+       } else if (remaining_movement < 0) {
+               remaining_movement = -remaining_movement;
        }
 
        int additional_cost = base_cost > remaining_movement ? 
remaining_movement : 0;


Reply via email to