Difference for common/map.c from version 1.31 to 1.32


version 1.31 version 1.32
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_map_c =   * static char *rcsid_map_c =
  *   "$Id: map.c,v 1.31 2001/12/19 08:53:58 garbled Exp $";   *   "$Id: map.c,v 1.32 2002/01/01 23:37:54 garbled Exp $";
  */   */
   
 /*  /*
Line 119
 
Line 119
 }  }
   
 /*  /*
    * same as create_pathname, but for the overlay maps.
    */
   
   char *create_overlay_pathname (char *name) {
       static char buf[MAX_BUF];
   
       /* Why?  having extra / doesn't confuse unix anyplace?  Dependancies
        * someplace else in the code? msw 2-17-97
        */
       if (*name == '/')
         sprintf (buf, "%s/%s%s", settings.localdir, settings.mapdir, name);
       else
         sprintf (buf, "%s/%s/%s", settings.localdir, settings.mapdir, name);
       return (buf);
   }
   
   /*
  * This makes absolute path to the itemfile where unique objects   * This makes absolute path to the itemfile where unique objects
  * will be saved. Converts '/' to '@'. I think it's essier maintain   * will be saved. Converts '/' to '@'. I think it's essier maintain
  * files than full directory structure, but if this is problem it can    * files than full directory structure, but if this is problem it can
Line 548
 
Line 565
  LOG(llevDebug,"Discarded object %s - invalid archetype.\n",op->name);   LOG(llevDebug,"Discarded object %s - invalid archetype.\n",op->name);
      continue;       continue;
  }   }
   
    if (!(mapflags & MAP_OVERLAY))
       SET_FLAG(op, FLAG_OBJ_ORIGINAL);
   
  switch(i) {   switch(i) {
    case LL_NORMAL:     case LL_NORMAL:
      insert_ob_in_map(op,m,op,INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP);       insert_ob_in_map(op,m,op,INS_NO_MERGE | INS_NO_WALK_ON | INS_ON_TOP);
Line 572
 
Line 593
  * and we only save the head of multi part objects - this is needed   * and we only save the head of multi part objects - this is needed
  * in order to do map tiling properly.   * in order to do map tiling properly.
  */   */
 void save_objects (mapstruct *m, FILE *fp, FILE *fp2) {  void save_objects (mapstruct *m, FILE *fp, FILE *fp2, int flag) {
     int i, j = 0,unique=0;      int i, j = 0,unique=0;
     object *op,  *otmp;      object *op,  *otmp;
     /* first pass - save one-part objects */      /* first pass - save one-part objects */
Line 596
 
Line 617
  if (unique || QUERY_FLAG(op, FLAG_UNIQUE))   if (unique || QUERY_FLAG(op, FLAG_UNIQUE))
      save_object( fp2 , op, 3);       save_object( fp2 , op, 3);
  else   else
        if (flag == 0 ||
    (flag == 2 && (!QUERY_FLAG(op, FLAG_OBJ_ORIGINAL) &&
    !QUERY_FLAG(op, FLAG_UNPAID))))
      save_object(fp, op, 3);       save_object(fp, op, 3);
   
 #if 0  #if 0
Line 866
 
Line 890
     LOG(llevDebug, "load_original_map: %s (%x)\n", filename,flags);      LOG(llevDebug, "load_original_map: %s (%x)\n", filename,flags);
     if (flags & MAP_PLAYER_UNIQUE)       if (flags & MAP_PLAYER_UNIQUE)
  strcpy(pathname, filename);   strcpy(pathname, filename);
       else if (flags & MAP_OVERLAY)
    strcpy(pathname, create_overlay_pathname(filename));
     else      else
  strcpy(pathname, create_pathname(filename));   strcpy(pathname, create_pathname(filename));
   
Line 948
 
Line 974
     return m;      return m;
 }  }
   
   /*
    * Loads a map, which has been loaded earlier, from file.
    * Return the map object we load into (this can change from the passed
    * option if we can't find the original map)
    */
   
   mapstruct *load_overlay_map(char *filename, mapstruct *m) {
       FILE *fp;
       int comp;
       char buf[MAX_BUF];
       char pathname[MAX_BUF];
   
       strcpy(pathname, create_overlay_pathname(filename));
   
       if((fp=open_and_uncompress(pathname, 0, &comp))==NULL) {
    LOG(llevDebug,"Can't open overlay %s\n", pathname);
    strcpy(buf, m->path);
    delete_map(m);
           m = load_original_map(buf, 0);
    if(m==NULL) return NULL;
    (*fix_auto_apply_func)(m); /* Chests which open as default */
    return m;
       }
      
       if (load_map_header(fp, m)) {
    LOG(llevError,"Error loading map header for overlay %s (%s)\n",
        m->path, pathname);
    delete_map(m);
           m = load_original_map(m->path, 0);
    return NULL;
       }
       m->compressed = comp;
       /*allocate_map(m);*/
   
       m->in_memory=MAP_LOADING;
       load_objects (m, fp, 0);
       close_and_delete(fp, comp);
       m->in_memory=MAP_IN_MEMORY;
       return m;
   }
   
 /******************************************************************************  /******************************************************************************
  * This is the start of unique map handling code   * This is the start of unique map handling code
  *****************************************************************************/   *****************************************************************************/
Line 1031
 
Line 1098
     }      }
          
     if (flag || (m->unique)) {      if (flag || (m->unique)) {
  if (!m->unique)   if (!m->unique) { /* flag is set */
        if (flag == 2)
    strcpy(filename, create_overlay_pathname(m->path));
        else
      strcpy (filename, create_pathname (m->path));       strcpy (filename, create_pathname (m->path));
  else /* means flag must be set */   } else
      strcpy (filename, m->path);       strcpy (filename, m->path);
   
  /* If the compression suffix already exists on the filename, don't   /* If the compression suffix already exists on the filename, don't
Line 1086
 
Line 1156
     if (m->msg) fprintf(fp,"msg\n%sendmsg\n", m->msg);      if (m->msg) fprintf(fp,"msg\n%sendmsg\n", m->msg);
     if (m->unique) fprintf(fp,"unique %d\n", m->unique);      if (m->unique) fprintf(fp,"unique %d\n", m->unique);
     if (m->outdoor) fprintf(fp,"outdoor %d\n", m->outdoor);      if (m->outdoor) fprintf(fp,"outdoor %d\n", m->outdoor);
       if (m->temp) fprintf(fp, "temp %d\n", m->temp);
       if (m->pressure) fprintf(fp, "pressure %d\n", m->pressure);
       if (m->humid) fprintf(fp, "humid %d\n", m->humid);
       if (m->windspeed) fprintf(fp, "windspeed %d\n", m->windspeed);
       if (m->winddir) fprintf(fp, "winddir %d\n", m->winddir);
       if (m->sky) fprintf(fp, "sky %d\n", m->sky);
   
     /* Save any tiling information */      /* Save any tiling information */
     for (i=0; i<4; i++)      for (i=0; i<4; i++)
  if (m->tile_path[i])   if (m->tile_path[i])
Line 1099
 
Line 1176
      * player)       * player)
      */       */
     fp2 = fp; /* save unique items into fp2 */      fp2 = fp; /* save unique items into fp2 */
     if (flag == 0 && !m->unique) {      if ((flag == 0 || flag == 2) && !m->unique) {
  sprintf (buf,"%s.v00",create_items_path (m->path));   sprintf (buf,"%s.v00",create_items_path (m->path));
  if ((fp2 = fopen (buf, "w")) == NULL) {   if ((fp2 = fopen (buf, "w")) == NULL) {
      LOG(llevError, "Can't open unique items file %s\n", buf);       LOG(llevError, "Can't open unique items file %s\n", buf);
  }   }
  save_objects (m, fp, fp2);   if (flag == 2)
        save_objects(m, fp, fp2, 2);
    else
        save_objects (m, fp, fp2, 0);
  if (fp2 != NULL) {   if (fp2 != NULL) {
      if (ftell (fp2) == 0) {       if (ftell (fp2) == 0) {
  fclose (fp2);   fclose (fp2);
Line 1115
 
Line 1195
      }       }
  }   }
     } else { /* save same file when not playing, like in editor */      } else { /* save same file when not playing, like in editor */
  save_objects (m, fp, fp);   save_objects(m, fp, fp, 0);
     }      }
   
     if (m->compressed && !flag)      if (m->compressed && !flag)
Line 1348
 
Line 1428
     /* Below here is stuff common to both first time loaded maps and      /* Below here is stuff common to both first time loaded maps and
      * temp maps.       * temp maps.
      */       */
       m=load_overlay_map(name, m);
       if (m==NULL)
    return NULL;
   
       decay_objects(m); /* start the decay */
     /* In case other objects press some buttons down */      /* In case other objects press some buttons down */
     update_buttons(m);      update_buttons(m);
     (*set_darkness_map_func)(m);      (*set_darkness_map_func)(m);


Legend:
line(s) removed in v.1.31 
line(s) changed
 line(s) added in v.1.32

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:13