[CODE] perform_immort_invis bugfix

From: Andrey Fidrya (andrey@alex-ua.com)
Date: 02/18/00


Some time ago I submitted do_order crash bug fix (by adding additional
variable struct char_data -> bool cloop_member; it isn't fixed yet, btw,
any player can crash MUD by calling "order" command). Here's my version
of perform_immort_invis (with correct visibility checking) which also uses
cloop_member variable (as visibility flag).

-void perform_immort_invis(struct char_data *ch, int level)
-{
-  struct char_data *tch;
-
-  if (IS_NPC(ch))
-    return;
-
-  for (tch = world[ch->in_room].people; tch; tch = tch->next_in_room) {
-    if (tch == ch)
-      continue;
-    if (GET_LEVEL(tch) >= GET_INVIS_LEV(ch) && GET_LEVEL(tch) < level)
-      act("You blink and suddenly realize that $n is gone.", FALSE, ch, 0,
-      tch, TO_VICT);
-    if (GET_LEVEL(tch) < GET_INVIS_LEV(ch) && GET_LEVEL(tch) >= level)
-      act("You suddenly realize that $n is standing beside you.", FALSE,
ch, 0,
-      tch, TO_VICT);
-  }
-
-  GET_INVIS_LEV(ch) = level;
-  sprintf(buf, "Your invisibility level is %d.\r\n", level);
-  send_to_char(buf, ch);
-}
+void perform_immort_invis(struct char_data *ch, int level)
+{
+  struct char_data *tch;
+
+  for (tch = world[ch->in_room].people; tch; tch = tch->next_in_room) {
+    if (tch == ch)
+      continue;
+    tch->cloop_member = CAN_SEE(tch, ch);
+  }
+
+  GET_INVIS_LEV(ch) = level;
+  sprintf(buf, "Your invisibility level is %d.\r\n", level);
+  send_to_char(buf, ch);
+
+  for (tch = world[ch->in_room].people; tch; tch = tch->next_in_room) {
+    if (tch == ch)
+      continue;
+    if (tch->cloop_member && !CAN_SEE(tch, ch)) {
+      sprintf(buf, "You blink and suddenly realize that %s is gone.\r\n",
+         GET_NAME(ch));
+      send_to_char(buf, tch);
+    } else if (!tch->cloop_member && CAN_SEE(tch, ch)) {
+      act("You suddenly realize that $n is standing beside you.",
+         FALSE, ch, 0, tch, TO_VICT);
+    }
+  }
+}

Andrey


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT