View Issue Details

IDProjectCategoryView StatusLast Update
0000514LDMud 3.3Runtimepublic2018-01-29 21:57
ReporterGnomi Assigned Tolars 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformi686OSDebian GNU/LinuxOS Version3.1
Product Version3.3.713 
Fixed in Version3.3.717 
Summary0000514: remove_shadow_actions and remove_action don't handle shadow actions very well
DescriptionHi,

remove_shadow_action assumes, that the shadow is the only shadow and that there are no shadows between it and the underlying object. But should go through the shadowing list till the underlying object just as add_action does.

remove_action doesn't work with actions by shadows at all, that means, only the underlying object can remove such an action, not the shadow itself. Because it searches for an action by the shadow, not by the underlying object.

I attached a patch, that should fix both issues. I left remove_action backward compatible in that manner, that the underlying object can still remove actions from its shadows (but shadows can only remove their actions).

Greetings,
Gnomi
TagsNo tags attached.
Attached Files
removeshadowaction.diff (1,767 bytes)   
Index: trunk/src/actions.c
===================================================================
--- trunk/src/actions.c	(Revision 2314)
+++ trunk/src/actions.c	(Arbeitskopie)
@@ -487,7 +487,15 @@
 
 {
     object_t *item;
+    object_t *shadowing;
 
+    /* Get the real underlying object, just as add_action does. */
+    while ((target->flags & O_SHADOW)
+     && NULL != (shadowing = O_GET_SHADOW(target)->shadowing))
+    {
+        target = shadowing;
+    }
+
     remove_shadow_action_sent(shadow, target);
     for (item = target->contains; item; item = item->next_inv)
     {
@@ -1888,7 +1896,7 @@
  */
 
 {
-    object_t    *ob;
+    object_t    *ob, *shadow_ob;
     string_t    *verb;
     sentence_t **sentp;
     action_t    *s;
@@ -1917,14 +1925,33 @@
         efun_gen_arg_error(1, sp[-1].type, sp);
         /* NOTREACHED */
     }
-
-    /* Now search and remove the sentence */
+    
     rc = 0;
     sentp = &ob->sent;
+
     ob = current_object;
+    shadow_ob = NULL;
+    
+    /* Look for the underlying object, just as add_action does. */
+    if (ob->flags & O_SHADOW && O_GET_SHADOW(ob)->shadowing)
+    {
+        object_t *shadowing;
+
+        shadow_ob = ob;
+
+        while ((ob->flags & O_SHADOW)
+         && NULL != (shadowing = O_GET_SHADOW(ob)->shadowing))
+        {
+            ob = shadowing;
+        }
+    }
+
+    /* Now search and remove the sentence */
     while ( NULL != (s = (action_t *)*sentp) )
     {
-        if (!SENT_IS_INTERNAL((*sentp)->type) && s->ob == ob && (!verb || s->verb == verb))
+        if (!SENT_IS_INTERNAL((*sentp)->type) && s->ob == ob 
+	 && (!verb || s->verb == verb)
+	 && (!shadow_ob || s->shadow_ob == shadow_ob))
         {
 #ifdef CHECK_OBJECT_REF
             if (sentp == &ob->sent)
removeshadowaction.diff (1,767 bytes)   

Activities

lars

2007-11-11 17:24

reporter   ~0000575

Added the patch - Thanks!

Issue History

Date Modified Username Field Change
2007-09-10 16:01 Gnomi New Issue
2007-09-10 16:01 Gnomi File Added: removeshadowaction.diff
2007-11-11 17:24 lars Status new => resolved
2007-11-11 17:24 lars Fixed in Version => 3.3.717
2007-11-11 17:24 lars Resolution open => fixed
2007-11-11 17:24 lars Assigned To => lars
2007-11-11 17:24 lars Note Added: 0000575
2009-04-14 12:14 zesstra Project LDMud => LDMud 3.3
2010-11-16 09:42 lars Source_changeset_attached => ldmud.git master 1c6725c3
2018-01-29 18:59 lars Source_changeset_attached => ldmud.git master 1c6725c3
2018-01-29 21:57 lars Source_changeset_attached => ldmud.git master 1c6725c3