Esempio n. 1
0
static void
list_untagged_handler (mu_imap_t imap, mu_list_t resp, void *data)
{
  struct list_closure *clos = data;
  struct imap_list_element *elt;
  size_t count;
  
  if (clos->error_code)
    return;

  mu_list_count (resp, &count);
  if (count == 4 &&
      _mu_imap_list_nth_element_is_string (resp, 0, clos->command))
    {
      struct mu_list_response *rp;

      rp = calloc (1, sizeof (*rp));
      if (!rp)
	{
	  clos->error_code = ENOMEM;
	  return;
	}
	  
      elt = _mu_imap_list_at (resp, 1);
      if (!(elt && elt->type == imap_eltype_list))
	return;
      rp->type = 0;
      mu_list_foreach (elt->v.list, list_attr_conv, rp);

      elt = _mu_imap_list_at (resp, 3);
      if (!(elt && elt->type == imap_eltype_string))
	return;
      rp->name = strdup (elt->v.string);
      if (!rp->name)
	{
	  free (rp);
	  clos->error_code = ENOMEM;
	  return;
	}

      elt = _mu_imap_list_at (resp, 2);
      if (!elt)
	return;
      if (_mu_imap_list_element_is_nil (elt))
	{
	  rp->separator = 0;
	  rp->level = 0;
	}
      else if (elt->type != imap_eltype_string)
	return;
      else
	{
	  rp->separator = elt->v.string[0];
	  rp->level = count_level (rp->name, rp->separator);
	}
      if ((clos->error_code = mu_list_append (clos->retlist, rp)))
	mu_list_response_free (rp);
    }
}
Esempio n. 2
0
// Check if a player doesn't get too many high casting level spell
bool check_max_spell_level( CHAR_DATA *ch, int sn ) {
  // Modified by SinaC 2001
  /*
  // if we already have more than one spell level MAX-1, we can't have spell level MAX
  if ( count_level( ch, MAX_CASTING_LEVEL-1 ) > 1
       && ch->pcdata->ability_info[sn].casting_level == MAX_CASTING_LEVEL-1 ) 
    return TRUE;
  // if we already have a spell level MAX, other spells can only be level MAX-2
  if ( count_level( ch, MAX_CASTING_LEVEL ) > 0 
       && ch->pcdata->ability_info[sn].casting_level == MAX_CASTING_LEVEL-2 ) 
    return TRUE;

  return FALSE;
  */
/*
  switch ( class_max_casting_rule( ch ) ) {
  default:
    bug("check_max_spell_level: invalid max_casting_rule: %d",
	class_max_casting_rule( ch ) );
    return TRUE;
    break;
    // case -1
  case CASTING_RULE_SKILL_ALL_LVL5:
    // only skills can be learned at higher level
    if ( ability_table[sn].type != TYPE_SKILL
	 || ch->pcdata->ability_info[sn].casting_level >= 5 )
      return TRUE;
    break;
    // case 0
  case CASTING_RULE_ALL_LVL1:
    // no casting level > 1
    if ( ch->pcdata->ability_info[sn].casting_level >= 1 )
      return TRUE;
    break;
    //case 1:
  case CASTING_RULE_ALL_LVL3:
    // no casting level > 3
    if ( ch->pcdata->ability_info[sn].casting_level >= 3 )
      return TRUE;
    break;
    //case 2:
  case CASTING_RULE_ALL_LVL4:
    // no casting level > 4
    if ( ch->pcdata->ability_info[sn].casting_level >= 4 )
      return TRUE;
    break;
    //case 3:
  case CASTING_RULE_LVL5_OTHER_LVL3:
    // one to level 5 and other to level 3
    if ( count_level( ch, 4 ) > 0 
	 && ch->pcdata->ability_info[sn].casting_level == 3 )
      return TRUE;
    // if we already have a casting level 5, other spells can only be level 3
    if ( count_level( ch, 5 ) > 0
	 && ch->pcdata->ability_info[sn].casting_level >= 3 ) 
      return TRUE;
    break;
    //case 4:
  case CASTING_RULE_LVL5_OTHER_LVL4:
    // one to level 5 and other to level 4
    // if we already have a casting level 5, other spells can only be level 4
    if ( count_level( ch, 5 ) > 0 
	 && ch->pcdata->ability_info[sn].casting_level >= 4 ) 
    return TRUE;
    break;
    // Added by SinaC 2003
  case CASTING_RULE_LVL4_OTHER_LVL3:
    // one to level 4 and other to level 3
    if ( count_level( ch, 3 ) > 0 
	 && ch->pcdata->ability_info[sn].casting_level == 3 )
      return TRUE;
    // if we already have a casting level 4, other spells can only be level 3
    if ( count_level( ch, 4 ) > 0
	 && ch->pcdata->ability_info[sn].casting_level >= 3 ) 
      return TRUE;
    break;
    // special case for immortals, they can get everything at casting level 5
  case CASTING_RULE_ALL_LVL5:
  if ( ch->pcdata->ability_info[sn].casting_level >= 5 )
      return TRUE;
    break;
  }
  return FALSE;
*/
  casting_rule_type rule = classes_casting_rule( ch, sn );
  int c = ch->pcdata->ability_info[sn].casting_level;
  // other == -1: every abilities at highest level
  if ( rule.other == -1 ) {
    if ( c >= rule.highest )
      return TRUE;
  }
  // other != 1: one ability at highest level, others abilities to other level
  else {
    // if we already have abilities higher level than .other+1
    //   and ability to test is at .other  then  we cannot train ability to test to a higher level
    if ( c == rule.other 
	 && count_higher_level( ch, rule.other+1 ) > 0 )
      return TRUE;
    // if we already have an ability to .higher
    //  and ability to test is >= .other  then  we cannot train ability to test to a higher level
    if ( c >= rule.other
	 && count_level( ch, rule.highest ) > 0 )
      return FALSE;
  }
  return FALSE;
}