Difference for common/anim.c from version 1.10 to 1.11


version 1.10 version 1.11
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_anim_c =   * static char *rcsid_anim_c =
  *   "$Id: anim.c,v 1.10 2001/11/28 04:44:41 michtoen Exp $";   *   "$Id: anim.c,v 1.11 2002/01/02 06:53:23 garbled Exp $";
  */   */
   
 /*  /*
Line 118
 
Line 118
     LOG(llevDebug,"done. got (%d)\n", num_animations);      LOG(llevDebug,"done. got (%d)\n", num_animations);
 }  }
   
 static int anim_compare(const void *a, const void *b) {  static int anim_compare(Animations *a, Animations *b) {
     return strcmp(((Animations*)a)->name,((Animations*) b)->name);      return strcmp(a->name, b->name);
 }  }
   
 /* Tries to find the animation id that matches name.  Returns an integer match   /* Tries to find the animation id that matches name.  Returns an integer match
Line 131
 
Line 131
   
     search.name = name;      search.name = name;
   
 #ifdef WIN32  
     match = (Animations*)bsearch(&search, animations, (num_animations+1),   
         sizeof(Animations), anim_compare);  
 #else  
     match = (Animations*)bsearch(&search, animations, (num_animations+1),       match = (Animations*)bsearch(&search, animations, (num_animations+1),
         sizeof(Animations), (int (*)())anim_compare);          sizeof(Animations), (int (*)())anim_compare);
 #endif  
   
   
     if (match) return match->num;      if (match) return match->num;
Line 146
 
Line 141
 }  }
   
 /*  /*
  * animate_object(object, count) updates the face-variable of an object.   * animate_object(object) updates the face-variable of an object.
  * If the object is the head of a multi-object, all objects are animated.   * If the object is the head of a multi-object, all objects are animated.
  */   */
   
 void animate_object(object *op, int count) {  void animate_object(object *op) {
     int max_state;  /* Max animation state object should be drawn in */      int max_state;  /* Max animation state object should be drawn in */
     int base_state; /* starting index # to draw from */      int base_state; /* starting index # to draw from */
     int dir;      int dir=op->direction;
     register object *oph = op;  
   
 #ifdef DEBUG /* hm, should really not happens */  
     if(!op->animation_id || !NUM_ANIMATIONS(op)) {      if(!op->animation_id || !NUM_ANIMATIONS(op)) {
  LOG(llevError,"Object lacks animation.\n");   LOG(llevError,"Object lacks animation.\n");
  dump_object(op);   dump_object(op);
  return;   return;
     }      }
 #endif      ++op->state;    /* increase draw state */
   
     /*  a animation is not only changing by anim_speed.  
      *  If we turn the object by teleporter for example, its direction & facing can  
      *  change, outside the normal animation loop.   
      *  We have then to change the frame and not increase the state */  
        
     /* when we change to "one arch/one png, we must use this also for */  
     /* the code above ... only the head then has an animation */  
     /* which gets updated one time when this is called per tick */  
     if(op->head)   
         oph=op->head;  
   
     op->state+=count;    /* increase draw state (of the animation frame) */      if (op->head) dir=op->head->direction;
     if(!count)  
     {  
         /* object needs no update for moving */  
         if(oph->anim_enemy_dir == oph->anim_enemy_dir_last &&   
                 oph->anim_moving_dir == oph->anim_moving_dir_last &&  
                 oph->anim_last_facing == oph->anim_last_facing_last)  
             return; /* no need to set the frame new */          
     }  
     dir=oph->direction;  
   
     /* If object is turning, then max animation state is half through the      /* If object is turning, then max animation state is half through the
      * animations.  Otherwise, we can use all the animations.       * animations.  Otherwise, we can use all the animations.
Line 207
 
Line 180
     }      }
     else if (NUM_FACINGS(op)==8) {      else if (NUM_FACINGS(op)==8) {
  if (dir==0) base_state=0;   if (dir==0) base_state=0;
  else base_state = (dir-1)*(NUM_ANIMATIONS(op)/8); /* was 4  before - typo? */    else base_state = (dir-1)*(NUM_ANIMATIONS(op)/4);
     }  
     /* thats the new extended animation: base_state is */  
     /* 0: thats the corpse */  
     /* 1-8:  guard/stand_still anim frames */  
     /* 9-16: move anim frames */  
     /* 17-24: fight anim frames */  
     /* TODO: allow different number of faces in each frame */  
   
     else if (NUM_FACINGS(op)==25) {  
         /* we have targeted an enemy and face him. when me move, we strave sidewards */  
         if(oph->anim_enemy_dir != -1 && (!QUERY_FLAG(op,FLAG_RUN_AWAY) && !QUERY_FLAG(op,FLAG_SCARED)))  
         {  
             dir = oph->anim_enemy_dir;      /* lets face to the enemy position */  
             oph->anim_enemy_dir_last = oph->anim_enemy_dir;  
             oph->anim_moving_dir_last = -1;  
             if (!dir)   /* special case, same spot will be mapped to south dir */  
                 dir = 4;  
             oph->anim_last_facing = dir;  
             oph->anim_last_facing_last = -1;  
             dir +=16;  
         }  
         else if (oph->anim_moving_dir != -1)/* test of moving */  
         {  
             dir = oph->anim_moving_dir;      /* lets face in moving direction */  
             oph->anim_moving_dir_last = oph->anim_moving_dir;  
             oph->anim_enemy_dir_last = -1;  
             if (!dir)   /* special case, same spot will be mapped to south dir */  
                 dir = 4;  
             oph->anim_last_facing = dir;  
             oph->anim_last_facing_last = -1;  
             dir +=8;  
         }  
         else /* if nothing to do: object do nothing. use original facing */  
         {  
             dir = oph->anim_last_facing;      /* lets face to last direction we had done something */  
             oph->anim_last_facing_last = dir;  
             if (!dir)   /* special case, same spot will be mapped to south dir */  
                 dir = 4;  
               
         }  
   
         base_state = dir*(NUM_ANIMATIONS(op)/25);   
     }      }
          
     /* If beyond drawable states, reset */      /* If beyond drawable states, reset */
Line 272
 
Line 203
     }      }
 #endif  #endif
     if(op->more)      if(op->more)
  animate_object(op->more, count);   animate_object(op->more);
     /* update_object will also recursively update all the pieces.      /* update_object will also recursively update all the pieces.
      * as such, we call it last, and only call it for the head       * as such, we call it last, and only call it for the head
      * piece, and not for the other tail pieces.       * piece, and not for the other tail pieces.


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

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