Difference for server/apply.c from version 1.43 to 1.44


version 1.43 version 1.44
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_apply_c =   * static char *rcsid_apply_c =
  *   "$Id: apply.c,v 1.43 2001/06/29 05:59:46 mwedel Exp $";   *   "$Id: apply.c,v 1.44 2001/07/14 04:11:18 mwedel Exp $";
  */   */
 /*  /*
     CrossFire, A Multiplayer game for X-windows      CrossFire, A Multiplayer game for X-windows
Line 29
 
Line 29
 #include <living.h>  #include <living.h>
 #include <spells.h>  #include <spells.h>
 #include <skills.h>  #include <skills.h>
 #if defined(SunArchitecture) && !(OSMajorVersion == 5)  
 #include <sys/types.h>  
 #endif  
   
 #ifndef __CEXTRACT__  #ifndef __CEXTRACT__
 #include <sproto.h>  #include <sproto.h>
Line 693
 
Line 691
     SET_FLAG(item,FLAG_UNPAID);      SET_FLAG(item,FLAG_UNPAID);
   item->x=converter->x;    item->x=converter->x;
   item->y=converter->y;    item->y=converter->y;
   insert_ob_in_map(item,converter->map,converter);    insert_ob_in_map(item,converter->map,converter,0);
   return 1;    return 1;
 }  }
      
Line 1039
 
Line 1037
     remove_ob (op);      remove_ob (op);
     op->x += freearr_x[i];      op->x += freearr_x[i];
     op->y += freearr_y[i];      op->y += freearr_y[i];
     rv = insert_ob_in_map (op, op->map, shop_mat) == NULL;      rv = insert_ob_in_map (op, op->map, shop_mat,0) == NULL;
     goto ret;      goto ret;
   }    }
   
Line 1110
 
Line 1108
   }    }
   recursion_depth++;    recursion_depth++;
   
     if (trap->head) trap=trap->head;
   switch (trap->type)    switch (trap->type)
   {    {
   case PLAYERMOVER:    case PLAYERMOVER:
Line 1207
 
Line 1206
         if(!(trap->value=(tot>trap->weight)?1:0))          if(!(trap->value=(tot>trap->weight)?1:0))
           goto leave;            goto leave;
  SET_ANIMATION(trap, trap->value);   SET_ANIMATION(trap, trap->value);
         update_object(trap);          update_object(trap,UP_OBJ_FACE);
       }        }
       for (ab = trap->above, max=100, sound_was_played = 0;        for (ab = trap->above, max=100, sound_was_played = 0;
            --max && ab && ! QUERY_FLAG (ab, FLAG_FLYING); ab=ab->above)             --max && ab && ! QUERY_FLAG (ab, FLAG_FLYING); ab=ab->above)
Line 1308
 
Line 1307
     goto leave;      goto leave;
   
   case ENCOUNTER:    case ENCOUNTER:
 #ifdef RANDOM_ENCOUNTERS      /* may be some leftovers on this */
     if (victim->type == PLAYER && QUERY_FLAG (trap, FLAG_IS_FLOOR))  
       random_encounter (victim, trap);  
 #endif  
     goto leave;      goto leave;
   
   case SHOP_MAT:    case SHOP_MAT:
Line 1749
 
Line 1745
       remove_ob(treas);        remove_ob(treas);
       draw_find(op,treas);        draw_find(op,treas);
       treas->x=op->x,treas->y=op->y;        treas->x=op->x,treas->y=op->y;
       treas = insert_ob_in_map (treas, op->map, op);        treas = insert_ob_in_map (treas, op->map, op,0);
       if (treas && treas->type == RUNE && treas->level        if (treas && treas->type == RUNE && treas->level
           && QUERY_FLAG (op, FLAG_ALIVE))            && QUERY_FLAG (op, FLAG_ALIVE))
         spring_trap (treas, op);          spring_trap (treas, op);
Line 1760
 
Line 1756
     if ( ! was_destroyed (tmp, tmp_tag) && tmp->inv == NULL)      if ( ! was_destroyed (tmp, tmp_tag) && tmp->inv == NULL)
       decrease_ob (tmp);        decrease_ob (tmp);
   
   #if 0
       /* Can't rely on insert_ob_in_map to do any restacking,
        * so lets disable this.
        */
     if ( ! was_destroyed (op, op_tag)) {      if ( ! was_destroyed (op, op_tag)) {
       /* Done to re-stack map with player on top? */        /* Done to re-stack map with player on top? */
       SET_FLAG (op, FLAG_NO_APPLY);        SET_FLAG (op, FLAG_NO_APPLY);
       remove_ob (op);        remove_ob (op);
       insert_ob_in_map (op, op->map, NULL);        insert_ob_in_map (op, op->map, NULL,0);
       CLEAR_FLAG (op, FLAG_NO_APPLY);        CLEAR_FLAG (op, FLAG_NO_APPLY);
     }      }
   #endif
 }  }
   
   
Line 1839
 
Line 1840
     play_again(player);      play_again(player);
     player->map->players--;      player->map->players--;
 #if MAP_MAXTIMEOUT   #if MAP_MAXTIMEOUT
     player->map->timeout = MAP_TIMEOUT(player->map);      MAP_SWAP_TIME(player->map) = MAP_TIMEOUT(player->map);
 #endif  #endif
 }  }
   
Line 1966
 
Line 1967
 int manual_apply (object *op, object *tmp, int aflag)  int manual_apply (object *op, object *tmp, int aflag)
 {  {
   int rtn_script;    int rtn_script;
     if (tmp->head) tmp=tmp->head;
   
   if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) {    if (QUERY_FLAG (tmp, FLAG_UNPAID) && ! QUERY_FLAG (tmp, FLAG_APPLIED)) {
     if (op->type == PLAYER) {      if (op->type == PLAYER) {
       new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first.");        new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first.");
Line 1993
 
Line 1996
     play_sound_map(op->map, op->x, op->y, SOUND_TURN_HANDLE);      play_sound_map(op->map, op->x, op->y, SOUND_TURN_HANDLE);
     tmp->value=tmp->value?0:1;      tmp->value=tmp->value?0:1;
     SET_ANIMATION(tmp, tmp->value);      SET_ANIMATION(tmp, tmp->value);
     update_object(tmp);      update_object(tmp,UP_OBJ_FACE);
     push_button(tmp);      push_button(tmp);
     return 1;      return 1;
   
Line 2605
 
Line 2608
   
     tmp->x=op->x,tmp->y=op->y;      tmp->x=op->x,tmp->y=op->y;
     SET_FLAG(tmp,FLAG_UNPAID);      SET_FLAG(tmp,FLAG_UNPAID);
     insert_ob_in_map(tmp,op->map,NULL);      insert_ob_in_map(tmp,op->map,NULL,0);
     CLEAR_FLAG(op,FLAG_AUTO_APPLY);      CLEAR_FLAG(op,FLAG_AUTO_APPLY);
     identify(tmp);      identify(tmp);
     break;      break;
Line 2647
 
Line 2650
   
   if(m==NULL) return;    if(m==NULL) return;
   
   for(x=0;x<m->map_object->x;x++)    for(x=0;x<MAP_WIDTH(m);x++)
     for(y=0;y<m->map_object->y;y++)      for(y=0;y<MAP_HEIGHT(m);y++)
       for(tmp=get_map_ob(m,x,y);tmp!=NULL;tmp=above) {        for(tmp=get_map_ob(m,x,y);tmp!=NULL;tmp=above) {
         above=tmp->above;          above=tmp->above;
   
Line 2682
 
Line 2685
             create_treasure(tmp->randomitems, tmp, GT_APPLY,              create_treasure(tmp->randomitems, tmp, GT_APPLY,
                             m->difficulty,0);                              m->difficulty,0);
       }        }
   for(x=0;x<m->map_object->x;x++)    for(x=0;x<MAP_WIDTH(m);x++)
     for(y=0;y<m->map_object->y;y++)      for(y=0;y<MAP_HEIGHT(m);y++)
       for(tmp=get_map_ob(m,x,y);tmp!=NULL;tmp=tmp->above)        for(tmp=get_map_ob(m,x,y);tmp!=NULL;tmp=tmp->above)
  if (tmp->above &&   if (tmp->above &&
             (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))              (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
Line 2868
 
Line 2871
 #endif  #endif
 }  }
   
 void apply_changes_to_player(object *player, object *change) {  void apply_changes_to_player(object *pl, object *change) {
   int excess_stat=0;  /* if the stat goes over the maximum    int excess_stat=0;  /* if the stat goes over the maximum
                          for the race, put the excess stat some                           for the race, put the excess stat some
                          where else. */                           where else. */
   
   switch (change->type) {    switch (change->type) {
   case CLASS:    case CLASS: {
     {       living *stats = &(pl->contr->orig_stats);
       living *stats = &(player->contr->orig_stats);  
       living *ns = &(change->stats);        living *ns = &(change->stats);
       object *walk;        object *walk;
       int flag_change_face=1;        int flag_change_face=1;
   
       /* the following code assigns stats up to the stat max        /* the following code assigns stats up to the stat max
          for the race, and if the stat max is exceeded,         * for the race, and if the stat max is exceeded,
          tries to randomly reassign the excess stat */         * tries to randomly reassign the excess stat
         */
       int i,j;        int i,j;
       for(i=0;i<7;i++) {        for(i=0;i<7;i++) {
         int stat=get_attr_value(stats,i);          int stat=get_attr_value(stats,i);
         int race_bonus = get_attr_value(&(player->arch->clone.stats),i);   int race_bonus = get_attr_value(&(pl->arch->clone.stats),i);
         stat += get_attr_value(ns,i);          stat += get_attr_value(ns,i);
         if(stat > 20 + race_bonus) {          if(stat > 20 + race_bonus) {
           excess_stat++;            excess_stat++;
Line 2894
 
Line 2898
         }          }
         set_attr_value(stats,i,stat);          set_attr_value(stats,i,stat);
       }        }
   
       for(j=0;excess_stat >0 && j<100;j++)  {/* try 100 times to assign excess stats */        for(j=0;excess_stat >0 && j<100;j++)  {/* try 100 times to assign excess stats */
         int i = RANDOM() %7;          int i = RANDOM() %7;
         int stat=get_attr_value(stats,i);          int stat=get_attr_value(stats,i);
         int race_bonus = get_attr_value(&(player->arch->clone.stats),i);   int race_bonus = get_attr_value(&(pl->arch->clone.stats),i);
         if(i==CHA) continue;  /* exclude cha from this */          if(i==CHA) continue;  /* exclude cha from this */
         if( stat < 20 + race_bonus) {          if( stat < 20 + race_bonus) {
           change_attr_value(stats,i,1);            change_attr_value(stats,i,1);
Line 2906
 
Line 2911
       }        }
   
       /* insert the randomitems from the change's treasurelist into        /* insert the randomitems from the change's treasurelist into
  the player ref: player.c*/        * the player ref: player.c
         */
       if(change->randomitems!=NULL)         if(change->randomitems!=NULL)
  give_initial_items(player,change->randomitems);   give_initial_items(pl,change->randomitems);
   
   
       /* set up the face, for some races. */        /* set up the face, for some races. */
   
       /* first, look for the force object banning         /* first, look for the force object banning
  changing the face.  Certain races never change face with class. */        * changing the face.  Certain races never change face with class.
       for(walk=player->inv;walk!=NULL;walk=walk->below)        */
        for(walk=pl->inv;walk!=NULL;walk=walk->below)
  if (!strcmp(walk->name,"NOCLASSFACECHANGE")) flag_change_face=0;   if (!strcmp(walk->name,"NOCLASSFACECHANGE")) flag_change_face=0;
   
       if(flag_change_face) {        if(flag_change_face) {
  player->animation_id = GET_ANIM_ID(change);   pl->animation_id = GET_ANIM_ID(change);
  player->face = change->face;   pl->face = change->face;
   
  if(QUERY_FLAG(change,FLAG_ANIMATE))    if(QUERY_FLAG(change,FLAG_ANIMATE))
    SET_FLAG(player,FLAG_ANIMATE);       SET_FLAG(pl,FLAG_ANIMATE);
  else   else
    CLEAR_FLAG(player,FLAG_ANIMATE);       CLEAR_FLAG(pl,FLAG_ANIMATE);
       }        }
   
       /* check the special case of can't use weapons */        /* check the special case of can't use weapons */
       /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(player,FLAG_USE_WEAPON);*/       /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON);*/
       if(!strcmp(change->name,"monk")) CLEAR_FLAG(player,FLAG_USE_WEAPON);       if(!strcmp(change->name,"monk")) CLEAR_FLAG(pl,FLAG_USE_WEAPON);
   
       break;        break;
   
     }      }
   }    }
       
     
 }  }
   
   


Legend:
line(s) removed in v.1.43 
line(s) changed
 line(s) added in v.1.44

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