示例#1
0
bool Monster::isRaceAggro(int x, bool checkInvert) const {
    x--;
    bool set = (raceAggro[x/8] & 1<<(x%8));
    if(!checkInvert)
        return(set);
    return(set ? !flagIsSet(M_RACE_AGGRO_INVERT) : flagIsSet(M_RACE_AGGRO_INVERT));
}
示例#2
0
bool Monster::isClassAggro(int x, bool checkInvert) const {
    x--;
    bool set = (cClassAggro[x/8] & 1<<(x%8));
    if(!checkInvert)
        return(set);
    return(set ? !flagIsSet(M_CLASS_AGGRO_INVERT) : flagIsSet(M_CLASS_AGGRO_INVERT));
}
示例#3
0
bool Monster::isDeityAggro(int x, bool checkInvert) const {
    x--;
    bool set = (deityAggro[x/8] & 1<<(x%8));
    if(!checkInvert)
        return(set);
    return(set ? !flagIsSet(M_DEITY_AGGRO_INVERT) : flagIsSet(M_DEITY_AGGRO_INVERT));
}
示例#4
0
bool Object::toggleFlag(int flag) {
    if(flagIsSet(flag))
        clearFlag(flag);
    else
        setFlag(flag);
    return(flagIsSet(flag));
}
示例#5
0
void Monster::diePermCrt() {
    std::map<int, crlasttime>::iterator it;
    crlasttime* crtm=0;
    Monster *temp_mob=0;
    UniqueRoom  *room=0;
    char    perm[80];
    long    t = time(0);
    int     i=0;

    strcpy(perm,getCName());

    if(!inUniqueRoom())
        return;
    room = getUniqueRoomParent();

    for(it = room->permMonsters.begin(); it != room->permMonsters.end() ; it++) {
        crtm = &(*it).second;
        if(!crtm->cr.id)
            continue;
        if(crtm->ltime + crtm->interval > t)
            continue;
        if(!loadMonster(crtm->cr, &temp_mob))
            continue;
        if(temp_mob->getName() == getName()) {
            crtm->ltime = t;
            free_crt(temp_mob);
            break;
        }
        free_crt(temp_mob);
    }

    if(flagIsSet(M_DEATH_SCENE) && !flagIsSet(M_FOLLOW_ATTACKER)) {
        int     fd,n;
        char    tmp[2048], file[80],pName[80];

        strcpy(pName, getCName());
        for(i=0; pName[i]; i++)
            if(pName[i] == ' ')
                pName[i] = '_';

        sprintf(file,"%s/%s_%d", Path::Desc, pName, level);
        fd = open(file,O_RDONLY,0);
        if(fd) {
            n = read(fd,tmp,2048);
            tmp[n] = 0;
            broadcast(nullptr, getRoomParent(), "\n%s", tmp);
        }
        close(fd);
    }
}
示例#6
0
int Monster::cleanMobForSaving() {

    // No saving pets!
    if(isPet())
        return(-1);

    // Clear the inventory
    clearMobInventory();

    // Clear any flags that shouldn't be set
    clearFlag(M_WILL_BE_LOGGED);

//  // If the creature is possessed, clean that up
    if(flagIsSet(M_DM_FOLLOW)) {
        clearFlag(M_DM_FOLLOW);
        Player* master;
        if(getMaster() != nullptr && (master = getMaster()->getAsPlayer()) != nullptr) {
            master->clearFlag(P_ALIASING);
            master->getAsPlayer()->setAlias(0);
            master->print("%1M's soul was saved.\n", this);
            removeFromGroup(false);
        }
    }

    // Success
    return(1);
}
示例#7
0
int getErrorCode(int err, int code, int retTrue, int retFalse)
{
    if ((err == code) && flagIsSet(FLAG_CORRECT_CODES))
        return retTrue;

    return retFalse;
}
示例#8
0
//***********************************************************************
//                      setSocketColors
//***********************************************************************
// Set color options on the socket according to player flags (which can
// overide what we've negotiated)
void Player::setSockColors() {
    if(flagIsSet(P_ANSI_COLOR)) {
        mySock->setColorOpt(ANSI_COLOR);
    } else {
        mySock->setColorOpt(NO_COLOR);
    }
}
示例#9
0
void dumpArgs() {
    if (!flagIsSet(FLAG_DEBUG))
        return;
    printf("\nDump argument settings:\n");
    printf("\tServer: %s\n", mServer);
    printf("\tUser: %s\n", mUser);
    if (flagIsSet(FLAG_DEBUGPWD))
        printf("\tPassword: %s\n", mPass);
    else
        printf("\tPassword: %s\n", mPass ? "Set" : "Not set");
    printf("\tPassword type: %s\n", mPwdType);
    printf("\tRead-only: %s\n", flagIsSet(FLAG_READONLY) ? "True" : "False");
    printf("\tLog file: %s\n", mLogFile);
    printf("\tMountpoint: %s\n", mMntPoint);
    printf("\tForce: %s\n", flagIsSet(FLAG_FORCE) ? "True" : "False");
    printf("\tUnmount: %s\n", flagIsSet(FLAG_UNMOUNT) ? "True" : "False");
    printf("\n");
}
示例#10
0
int Monster::getNumMobs() const {
    int     i=0;

    if(flagIsSet(M_DM_FOLLOW) || flagIsSet(M_WAS_PORTED))
        return(0);
    if(!this->inRoom())
        return(0);
    const BaseRoom* room = getConstRoomParent();
    if(!room)
        return(0);
    for(Monster* mons : room->monsters) {
        if(mons->getName() == getName()) {
            i++;
            if(mons == this)
                return(i);
        }
    }
    return(0);
}
示例#11
0
void Monster::checkSpellWearoff() {
    long t = time(0);

    /*
    if(flagIsSet(M_WILL_MOVE_FOR_CASH)) {
        if(t > LT(this, LT_MOB_PASV_GUARD)) {
            // Been 30 secs, time to stand guard again
            setFlag(M_PASSIVE_EXIT_GUARD);
        }
    }
     */

    if(t > LT(this, LT_CHARMED) && flagIsSet(M_CHARMED)) {
        printColor("^y%M's demeanor returns to normal.\n", this);
        clearFlag(M_CHARMED);
    }
}
示例#12
0
bstring Player::getFlagList(bstring sep) const {
    std::ostringstream ostr;
    bool found = false;
    for(int i=0; i<MAX_PLAYER_FLAGS; i++) {
        if(flagIsSet(i)) {
            if(found)
                ostr << sep;

            ostr << get_pflag(i) << "(" << i+1 << ")";
            found = true;
        }
    }

    if(!found)
        return("None");
    else
        return ostr.str();
}
示例#13
0
int Creature::displayFlags() const {
    int flags = 0;
    if(isEffected("detect-invisible"))
        flags |= INV;
    if(isEffected("detect-magic"))
        flags |= MAG;
    if(isEffected("true-sight"))
        flags |= MIST;
    if(isPlayer()) {
        if(cClass == CreatureClass::BUILDER)
            flags |= ISBD;
        if(cClass == CreatureClass::CARETAKER)
            flags |= ISCT;
        if(isDm())
            flags |= ISDM;
        if(flagIsSet(P_NO_NUMBERS))
            flags |= NONUM;
    }
    return(flags);
}
示例#14
0
int Object::doSpecial(Player* player) {
    BaseRoom* room = player->getRoomParent();
    Socket* sock = player->getSock();
    char    str[80], str2[160];
    unsigned int i=0;

    switch(special) {
    case SP_MAPSC:
        strcpy(str, getCName());
        for(i=0; i<strlen(str); i++)
            if(str[i] == ' ')
                str[i] = '_';
        sprintf(str2, "%s/%s.txt", Path::Sign, str);
        if(flagIsSet(O_LOGIN_FILE))
            viewLoginFile(player->getSock(), str2);
        else
            viewFile(player->getSock(), str2);
        break;
        
    case SP_COMBO:
        char    str[80];
        int     dmg, i;

        str[0] = damage.getSides()+'0';
        str[1] = 0;

        if(damage.getNumber() == 1 || strlen(sock->tempstr[3]) > 70)
            strcpy(sock->tempstr[3], str);
        else
            strcat(sock->tempstr[3], str);

        player->print("Click.\n");
        if(player->getName() == "Bane")
            player->print("Combo so far: %s\n", sock->tempstr[3]);

        broadcast(sock, room, "%M presses %P^x.", player, this);

        if(strlen(sock->tempstr[3]) >= strlen(use_output)) {
            if(strcmp(sock->tempstr[3], use_output)) {
                dmg = mrand(20,40 + player->getLevel());
                player->hp.decrease(dmg);
                player->printColor("You were zapped for %s%d^x damage!\n", player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                broadcast(sock, room, "%M was zapped by %P^x!", player, this);
                sock->tempstr[3][0] = 0;

                if(player->hp.getCur() < 1) {
                    player->print("You died.\n");
                    player->die(ZAPPED);
                }
            } else {
                Exit* toOpen = 0;
                i = 1;
                for(Exit* ext : room->exits) {
                    if(i++ >= damage.getPlus())
                        toOpen = ext;
                }
//              for(i=1, xp = room->first_ext;
//                      xp && i < damage.getPlus();
//                      i++, xp = xp->next_tag)
//                  ;
                if(!toOpen)
                    return(0);
                player->statistics.combo();
                player->print("You opened the %s!\n", toOpen->getCName());
                broadcast(player->getSock(), player->getParent(),
                    "%M opened the %s!", player, toOpen->getCName());
                toOpen->clearFlag(X_LOCKED);
                toOpen->clearFlag(X_CLOSED);
                toOpen->ltime.ltime = time(0);
            }
        }
        break;
        
    default:
        player->print("Nothing.\n");
        break;
    }

    return(0);
}
示例#15
0
void Monster::adjust(int buffswitch) {
    int     buff=0, crthp=0;
    long    xpmod=0;

    if(buffswitch == -1)
        buff = mrand(1,3)-1;
    else
        buff = MAX(0, MIN(buffswitch, 2));


    /*          Web Editor
     *           _   _  ____ _______ ______
     *          | \ | |/ __ \__   __|  ____|
     *          |  \| | |  | | | |  | |__
     *          | . ` | |  | | | |  |  __|
     *          | |\  | |__| | | |  | |____
     *          |_| \_|\____/  |_|  |______|
     *
     *      If you change anything here, make sure the changes are reflected in the web
     *      editor! Either edit the PHP yourself or tell Dominus to make the changes.
     */
    if(!flagIsSet(M_CUSTOM)) {
        if(level >= 1 && level <= MAXALVL) {
            setArmor(balancedStats[level].armor);
            weaponSkill = (level-1)*10;
            defenseSkill = (level-1)*10;
            setExperience(balancedStats[level].experience);
            damage.setNumber(balancedStats[level].ndice);
            damage.setSides(balancedStats[level].sdice);
            damage.setPlus(balancedStats[level].pdice);
        } else {
            setArmor(100);
            weaponSkill = 1;
            defenseSkill = 1;
            setExperience(6);
            damage.setNumber(1);
            damage.setSides(4);
            damage.setPlus(0);
        }


        if(cClass == CreatureClass::NONE)
            hp.setInitial(level * monType::getHitdice(type));
        else {
            crthp = class_stats[(int) cClass].hpstart + (level*class_stats[(int) cClass].hp);
            hp.setInitial(MAX(crthp, (level * monType::getHitdice(type))));
        }

        hp.restore();

        xpmod = experience / 10;
        xpmod *= monType::getHitdice(type) - monType::getHitdice(HUMANOID);

        if(xpmod > 0)
            addExperience(xpmod);
        else
            subExperience(xpmod*-1);
    }


    switch(buff) {
    case 1:         // Mob is weak.
        hp.setInitial( hp.getMax() - hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 4 / 5, GOLD);

        subExperience(experience / 5);
        setArmor(armor - 100);
        damage.setNumber(damage.getNumber() * 9 / 10);
        damage.setPlus(damage.getPlus() * 9 / 10);
        break;
    case 2:         // Mob is stronger
        hp.setInitial( hp.getMax() + hp.getMax()/5);
        hp.restore();
        coins.set(coins[GOLD] * 6 / 5, GOLD);

        addExperience(experience / 5);
        defenseSkill += 5;
        weaponSkill += 5;
        setArmor(armor + 100);

        damage.setNumber(damage.getNumber() * 11 / 10);
        damage.setPlus(damage.getPlus() * 11 / 10);
        break;
    default:
        break;
    }

    armor = MAX<unsigned int>(MIN(armor, MAX_ARMOR), 0);

    if(level >= 7)
        setFlag(M_BLOCK_EXIT);

}
示例#16
0
bool Creature::canFlee(bool displayFail, bool checkTimer) {
    bool    crtInRoom=false;
    long    t=0;
    int     i=0;

    if(isMonster()) {

        if(!flagIsSet(M_WILL_FLEE) || flagIsSet(M_DM_FOLLOW))
            return(false);

        if(hp.getCur() > hp.getMax()/5)
            return(false);

        if(flagIsSet(M_PERMENANT_MONSTER))
            return(false);

    } else {
        //Player* pThis = getPlayer();
        if(!ableToDoCommand())
            return(false);

        if(flagIsSet(P_SITTING)) {
            if(displayFail)
                print("You have to stand up first.\n");
            return(false);
        }

        if(isEffected("hold-person")) {
            if(displayFail)
                print("You are unable to move right now.\n");
            return(false);
        }

        // blah blah re-submit
        if( (cClass == CreatureClass::BERSERKER || cClass == CreatureClass::CLERIC) &&
            isEffected("berserk") )
        {
            if(displayFail)
                printColor("^rYour lust for battle prevents you from fleeing!\n");
            return(false);
        }

        if(checkTimer && !isEffected("fear") && !isStaff()) {
            t = time(0);
            i = MAX(getLTAttack(), MAX(lasttime[LT_SPELL].ltime,lasttime[LT_READ_SCROLL].ltime)) + 3L;
            if(t < i) {
                if(displayFail)
                    pleaseWait(i-t);
                return(false);
            }
        }

        // confusion and drunkenness overrides following checks
        if(isEffected("confusion") || isEffected("drunkenness"))
            return(true);


        // players can only flee if someone/something else is in the room
        for(Monster* mons : getConstRoomParent()->monsters) {
            if(!mons->isPet()) {
                crtInRoom = true;
                break;
            }
        }

        if(!crtInRoom) {
            for(Player* ply : getConstRoomParent()->players) {
                if(ply == this)
                    continue;
                if(!ply->isStaff()) {
                    crtInRoom = true;
                    break;
                }
            }
        }

        if( !crtInRoom && !checkStaff("There's nothing to flee from!\n") ) {
            getAsPlayer()->setFleeing(false);
            return(false);
        }
    }

    return(true);
}
示例#17
0
int Monster::mobileCrt() {
    BaseRoom *newRoom=0;
    AreaRoom *caRoom = getAreaRoomParent();
    int     i=0, num=0, ret=0;
    bool    mem=false;


    if( !flagIsSet(M_MOBILE_MONSTER) ||
        flagIsSet(M_PERMENANT_MONSTER) ||
        flagIsSet(M_PASSIVE_EXIT_GUARD)
    )
        return(0);

    if(nearEnemy())
        return(0);

    for(Exit* exit : getRoomParent()->exits) {
        // count up exits
        if(mobileEnter(exit))
            i += 1;
    }

    if(!i)
        return(0);

    num = mrand(1, i);
    i = 0;

    for(Exit* exit : getRoomParent()->exits) {
        if(mobileEnter(exit))
            i += 1;

        if(i == num) {

            // get us out of this room
            if(!Move::getRoom(this, exit, &newRoom))
                return(0);
            if(newRoom->isAreaRoom()) {
                mem = newRoom->getAsAreaRoom()->getStayInMemory();
                newRoom->getAsAreaRoom()->setStayInMemory(true);
            }

            // make sure there are no problems with the new room
            if(!newRoom)
                return(0);
            if(newRoom->countCrt() >= newRoom->getMaxMobs())
                return(0);

            // no wandering between live/construction areas
            if(newRoom->isConstruction() != getRoomParent()->isConstruction())
                return(0);

            if(exit->flagIsSet(X_CLOSED) && !exit->flagIsSet(X_LOCKED)) {
                broadcast(nullptr, getRoomParent(), "%M just opened the %s.", this, exit->getCName());
                exit->clearFlag(X_CLOSED);
            }

            if(flagIsSet(M_WILL_SNEAK) && flagIsSet(M_HIDDEN))
                setFlag(M_SNEAKING);

            if( flagIsSet(M_SNEAKING) &&
                mrand (1,100) <= (3+dexterity.getCur())*3)
            {
                broadcast(::isStaff, getSock(), getRoomParent(), "*DM* %M just snuck to the %s.", this,exit->getCName());
            } else {
                Creature* lookingFor = nullptr;
                if(flagIsSet(M_CHASING_SOMEONE) && hasEnemy() && ((lookingFor = getTarget(false)) != nullptr) ) {

                    broadcast(nullptr, getRoomParent(), "%M %s to the %s^x, looking for %s.",
                        this, Move::getString(this).c_str(), exit->getCName(), lookingFor->getCName());
                }
                else
                    broadcast(nullptr, getRoomParent(), "%M just %s to the %s^x.",
                        this, Move::getString(this).c_str(), exit->getCName());

                clearFlag(M_SNEAKING);
            }


            // see if we can recycle this room
            deleteFromRoom();
            if(caRoom && newRoom == caRoom && newRoom->isAreaRoom()) {
                newRoom = Move::recycle(newRoom->getAsAreaRoom(), exit);
            }
            addToRoom(newRoom);

            // reset stayInMemory
            if(newRoom->isAreaRoom())
                newRoom->getAsAreaRoom()->setStayInMemory(mem);

            lasttime[LT_MON_WANDER].ltime = time(0);
            lasttime[LT_MON_WANDER].interval = mrand(5,60);

            ret = 1;
            break;
        }
    }

    if(mrand(1,100) > 80)
        clearFlag(M_MOBILE_MONSTER);

    return(ret);
}
示例#18
0
int Monster::doHarmfulAuras() {
    int         a=0,dmg=0,aura=0, saved=0;
    long        i=0,t=0;
    BaseRoom    *inRoom=0;
    Creature* player=0;

    if(isPet())
        return(0);
    if(hp.getCur() < hp.getMax()/10)
        return(0);
    if(flagIsSet(M_CHARMED))
        return(0);

    for(a=0;a<MAX_AURAS;a++) {
        if(flagIsSet(M_FIRE_AURA + a))
            aura++;
    }

    if(!aura)
        return(0);

    i = lasttime[LT_M_AURA_ATTACK].ltime;
    t = time(0);

    if(t - i < 20L) // Mob has to wait 20 seconds.
        return(0);
    else {
        lasttime[LT_M_AURA_ATTACK].ltime = t;
        lasttime[LT_M_AURA_ATTACK].interval = 20L;
    }

    inRoom = getRoomParent();
    if(!inRoom)
        return(0);

    for(a=0;a<MAX_AURAS;a++) {

        if(!flagIsSet(M_FIRE_AURA + a))
            continue;
        PlayerSet::iterator pIt = inRoom->players.begin();
        PlayerSet::iterator pEnd = inRoom->players.end();
        while(pIt != pEnd) {
            player = (*pIt++);

            if(player->isEffected("petrification") || player->isCt())
                continue;

            dmg = mrand(level/2, (level*3)/2);

            dmg = MAX(2,dmg);

            switch(a+M_FIRE_AURA) {
            case M_FIRE_AURA:
                if(player->isEffected("heat-protection") || player->isEffected("alwayswarm"))
                    continue;

                saved = player->chkSave(BRE, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^R%M's firey aura singes you for %s%d^R damage!\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_COLD_AURA:
                if(player->isEffected("warmth") || player->isEffected("alwayscold"))
                    continue;

                saved = player->chkSave(BRE, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^C%M's freezing aura chills you for %s%d^C damage!\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_NAUSEATING_AURA:
                if(player->immuneToPoison())
                    continue;

                saved = player->chkSave(POI, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^g%M's foul stench chokes and nauseates you for %s%d^g damage.\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_NEGATIVE_LIFE_AURA:
                if(player->isUndead() || player->isEffected("drain-shield"))
                    continue;

                saved = player->chkSave(DEA, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^m%M's negative aura taps your life for %s%d^m damage.\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            case M_TURBULENT_WIND_AURA:
                if(player->isEffected("wind-protection"))
                    continue;

                saved = player->chkSave(BRE, this, 0);
                if(saved)
                    dmg /=2;
                player->printColor("^W%M's turbulent winds buff you about for %s%d^W damage.\n", this, player->customColorize("*CC:DAMAGE*").c_str(), dmg);
                break;
            }

            player->hp.decrease(dmg);
            if(player->checkDie(this))
                return(1);

        }// End while
    }// End for

    return(0);
}
示例#19
0
// Initializes last times, inventory, scrolls, etc
int Monster::initMonster(bool loadOriginal, bool prototype) {
    int n=0, alnum=0, x=0;
    long t=0;
    Object* object=0;

    t = time(0);
    // init the timers
    lasttime[LT_MON_SCAVANGE].ltime =
    lasttime[LT_MON_WANDER].ltime =
    lasttime[LT_MOB_THIEF].ltime =
    lasttime[LT_TICK].ltime = t;
    lasttime[LT_TICK_SECONDARY].ltime = t;
    lasttime[LT_TICK_HARMFUL].ltime = t;

    // Make sure armor is set properly
    if(armor < (unsigned)(balancedStats[MIN<short>(level, MAXALVL)].armor - 150)) {
        armor = balancedStats[MIN<short>(level, MAXALVL)].armor;
    }

    if(dexterity.getCur() < 200)
        setAttackDelay(30);
    else
        setAttackDelay(20);

    if(flagIsSet(M_FAST_TICK))
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 15L;
    else if(flagIsSet(M_REGENERATES))
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 15L;
    else
        lasttime[LT_TICK].interval = lasttime[LT_TICK_SECONDARY].interval = 60L - (2*bonus((int)constitution.getCur()));

    lasttime[LT_TICK_HARMFUL].interval = 30;
    // Randomize alignment and gold unless we don' want it
    if(!loadOriginal) {
        if(flagIsSet(M_ALIGNMENT_VARIES) && alignment != 0) {
            alnum = mrand(1,100);
            if(alnum == 1)
                alignment = 0;
            else if(alnum < 51)
                alignment = mrand((short)1, (short)std::abs(alignment)) * -1;
            else
                alignment = mrand((short)1, (short)std::abs(alignment));
        }

        if(!flagIsSet(M_NO_RANDOM_GOLD) && coins[GOLD])
            coins.set(mrand(coins[GOLD]/10, coins[GOLD]), GOLD);
    }
    // Check for loading of random scrolls
    if(checkScrollDrop()) {
        n = new_scroll(level, &object);
        if(n > 0) {
            object->value.zero();
            addObj(object);
            object->setFlag(O_JUST_LOADED);
        }
    }

    // Now load up any always drop objects (Trading perms don't drop inventory items)
    if(!flagIsSet(M_TRADES)) {
        for(x=0;x<10;x++) {
            if(!loadObject(carry[x].info, &object))
                continue;
            object->init(!prototype);
            if( object->flagIsSet(O_ALWAYS_DROPPED) &&
                !object->getName().empty() &&
                object->getName()[0] != ' ' )
            {
                addObj(object);
                object->setFlag(O_JUST_LOADED);
            } else {
                delete object;
                continue;
            }
        }

        object = 0;

        int numDrops = mrand(1,100), whichDrop=0;

             if(numDrops<90)    numDrops=1;
        else if(numDrops<96)    numDrops=2;
        else                    numDrops=3;

        if(prototype)
            numDrops = 10;
        for(x=0; x<numDrops; x++) {
            if(prototype)
                whichDrop=x;
            else
                whichDrop = mrand(0,9);
            if(carry[whichDrop].info.id && !flagIsSet(M_TRADES)) {
                if(!loadObject(carry[whichDrop].info, &object))
                    continue;
                if( object->getName().empty() || object->getName()[0] == ' ')
                {
                    delete object;
                    continue;
                }

                object->init(!prototype);

                // so we don't get more than one always drop item.
                if(object->flagIsSet(O_ALWAYS_DROPPED)) {
                    delete object;
                    continue;
                }

                object->value.set(mrand((object->value[GOLD]*9)/10,(object->value[GOLD]*11)/10), GOLD);

                addObj(object);
                object->setFlag(O_JUST_LOADED);
            }
        }
    }

    if(weaponSkill < (level * 3))
        weaponSkill = (level-1) * mrand(9,11);
    return(1);
}
示例#20
0
int main(int argc, char *argv[])
{
    int rc, i;
    struct statvfs vfs;

    if (getuid() != 0) {
        fprintf(stderr, "Error: You need to run %s as root!\n", argv[0]);
        return EXIT_FAILURE;
    }

    flags = parseArgs(argc, argv);

    if (!mServer || !mUser || !mPass || !mMntPoint)
        usage(argv[0]);

    if (strcmp(mPwdType, "b64") == 0)
        mPass = strdup(unbase64(mPass));

    dumpArgs();

    if (flagIsSet(FLAG_UNMOUNT) || (flagIsSet(FLAG_FORCE))) {
        rc = unmount( replace(argv[0], "./", ""), mMntPoint, flagIsSet(FLAG_FORCE) );

        if (flagIsSet(FLAG_UNMOUNT))
            return rc;

        if ((rc != 0) && (flagIsSet(FLAG_UNMOUNT)))
            fprintf(stderr, "Warning: Error unmounting mountpoint %s\n", mMntPoint);
    }

    if (statvfs(mMntPoint, &vfs) == 0) {
        if (vfs.f_fsid == 0) { /* Observed when mounted (FUSE mount) */
            fprintf(stderr, "Path %s seems to be already mounted. Cannot "
                    "continue. Quiting...\n", mMntPoint);
            return EXIT_FAILURE;
        }
    }

    if (mysql_init(&sql) == NULL)
        return EXIT_FAILURE;

    if (!mysql_real_connect(&sql, mServer, mUser, mPass, NULL, 0, NULL, 0)) {
        fprintf(stderr, "MySQL connection error: %s (%d)\n", mysql_error(&sql),
                mysql_errno(&sql));
        mysql_close(&sql);
        return EXIT_FAILURE;
    }

    /* Unset all the arguments for fuse_main */
    for (i = 1; i > argc; i++)
        free(argv[i]);
    argc = 2;
    /* Set only the mountpoint argument */
    argv[1] = mMntPoint;

    printf("Process %s started successfully\n", argv[0]);

    rc = fuse_main(argc, argv, &fmysql_oper, NULL);
    mysql_close(&sql);

    return rc;
}