Zone flags Modifications [by Del]
Snippet Posted Tuesday, May 11th @ 10:44:02 AM, by George Greer in the Zones dept.
Del wrote in with a patch on how to add zone flags and the changes necessary to modify OasisOLC. Most snippets are instructional, this happens to be a patch. Just remember that you're better off applying this by hand like instructions anyway.

Zone flags.

diff -uprN src_orig/constants.c src_w_flags/constants.c
--- src_orig/constants.c	Sun Apr 11 20:55:11 1999
+++ src_w_flags/constants.c	Mon May  3 23:29:57 1999
@@ -55,6 +55,13 @@ const char *dirs[] =
    "\n"
  };
 
+const char *zone_bits[] = {
+  "OPEN",
+  "CLOSED",
+  "!RECALL",
+  "!SUMMON",
+  "REMORTS"
+ };
 
 /* ROOM_x */
 const char *room_bits[] = {
diff -uprN src_orig/db.c src_w_flags/db.c
--- src_orig/db.c	Mon Apr 26 22:53:57 1999
+++ src_w_flags/db.c	Tue May  4 10:03:55 1999
@@ -738,8 +738,10 @@ void index_boot(int mode)
 
 void discrete_load(FILE * fl, int mode, char *filename)
 {
-  int nr = -1, last;
-  char line[256];
+  int nr = -1, last = 0, version = 1;
+  char *line = get_buffer(256);
+/* George's buffers installed so you may have to keep the original */
+/*  char line[256]; */
 
   const char *modes[] = {"world", "mob", "obj", "ZON", "SHP", "HLP", "trg"};
   /* modes positions correspond to DB_BOOT_xxx in db.h */
@@ -761,8 +763,20 @@ void discrete_load(FILE * fl, int mode, 
 	}
 	exit(1);
       }
-    if (*line == '$')
-      return;
+     if (*line == '$')
+         {
+         release_buffer(line);
+         return;
+         }
+      else if(*line=='@')
+         {
+         if(sscanf(line,"@Version: %d",&version)!=1)
+            {
+            log("SYSERR: Format error after %s #%d", modes[mode], last);
+            log("SYSERR: ...Line: %s",line);
+            exit(1);
+            }
+         }
 
     if (*line == '#') {
       last = nr;
@@ -1536,8 +1550,8 @@ char *parse_object(FILE * obj_f, int nr)
 void load_zones(FILE * fl, char *zonename)
 {
   static zone_rnum zone = 0;
-  int cmd_no = 0, num_of_cmds = 0, line_num = 0, tmp, error, arg_num;
-  char *ptr, buf[256], zname[256];
+  int cmd_no = 0, num_of_cmds = 0, line_num = 0, tmp, error, arg_num, version = 1;
+  char *ptr, *line = get_buffer(256), zname[256];
 
   strcpy(zname, zonename);
 
@@ -1552,7 +1566,15 @@ void load_zones(FILE * fl, char *zonenam
     CREATE(Z.cmd, struct reset_com, num_of_cmds);
 
   line_num += get_line(fl, buf);
-
+    if(*buf=='@') {
+     if(sscanf(buf,"@Version: %d", &version)!=1)
+            {
+             log("SYSERR: Format error in %s (version)", zname);
+             log("SYSERR: ...Line: %s", line);
+             exit(1);
+            }
+        line_num+=get_line(fl,buf);
+     }
   if (sscanf(buf, "#%hd", &Z.number) != 1) {
     log("SYSERR: Format error in %s, line %d", zname, line_num);
     exit(1);
@@ -1570,10 +1592,20 @@ void load_zones(FILE * fl, char *zonenam
   Z.builders = str_dup(buf);
 
   line_num += get_line(fl, buf);
-  if (sscanf(buf, " %hd %d %d ", &Z.top, &Z.lifespan, &Z.reset_mode) != 3) {
-    log("SYSERR: Format error in 3-constant line of %s", zname);
-    exit(1);
-  }
+
+
+   if (version >= 2) {
+      if  (sscanf(buf, " %hd %d %d %ld ", &Z.top, &Z.lifespan, &Z.reset_mode, &Z.zone_flags) != 4) {
+           log("SYSERR: Format error in 4-constant line of %s", zname);
+           exit(1);
+      }
+    }
+   else {
+    if (sscanf(buf, " %hd %d %d ", &Z.top, &Z.lifespan, &Z.reset_mode) != 3) {
+      log("SYSERR: Format error in 3-constant line of %s", zname);
+      exit(1);
+     }
+    }
   cmd_no = 0;
 
   for (;;) {
diff -uprN src_orig/db.h src_w_flags/db.h
--- src_orig/db.h	Mon Apr 19 11:55:18 1999
+++ src_w_flags/db.h	Mon May  3 22:02:26 1999
@@ -169,6 +169,7 @@ struct zone_data {
 
    char *builders;	    /* for OLC.  OBuild like extention,   *
                              * part of OLC+                       */
+   bitvector_t zone_flags;   /* for zone flags */
    /*
 	*  Reset mode:                              
 	*  0: Don't reset, and don't update age.    
@@ -245,3 +246,6 @@ extern char	*OK;
 extern char	*NOPERSON;
 extern char	*NOEFFECT;
 #endif
+
+#define CUR_WORLD_VERSION 1
+#define CUR_ZONE_VERSION 2
diff -uprN src_orig/olc.h src_w_flags/olc.h
--- src_orig/olc.h	Tue Mar 30 15:32:09 1999
+++ src_w_flags/olc.h	Tue May  4 00:14:15 1999
@@ -30,6 +30,7 @@
  * Macros, defines, structs and globals for the OLC suite.
  */
 
+#define NUM_ZONE_FLAGS		5
 #define NUM_ROOM_FLAGS 		18
 #define NUM_ROOM_SECTORS	10
 
@@ -238,6 +239,7 @@ extern struct olc_save_info *olc_save_li
 #define ZEDIT_ZONE_BUILDERS		15
 #define ZEDIT_PROB                      16
 #define ZEDIT_PROB2                     17
+#define ZEDIT_ZONE_FLAGS		18
 
 /*
  * Submodes of MEDIT connectedness.
diff -uprN src_orig/structs.h src_w_flags/structs.h
--- src_orig/structs.h	Wed Apr 28 10:15:47 1999
+++ src_w_flags/structs.h	Mon May  3 22:39:30 1999
@@ -83,6 +83,17 @@
 #define ROOM_FLY                (1 << 16)  /* Flying room only          */
 #define ROOM_TELEPORT           (1 << 17)  /* Teleport room             */
 
+
+/* Zone info: Used in zone_data.zone_flags */
+#define ZONE_OPEN              (1 << 0)
+#define ZONE_CLOSED            (1 << 1)
+#define ZONE_NORECALL          (1 << 2)
+#define ZONE_NOSUMMON          (1 << 3)
+#define ZONE_REMORT_ONLY       (1 << 4)
+
+
+
+
 /* Exit info: used in room_data.dir_option.exit_info */
 #define EX_ISDOOR		(1 << 0)   /* Exit is a door		*/
 #define EX_CLOSED		(1 << 1)   /* The door is closed	*/
diff -uprN src_orig/utils.h src_w_flags/utils.h
--- src_orig/utils.h	Wed Apr 28 10:17:33 1999
+++ src_w_flags/utils.h	Mon May  3 22:45:39 1999
@@ -236,6 +236,7 @@ void	update_pos(struct char_data *victim
 #define AFF_FLAGS(ch)  ((ch)->char_specials.saved.affected_by)
 #define ROOM_FLAGS(loc)        (world[(loc)].room_flags)
 #define SPELL_ROUTINES(spl)    (spell_info[spl].routines)
+#define ZONE_FLAGS(loc)		(zone[(loc)].zone_flags)
 
 #define IS_NPC(ch)	(IS_SET(MOB_FLAGS(ch), MOB_ISNPC))
 /* #define IS_NPC(ch)	(GET_PFILEPOS(ch) == -1)	Not yet. */
@@ -246,6 +247,9 @@ void	update_pos(struct char_data *victim
 #define AFF_FLAGGED(ch, flag) (IS_SET(AFF_FLAGS(ch), (flag)))
 #define PRF_FLAGGED(ch, flag) (IS_SET(PRF_FLAGS(ch), (flag)))
 #define ROOM_FLAGGED(loc, flag) (IS_SET(ROOM_FLAGS(loc), (flag)))
+
+#define ZONE_FLAGGED(loc, flag)  (IS_SET(ZONE_FLAGS(loc), (flag)))
+
 #define EXIT_FLAGGED(exit, flag) (IS_SET((exit)->exit_info, (flag)))
 #define OBJVAL_FLAGGED(obj, flag) (IS_SET(GET_OBJ_VAL((obj), 1), (flag)))
 #define OBJWEAR_FLAGGED(obj, flag) (IS_SET((obj)->obj_flags.wear_flags, (flag)))
diff -uprN src_orig/zedit.c src_w_flags/zedit.c
--- src_orig/zedit.c	Mon Apr 19 12:06:22 1999
+++ src_w_flags/zedit.c	Tue May  4 01:15:31 1999
@@ -36,6 +36,7 @@ extern struct obj_data *obj_proto;
 extern struct index_data *obj_index;
 extern char *equipment_types[];
 extern char *dirs[];
+extern const char *zone_bits[];
 
 /*-------------------------------------------------------------------*/
 
@@ -57,6 +58,7 @@ void zedit_save_internally(struct descri
 void zedit_save_to_disk(int zone_num);
 void zedit_create_index(int znum, char *type);
 void zedit_new_zone(struct char_data *ch, int vzone_num);
+void zedit_disp_flag_menu(struct descriptor_data *d);
 
 /*-------------------------------------------------------------------*/
 
@@ -93,6 +95,7 @@ void zedit_setup(struct descriptor_data 
   zone->lifespan = zone_table[OLC_ZNUM(d)].lifespan;
   zone->top = zone_table[OLC_ZNUM(d)].top;
   zone->reset_mode = zone_table[OLC_ZNUM(d)].reset_mode;
+  zone->zone_flags = zone_table[OLC_ZNUM(d)].zone_flags;
   /*
    * The remaining fields are used as a 'has been modified' flag  
    */
@@ -289,6 +292,7 @@ void zedit_new_zone(struct char_data *ch
   new_table[i].lifespan = 30;
   new_table[i].age = 0;
   new_table[i].reset_mode = 2;
+  new_table[i].zone_flags = 0;
   /*
    * No zone commands, just terminate it with an 'S'
    */
@@ -457,6 +461,7 @@ void zedit_save_internally(struct descri
     zone_table[OLC_ZNUM(d)].top = OLC_ZONE(d)->top;
     zone_table[OLC_ZNUM(d)].reset_mode = OLC_ZONE(d)->reset_mode;
     zone_table[OLC_ZNUM(d)].lifespan = OLC_ZONE(d)->lifespan;
+    zone_table[OLC_ZNUM(d)].zone_flags = OLC_ZONE(d)->zone_flags;
   }
   olc_add_to_save_list(zone_table[OLC_ZNUM(d)].number, OLC_SAVE_ZONE);
 }
@@ -485,10 +490,12 @@ void zedit_save_to_disk(int zone_num)
     return;
   }
 
+  fprintf(zfile,"@Version: %d\n",CUR_ZONE_VERSION);
+
   /*
    * Print zone header to file  
    */
-  fprintf(zfile, "#%d\n" "%s~\n" "%s~\n" "%d %d %d\n",
+  fprintf(zfile, "#%d\n" "%s~\n" "%s~\n" "%d %d %d %ld\n",
 	  zone_table[zone_num].number,
 	  (zone_table[zone_num].name && *zone_table[zone_num].name)
 		? zone_table[zone_num].name : "undefined",
@@ -496,7 +503,8 @@ void zedit_save_to_disk(int zone_num)
                 ? zone_table[zone_num].builders : "",
 	  zone_table[zone_num].top,
 	  zone_table[zone_num].lifespan,
-	  zone_table[zone_num].reset_mode
+	  zone_table[zone_num].reset_mode,
+          zone_table[zone_num].zone_flags
 	  );
 
 #if defined(ZEDIT_HELP_IN_FILE)
@@ -810,6 +818,8 @@ void zedit_disp_menu(struct descriptor_d
   get_char_cols(d->character);
   room = real_room(OLC_NUM(d));
  
+  sprintbit((long)OLC_ZONE(d)->zone_flags, zone_bits, buf1);
+
   /*
    * Menu header  
    */
@@ -823,7 +833,8 @@ send_to_char(buf, d->character);
 	  "%sZ%s) Zone name   : %s%s\r\n"
 	  "%sL%s) Lifespan    : %s%d minutes\r\n"
 	  "%sT%s) Top of zone : %s%d\r\n"
-	  "%sR%s) Reset Mode  : %s%s%s\r\n"
+	  "%sR%s) Reset Mode  : %s%s\r\n"
+          "%sF%s) Zone Flags  : %s%s%s\r\n"
 	  "[Command list]\r\n",
 
 	  cyn, OLC_NUM(d), nrm,
@@ -836,7 +847,8 @@ send_to_char(buf, d->character);
 	  ((OLC_ZONE(d)->reset_mode == 1) ?
 	   "Reset when no players are in zone." :
 	   "Normal reset.") :
-	  "Never reset", nrm
+	  "Never reset",
+          grn, nrm, yel, buf1, nrm
 	  );
 
   /*
@@ -1123,7 +1135,7 @@ void zedit_disp_arg4(struct descriptor_d
 
 void zedit_parse(struct descriptor_data *d, char *arg)
 {
-  int pos, i = 0;
+  int pos, i = 0, number;
 
   switch (OLC_MODE(d)) {
 /*-------------------------------------------------------------------*/
@@ -1231,8 +1243,8 @@ void zedit_parse(struct descriptor_data 
       break;
     case 'b':
     case 'B':
-      if (GET_LEVEL(d->character) < LVL_IMPL) {
-        send_to_char("Only Implementors can modify the builder list.\r\n", d->character);
+      if (GET_LEVEL(d->character) < LVL_COIMPL) {
+        send_to_char("Only COIMPL or higher can modify the builder list.\r\n", d->character);
         zedit_disp_menu(d);
       } else { 
         /*
@@ -1250,6 +1262,10 @@ void zedit_parse(struct descriptor_data 
       send_to_char("Which command? ", d->character);
       OLC_MODE(d) = ZEDIT_PROB;
       break;
+    case 'f':
+    case 'F':
+      zedit_disp_flag_menu(d);
+      break;
     default:
       zedit_disp_menu(d);
       break;
@@ -1599,6 +1615,27 @@ case ZEDIT_ARG4:
     }
     break;
 
+/* --------------------------------------------------------------- */
+  case ZEDIT_ZONE_FLAGS:
+
+    number = atoi(arg);
+    if ((number < 0) || (number > NUM_ZONE_FLAGS)) {
+      send_to_char("That is not a valid choice!\r\n", d->character);
+      zedit_disp_flag_menu(d);
+      }
+    else
+      if (number == 0) {
+      zedit_disp_menu(d); 
+       break; 
+       }
+    else {
+      TOGGLE_BIT(OLC_ZONE(d)->zone_flags, 1 << (number - 1));
+      OLC_ZONE(d)->number = 1;
+      zedit_disp_flag_menu(d);
+    }
+    return;
+
+  break;
 /*-------------------------------------------------------------------*/
   case ZEDIT_ZONE_LIFE:
     /*
@@ -1637,6 +1674,28 @@ case ZEDIT_ARG4:
     break;
   }
 }
+
+void zedit_disp_flag_menu(struct descriptor_data *d)
+{
+  int counter, columns = 0;
+
+  get_char_cols(d->character);
+#if defined(CLEAR_SCREEN)
+sprintf(buf, "%c[H%c[J", 27, 27);
+send_to_char(buf, d->character);
+#endif
+  for (counter = 0; counter < NUM_ZONE_FLAGS; counter++) {
+    sprintf(buf, "%s%2d%s) %-20.20s %s", grn, counter + 1, nrm,
+		zone_bits[counter], !(++columns % 2) ? "\r\n" : "");
+    send_to_char(buf, d->character);
+  }
+  sprintbit(OLC_ZONE(d)->zone_flags, zone_bits, buf1);
+  sprintf(buf, "\r\nZone flags: %s%s%s\r\n"
+	  "Enter zone flags, 0 to quit : ", cyn, buf1, nrm);
+  send_to_char(buf, d->character);
+  OLC_MODE(d) = ZEDIT_ZONE_FLAGS;
+}
+
 
 /*
  * End of parse_zedit()  


ZONE FLAGS:

The zoneflags.diff is how I added zone flags with the help of
"Angus Mezick" . He helped me get the file format
and version setup, so original files can be used. A lot of thanks to 
him and credit to him for that. The rest was adding in olc support.
I don't want credit for this. I just have the satisfaction of returning
to the community for all the help I receive. If credit is due, please
give it to Angus!

I have George's Buffers installed, so you might have to modify a line
in db.c to get it correct.

I know I have seen many question on the mailing list on zone flags
so I hope this helps all those in need of something similar.

The only thing you should have to do now, is put checks into act.movement.c
act.wizard.c, and probably spells (for sum/word of recall/etc) to check
zone_flags.

Lastly, use this file at your own risk (standard disclaimer). You take full
responsibility for your files and any damage that might result (MAKE A FULL
BACKUP prior to adding).

Del
caminturn@earthlink.net

<< FTP Uploads 1999/05/11 | Reply | View as text | Threaded | GlobalChat 2.0 >>

 


Related Links
  Del
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.