Difference for common/map.c from version 1.9 to 1.10


version 1.9 version 1.10
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_map_c =   * static char *rcsid_map_c =
  *   "$Id: map.c,v 1.9 2000/10/12 17:17:04 peterm Exp $";   *   "$Id: map.c,v 1.10 2001/02/11 09:12:12 cvs Exp $";
  */   */
   
 /*  /*
Line 560
 
Line 560
 /*  /*
  * Loads (ands parses) the objects into a given map from the specified   * Loads (ands parses) the objects into a given map from the specified
  * file pointer.   * file pointer.
  * If block is true, the game will be blocked until all objects have   * mapflags is the same as we get with load_original_map
  * been loaded (this is needed to avoid certain critical regions).  
  */   */
   
 void load_objects (mapstruct *m, FILE *fp, int block) {  void load_objects (mapstruct *m, FILE *fp, int mapflags) {
     int i;      int i;
 #if defined(PROCESS_WHILE_LOADING) && CHECK_ACTIVE_MAPS  
     int  j = 0;  
 #endif  
   
     object *op, *prev=NULL,*last_more=NULL;      object *op, *prev=NULL,*last_more=NULL;
 /*    MapLook maplook;*/  
   
     op=get_object();      op=get_object();
     op->map = m; /* To handle buttons correctly */      op->map = m; /* To handle buttons correctly */
   
     while((i=load_object(fp,op,LO_REPEAT))) {      while((i=load_object(fp,op,LO_REPEAT, mapflags))) {
  /* if the archetype for the object is null, means that we   /* if the archetype for the object is null, means that we
  * got an invalid object.  Don't do anythign with it - the game   * got an invalid object.  Don't do anythign with it - the game
  * or editor will not be able to do anything with it either.   * or editor will not be able to do anything with it either.
Line 586
 
Line 580
  LOG(llevDebug,"Discarded object %s - invalid archetype.\n",op->name);   LOG(llevDebug,"Discarded object %s - invalid archetype.\n",op->name);
      continue;       continue;
  }   }
 #if 0  
  /* this hack allows for 'unused' altars (see below) to have a   
  * random god (see the 'god table' in god.c) associated w/ it -b.t.   
  */  
 #ifdef MULTIPLE_GODS  
  if(op->type==ALTAR && !op->value && !editor && !op->stats.sp)  
     if(baptize_altar(op))  
  LOG(llevDebug,"Baptized altar to %s\n",op->title);  
 #endif  
 #endif  
  switch(i) {   switch(i) {
    case LL_NORMAL:     case LL_NORMAL:
      insert_ob_in_map_simple(op,m);       insert_ob_in_map_simple(op,m);
 #if 1  
      if (op->inv) sum_weight(op);       if (op->inv) sum_weight(op);
 #else  
      if (op->inv) fix_container(op);  
 #endif  
      prev=op,last_more=op;       prev=op,last_more=op;
      break;       break;
 #if 0 /* internal inventories should be handled by load routine */  
    case 2:  
      op = insert_ob_in_ob(op,prev);  
      break;  
 #endif  
    case LL_MORE:     case LL_MORE:
      insert_ob_in_map_simple(op,m);       insert_ob_in_map_simple(op,m);
      op->head=prev,last_more->more=op,last_more=op;       op->head=prev,last_more->more=op,last_more=op;
      break;       break;
  }   }
   
  /* Small hack to set the floor object for the maps.  This  
  * increases the performance for color pixmaps, as not the floor  
  * and top object are easily accessible.  Before, it had to  
  * search through the objects for the map space to find the  
  * floor.  
  *  
  * This should probably be someplace else, but I could not  
  * figure out the set_map_ob function, which then calls the  
  * set_map function, in where the floor is determined.  
  * I am also assuming that the floor can not change.  As such,  
  * the floor only needs to be determined once.  
  * Mark Wedel (master@rahul.net)  
  */  
 #if 0  
  if (QUERY_FLAG(op,FLAG_IS_FLOOR)) {  
  maplook.face = op->face;  
  maplook.flags = 0;  
  m->floor[op->x+ m->mapx*op->y] = maplook;  
  }  
 #endif  
  op=get_object();   op=get_object();
         op->map = m;          op->map = m;
 #if defined(PROCESS_WHILE_LOADING) && CHECK_ACTIVE_MAPS  
  if(!block && j++>CHECK_ACTIVE_MAPS) {  
      j=0;  
      /* We don't want to freeze the whole game too long */  
      (*process_active_maps_func)();   
  }  
 #endif  
     }      }
     free_object(op);      free_object(op);
 }  }
Line 653
 
Line 601
 void save_objects (mapstruct *m, FILE *fp, FILE *fp2) {  void save_objects (mapstruct *m, FILE *fp, FILE *fp2) {
     int i, j = 0,unique=0;      int i, j = 0,unique=0;
     object *op, *tmp, *otmp;      object *op, *tmp, *otmp;
 #if 0 /*defined(PROCESS_WHILE_LOADING) && CHECK_ACTIVE_MAPS*/  
     int  elapsed = 0;  
 #endif  
     /* first pass - save one-part objects */      /* first pass - save one-part objects */
     for(i = 0; i < m->mapx; i++)      for(i = 0; i < m->mapx; i++)
  for (j = 0; j < m->mapy; j++) {   for (j = 0; j < m->mapy; j++) {
Line 679
 
Line 624
  else   else
      save_object(fp, op, 3);       save_object(fp, op, 3);
   
 /* Would be nice to let players still do stuff while a map is saving.  
  * The problem is, having a player enter a map that is in the process  
  * of being saved.  The maps needs to finish saving, and then be  
  * re-loaded.  
  */  
 #if 0 /*defined(PROCESS_WHILE_LOADING) && CHECK_ACTIVE_MAPS*/  
        if(elapsed++>CHECK_ACTIVE_MAPS) {  
  elapsed=0;  
  /* We don't want to freeze the whole game too long */  
  (*process_active_maps_func)();   
        }  
 #endif  
      }       }
  }   }
     /* second pass - save multi-part objects */      /* second pass - save multi-part objects */
Line 725
 
Line 658
  save_object(fp, tmp, 3);   save_object(fp, tmp, 3);
      }       }
  }   }
 #if 0 /*defined(PROCESS_WHILE_LOADING) && CHECK_ACTIVE_MAPS*/  
        if(elapsed++>CHECK_ACTIVE_MAPS) {  
  elapsed=0;  
  /* We don't want to freeze the whole game too long */  
  (*process_active_maps_func)();   
        }  
 #endif  
      }       }
  }   }
 }  }
Line 743
 
Line 669
  * flags correspond to those in map.h.  Main ones used are   * flags correspond to those in map.h.  Main ones used are
  * MAP_PLAYER_UNIQUE, in which case we don't do any name changes, and   * MAP_PLAYER_UNIQUE, in which case we don't do any name changes, and
  * MAP_BLOCK, in which case we block on this load.   * MAP_BLOCK, in which case we block on this load.
    * MAP_STYLE: style map - don't add active objects, don't add to server
    * managed map list.
  */   */
   
 mapstruct *load_original_map(char *filename, int flags) {  mapstruct *load_original_map(char *filename, int flags) {
Line 752
 
Line 680
     int comp;      int comp;
     char pathname[MAX_BUF];      char pathname[MAX_BUF];
          
     LOG(llevDebug, "load_original_map: %s\n", filename);      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      else
Line 766
 
Line 694
                  
     op = get_object();      op = get_object();
   
     if (!load_object(fp, op,LO_NEWFILE) || op->type != MAP) {      if (!load_object(fp, op,LO_NEWFILE, flags) || op->type != MAP) {
  LOG(llevError,"Error in map (%s) - map object not found\n", filename);   LOG(llevError,"Error in map (%s) - map object not found\n", filename);
         close_and_delete(fp, comp);          close_and_delete(fp, comp);
  return (NULL);   return (NULL);
Line 790
 
Line 718
     op->map = m;      op->map = m;
   
     m->in_memory=MAP_LOADING;      m->in_memory=MAP_LOADING;
     load_objects (m, fp, (flags & MAP_BLOCK?1:0));      load_objects (m, fp, flags & (MAP_BLOCK|MAP_STYLE));
     close_and_delete(fp, comp);      close_and_delete(fp, comp);
     m->in_memory=MAP_IN_MEMORY;      m->in_memory=MAP_IN_MEMORY;
     m->difficulty=calculate_difficulty(m);      m->difficulty=calculate_difficulty(m);
Line 836
 
Line 764
          
     op = get_object();      op = get_object();
   
     load_object(fp,op,LO_NEWFILE);      load_object(fp,op,LO_NEWFILE,0);
     if (op->arch == NULL || op->type != MAP) {      if (op->arch == NULL || op->type != MAP) {
  LOG(llevError,"Error in temporary map '%s'\n", m->path);   LOG(llevError,"Error in temporary map '%s'\n", m->path);
         m = load_original_map(m->path,0);          m = load_original_map(m->path,0);
Line 916
 
Line 844
     m->in_memory=MAP_LOADING;      m->in_memory=MAP_LOADING;
     if (m->tmpname == NULL)    /* if we have loaded unique items from */      if (m->tmpname == NULL)    /* if we have loaded unique items from */
       delete_unique_items(m); /* original map before, don't duplicate them */        delete_unique_items(m); /* original map before, don't duplicate them */
     load_object(fp, NULL, LO_NOREAD);      load_object(fp, NULL, LO_NOREAD,0);
     load_objects (m, fp, 0);      load_objects (m, fp, 0);
     close_and_delete(fp, comp);      close_and_delete(fp, comp);
     m->in_memory=MAP_IN_MEMORY;      m->in_memory=MAP_IN_MEMORY;


Legend:
line(s) removed in v.1.9 
line(s) changed
 line(s) added in v.1.10

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