Re: [CODE]

From: Del (caminturn@earthlink.net)
Date: 06/29/01


Sammy wrote:
>
> This is a *very* cool hack.
>
> In case people missed the big advantage here, this lets you start add
> percentage (random) loading _without_any_file_conversion_.
>
> I'd hate to see this go ignored.
>

I missed a few things in the code. Basically, if the alternate item/object
loads, it doesn't prevent the first from loading next time around.

if you have something like:
load moba 50%
otherwise load mobb 50%
otherwise load mobc 100%

Nothing prevents moba and mobb from loading if mobc loads.
Or, nothing prevents mobc loading if moba loads.

This is hard to explain, but this code checks all the next (if_flag = 2)
commands and previous commands to see if any of those mobs/objects are
loaded. Some tweaking will be needed if you want more than one object
or mob from loading (i.e. check the max loads).

diff -rub /home/del/src/orig/db.c /home/del/src/db.c
--- /home/del/src/orig/db.c     Tue Jun 26 22:43:39 2001
+++ /home/del/src/db.c  Fri Jun 29 19:17:42 2001
@@ -2086,6 +2086,69 @@
         { log_zone_error(zone, cmd_no, message); last_cmd = FALSE; }


+int check_previous_if_flag(int zone, int cmd_no)
+{
+  int i = 0;
+
+  for (;;) {
+    i++;
+    switch (zone_table[zone].cmd[cmd_no-i].command) {
+      case 'M':
+        if (mob_index[zone_table[zone].cmd[cmd_no-i].arg1].number > 0)
+          return TRUE;
+        break;
+      case 'O':
+      case 'G':
+      case 'P':
+      case 'E':
+        if (obj_index[zone_table[zone].cmd[cmd_no-i].arg1].number > 0)
+          return TRUE;
+        break;
+      default:
+       log("Default reached in previous if flag check");
+       break;
+    }
+
+    if (zone_table[zone].cmd[cmd_no-i].if_flag != 2)
+      return FALSE;   /* means this was the first in the series */
+
+  } /* end of for loop */
+  return FALSE;
+
+}
+
+int check_next_if_flag(int zone, int cmd_no)
+{
+  int i = 0;
+
+  for (;;) {
+    i++;
+
+    if (zone_table[zone].cmd[cmd_no+i].if_flag != 2)
+      return FALSE;
+    else {
+      switch (zone_table[zone].cmd[cmd_no+i].command) {
+        case 'M':
+          if (mob_index[zone_table[zone].cmd[cmd_no+i].arg1].number > 0)
+            return TRUE;
+          break;
+        case 'O':
+        case 'G':
+        case 'P':
+        case 'E':
+          if (obj_index[zone_table[zone].cmd[cmd_no+i].arg1].number > 0)
+            return TRUE;
+          break;
+        default:
+         log("Default reached in if flag check");
+         break;
+      }
+    }
+  }
+  return FALSE;
+
+}
+
 void reset_zone(int zone, int override_limit)
 {
   int cmd_no, last_cmd = FALSE;
@@ -2112,6 +2176,14 @@
       obj_load = FALSE;
     }

+    if (ZCMD.if_flag == 2) {
+      if (check_previous_if_flag(zone, cmd_no))
+        continue;
+    }
+
+    if (check_next_if_flag(zone, cmd_no))
+      continue;
+
     switch (ZCMD.command) {
     case '*': /* ignore command */
       break;

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST