<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40414 >

 Lua call find.role_unit_type crashes if ruleset contains no units for
the specified role. Fix attached.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/scripting/api_find.c 
freeciv/server/scripting/api_find.c
--- freeciv/server/scripting/api_find.c 2008-07-05 14:46:49.000000000 +0300
+++ freeciv/server/scripting/api_find.c 2008-08-01 22:38:46.000000000 +0300
@@ -65,8 +65,10 @@
 
   if (pplayer) {
     return best_role_unit_for_player(pplayer, role);
-  } else {
+  } else if (num_role_units(role) > 0) {
     return get_role_unit(role, 0);
+  } else {
+    return NULL;
   }
 }
 
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to