If someone is flagged Leave_behind and one of their followers leave the room
authornveid <nveid@comcast.net>
Sun, 29 Oct 2006 10:12:49 +0000 (10:12 +0000)
committernveid <nveid@comcast.net>
Sun, 29 Oct 2006 10:12:49 +0000 (10:12 +0000)
theyr'e in, they automatically unfollow them.

game/txt/changes/0.73
hdrs/dbdefs.h
src/flags.c
src/move.c

index b67acc5f21bc71a08e042e89463b9dc3f5295fd9..7fa4fabceebebfe2a1637764f43044f24be353a7 100644 (file)
@@ -4,6 +4,10 @@ CobraMUSH Version 0.73
   interest to the user.
   (See 'changes entries' for a list of all versions.)
 
+ Flags:
+   * LEAVE_BEHIND - When a player leaves the location of 
+     someone they're flowing with this flag it unfollows
+     the follower.
  Fixes:
    * All fixes from 0.72 stable development series
 
index 015a8052779f428e8ddb001805fc957d89e426bb..20b176396d093e08f2135a4aca814fb899214b22 100644 (file)
@@ -78,6 +78,9 @@ extern dbref first_free;      /* pointer to free list */
 
 #define GoodObject(x) ((x >= 0) && (x < db_top))
 
+/* Leave Followers Behind */
+#define Leave_Behind(x) has_flag_by_name(x, "LEAVE_BEHIND", TYPE_THING | TYPE_PLAYER)
+
 /* Can guy talk? */
 #define Mute(x)                (has_flag_by_name(x, "MUTE", TYPE_THING | TYPE_PLAYER | TYPE_ROOM))
 #define IsMuted(x,y)   (Mute(x) || Mute(Location(x)))
index c956d489408775395e3201a53bd92676a014f8d6..5a5dfe69db997780d6a0454c508bb72573709459 100644 (file)
@@ -753,6 +753,7 @@ flag_add_additional(void)
   add_flag("BUILDER", '\0', TYPE_PLAYER, F_PRIVILEGE, F_PRIVILEGE);
   add_flag("AUTH_PARENT", '\0', NOTYPE, F_PRIVILEGE, F_PRIVILEGE);
   add_flag("MUTE", '\0', TYPE_PLAYER, F_PRIVILEGE, F_PRIVILEGE);
+  add_flag("LEAVE_BEHIND", '\0', TYPE_PLAYER | TYPE_THING, F_ANY, F_ANY);
 #ifdef RPMODE_SYS
   add_flag("RPMODE", '\0', TYPE_PLAYER, F_PRIVILEGE, F_PRIVILEGE);
   add_flag("BLIND", '\0', TYPE_PLAYER, F_PRIVILEGE, F_PRIVILEGE);
index 97934f824ec70b91edcbe7213cfaaec92452d767..a51d450d70bb40eb87bdc9a30b8ecccf017e15ed 100644 (file)
@@ -1363,7 +1363,7 @@ clear_following(dbref follower, int noisy)
 static void
 follower_command(dbref leader, dbref loc, const char *com)
 {
-  dbref follower;
+  dbref cur_obj;
   ATTR *a;
   char *s, *sp;
   char tbuf1[BUFFER_LEN];
@@ -1372,21 +1372,38 @@ follower_command(dbref leader, dbref loc, const char *com)
     return;
   strcpy(combuf, com);
   a = atr_get_noparent(leader, "FOLLOWERS");
-  if (!a)
-    return;                    /* No followers */
+  if (!a) {
+     /* No-followers.. Check to see if they're following anyone.. And if that person they're following has
+      * the LEAVE_BEHIND flag.. then unfollow us
+      */
+    a = atr_get(leader, "FOLLOWING");
+    if(!a) /* Not following anyone either */
+      return;
+    strcpy(tbuf1, atr_value(a));
+    s = tbuf1;
+    while(s) {
+      sp = split_token(&s, ' ');
+      cur_obj = parse_dbref(sp);
+      if(GoodObject(cur_obj) && Location(cur_obj) == loc && Leave_Behind(cur_obj)) {
+       /* K.. we found someone we suppose to be following.. Trigger unfollow on them */
+       do_unfollow(leader, unparse_dbref(cur_obj));
+      }
+    }
+    return;
+  }
   strcpy(tbuf1, atr_value(a));
   s = tbuf1;
   while (s) {
     sp = split_token(&s, ' ');
-    follower = parse_dbref(sp);
-    if (GoodObject(follower) && (Location(follower) == loc)
-       && (Connected(follower) || IsThing(follower))
+    cur_obj = parse_dbref(sp);
+    if (GoodObject(cur_obj) && (Location(cur_obj) == loc)
+       && (Connected(cur_obj) || IsThing(cur_obj))
        && (!(DarkLegal(leader)
-             || (Dark(Location(follower)) && !Light(leader)))
-           || CanSee(follower, leader))) {
+             || (Dark(Location(cur_obj)) && !Light(leader)))
+           || CanSee(cur_obj, leader))) {
       /* This is a follower who was in the room with the leader. Follow. */
-      notify_format(follower, T("You follow %s."), Name(leader));
-      process_command(follower, combuf, follower, follower, 0);
+      notify_format(cur_obj, T("You follow %s."), Name(leader));
+      process_command(cur_obj, combuf, cur_obj, cur_obj, 0);
     }
   }
 }