Author: cazfi
Date: Sat Dec 26 01:48:08 2015
New Revision: 31202

URL: http://svn.gna.org/viewcvs/freeciv?rev=31202&view=rev
Log:
Added lua "city_transfered" signal for all city transfers. Existing "city_lost" 
signal, that
was able to handle only the conquest case, deprecated.

See patch #6673

Modified:
    trunk/data/default/default.lua
    trunk/server/citytools.c
    trunk/server/diplhand.c
    trunk/server/diplomats.c
    trunk/server/plrhand.c
    trunk/server/scripting/script_server.c

Modified: trunk/data/default/default.lua
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/default/default.lua?rev=31202&r1=31201&r2=31202&view=diff
==============================================================================
--- trunk/data/default/default.lua      (original)
+++ trunk/data/default/default.lua      Sat Dec 26 01:48:08 2015
@@ -176,8 +176,8 @@
   c) The player must run either a democracy or a communist society.
 ]]--
 
-function default_make_partisans_callback(city, loser, winner)
-  if city:inspire_partisans(loser) <= 0 then
+function default_make_partisans_callback(city, loser, winner, reason)
+  if not reason == 'conquest' or city:inspire_partisans(loser) <= 0 then
     return
   end
 
@@ -192,7 +192,7 @@
       _("The loss of %s has inspired partisans!"), city.name)
 end
 
-signal.connect("city_lost", "default_make_partisans_callback")
+signal.connect("city_transfered", "default_make_partisans_callback")
 
 
 -- Notify player about the fact that disaster had no effect if that is

Modified: trunk/server/citytools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/citytools.c?rev=31202&r1=31201&r2=31202&view=diff
==============================================================================
--- trunk/server/citytools.c    (original)
+++ trunk/server/citytools.c    Sat Dec 26 01:48:08 2015
@@ -1963,6 +1963,11 @@
   }
 
   if (city_remains) {
+    script_server_signal_emit("city_transfered", 4,
+                              API_TYPE_CITY, pcity,
+                              API_TYPE_PLAYER, cplayer,
+                              API_TYPE_PLAYER, pplayer,
+                              API_TYPE_STRING, "conquest");
     script_server_signal_emit("city_lost", 3,
                               API_TYPE_CITY, pcity,
                               API_TYPE_PLAYER, cplayer,

Modified: trunk/server/diplhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplhand.c?rev=31202&r1=31201&r2=31202&view=diff
==============================================================================
--- trunk/server/diplhand.c     (original)
+++ trunk/server/diplhand.c     Sat Dec 26 01:48:08 2015
@@ -527,8 +527,14 @@
                         _("You give the city of %s to %s."),
                         city_link(pcity), player_name(pdest));
 
-          (void) transfer_city(pdest, pcity, -1, TRUE, TRUE, FALSE,
-                               !is_barbarian(pdest));
+          if (transfer_city(pdest, pcity, -1, TRUE, TRUE, FALSE,
+                            !is_barbarian(pdest))) {
+            script_server_signal_emit("city_transfered", 4,
+                                      API_TYPE_CITY, pcity,
+                                      API_TYPE_PLAYER, pgiver,
+                                      API_TYPE_PLAYER, pdest,
+                                      API_TYPE_STRING, "trade");
+          }
          break;
        }
       case CLAUSE_CEASEFIRE:

Modified: trunk/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplomats.c?rev=31202&r1=31201&r2=31202&view=diff
==============================================================================
--- trunk/server/diplomats.c    (original)
+++ trunk/server/diplomats.c    Sat Dec 26 01:48:08 2015
@@ -47,6 +47,9 @@
 #include "techtools.h"
 #include "unithand.h"
 #include "unittools.h"
+
+/* server/scripting */
+#include "script_server.h"
 
 /****************************************************************************/
 
@@ -869,8 +872,14 @@
 
   /* Transfer city and units supported by this city (that
      are within one square of the city) to the new owner. */
-  (void) transfer_city(pplayer, pcity, 1, TRUE, TRUE, FALSE,
-                       !is_barbarian(pplayer));
+  if (transfer_city(pplayer, pcity, 1, TRUE, TRUE, FALSE,
+                    !is_barbarian(pplayer))) {
+    script_server_signal_emit("city_transfered", 4,
+                              API_TYPE_CITY, pcity,
+                              API_TYPE_PLAYER, cplayer,
+                              API_TYPE_PLAYER, pplayer,
+                              API_TYPE_STRING, "incited");
+  }
 
   /* Check if a spy survives her mission. Diplomats never do.
    * _After_ transferring the city, or the city area is first fogged

Modified: trunk/server/plrhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/plrhand.c?rev=31202&r1=31201&r2=31202&view=diff
==============================================================================
--- trunk/server/plrhand.c      (original)
+++ trunk/server/plrhand.c      Sat Dec 26 01:48:08 2015
@@ -157,8 +157,14 @@
       /* Transfer city to original owner, kill all its units outside of
          a radius of 3, give verbose messages of every unit transferred,
          and raze buildings according to raze chance (also removes palace) */
-      (void) transfer_city(pcity->original, pcity, 3, TRUE, TRUE, TRUE,
-                           TRUE);
+      if (transfer_city(pcity->original, pcity, 3, TRUE, TRUE, TRUE,
+                        TRUE)) {
+        script_server_signal_emit("city_transfered", 4,
+                                  API_TYPE_CITY, pcity,
+                                  API_TYPE_PLAYER, pplayer,
+                                  API_TYPE_PLAYER, pcity->original,
+                                  API_TYPE_STRING, "death-back_to_original");
+      }
     }
   } city_list_iterate_safe_end;
   game.server.savepalace = save_palace;
@@ -196,8 +202,14 @@
 
     /* Transfer any remaining cities */
     city_list_iterate_safe(pplayer->cities, pcity) {
-      (void) transfer_city(barbarians, pcity, -1, FALSE, FALSE, FALSE,
-                           FALSE);
+      if (transfer_city(barbarians, pcity, -1, FALSE, FALSE, FALSE,
+                        FALSE)) {
+        script_server_signal_emit("city_transfered", 4,
+                                  API_TYPE_CITY, pcity,
+                                  API_TYPE_PLAYER, pplayer,
+                                  API_TYPE_PLAYER, barbarians,
+                                  API_TYPE_STRING, "death-barbarians_get");
+      }
     } city_list_iterate_safe_end;
 
     game.server.savepalace = palace;
@@ -2737,6 +2749,11 @@
                         _("%s declares allegiance to the %s."),
                         city_link(pcity),
                         nation_plural_for_player(cplayer));
+          script_server_signal_emit("city_transfered", 4,
+                                  API_TYPE_CITY, pcity,
+                                  API_TYPE_PLAYER, pplayer,
+                                  API_TYPE_PLAYER, cplayer,
+                                  API_TYPE_STRING, "civil_war");
         }
         i--;
       }

Modified: trunk/server/scripting/script_server.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/scripting/script_server.c?rev=31202&r1=31201&r2=31202&view=diff
==============================================================================
--- trunk/server/scripting/script_server.c      (original)
+++ trunk/server/scripting/script_server.c      Sat Dec 26 01:48:08 2015
@@ -382,6 +382,12 @@
   /* First player is city owner, second is enemy. */
   luascript_signal_create(fcl_main, "city_destroyed", 3,
                           API_TYPE_CITY, API_TYPE_PLAYER, API_TYPE_PLAYER);
+
+  /* First player is former owner, second new one. */
+  luascript_signal_create(fcl_main, "city_transfered", 4,
+                          API_TYPE_CITY, API_TYPE_PLAYER, API_TYPE_PLAYER, 
API_TYPE_STRING);
+
+  /* Deprecated form of the 'city_transfered' signal for the case of conquest. 
*/
   luascript_signal_create(fcl_main, "city_lost", 3,
                           API_TYPE_CITY, API_TYPE_PLAYER, API_TYPE_PLAYER);
 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to