Author: anonymissimus
Date: Sat Mar 31 16:22:31 2012
New Revision: 53717

URL: http://svn.gna.org/viewcvs/wesnoth?rev=53717&view=rev
Log:
Improve conversion algorithm (bug #19287)

Fix a variable leak, a misplaced key and add a fallback
to the existing type in case we cannot find a suitable type to
turn into + a beg to report this. Theoretically we can also
have level 3 units on the enemy side here which aren't taken care
of.

Modified:
    trunk/data/campaigns/Liberty/scenarios/04_Unlawful_Orders.cfg

Modified: trunk/data/campaigns/Liberty/scenarios/04_Unlawful_Orders.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/campaigns/Liberty/scenarios/04_Unlawful_Orders.cfg?rev=53717&r1=53716&r2=53717&view=diff
==============================================================================
--- trunk/data/campaigns/Liberty/scenarios/04_Unlawful_Orders.cfg (original)
+++ trunk/data/campaigns/Liberty/scenarios/04_Unlawful_Orders.cfg Sat Mar 31 
16:22:31 2012
@@ -312,6 +312,21 @@
         [/set_variables]
     [/event]
 
+    #define FALLBACK
+        [if]
+            [variable]
+                name=type_to_turn_into
+                equals=$null
+            [/variable]
+            [then]
+                [wml_message]
+                    logger=error
+                    message="Could not convert a $stored_changers[$i].type, 
please report!"
+                [/wml_message]
+                {VARIABLE type_to_turn_into $stored_changers[$i].type}
+            [/then]
+        [/if]
+    #enddef
     [event]
         name=new turn
         first_time_only=no
@@ -385,6 +400,7 @@
                         [/if]
                     {NEXT j}
 
+                    {FALLBACK}
                     [unit]
                         type=$type_to_turn_into
                         side=3
@@ -404,6 +420,7 @@
                         [/variables]
                         to_variable=changer
                     [/unit]
+                    {CLEAR_VARIABLE type_to_turn_into}
 
                     [if]
                         [variable]
@@ -498,6 +515,7 @@
                         [/if]
                     {NEXT j}
 
+                    {FALLBACK}
                     [if]
                         [variable]
                             
name=stored_changers[$i].variables.turned_to_undead_at_least_once
@@ -519,9 +537,10 @@
                                         name=trait
                                         
variable=stored_changers[$i].variables.stored_trait
                                     [/insert_tag]
-
+                                [/modifications]
+                                [variables]
                                     turned_to_undead_at_least_once=yes
-                                [/modifications]
+                                [/variables]
                                 to_variable=changer
                             [/unit]
                         [/then]
@@ -540,6 +559,7 @@
                             [/unit]
                         [/else]
                     [/if]
+                    {CLEAR_VARIABLE type_to_turn_into}
 
                     [if]
                         [variable]
@@ -561,6 +581,7 @@
             [/then]
         [/if]
     [/event]
+    #undef FALLBACK
 
     [event]
         name=turn 4


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to