void master_check_completion (int rc, const char *value, int value_len,
                              const struct Stat *stat, const void *data) {
    int master_id;
    switch (rc) {
        case ZCONNECTIONLOSS:
        case ZOPERATIONTIMEOUT:
            check_master();
            
            break;
        case ZOK:
            sscanf(value, "%x", &master_id );
            if(master_id == server_id) {
                take_leadership();
                LOG_DEBUG(("Elected primary master"));
            } else {
                master_exists();
                LOG_DEBUG(("The primary is some other process"));
            }
            
            break;
        case ZNONODE:
            run_for_master();
            
            break;
        default:
	    LOG_ERROR(("Something went wrong when checking the master lock: %s", rc2string(rc)));
            
            break;
    }
}
Example #2
0
int can_gain( CHAR_DATA *ch, int sn ){
  // god, race or clan skill
  if ( get_clanability( ch, sn )
       /*|| get_godskill( ch, sn )   removed by SinaC 2003*/
       || get_raceability( ch, sn ) )
    return ERR_GOD_CLAN_RACE;

  // skill/spell not known
  if ( ch->pcdata->ability_info[sn].learned == 0 ) {
    // player is allowed to learn that spell/skill
    // Modified by SinaC 2003
    if ( class_gainabilityrating( ch, sn, 1 ) > 0 )
      // player higher level enough ?, Modified by SinaC 2001
      // REMOVED by SinaC 2003, player can gain first casting level of an ability even if they are
      //  too low level but they can't gain higher ability casting level
      //if ( ch->level < class_abilitylevel( /*ch->cstat(classes)*/ch, sn ) )
      //return ERR_LEVEL_TOO_LOW;
      //else
	return check_gain_prereq( ch, sn );
    else
      return ERR_CANT_LEARN;
  }
  // skill/spell already known
  else {
    // so people who have learn the 1st level with a item giving the right class
    //  can't learn the next level of that spell
    // or class which got it from a sphere
    // or for immortals who have 'set skill <self> all perc 100'
    // Modified by SinaC 2003
    if ( class_gainabilityrating( ch, sn, ch->pcdata->ability_info[sn].casting_level ) <= 0 )
      //return ERR_CANT_LEARN;
      return ERR_STUDIED_SPELL;

// WAS BEFORE THE PREVIOUS TEST, SinaC 2001

    // was after the next test
    // no more than 1 level for that spell
    if ( ability_table[sn].nb_casting_level <= 1 )
      return ERR_SPELL_NO_LEVEL;
    // player higher level enough ?, Modified by SinaC 2001
    if ( ch->level < class_abilitylevel( /*ch->cstat(classes)*/ch, sn ) )
      return ERR_LEVEL_TOO_LOW;

    // already master at that skill/spell
    if ( check_master( ch, sn ) )
      return ERR_ALREADY_MASTER;
    // already have enough more than level 1 spell
    if ( check_max_spell_level( ch, sn ) )
      return ERR_ALREADY_MAX_LEVEL;
    // does player has 90% in that skill/spell
    if ( ch->pcdata->ability_info[sn].learned < 90 )
      return ERR_NOT_ENOUGH_PERC;
    return check_gain_prereq( ch, sn );
  }
}
void master_create_completion (int rc, const char *value, const void *data) {
    switch (rc) {
        case ZCONNECTIONLOSS:
            check_master();
            
            break;
            
        case ZOK:
            take_leadership();
            
            break;
            
        case ZNODEEXISTS:
            master_exists();
            
            break;
            
        default:
            LOG_ERROR(("Something went wrong when running for master."));

            break;
    }
}